Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

ykimura517/RAG-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

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.

Usage

Set Your OpenAI API Key

export OPENAI_API_KEY={{your-api-key}}

Install Required Libraries

pip install -r requirements.txt

Save Sample Data

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.

Run Sample Code

python3 main.py

The detailed steps in this script are as follows:

  1. Embed the user query using OpenAI Embeddings.
  2. Search for the nearest data in sample_data.json based on cosine similarity.
  3. Use the data retrieved in step 2 to construct a prompt and generate an answer with GPT.

That's all! Happy hacking!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages