Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gemini does not respect the order of the properties in a schema #533

Open
seungduk-yanolja opened this issue Sep 2, 2024 · 3 comments
Open
Assignees
Labels
component:python sdk Issue/PR related to Python SDK status:triaged Issue/PR triaged to the corresponding sub-team type:bug Something isn't working

Comments

@seungduk-yanolja
Copy link

seungduk-yanolja commented Sep 2, 2024

Description of the bug:

Let's imagine a situation where you want an answer and a rationale from the LLM. You want it to be in a JSON format like

{
  "choice": 4,
  "rationale": "The answer is 4 because..."
}

If the LLM completes the choice property first, then the next rationale can be made up to justify the choice.
However, if the rational comes first like

{
  "rationale": "The answer is 4 because...",
  "choice": 4
}

Then, the choice will be determined by rationale. It is similar to CoT.

It is important that the LLM follows the given order of the properties in an object. However, I found that Gemini SDK ignores it.

    properties: MutableMapping[str, "Schema"] = proto.MapField(
        proto.STRING,
        proto.MESSAGE,
        number=3,
        message="Schema",
    )

I think this one better to be a repeated, not a map field, to keep the order of the properties.

Actual vs expected behavior:

Gemini SDK ignores the order of the properties in an object.

Any other information you'd like to share?

No response

@Gunand3043 Gunand3043 added type:bug Something isn't working status:triaged Issue/PR triaged to the corresponding sub-team component:python sdk Issue/PR related to Python SDK labels Sep 3, 2024
@seungduk-yanolja
Copy link
Author

Any updates? also there is another issue:
google/generative-ai-go#211

@httplups
Copy link

I am having the same issue that Gemini ignores the order; it tends to hallucinate

@httplups
Copy link

httplups commented Oct 1, 2024

Hi. I was able to make the model follow the order by changing the field names to 'step_one' and 'step_two'. It is not ideal, but its a workaround to have an structured output with reasoning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:python sdk Issue/PR related to Python SDK status:triaged Issue/PR triaged to the corresponding sub-team type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants