paulm0016 commited on
Commit
3df0dc4
·
verified ·
1 Parent(s): 7473403

Create newtest 2

Browse files
Files changed (1) hide show
  1. newtest 2 +13 -0
newtest 2 ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # 使用 Hugging Face 的 fill-mask 模型
5
+ classifier = pipeline("fill-mask")
6
+
7
+ def fill_mask(text):
8
+ results = classifier(text, top_k=5)
9
+ return [f"{res['sequence']} (score: {res['score']:.4f})" for res in results]
10
+
11
+ # 创建 Gradio 界面
12
+ demo = gr.Interface(fn=fill_mask, inputs="text", outputs="text")
13
+ demo.launch()