Skip to content

The output is comments, not code #93

Description

@starplatinum3

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions