title | emoji | colorFrom | colorTo | sdk | app_file | pinned |
---|---|---|---|---|---|---|
Haystack-7-wonders |
🚀 |
indigo |
red |
docker |
app.py |
false |
This chatbot uses RAG to answer questions about the Seven Wonders of the Ancient World.
Here are sample questions you can ask it:
- What is the Great Pyramid of Giza?
- What is the Hanging Gardens of Babylon?
- What is the Temple of Artemis at Ephesus?
- What is the Statue of Zeus at Olympia?
- What is the Mausoleum at Halicarnassus?
- Where is Gardens of Babylon?
- Why did people build Great Pyramid of Giza?
- What does Rhodes Statue look like?
- Why did people visit the Temple of Artemis?
- What is the importance of Colossus of Rhodes?
- What happened to the Tomb of Mausolus?
- How did Colossus of Rhodes collapse?
This project uses Poetry for package management.
It uses this pyproject.toml
file
To install dependencies:
pip install poetry
poetry install
The data is from the [Seven Wonders dataset][1] on Hugging Face. https://huggingface.co/datasets/bilgeyucel/seven-wonders
The chatbots retrieval mechanism is developed using Retrieval Augmented Generation (RAG) with Haystack and its user interface is built with Chainlit. It is using OpenAI GPT-3.5-turbo.
Pipeline steps (Haystack) - check the full script here: app.py
- Initialize in-memory Document store
# Initialize Haystack's QA system
document_store = InMemoryDocumentStore(use_bm25=True)
- Load dataset from HF
dataset = load_dataset("bilgeyucel/seven-wonders", split="train")
- Transform documents and load into document store
document_store.write_documents(dataset)
- Initialize a RAG prompt
rag_prompt = PromptTemplate(
prompt="""Synthesize a brief answer from the following text for the given question.
Provide a clear and concise response that summarizes the key points and information presented in the text.
Your answer should be in your own words and be no longer than 50 words.
\n\n Related text: {join(documents)} \n\n Question: {query} \n\n Answer:""",
output_parser=AnswerParser(),
)
- Set a Retriever node using
BM25Retriever
retriever = BM25Retriever(document_store=document_store, top_k=2)
- Set a prompt node using GPT-3.5-turbo
pn = PromptNode("gpt-3.5-turbo",
api_key=MY_API_KEY,
model_kwargs={"stream":False},
default_prompt_template=rag_prompt)
- Build the pipeline
# Set up pipeline
pipe = Pipeline()
pipe.add_node(component=retriever, name="retriever", inputs=["Query"])
pipe.add_node(component=pn, name="prompt_node", inputs=["retriever"])
@cl.on_message
async def main(message: str):
# Use the pipeline to get a response
output = pipe.run(query=message)
# Create a Chainlit message with the response
response = output['answers'][0].answer
msg = cl.Message(content=response)
# Send the message to the user
await msg.send()
poetry run chainlit run app.py --port 7860