examples/projects/question-answering-rag/README.md
This project demonstrates how to build a Retrieval-Augmented Generation (RAG) pipeline using Pathway. You can learn more about this here.
The RAG pipeline is designed to enhance the accuracy and relevance of responses to user queries by leveraging a combination of document retrieval and generative language models. This approach ensures that the generated answers are not only coherent but also grounded in the most relevant information available.
Before you start, ensure you have the necessary package installed. You can install it using the following command:
pip install pathway[xpack-llm] python-dotenv
Here's how the RAG structure works:
By integrating retrieval and generation, RAG ensures that the responses are not only accurate but also contextually relevant, making it a robust solution for complex information retrieval tasks.
This project comes with a light HTTP server to send queries and retrieve answers.
By default, the host is 0.0.0.0 and the port is 8011, you can configure it by editing this line:
webserver = pw.io.http.PathwayWebserver(host="0.0.0.0", port=8011)
Clone the Repository:
git clone https://github.com/pathwaycom/pathway.git
cd ./examples/projects/question-answering-rag/
Install Dependencies:
pip install pathway[xpack-llm] python-dotenv
Environment Variables:
Create a .env file in the project root and add your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key_here
Run the Pipeline:
python main.py
Submit a Query:
Use curl to send a query to the web server:
curl --data '{ "messages": "What is the value of X?"}' http://localhost:8011
Receive the Response: The server will process the query and return a generated response based on the retrieved documents.
This project provides a simple RAG pipeline using Pathway. The RAG is live by default, updating the index whenever the documentation changes.
You can find more ready-to-run pipelines in our templates section.