generative-ai-python icon indicating copy to clipboard operation
generative-ai-python copied to clipboard

[Feature] Add Support on Log Probability Value from Returned Response of Gemini Models.

Open jacklanda opened this issue 1 year ago • 8 comments

Description of the feature request:

How about providing new support for retrieving the log probability of each predicted token by Google models like Gemini?

Something just like the same function illustrated in this OpenAI post: User Logprobs.

What problem are you trying to solve with this feature?

Getting the returned log prob of each generated token does help me (and other users maybe) to confirm the confidence of the model's prediction. Further, this feature can help users compute the perplexity of generated sentences to better understand the textual continuation quality.

Any other information you'd like to share?

No response

jacklanda avatar Mar 14 '24 04:03 jacklanda

Any thoughts about it?

jacklanda avatar Mar 18 '24 10:03 jacklanda

I also think it would be extremely helpful if the API could provide the top-k log probabilities of each predicted token.

Brian-Ckwu avatar Apr 04 '24 08:04 Brian-Ckwu

Really need this as I found Gemini to be hallucinating quite abit on a RAG application.

Btw your title refers to claude and not gemini. [Feature] Add Support on Log Probability Value from Returned Response of Claude Models

krenova avatar Apr 09 '24 01:04 krenova

Really need this as I found Gemini to be hallucinating quite abit on a RAG application.

Btw your title refers to claude and not gemini. [Feature] Add Support on Log Probability Value from Returned Response of Claude Models

Thanks for reminding 🤗

jacklanda avatar Apr 09 '24 02:04 jacklanda

Many hallucination detection approaches rely on log probability as a key feature. It's one of the most essential elements when building a serious product with a LLM.

simpleusername96 avatar Apr 19 '24 05:04 simpleusername96

This would be extremely helpful!

anwang427 avatar May 09 '24 23:05 anwang427

As all others previously mentioned, it would be great to somehow get access to the logsprobs in a similar fashion as OpenAI does so with the models. Based on that we could then e.g. calculate the perplexity score and various other evaluation metrics.

Said-Apollo avatar Jul 16 '24 11:07 Said-Apollo

Yep, this would make it possible to use gemini in production

haugmarkus avatar Jul 23 '24 11:07 haugmarkus

+1 - useful also for classification tasks.

waveworks-ai avatar Aug 13 '24 15:08 waveworks-ai

+1

lavanyanemani96 avatar Aug 15 '24 16:08 lavanyanemani96

+1 it is critical. Chatgpt and other major models are now all supporting this feature. please help!

luna-b20 avatar Aug 20 '24 21:08 luna-b20

+1 it is critical. Chatgpt and other major models are now all supporting this feature. please help!

Can you please specify what major models support this feature? Because I'm also in search for the alternatives. Now I don't see any other players supporting this except from OpenAI. No Anthropic, No Mistral...

michaelgfeldman avatar Aug 26 '24 19:08 michaelgfeldman

b/361194489

MarkDaoust avatar Aug 26 '24 20:08 MarkDaoust

I also think it would be extremely helpful if the API could provide the top-k log probabilities of each predicted token.

Yes, this would allow evaluating Gemini with threshold-free evaluation metrics. That would be excellent.

MFajcik avatar Aug 30 '24 13:08 MFajcik

Google's Vertex-AI Just launched this, hopefully that means it's coming soon here, but I don't have a timeline.

MarkDaoust avatar Aug 30 '24 14:08 MarkDaoust

Google's Vertex-AI Just launched this, hopefully that means it's coming soon here, but I don't have a timeline.

can you share a link?

michaelgfeldman avatar Sep 03 '24 11:09 michaelgfeldman

Google's Vertex-AI Just launched this, hopefully that means it's coming soon here, but I don't have a timeline.

can you share a link?

They have added a field 'avgLogprobs' to the response documentation in https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#nodejs but I am unable to get a response with such field.

haugmarkus avatar Sep 06 '24 12:09 haugmarkus

Yeah, this API is related, but separate from vertex. Hopefully this API will catch up soon.

MarkDaoust avatar Sep 06 '24 16:09 MarkDaoust

  • 1

kauabh avatar Oct 04 '24 05:10 kauabh

This is fixed in the latest version:

code: https://github.com/google-gemini/generative-ai-python/pull/561 tutorial: https://github.com/google-gemini/cookbook/blob/main/quickstarts/New_in_002.ipynb

MarkDaoust avatar Oct 04 '24 16:10 MarkDaoust