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

Output probabilities #591

Closed
dnhkng opened this issue Jan 26, 2024 · 3 comments
Closed

Output probabilities #591

dnhkng opened this issue Jan 26, 2024 · 3 comments
Labels

Comments

@dnhkng
Copy link
Contributor

dnhkng commented Jan 26, 2024

The library CAPPR allows the probabilities for each completion to be calculated. Although these are not usable as a measure of certainty in LLMs, I have a strong need to get access to them.

Currently, we can use this code to get categorical answers:

import outlines

model = outlines.models.transformers("mistralai/Mistral-7B-v0.1")

prompt = """You are a sentiment-labelling assistant.
Is the following review positive or negative?

Review: This restaurant is just awesome!
"""

generator = outlines.generate.choice(model, ["Positive", "Negative"])
answer = generator(prompt)

print(answer) # Positive

I want this "probability" method:

import outlines

model = outlines.models.transformers("mistralai/Mistral-7B-v0.1")

prompt = """You are a sentiment-labelling assistant.
Is the following review positive or negative?

Review: This restaurant is just awesome!
"""

generator = outlines.generate.probability(model, ["Positive", "Negative"])
answer = generator(prompt)

print(answer) # [0.8. 0.2]
@rlouf
Copy link
Member

rlouf commented Jan 26, 2024

Possible duplicate of #479

@rlouf rlouf added the question label Jan 26, 2024
@dnhkng
Copy link
Contributor Author

dnhkng commented Jan 26, 2024

@rlouf Point me to the right place in the code, and I'll try to implement it.

@dnhkng
Copy link
Contributor Author

dnhkng commented Jan 26, 2024

Yes, its a dupe, but rather than modifying "choice", I would like a new method. But I'll close this issue.

@dnhkng dnhkng closed this as completed Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants