-
Notifications
You must be signed in to change notification settings - Fork 308
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
generate.json() gives ValidationError when run with mistral-7b-instruct-v0.2.Q6_K.gguf #837
Comments
Can the issue acutally be with the model I am using instead of the mistralai/Mistral-7B-v0.1? |
I have the same problem with "mistral-7b-instruct-v0.2.Q5_K_S.gguf"
My code is from the example too. from outlines import models
import outlines
from outlines import generate
from llama_cpp import Llama
json_grammar = outlines.grammars.json
def add(a: int, b: int):
return a + b
llm = Llama("./mistral-7b-instruct-v0.2.Q5_K_S.gguf", chat_format="mistral")
model = models.LlamaCpp(llm)
generator = generate.json(model, add)
result = generator("Return two integers named a and b respectively. a is odd and b even.")
print(add(**result)) |
Can you try |
Yes it works as expected with this. |
After digging around, I found that the model stopped earlier before the json is completed. |
Hej! Yes, increasing max_tokens was the trick for me too! Thank you so much
for your very helpful advice :)
…On Fri, May 3, 2024 at 5:03 PM Haoxian WANG ***@***.***> wrote:
Can you try generator = generate.json(model, add, whitespace_pattern="") ?
After digging around, I found that the model stopped earlier before the
json is completed.
By adding max_tokens=100 of some big enough value for the whole output
json, it works.
I think it's important to be able to detect this when the model's output
is somehow stopped due to the generation control.
—
Reply to this email directly, view it on GitHub
<#837 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A2ZM2DY23QZATSH47SRWP6LZAORMPAVCNFSM6AAAAABGYYBI4CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJTGIYDCNZWGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
We may need to override |
I have the same problem with higher max_tokens if I do not set The problem with Example: class Person(pydantic.BaseModel):
name: str
description: typing.Annotated[str, pydantic.StringConstraints(strip_whitespace=True, max_length=300)] |
Describe the issue as clearly as possible:
Example code with Pydantic and generate.json() throws a ValidationError
Code is run from Jupyter Notebook
Output is ok if age: int is removed from the Pydantic class
Steps/code to reproduce the bug:
Expected result:
Error message:
Outlines/Python version information:
Version information
0.0.40
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
Context for the issue:
I would like to present Outlines as an intuitive and fast alternative to Guidance or LMQL in my diploma school project
The text was updated successfully, but these errors were encountered: