I have been using the gemini-1.5-flash-001 model (free tier) to extract information from scientific publications; so there is a prompt describing the task (what to extract and how to format the reply) appended to the plain text of the scientific paper. Most of these have worked well, but 5 out of 30 return the following:
response:
GenerateContentResponse(
done=True,
iterator=None,
result=glm.GenerateContentResponse({
"candidates": [
{
"finish_reason": 4,
"index": 0,
"safety_ratings": [],
"token_count": 0,
"grounding_attributions": []
}
]
}),
)
All of the documentation says the finish reasons are from this list which are not listed by number. It is not clear which of these the “4” represents (or even if that is the right way to interpret it!).
Also, just to be clear, I was hitting the API well below the limits published and these errors persisted on another day when I tried several of these files individually (so I don’t think I broke the rate limit).
The call was:
model=genai.GenerativeModel(
model_name="gemini-1.5-flash-001",
system_instruction=system_prompt_text)
temp = 0.2
max_reply_tokens = 4096
model_config = {
"temperature": temp,
"max_output_tokens": max_reply_tokens,
'response_mime_type':'application/json'
}
completion = model.generate_content(submit_prompt,
generation_config=model_config,
safety_settings={
HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_ONLY_HIGH
}
)
Note that the stuff about harm categories was due to the fact that some of the scientific papers discussed drug abuse and some were coming back with dangerous content warnings of “medium.”
Although it would take up a lot of space, I could upload a example prompt/paper. But these are on the order of 6000-8000 tokens, so not gigantic things. The prompt asks for JSON responses and for the other papers this worked well.
But I really just want to know how to translate this to the actual finish reasons. Thanks if you can help!