Hi,
I was creating a personal agent using gemini-1.5-pro-preview-0409 to refactor user code based on some coding standards. However, I’ve run into this error multiple times where I don’t get a response and instead receive: "finish_reason": "RECITATION", ... and some citation_metadata which refers to another link.
All the safety ratings are negligible
I’ve tried setting response_validation=False in the start_chat() function but it’s of no avail.
It’s really annoying because my use-case just uses gemini to refactor already provided code and it doesn’t make sense to restrict an end user to not provide copyrighted code or a famous code file to test the refactoring.
Can anyone please suggest a workaround or fix? Is there a way to set RECITATION off?
This is a finish_reason. It indicates why the model stopped generating.
In case of recitation, it means it “recited” from copyrighted material in the foundational LLM’s training data.
The citation_metadata is likely pointing to the source of copyrighted material.
This field may be populated with recitation information for any text included in the content . These are passages that are “recited” from copyrighted material in the foundational LLM’s training data.
I found that when asking to transcribe noisy audio this finish reason often comes up if temperature =0. Upon closer inspection it seems to interpret repeated characters like “na na na…” or “a a a a…” that go for too long as “Recitation”! Obviously this kind of repeated pattern is in the training data verbatim many times.
My solution was to increase the temperature to 1 for transcriptions.
HTH someone.
To answer directly, no way to stop that model behavior (or inexplicable content generation block due to finishReason OTHER) and no response from anyone at Google about how to mitigate this issue.
If a particular response is blocked with finishReason RECITATION, using the exact same prompt again may generate a response that doesn’t trigger the RECITATION block. So, you can treat it as an error condition that is eligible for retry. And no need to include exponential back off provisions for this class of retry-eligible problems.