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

The output is comments, not code #93

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

The output is comments, not code #93

starplatinum3 opened this issue May 10, 2024 · 0 comments

Comments

@starplatinum3
Copy link

starplatinum3 commented May 10, 2024

The output is comments, not code

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

model_path="/home/ubuntu/model_test/THUDM/codegen"
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_path)

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

inputs = tokenizer(prompt, return_tensors="pt")


sample = model.generate(**inputs, max_length=128)
print(tokenizer.decode(sample[0]))

output:

// language: Java
// Write a class with fields for name, ID, age, address, and company
// and a constructor that takes the name, ID, age, address, and company as parameters
// and initializes the fields.
//
// Write a method that returns the age of the employee.
//
// Write a method that returns the address of the employee.
//
// Write a method that returns the company of the employee.
//
// Write a method that returns the name of the employee.
//
// Write a method that returns the ID of the employee.
//

model use this
Salesforce/codegen25-7b-mono_P · HF Mirror
https://hf-mirror.com/Salesforce/codegen25-7b-mono_P

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