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

请问想接上下句古诗 需要怎么写提示词? #120

Open
5 tasks done
goog opened this issue Aug 15, 2023 · 0 comments
Open
5 tasks done

请问想接上下句古诗 需要怎么写提示词? #120

goog opened this issue Aug 15, 2023 · 0 comments
Labels
question Further information is requested

Comments

@goog
Copy link

goog commented Aug 15, 2023

Required prerequisites

Questions

from transformers import AutoModelForCausalLM, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("baichuan-inc/Baichuan-7B", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("baichuan-inc/Baichuan-7B", device_map="auto", trust_remote_code=True)
inputs = tokenizer('犹有渔人数家住', return_tensors='pt')
inputs = inputs.to('cuda:0')
pred = model.generate(**inputs, max_new_tokens=128,repetition_penalty=1.1,
                     do_sample=True,
                     top_k=30,
                     top_p=0.92,
                     #temperature=0.001,
                     num_return_sequences=5)

#print(pred.cpu())
sample_outputs = pred.cpu()
for i, sample_output in enumerate(sample_outputs):
    print("{}: {}".format(i, tokenizer.decode(sample_output, skip_special_tokens=True)))
#print(tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))

33_20230815181802

Checklist

  • I have provided all relevant and necessary information above.
  • I have chosen a suitable title for this issue.
@goog goog added the question Further information is requested label Aug 15, 2023
@goog goog changed the title 请问想接上下句古诗 需要怎么提示词? 请问想接上下句古诗 需要怎么写提示词? Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant