Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,27 +1,23 @@
|
|
| 1 |
-
|
| 2 |
-
import os
|
| 3 |
-
#os.system("pip install gradio[notebook]")
|
| 4 |
import gradio as gr
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
model = AutoModelForSeq2SeqLM.from_pretrained("cognitivecomputations/dolphin-2_6-phi-2")
|
| 11 |
|
| 12 |
-
def
|
| 13 |
-
inputs = tokenizer(
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
description="you are a good teacher of python code generation student models.",
|
| 24 |
-
theme="dark",
|
| 25 |
-
analytics_enabled=False)
|
| 26 |
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 3 |
|
| 4 |
+
# Load your teacher model
|
| 5 |
+
model_name = "cognitivecomputations-dolphin-2_6-phi-2"
|
| 6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 7 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
|
|
|
| 8 |
|
| 9 |
+
def generate_response(prompt):
|
| 10 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 11 |
+
with torch.no_grad():
|
| 12 |
+
outputs = model.generate(**inputs, max_length=100)
|
| 13 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 14 |
+
return response
|
| 15 |
|
| 16 |
+
interface = gr.Interface(fn=generate_response,
|
| 17 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your prompt here..."),
|
| 18 |
+
outputs="text",
|
| 19 |
+
title="Text Generation with Dolphin-2_6-Phi-2",
|
| 20 |
+
description="This model generates responses based on the input prompt. Try it out!")
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
interface.launch()
|