Spaces:
Runtime error
Runtime error
updated app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,17 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
|
4 |
+
# Load the model and tokenizer
|
5 |
+
model_name = "tiiuae/falcon-11b"
|
6 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
|
9 |
+
# Define the inference function
|
10 |
+
def generate_text(prompt):
|
11 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
12 |
+
outputs = model.generate(inputs['input_ids'], max_length=50)
|
13 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
14 |
+
|
15 |
+
# Create the Gradio interface
|
16 |
+
interface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
|
17 |
+
interface.launch()
|