Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
from transformers import AutoModel, AutoTokenizer
|
2 |
import gradio as gr
|
3 |
-
import os
|
4 |
|
5 |
# 加载模型和分词器
|
6 |
model_id = "BioMistral/BioMistral-7B"
|
@@ -12,8 +11,9 @@ def generate_text(prompt):
|
|
12 |
inputs = tokenizer(prompt, return_tensors="pt")
|
13 |
# 生成文本(这里使用模型的输出作为示例)
|
14 |
outputs = model(**inputs)
|
15 |
-
|
16 |
-
|
|
|
17 |
|
18 |
# 创建Gradio界面
|
19 |
iface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
|
|
|
1 |
from transformers import AutoModel, AutoTokenizer
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
# 加载模型和分词器
|
5 |
model_id = "BioMistral/BioMistral-7B"
|
|
|
11 |
inputs = tokenizer(prompt, return_tensors="pt")
|
12 |
# 生成文本(这里使用模型的输出作为示例)
|
13 |
outputs = model(**inputs)
|
14 |
+
|
15 |
+
# 处理输出(这里返回最后一个隐藏状态的形状作为示例)
|
16 |
+
return outputs.last_hidden_state.tolist() # 转换为列表以便Gradio显示
|
17 |
|
18 |
# 创建Gradio界面
|
19 |
iface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
|