-
Notifications
You must be signed in to change notification settings - Fork 431
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
Llamacpp has Attributeerror with token_eos for Hermest-Pro-7B when using structured grammar generation #771
Comments
Facing the same issue with Mistral Instruct: from llama_cpp import Llama
from outlines import models, generate
arithmetic_grammar = """
?start: expression
?expression: term (("+" | "-") term)*
?term: factor (("*" | "/") factor)*
?factor: NUMBER
| "-" factor
| "(" expression ")"
%import common.NUMBER
"""
llm = Llama.from_pretrained(
repo_id="TheBloke/Mistral-7B-Instruct-v0.1-GGUF",
filename="mistral-7b-instruct-v0.1.Q4_K_S.gguf",
verbose=True
)
model = models.LlamaCpp(llm)
generator = generate.cfg(model, arithmetic_grammar)
sequence = generator(
"Alice had 4 apples and Bob ate 2. "
+ "Write an expression for Alice's apples:"
) |
I am so sorry this is happening! I will investigate early next week. |
@rlouf I was just trying to use outlines again, this time with phi-3, still no luck, but I did make some progress. It seems like the issue is that LlamaTokenizer in llama-cpp-python is fundamentally a different object than what you're expecting in SequenceGenerator, which appears to be. You can patch on the attributes needed with something like the following:
This doesn't work because tokenizer.encode is expecting a str, not a list. So I patched that:
But then I run into an error at line At this point I'm out of my depth. I don't quite understand what attention masks are — why would you want to ignore tokens? Why wouldn't this tokenizer return it if you're expecting it? But, I decided to try to just say 'let's not ignore any of them' and patched it in:
Which resulted in this error:
I'm pretty sure there's something broken with the llama-cpp integration. Even this, from the examples
Throws an error since you need to create LLama manually, which if you fix it leads again to the error:
So, something has probably changed in llama-cpp-python since the integration was created which broke this. Thanks for taking a look! |
@maxtheman I couldn't reproduce the error in your script. Is it possible aacc633 fixed it? Please let me know if the issue still occurs on the latest version of outlines. |
Yes, it would have fixed it. Please update outlines to use the latest version and give it another try. |
Oh excellent! I do still have a project I can try this on. Away from my
computer this weekend but will confirm tomorrow.
…On Sun, May 19, 2024, 4:48 AM Rémi Louf ***@***.***> wrote:
Yes, it would have fixed it. Please update outlines to use the latest
version and give it another try.
—
Reply to this email directly, view it on GitHub
<#771 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQSOUJKJH7EAZFZ4TIV2NTZDCGQ5AVCNFSM6AAAAABFJ624C2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJZGIYDOMJWGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Appears to be solved. Please reopen if that’s not the case. |
Describe the issue as clearly as possible:
When I try to use Hermes-Pro-7b with llama-cpp-python, I cannot use
cfg
to generate structured grammarThis is ONLY an issue with structured grammar generation via
cfg
.generate.json
doesn'tSteps/code to reproduce the bug:
Expected result:
I'd expect the Attributeerror to not occur, and instead the sequence should print to Stdout.
Error message:
The text was updated successfully, but these errors were encountered: