We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
原始生成 其中input_ids未定义,小小的问题提一下下。
`from transformers import AutoModelForCausalLM, AutoTokenizer import torch
model_name = "llama-2-7b-hf" # 用你下载的模型的文件夹位置 model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto") tokenizer = AutoTokenizer.from_pretrained(model_name)
text = "say" inputs = tokenizer(text, return_tensors="pt") print(f"inputs:{inputs}")
logits = model.forward(input_ids) print("Logits Shape:", logits.logits.shape) print(f"logits:{logits.logits}")
next_token = torch.argmax(logits.logits, dim=-1).reshape(-1)[1] print(f"next_token:{next_token}")
next_word = tokenizer.decode(next_token) print(f"next_word:{next_word}")`
The text was updated successfully, but these errors were encountered:
No branches or pull requests
原始生成
其中input_ids未定义,小小的问题提一下下。
`from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_name = "llama-2-7b-hf" # 用你下载的模型的文件夹位置
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_name)
text = "say"
inputs = tokenizer(text, return_tensors="pt")
print(f"inputs:{inputs}")
定义一下 input_ids = inputs['input_ids']
logits = model.forward(input_ids)
print("Logits Shape:", logits.logits.shape)
print(f"logits:{logits.logits}")
next_token = torch.argmax(logits.logits, dim=-1).reshape(-1)[1]
print(f"next_token:{next_token}")
next_word = tokenizer.decode(next_token)
print(f"next_word:{next_word}")`
The text was updated successfully, but these errors were encountered: