8000 Do not set `grammar` to `None` for new `LlamaGrammar` objects by mthuurne · Pull Request #834 · abetlen/llama-cpp-python · GitHub
[go: up one dir, main page]

Skip to content

Do not set grammar to None for new LlamaGrammar objects #834

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

Merged
merged 2 commits into from
Nov 21, 2023

Conversation

mthuurne
Copy link
Contributor
@mthuurne mthuurne commented Oct 22, 2023

The LlamaGrammar.grammar attribute is written by init(), but that method always returns None, so __init__() would then discard the previously written object.

Note that Llama.generate() will call LlamaGrammar.reset() before using the grammar, so it will also work fine without this change, but Llama.sample() does not call the reset() method.

The `grammar` attribute is written by `init()`, but that method always
returns `None`, so `__init__()` would then discard the previously
written object.
@abetlen abetlen force-pushed the main branch 2 times, most recently from 8c93cf8 to cc0fe43 Compare November 14, 2023 20:24
@abetlen
Copy link
Owner
abetlen commented Nov 21, 2023

@mthuurne thank you!

@abetlen abetlen merged commit c21edb6 into abetlen:main Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0