This is a simple step-by-step example of Retrieval-Augmented Generation (RAG) created by ykimura517.
For more details about this repository, please visit my blog post.
If you have any questions, feel free to reach out to me.
export OPENAI_API_KEY={{your-api-key}}
pip install -r requirements.txt
python3 embedder.py
By running this script, sample_data.json
will be saved in the local directory. It contains sample texts along with their vector data.
python3 main.py
The detailed steps in this script are as follows:
- Embed the user query using OpenAI Embeddings.
- Search for the nearest data in sample_data.json based on cosine similarity.
- Use the data retrieved in step 2 to construct a prompt and generate an answer with GPT.
That's all! Happy hacking!