File size: 526 Bytes
e258a3b ed6b9f3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import gradio as gr
# pipeline函数用来加载模型并且推理
from transformers import pipeline
# 创建文本生成管道
pipe = pipeline("text-generation", model="Bush233/olmo3-190m-zh-full-continue")
# 定义预测(predict)函数
def predict(message):
# 调用pipe管道实现文本生成
# message:输入的提示词
# max_new_tokens:输出token的最大值
output = pipe(message, max_new_tokens=256)
return output[0]["generated_text"]
gr.Interface(fn=predict, inputs="text", outputs="text").launch() |