You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I searched existing ideas and did not find a similar one
I added a very descriptive title
I've clearly described the feature request and motivation for it
Feature request
It would be valuable for LangChain to expose logprobs support when using both the Vertex AI models and the Gemini API directly.
Both Google APIs now allow retrieving token-level log probabilities (logprobs) alongside completions. This is important for downstream tasks like uncertainty estimation, calibration, forced decoding, or model-based reasoning steps.
Currently, LangChain’s interfaces for Vertex and Gemini do not surface this information, and even if the underlying APIs support it, LangChain users cannot access it natively without writing custom wrappers.
Return the logprobs in the generation_info or equivalent output object
Ideally, include an option to control how many top logprobs (top_logprobs) are returned, since both Vertex and Gemini support a top_k setting. as done in OpenAI or AzureOpenAI - https://python.langchain.com/docs/how_to/logprobs/
This could follow the style already used by other integrations (like OpenAI models via LangChain) where logprobs is optional but cleanly handled if requested.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Checked
Feature request
It would be valuable for LangChain to expose logprobs support when using both the Vertex AI models and the Gemini API directly.
Both Google APIs now allow retrieving token-level log probabilities (logprobs) alongside completions. This is important for downstream tasks like uncertainty estimation, calibration, forced decoding, or model-based reasoning steps.
Currently, LangChain’s interfaces for Vertex and Gemini do not surface this information, and even if the underlying APIs support it, LangChain users cannot access it natively without writing custom wrappers.
Documentation:
Motivation
Many advanced applications need token-level information, not just final completions. For example:
Without logprobs access, LangChain users must bypass LangChain itself and directly call the Google APIs.
I really love langchain, but this really is a stopper for me to use it.
Proposal (If applicable)
Update the internal handlers (VertexAI and ChatVertexAI, ChatGoogleGenerativeAI and related models) to:
Accept a logprobs parameter as done in
OpenAI
orAzureOpenAI
- https://python.langchain.com/docs/how_to/logprobs/Return the logprobs in the generation_info or equivalent output object
Ideally, include an option to control how many top logprobs (top_logprobs) are returned, since both Vertex and Gemini support a top_k setting. as done in
OpenAI
orAzureOpenAI
- https://python.langchain.com/docs/how_to/logprobs/This could follow the style already used by other integrations (like OpenAI models via LangChain) where logprobs is optional but cleanly handled if requested.
Beta Was this translation helpful? Give feedback.
All reactions