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

feat(google-common): Gemini logprobs #7472

Merged
merged 7 commits into from
Jan 10, 2025

Conversation

afirstenberg
Copy link
Contributor

Add support for OpenAI compatible logprobs, including:

  • logprobs boolean model parameter
  • topLogprobs numeric model parameter
  • logprobs returned in response_metadata in the same format OpenAI uses
  • updated documentation to indicate availability

Add support for token selection updates in model parameters:

  • presencePenalty
  • frequencyPenalty

Added tests for same.

  • Note that the tests for logprobs are essential since Google is highly restrictive on its use.
  • Note that the penalty test is somewhat non-deterministic

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jan 6, 2025
Copy link

vercel bot commented Jan 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Jan 10, 2025 10:13pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Jan 10, 2025 10:13pm

@afirstenberg afirstenberg changed the title feature(google-common): Gemini logprobs feat(google-common): Gemini logprobs Jan 6, 2025
@dosubot dosubot bot added auto:documentation Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features labels Jan 6, 2025
@@ -189,8 +189,16 @@ export abstract class ChatGoogleBase<AuthOptions>

topK = 40;

presencePenalty = undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to init as undefined - should have their actual typing

stopSequences: string[] = [];

logprobs: false;
Copy link
Collaborator

@jacoblee93 jacoblee93 Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that the only acceptable value is false

Did you mean to set logprobs = false?

and topLogprobs = 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh! Yeah. Thanks for catching this.

Copy link
Collaborator

@jacoblee93 jacoblee93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Some nits

@afirstenberg
Copy link
Contributor Author

Fixed the type declarations. Thanks!

stopSequences: string[] = [];

logprobs: boolean = false;

topLogprobs: number = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you can just do topLogprobs = 0 and logprobs = false

Copy link
Collaborator

@jacoblee93 jacoblee93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dosubot dosubot bot added the lgtm PRs that are ready to be merged as-is label Jan 10, 2025
@jacoblee93 jacoblee93 merged commit acdd972 into langchain-ai:main Jan 10, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:documentation Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features lgtm PRs that are ready to be merged as-is size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants