Rag pipeline builder

From eddiebelaval/squire · View interactive version

Rag pipeline builder is an AI agent skill from the GitHub repository eddiebelaval/squire. Build retrieval-augmented generation systems that ground LLM responses in your data

How to use this skill

Skill file

RAG Pipeline Builder

The RAG Pipeline Builder skill guides you through designing and implementing Retrieval-Augmented Generation systems that enhance LLM responses with relevant context from your own data. RAG combines the power of large language models with the precision of information retrieval, reducing hallucinations and enabling AI to work with private, current, or domain-specific knowledge.

This skill covers the complete RAG stack: document ingestion, chunking strategies, embedding generation, vector storage, retrieval optimization, context injection, and response generation. It helps you make informed decisions at each stage based on your specific requirements for accuracy, latency, cost, and scale.

Whether you are building a documentation Q&A bot, a customer support system, or an enterprise knowledge assistant, this skill ensures your RAG implementation follows production best practices.

Core Workflows

Workflow 1: Design RAG Architecture

  1. Define requirements:
  1. Choose components:
  1. Design data flow:

```

Documents → Loader → Chunker → Embedder → Vector DB

↓

Query → Embedder → Vector Search → Reranker → Context

↓

Context + Query → LLM → Response

```

  1. Document architecture decisions

Workflow 2: Implement Ingestion Pipeline

  1. Set up document loaders:
  1. Implement chunking:

```python

def smart_chunk(doc, chunk_size=500, overlap=50):

# Respect document structure

sections = extract_sections(doc)

chunks = []

for section in sections:

if len(section) > chunk_size:

chunks.extend(sliding_window(section, chunk_size, overlap))

else:

chunks.append(section)

return add_metadata(chunks, doc)

```

  1. Generate embeddings with batching
  2. Store in vector database with metadata
  3. Verify ingestion quality

Workflow 3: Optimize Retrieval Quality

  1. Measure baseline retrieval performance:
  1. Apply optimization techniques:
  1. Tune retrieval parameters:
  1. Validate improvements with test set

Quick Reference

| Action | Command/Trigger |

|--------|-----------------|

| Design RAG system | "Help me design a RAG pipeline for [use case]" |

| Choose vector DB | "Which vector database for RAG" |

| Optimize chunking | "Best chunking strategy for [content type]" |

| Improve retrieval | "My RAG has poor retrieval quality" |

| Reduce hallucinations | "RAG still hallucinating, help fix" |

| Scale pipeline | "Scale RAG to [X] documents" |

Best Practices

Advanced Techniques

Multi-Index Strategy

Use different indexes for different content types:

Index 1: FAQs (short, self-contained)
Index 2: Documentation (long-form, structured)
Index 3: Conversations (temporal, contextual)

Route queries to appropriate index based on intent

Query Transformation Pipeline

Improve retrieval with query processing:

def transform_query(query):
    # Step 1: Classify query type
    query_type = classify_query(query)

    # Step 2: Extract entities
    entities = extract_entities(query)

    # Step 3: Generate search queries
    if query_type == "factual":
        return generate_keyword_queries(query, entities)
    elif query_type == "conceptual":
        return generate_semantic_queries(query)
    else:
        return [query]  # Use as-is

Contextual Compression

Reduce noise in retrieved context:

Retrieved chunks (verbose) → LLM compressor → Relevant excerpts only

Agentic RAG

Let the LLM control retrieval:

def agentic_rag(query):
    # LLM decides what to search for
    search_plan = llm.plan_searches(query)

    # Execute searches
    results = []
    for search in search_plan:
        results.extend(retriever.search(search.query, filters=search.filters))

    # LLM synthesizes answer
    return llm.synthesize(query, results)

Evaluation Framework

Continuously measure RAG quality:

Metrics:
- Retrieval: Precision@k, Recall@k, MRR
- Generation: Faithfulness, Answer Relevance, Context Utilization
- End-to-end: Task Success Rate, User Satisfaction

Tools: Ragas, TruLens, LangSmith

Common Pitfalls to Avoid

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.