I am using hugging face to make a question and answer bot there are a few questions I've entered and it gave a few word answers but I am unable to get the link or the full context to show, I was wondering if there is a way to make the bot more accurate, below is my code
import streamlit as st
import transformers
from transformers import pipeline
def create_qa_bot():
# Load the question-answering pipeline
qa_pipeline = pipeline("question-answering")
return qa_pipeline
def ask_question(context, question, qa_pipeline):
# Use the pipeline to answer the question based on the context
result = qa_pipeline(context=context, question=question)
return result['answer']
def main():
# Create the question-answering bot
qa_bot = create_qa_bot()
# Example context and questions
context = "To reset your password, go to the forget password link and a code will be sent to your email, then go to this link: www.google.com."
st.title("Question Answering App")
input_text = st.text_area("Question", value="Enter question here")
# Ask questions and print answers
if input_text == "Enter question here":
st.markdown("A:")
else:
answer = ask_question(context, input_text, qa_bot)
st.markdown(f"A: {answer}")
if __name__ == "__main__":
main()
Example input and output:
Input: How do I reset my password
Output: Go to the forget password link
Input: Can I get the link to reset my password
Output: Go to the forget password link
Input: What should I do after getting a code to my email
Output: go to the forget password link
Input: What is the Eiffel tower
Output: forget password link