ai-data-engineering-rag-pipeline

Build local RAG pipelines with BM25 search, hierarchical chunking, and retrieval evaluation.

5|1|Updated May 16, 2026
One-click install
npx skills add https://github.com/reason-machines/data-skills --skill ai-data-engineering-rag-pipeline-reason-machines
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: ai-data-engineering-rag-pipeline
Source: https://github.com/reason-machines/data-skills/tree/main/skills/ai-data-engineering-rag-pipeline
Command: npx skills add https://github.com/reason-machines/data-skills --skill ai-data-engineering-rag-pipeline-reason-machines

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires rank-bm25, sentence-transformers, faiss-cpu, numpy.

What problem does it solve? Building a retrieval-augmented generation system from scratch requires solving chunking strategy, search ranking, and evaluation simultaneously, and most developers lack a structured path to implement and measure each piece correctly. ## Core Features & Use Cases - BM25 Baseline Search: Build an inverted index with Okapi BM25 ranking and measure quality with Recall@10 against a golden dataset. - Hierarchical Chunking: Create document, section, and paragraph level chunks with deterministic IDs and parent-child metadata linkage. - Hybrid Retrieval & Evaluation: Combine BM25 with FAISS vector search using tunable alpha weights, then compare granularity levels with recall, precision, and MRR metrics. - Use Case: You have a corpus of technical documents and need to determine whether paragraph-level or section-level chunking retrieves better answers. Use this Skill to index both granularities, run your golden question set, and compare Recall@10 scores. ## Quick Start Clone the ai-data-engineering-roadmap repository, install the Day_02 and Day_03 requirements, and ask the assistant to build a BM25 baseline search engine evaluated against the golden dataset.

Frequently Asked Questions about ai-data-engineering-rag-pipeline

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a BM25 search engine in Python?▼

Use the rank-bm25 library's BM25Okapi class with a tokenized corpus built by lowercasing and splitting document text. Call get_scores with a tokenized query, then use numpy argsort to retrieve the top-k ranked documents.

How to implement hierarchical chunking for RAG pipelines?▼

Split documents into document, section, and paragraph levels using newline delimiters, then assign each chunk a deterministic ID from a SHA-256 content hash. Store parent_id references so fine-grained matches can be expanded with parent context at retrieval time.

What is Recall@10 and how do I evaluate retrieval quality?▼

Recall@10 measures the fraction of relevant documents appearing in the top 10 retrieved results for each query in a golden dataset. Compare retrieved document IDs against the relevant_docs field in a questions.jsonl file and average across all queries.

Can I combine BM25 with vector search for hybrid retrieval?▼

Yes, normalize BM25 scores and FAISS cosine similarity scores, then combine them with a weighted sum using an alpha parameter. Tune alpha between 0 and 1 to balance keyword matching against semantic similarity for your domain.

Why does FAISS throw a dimension mismatch error?▼

The error occurs when query embedding dimensions differ from the index dimension, usually from switching embedding models after indexing. Verify query_emb.shape matches faiss_index.d and re-encode the corpus if you change the sentence-transformers model.

Why is my Recall@10 score unexpectedly low?▼

Low recall typically comes from malformed golden datasets, overly aggressive chunk length filters, or poor tokenization. Validate each questions.jsonl line has query and relevant_docs fields, lower minimum chunk length thresholds, and experiment with hybrid alpha values.