Spaces:
Sleeping
Sleeping
File size: 497 Bytes
098beb3 925510a 098beb3 cbecf26 202216b |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
from transformers import pipeline
# 中文 GPT2 模型(兼容 Hugging Face pipeline)
model_b = pipeline("text-generation", model="uer/gpt2-chinese-cluecorpussmall", tokenizer="uer/gpt2-chinese-cluecorpussmall")
def run_model_b(prompt: str) -> str:
output = model_b(prompt,
max_length=100,
do_sample=True,
temperature=0.8,
top_k=50,
top_p=0.95)
return output[0]["generated_text"] |