Skip to content
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

回答是空的 #245

Open
starplatinum3 opened this issue May 9, 2024 · 0 comments
Open

回答是空的 #245

starplatinum3 opened this issue May 9, 2024 · 0 comments

Comments

@starplatinum3
Copy link

这个问题回答是空的
prompt = "// language: Java\n //Write a class with fields for name, ID, age, address, and company\n"

from transformers import AutoTokenizer, AutoModel

model_path="/home/ubuntu/model_test/THUDM/codegeex2-6b"

tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
model = AutoModel.from_pretrained(model_path, trust_remote_code=True, device='cuda')

model = model.eval()


prompt = "// language: Java\n //Write a class with fields for name, ID, age, address, and company\n"

inputs = tokenizer.encode(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(inputs, max_length=256, top_k=1)
response = tokenizer.decode(outputs[0])

print("response")
print(response)
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

No branches or pull requests

1 participant