Downloads · 30 days
14
3% of all-time downloads
xmj2002/gpt2_tang_poetry
gpt2_tang_poetry is a text generation model from xmj2002. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
使用的预训练模型为uer/gpt2-chinese-cluecorpussmall
Downloads · 30 days
14
3% of all-time downloads
All-time downloads
549
Public
Repo size
842 MB
Likes
1
Public
Click a slice to open those files.
.bin421 MB · 100%
From the Hugging Face model README
使用的预训练模型为uer/gpt2-chinese-cluecorpussmall
from transformers import AutoModelForCausalLM
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("xmj2002/gpt2_tang_poetry")
model = AutoModelForCausalLM.from_pretrained("xmj2002/gpt2_tang_poetry")
text = "白居易《远方》"
inputs = tokenizer(text, return_tensors="pt").input_ids
outputs = model.generate(inputs, max_new_tokens=100, do_sample=True, top_k=100, top_p=0.95)
tokenizer.decode(outputs[0], skip_special_tokens=True)