- Python 95%
- Makefile 5%
RAG #
NOTE: Goal is to do this probect without AI as much as possible. Only current use is to explain the subject. Since AI wrote it, let AI explain the painfull english used in them. Also really important design choices. #
Day 0 #
RAG-basics: #
- Subject 42h
- Res from git: https://arxiv.org/pdf/2005.11401
- What is LLM: https://www.iese.fraunhofer.de/blog/retrieval-augmented-generation-rag/
- What is LLM: https://www.ibm.com/think/topics/retrieval-augmented-generation
- Parametric and non-parametric memory: https://lawrence-emenike.medium.com/a-straightforward-explanation-of-parametric-vs-non-parametric-memory-in-llms-f0b00ac64167
- Fine-tuning RAG: https://arxiv.org/pdf/2505.10792
- RAG vs Finetuning: https://www.ibm.com/think/topics/rag-vs-fine-tuning
- Understanding Recall@k: https://krishnapullak.medium.com/understanding-precision-recall-and-f-score-at-k-in-recommender-systems-7146a0dce68e
- RAG Indexing: https://medium.com/@j13mehul/rag-part-4-indexing-1985f4000f72
- Chunking and types of chunking :https://community.databricks.com/t5/technical-blog/the-ultimate-guide-to-chunking-strategies-for-rag-applications/ba-p/113089
- Retrieval methods: TF-IDF vs BM25: https://kmwllc.com/index.php/2020/03/20/understanding-tf-idf-and-bm-25/
- Hands on deep learning: https://ocw.mit.edu/courses/15-773-hands-on-deep-learning-spring-2024/pages/syllabus/
- Retrieval-Augmented Generation (RAG): https://link.springer.com/article/10.1007/s12599-025-00945-3
- vLLM : https://www.redhat.com/en/topics/ai/what-is-vllm
- Learn RAG From Scratch – Python AI Tutorial from a LangChain Engineer: https://www.youtube.com/watch?v=sVcwVQRHIc8
- Good simple explanation on entire RAG (also check other parts): https://medium.com/@j13mehul/rag-part-1-from-naive-to-advanced-cb40674a7738
- How to count tokens with Tiktoken: https://developers.openai.com/cookbook/examples/how_to_count_tokens_with_tiktoken
- RAG from scratch: video supliment: https://github.com/langchain-ai/rag-from-scratch
- toml: https://toml.io/en/
To scan the folder and find txt and python files 19. https://www.geeksforgeeks.org/python/python-loop-through-folders-and-files-in-directory/
To loop through files in the directory and find path: 20. https://www.geeksforgeeks.org/python/os-walk-python/ 21. https://www.tutorialspoint.com/python/os_walk.htm 22. https://stackoverflow.com/questions/16465399/need-the-path-for-particular-files-using-os-walk
Implementing different chunking statergies based on file types: 23. https://jillanisofttech.medium.com/optimizing-chunking-strategies-for-retrieval-augmented-generation-rag-applications-with-python-c3ab5060d3e4
sentense transformers: 24. https://www.sbert.net/ natural language toolkit: 25. https://www.nltk.org/ 26. https://guides.library.upenn.edu/penntdm/python/nltk
Document based chunking using recursive mechanism: 27. https://weaviate.io/blog/chunking-strategies-for-rag
Chunk size and Chunk Overlap: 28. https://dev.to/tak089/what-is-chunk-size-and-chunk-overlap-1hlj
Hybrid retrival: 0. https://www.youtube.com/watch?v=r0Dciuq0knU
What is RAG: #
- Retrieval Augmented Generation is an architecture for optimizing the performance of an AI model by connecting it to external knowledge bases: databases, document collections etc.[2][3]
Benefits of RAG:[3] #
- Larger information pool availablilty so more relevant data source.
- Access to current domain-specific data
Types of memory:[4] #
- Parametric memory: Knowledge hard-coded directly into the LLM's weights during training.
- Non-parametric memory: Retrieving\storing external knowledge using RAG and Vector databases.
NOTE: #
The difference between Parametric and non-Parametric memory is available in [4].
What is indexing in RAG: #
Organizing a vast amount of text data in a way that allows RAG system to quickly access the most relevant piece of information for given query.[6]
Chunking stratergies: #
Subject requires two distinct chunking stratergies:
- Python code chunking
- Markdown / text chunking
A good resource for chunking:[9]. Also contain different methods of chunking. Indexing a target corpus: the indexer chunks every file and persists the index under data/processed/.
Retrieval methods: #
- TFT-IDF
- BM25
NOTE: #
At least one of this must be implemented.
Day 1 #
Note: #
-
Chunk size is configurable through a CLI argument (--max_chunk_size), with a default of 2000 characters. Do not go above it: the moulinette rejects any retrieved source longer than 2000 characters (its max_context_length), and a single over-long source makes your whole output invalid. Smaller chunks are fine; report the effect on your recall@k. [0]
-
Code to run: uv run python -m src index --max_chunk_size 2000
-
Need a better explanation on each parts like chunking, retrieval etc.
Retrieval #
Once we get the index built from chunking process, we get top-k most releveant snippets based on our search query.
Tiktoken, LangChain, cosine_similarity, bs4 soupstrainer,