Spaces:
Runtime error
Runtime error
# import gradio as gr | |
# from transformers import pipeline | |
# # Load the pre-trained model | |
# generator = pipeline("question-answering", model="EleutherAI/gpt-neo-2.7B") | |
# # Define Gradio interface | |
# def generate_response(prompt): | |
# # Generate response based on the prompt | |
# response = generator(prompt, max_length=50, do_sample=True, temperature=0.9) | |
# return response[0]['generated_text'] | |
# # Create Gradio interface | |
# iface = gr.Interface( | |
# fn=generate_response, | |
# inputs="text", | |
# outputs="text", | |
# title="OpenAI Text Generation Model", | |
# description="Enter a prompt and get a generated text response.", | |
# ) | |
# # Deploy the Gradio interface | |
# iface.launch(share=True) | |
import gradio as gr | |
from transformers import pipeline | |
# Load the question answering pipeline | |
qa_pipeline = pipeline("question-answering", model="distilbert-base-cased-distilled-squad", tokenizer="distilbert-base-cased") | |
# Define a function to generate answer for the given question | |
def generate_answer(question): | |
# Call the question answering pipeline | |
result = qa_pipeline(question=question, context=None) | |
return result["answer"] | |
iface = gr.Interface( | |
fn=generate_answer, | |
inputs="text", | |
outputs="text", | |
title="Open-Domain Question Answering", | |
description="Enter your question to get an answer.", | |
) | |
iface.launch(share=True) # Deploy the interface | |