Spaces:
Runtime error
Runtime error
jordigonzm
commited on
Commit
•
82cc52b
1
Parent(s):
95a989a
Load the model using Hugging Face's transformers pipeline
Browse files
app.py
CHANGED
@@ -1,13 +1,15 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
model
|
|
|
5 |
|
6 |
-
def
|
7 |
-
|
8 |
-
|
|
|
9 |
|
10 |
-
def main():
|
11 |
with gr.Blocks() as blocks:
|
12 |
with gr.Tab("Model Info"):
|
13 |
gr.Markdown("""
|
@@ -22,11 +24,10 @@ def main():
|
|
22 |
The information provided should not be seen as a modification of the licensing under which the model is released.
|
23 |
[More information](https://huggingface.co/microsoft/Phi-3-mini-128k-instruct)
|
24 |
""")
|
25 |
-
with gr.Tab("
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
input_text.change(fn=chat_with_model, inputs=input_text, outputs=output_text)
|
30 |
|
31 |
blocks.launch()
|
32 |
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
def main():
|
5 |
+
# Load the model using Hugging Face's transformers pipeline
|
6 |
+
model = pipeline("text-generation", model="microsoft/Phi-3-mini-128k-instruct")
|
7 |
|
8 |
+
def generate_text(input_text):
|
9 |
+
# Generate text using the model
|
10 |
+
result = model(input_text, max_length=50)
|
11 |
+
return result[0]['generated_text']
|
12 |
|
|
|
13 |
with gr.Blocks() as blocks:
|
14 |
with gr.Tab("Model Info"):
|
15 |
gr.Markdown("""
|
|
|
24 |
The information provided should not be seen as a modification of the licensing under which the model is released.
|
25 |
[More information](https://huggingface.co/microsoft/Phi-3-mini-128k-instruct)
|
26 |
""")
|
27 |
+
with gr.Tab("Generate Text"):
|
28 |
+
input_text = gr.Textbox(placeholder="Type here to generate text")
|
29 |
+
output_text = gr.Textbox(label="Generated Text")
|
30 |
+
input_text.submit(fn=generate_text, inputs=input_text, outputs=output_text)
|
|
|
31 |
|
32 |
blocks.launch()
|
33 |
|