Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Initialize the pipeline with the LLaMA model
|
5 |
+
model_name = "ksh-nyp/llama-2-7b-chat-TCMKB2"
|
6 |
+
pipe = pipeline("text-generation", model=model_name)
|
7 |
+
|
8 |
+
def generate_text(prompt):
|
9 |
+
# Generate text based on the input prompt
|
10 |
+
results = pipe(prompt, max_length=1024) # Adjust max_length as needed
|
11 |
+
return results[0]['generated_text']
|
12 |
+
|
13 |
+
# Create the Gradio interface
|
14 |
+
interface = gr.Interface(
|
15 |
+
fn=generate_text,
|
16 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your prompt here..."),
|
17 |
+
outputs="text",
|
18 |
+
title="Text Generation with TCM Fine-Tuned LLaMA 2 7B",
|
19 |
+
description="Enter a prompt to generate text using the TCM Fine-Tuned LLaMA 2 7B model."
|
20 |
+
)
|
21 |
+
|
22 |
+
# Launch the app
|
23 |
+
interface.launch()
|