-
Notifications
You must be signed in to change notification settings - Fork 990
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
phi-2 issue #681
Comments
Just trying now with the infrastructure in #674 .... I do note that "Janet's" uses a different apostrophe, which looks rather like the one in |
Can confirm, it's the apostrophe in "Janet's" - changing to a regular apostrophe allows the code to run (although putting a |
Interesting! Can we check how the |
Note, this is likely the same underlying issue as #682 |
Experimenting with calling Phi-2 directly, the following works (until the final def test_unicode_temp():
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model = AutoModelForCausalLM.from_pretrained("microsoft/phi-2", torch_dtype=torch.float32, trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-2", trust_remote_code=True)
prompt = "Janet’s ducks lay 16 eggs per day"
inputs = tokenizer(prompt, return_tensors="pt", return_attention_mask=False)
outputs = model.generate(**inputs, max_length=200)
text = tokenizer.batch_decode(outputs)[0]
print(text)
assert False, text |
A part of the problem is that the transformer model returns 51200 logits when you call it but Why that is I don't know...seems like a problem with Phi-2 in transformers? from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model = AutoModelForCausalLM.from_pretrained("microsoft/phi-2", torch_dtype=torch.float32, trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-2", trust_remote_code=True)
prompt = "bla"
inputs = tokenizer(prompt, return_tensors="pt", return_attention_mask=False)
outs = model(**inputs)
print(len(tokenizer.get_vocab())) # 50295
print(outs.logits.shape) # torch.Size([1, 138, 51200]) |
Okay after a lot of digging the bigger problem here is that the Phi2 tokenizer does not have the For example: I am not sure how to fix this, there must be some way to extract the actual byte-string tokens from the tokenizer but I don't know how. @riedgar-ms if you have any ideas let me know :) |
@slundberg I have opened a discussion on Hugging Face about this: |
Side note: I have just spotted that we were getting a warning |
…ance-ai#681, etc)" This reverts commit cd250cd.
…rs (guidance-ai#681, etc)"" This reverts commit 354b0b7.
The bug
List index out of range error when attempting to get a generation from phi-2
Traceback:
File "evaluate_success.py", line 238, in evaluate_phi2_constrained_gsm8k
response = model + prompt + gen("reason", max_tokens=220) + "\n" + "Answer: " + gen("answer", regex='\d+')
File "/home/xfernandes/code/envs/venv/lib/python3.8/site-packages/guidance/models/_model.py", line 302, in add
out = lm._run_stateless(value)
File "/home/xfernandes/code/envs/venv/lib/python3.8/site-packages/guidance/models/_model.py", line 465, in _run_stateless
for new_bytes, is_generated, new_bytes_prob, capture_groups, capture_group_log_probs, new_token_count in gen_obj:
File "/home/xfernandes/code/envs/venv/lib/python3.8/site-packages/guidance/models/_model.py", line 819, in call
sampled_token = self.tokens[sampled_token_ind]
IndexError: list index out of range
To Reproduce
System info (please complete the following information):
The text was updated successfully, but these errors were encountered: