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