-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[WIP][Bug] Issue 934 #962
Open
riedgar-ms
wants to merge
12
commits into
guidance-ai:main
Choose a base branch
from
riedgar-ms:riedgar-ms/issue-934
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+37
−4
Open
[WIP][Bug] Issue 934 #962
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
91e6bc9
Convert issue into test
riedgar-ms 58994d3
Add extra model
riedgar-ms 2b1c89c
Move test to better location
riedgar-ms 5477fd3
Hook new model into PR gate
riedgar-ms 3ebd297
Add note into test
riedgar-ms a0d8acd
Merge remote-tracking branch 'upstream/main' into riedgar-ms/issue-934
riedgar-ms 9ff140a
Fixing model
riedgar-ms 6e79e50
Draft of a fix
riedgar-ms ef0e515
Better check
riedgar-ms 1ec2793
mypy fix
riedgar-ms 207b686
Merge branch 'main' into riedgar-ms/issue-934
riedgar-ms 362c7ec
Merge branch 'main' into riedgar-ms/issue-934
riedgar-ms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,13 @@ def my_function(lm): | |
assert str(lm) in ["this is a test another item1", "this is a test another item2"] | ||
|
||
|
||
def test_with_multitokenchars(selected_model: guidance.models.Model): | ||
# Taken from https://github.com/guidance-ai/guidance/issues/934 | ||
lm = selected_model | ||
lm += "歪" + select(["打正着", "门邪道"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the record: >>> a
'打'
>>> b
'门'
>>> a.encode()
b'\xe6\x89\x93'
>>> b.encode()
b'\xe9\x97\xa8' So the two leading characters in the |
||
assert str(lm) == "歪打正着" or str(lm) == "歪门邪道" | ||
|
||
|
||
def test_token_count(selected_model): | ||
lm = selected_model | ||
lm2 = lm + " 1 1 1 1 1" + gen(max_tokens=9) + gen(max_tokens=9) | ||
|
@@ -36,9 +43,7 @@ def test_token_healing(selected_model): | |
if model_type != "GPT2LMHeadModel": | ||
pytest.skip("Test for GPT2 bug only") | ||
gpt2 = selected_model | ||
lm = gpt2 + ( | ||
"This is a story of 10 or 5 or " + zero_or_more(byte_range(b"0", b"9")) | ||
) | ||
lm = gpt2 + ("This is a story of 10 or 5 or " + zero_or_more(byte_range(b"0", b"9"))) | ||
assert len(lm) > len("This is a story of 10 or 5 or ") | ||
|
||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very optimistic about this. This 'fix' almost certainly breaks
recode()
when said fix kicks in. And fundamentally, these bytes came from the LLM, so why on earth is its tokeniser refusing to have anything to do with them?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for investigating this Richard. I agree, this feels like potentially buggy behavior directly in llama-cpp. Do we have a repro for 934 that directly uses the
llama-cpp
(or maybellama-cpp-python
if we need to) bindings? Instead of attempting to fix through this route, a lower level repo might mean we could/should raise an issue on llama-cpp?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@knilink had found:
printf '\xe6\xad' | ./llama-tokenize -m ./Meta-Llama-3-8B-Instruct.Q8_0.gguf --stdin
I have filed a
llama-cpp-python
-based issue (rewritten from @knilink 's investigation) directly on the HF repo whence I'm grabbing the GGUFThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And filed the LlamaCpp bug:
ggerganov/llama.cpp#8691