Spaces:
Runtime error
Runtime error
pokeberrypie
commited on
Commit
•
7c2904b
1
Parent(s):
960caef
Create falco_180b_gradio.py
Browse files- falco_180b_gradio.py +23 -0
falco_180b_gradio.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# falcon_180b_gradio.py
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
5 |
+
|
6 |
+
def main():
|
7 |
+
# Load the model and tokenizer
|
8 |
+
model_name = "bigscience/falcon-180b" # Replace with the correct model name if different
|
9 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
10 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
11 |
+
|
12 |
+
# Define the function that uses the model
|
13 |
+
def generate_text(input_text):
|
14 |
+
inputs = tokenizer(input_text, return_tensors="pt", max_length=512, truncation=True)
|
15 |
+
outputs = model.generate(**inputs, max_length=512, min_length=50, num_return_sequences=1)
|
16 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
17 |
+
|
18 |
+
# Create and launch the Gradio interface
|
19 |
+
iface = gr.Interface(fn=generate_text, inputs="text", outputs="text", title="Falcon 180B Text Generator")
|
20 |
+
iface.launch()
|
21 |
+
|
22 |
+
if __name__ == "__main__":
|
23 |
+
main()
|