File size: 1,428 Bytes
221c587
b3f4fd2
221c587
b3f4fd2
 
 
95383f2
b3f4fd2
 
 
 
 
 
184c5ea
 
89ec919
 
b3f4fd2
 
723c51d
89ec919
 
723c51d
89ec919
b3f4fd2
89ec919
 
b3f4fd2
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
from transformers import pipeline

# Load the model using Hugging Face's pipeline
model_name = "thangduong0509/distilbert-finetuned-squadv2"
qa_pipeline = pipeline('question-answering', model=model_name)

# Define a function that the interface will use
def answer_question(context, question):
    return qa_pipeline(context=context, question=question)['answer']

# Define a single example
examples = [
    ["Tính đến tháng 6/2023, Vườn ươm Viện Đổi mới sáng tạo đã ươm tạo gần 100 dự án khởi nghiệp, trong đó có 19 dự án thành lập công ty, hơn 7600 người tham dự các hoạt động và tổng giá trị đầu tư mạo hiểm đạt 350.000 USD.", 
     "Tổng giá trị đầu tư mạo hiểm của Vườn ươm Viện Đổi mới sáng tạo là bao nhiêu?"]
]

# Create the Gradio interface
iface = gr.Interface(fn=answer_question,
                     inputs=[
                         gr.Textbox(lines=7, placeholder="Enter the context here...", label="Context"),
                         gr.Textbox(placeholder="Enter your question here...", label="Question")
                     ],
                     outputs=gr.Textbox(label="Answer"),
                     title='UEH-QA',
                     description='Creating safe AGI that benefits all of humanity.',
                     examples=examples)

# Launch the interface
iface.launch()