Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RAG

We built a simple RAG (Retrieval-augmented generation) pipeline from scratch, using the following open sources models on huggingface:

Two ways:

  • rag_simple.py: simple vector store in memory.
  • rag_chroma.py: vector store with Chroma Vector DB

RAG modules:

  1. SimpeFileReader: just read a text file
  2. SentenceSplitter: split the docs with specified chunk size and overlap.
  3. VectorStoreIndex: build a vector store with the chunked nodes and create the index.

Work steps:

  1. read the text file.
  2. normalize the file content.
  3. split the content into chunks.
  4. build the vector store with the chunks.
  5. define the question.
  6. query the context of this question from vector store.
  7. format the prompt with the question and it's context.
  8. predict the prompt with the LLM.
  9. get the answer.

Tested and run under Python 3.12.6, the following packages are also required

The test text documents were obtained from Google search on the Internet.

About

Build a simple RAG pipeline from scratch

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages