efrenam commited on
Commit
73b7e8b
·
verified ·
1 Parent(s): b19e66c

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.txt +0 -0
  2. app.py +23 -0
  3. requirements.txt +3 -0
README.txt ADDED
File without changes
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ # Initialize the text generation pipeline
5
+ generator = pipeline("text-generation", model="gpt2")
6
+
7
+ def generate_response(prompt):
8
+ """Generate text based on the user's prompt."""
9
+ response = generator(prompt, max_length=100, num_return_sequences=1)
10
+ return response[0]["generated_text"]
11
+
12
+ # Create a Gradio interface
13
+ interface = gr.Interface(
14
+ fn=generate_response,
15
+ inputs="text",
16
+ outputs="text",
17
+ title="Simple LLM",
18
+ description="Enter a prompt to get a response generated by GPT-2!"
19
+ )
20
+
21
+ # Launch the app
22
+ if __name__ == "__main__":
23
+ interface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ torch
3
+ gradio