Spaces:
Runtime error
Runtime error
Commit
·
abba6e8
1
Parent(s):
7d35e7d
Added default model gpt-2 for prompting
Browse files
app.py
CHANGED
@@ -1,23 +1,34 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
2 |
|
3 |
theme = gr.themes.Soft()
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
]
|
10 |
|
11 |
-
#
|
12 |
-
def echo_text(input_text):
|
13 |
-
return input_text
|
14 |
|
15 |
with gr.Interface(
|
16 |
-
fn=
|
17 |
inputs=gr.Textbox(placeholder="Enter text here..."),
|
18 |
outputs=gr.Textbox(),
|
19 |
-
examples=
|
20 |
-
live=
|
21 |
title="LLM Evaluator with Linguistic Scrutiny",
|
22 |
theme=theme
|
23 |
) as iface:
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Initialize the GPT-2 pipeline
|
5 |
+
pipe = pipeline("text-generation", model="gpt2")
|
6 |
|
7 |
theme = gr.themes.Soft()
|
8 |
|
9 |
+
# Function that generates text based on instruction-based prompting
|
10 |
+
def generate_text(input_instruction):
|
11 |
+
# Use the input instruction to generate text
|
12 |
+
generated_text = pipe(input_instruction, max_length=100)[0]['generated_text']
|
13 |
+
return generated_text
|
14 |
+
|
15 |
+
# Define example instructions for testing
|
16 |
+
instruction_examples = [
|
17 |
+
("Write a short story about a cat."),
|
18 |
+
("Explain the concept of artificial intelligence."),
|
19 |
+
("Compose a poem about nature."),
|
20 |
]
|
21 |
|
22 |
+
# Function that echoes the input text
|
23 |
+
#def echo_text(input_text):
|
24 |
+
# return input_text
|
25 |
|
26 |
with gr.Interface(
|
27 |
+
fn=generate_text,
|
28 |
inputs=gr.Textbox(placeholder="Enter text here..."),
|
29 |
outputs=gr.Textbox(),
|
30 |
+
examples=instruction_examples,
|
31 |
+
live=False,
|
32 |
title="LLM Evaluator with Linguistic Scrutiny",
|
33 |
theme=theme
|
34 |
) as iface:
|