AIwithhassan

RAG Crash Course — AI skill for Claude Code

AI community

Step-by-step RAG tutorial in Python: basic, hybrid (BM25 + dense), query rewriting, re-ranking, metadata filters and agentic RAG, using Actian VectorAI DB.

How to install RAG Crash Course

This entry records only its repository, not the path inside it, so there is no exact command to give. Open AIwithhassan/rag-crash-course and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What RAG Crash Course does

Step-by-step RAG tutorial in Python: basic, hybrid (BM25 + dense), query rewriting, re-ranking, metadata filters and agentic RAG, using Actian VectorAI DB.

Alternatives in AI

  • Xerj — Local-first search engine and MCP server for AI agents 12.5k ★
  • Codeseek — Rust-powered code intelligence CLI for AI coding agents 764 ★
  • K Dense Byok — An AI co-scientist powered by Claude Scientific Skills running on your desktop 583 ★

README

RAG Crash Course

📺 **Video tutorial:** [Watch on YouTube](https://youtu.be/hYYk9S_8UXg)

A hands-on, step-by-step tutorial that builds a Retrieval-Augmented Generation (RAG) chatbot from scratch. Each step is one small Python file that adds **one new idea** and ends by showing a question the current approach still fails on, which motivates the next step.

The demo company is **Star Motors**, a fictional motorcycle maker. Its knowledge base is 10 short documents (HR policies, maintenance manuals, parts catalogs, safety rules, a confidential salary sheet) in [data/star_motors.py](data/star_motors.py).

**Stack:** [Actian VectorAI DB](https://www.actian.com/) (vector database, runs in Docker) · `sentence-transformers` (local embeddings and re-ranker) · `rank-bm25` (keyword search) · an LLM of your choice (OpenAI, Anthropic or Gemini).

The steps

Step File New idea Fails on, so we need the next step
0 build_index.py Chunk → embed → store. Split documents into paragraphs, embed them, save them in VectorAI DB. n/a (run this first)
1 step1_basic_rag.py Semantic (dense) search + answer only from the retrieved chunks. Exact codes like BRK-2270 have no "meaning" for an embedding model.
2 step2_hybrid_search.py Hybrid search: dense + BM25 keyword search, merged with Reciprocal Rank Fusion. A German question against English documents shares no words and no embedding space.
3a step3a_query_rewriting.py Query rewriting: the LLM turns a messy question into a clean English query; both are searched and fused server-side. The right chunk can still rank below look-alike chunks (e.g. prices vs. wear limits).
3b step3b_reranking.py Re-ranking with a cross-encoder: fetch 20 candidates fast, re-score them carefully. Better