Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,8 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
"""
|
| 5 |
-
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 6 |
-
"""
|
| 7 |
from transformers import pipeline
|
| 8 |
|
| 9 |
-
model_name = "EleutherAI/gpt-neo-
|
| 10 |
generator = pipeline("text-generation", model=model_name, torch_dtype=torch.float16)
|
| 11 |
|
| 12 |
def generate_text(prompt):
|
|
@@ -16,6 +12,13 @@ interface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
|
|
| 16 |
interface.launch()
|
| 17 |
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 20 |
|
| 21 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import torch # Add this import
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
+
model_name = "EleutherAI/gpt-neo-2.7B" # Adjusted to use a smaller model
|
| 6 |
generator = pipeline("text-generation", model=model_name, torch_dtype=torch.float16)
|
| 7 |
|
| 8 |
def generate_text(prompt):
|
|
|
|
| 12 |
interface.launch()
|
| 13 |
|
| 14 |
|
| 15 |
+
def generate_text(prompt):
|
| 16 |
+
return generator(prompt, max_length=50)[0]["generated_text"]
|
| 17 |
+
|
| 18 |
+
interface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
|
| 19 |
+
interface.launch()
|
| 20 |
+
|
| 21 |
+
|
| 22 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 23 |
|
| 24 |
|