File size: 1,024 Bytes
4350100
3e60bd8
 
 
 
 
 
 
 
4350100
d698ee5
 
3e60bd8
d698ee5
 
3e60bd8
 
2e0f0bc
 
 
 
74ba6e5
2e0f0bc
11cd583
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, AutoModelForQuestionAnswering
import gradio as gr
import torch


title = "🤖AI ChatBot"
description = "A State-of-the-Art Large-scale Pretrained Response generation model (DialoGPT)"
examples = [["How are you?"]]

model = AutoModelForQuestionAnswering.from_pretrained("bert-large-uncased-whole-word-masking-finetuned-squad",return_dict=False)
tokenizer = AutoTokenizer.from_pretrained("bert-large-uncased-whole-word-masking-finetuned-squad")
nlp = pipeline("question-answering", model=model, tokenizer=tokenizer)

# tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-large")
# model = AutoModelForCausalLM.from_pretrained("microsoft/DialoGPT-large")


def func(context, question):
  result = nlp(question = question, context=context)
  return result['answer']

app = gr.Interface(fn=func, inputs = ['textbox', 'text'], outputs = 'textbox', title = 'Farm QA Bot', theme = 'dark-grass', description = 'Farm QA Bot')

app.launch(inline=False)