Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
model_path = 'kahennefer/fine_tuned_gpt2'
|
5 |
+
|
6 |
+
model = AutoModelForCausalLM.from_pretrained(model_path)
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
8 |
+
|
9 |
+
text_gen_pipeline = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
10 |
+
|
11 |
+
def generate_answer(question):
|
12 |
+
result = text_gen_pipeline(question, max_length=100, num_return_sequences=1)
|
13 |
+
return result[0]['generated_text']
|
14 |
+
|
15 |
+
iface = gr.Interface(
|
16 |
+
fn=generate_answer,
|
17 |
+
inputs=gr.Textbox(lines=2, placeholder="Ask a question about the case..."),
|
18 |
+
outputs=gr.Text(label="Answer"),
|
19 |
+
title="Case-Specific Question Answering System",
|
20 |
+
description="Ask any question about the case, and the model will provide an answer based on its knowledge."
|
21 |
+
)
|
22 |
+
|
23 |
+
iface.launch(enable_queue=True)
|