Overview of ragnar RAG workflows
mainragnar is an R package designed to implement Retrieval-Augmented Generation (RAG) workflows. It provides a complete solution for building RAG pipelines with sensible defaults while allowing users to inspect intermediate steps to avoid a "black box" experience.
A typical ragnar workflow follows these stages:
- Document Processing: Preparing markdown or HTML files.
- Text Chunking: Dividing documents into smaller, semantically meaningful pieces.
- Context Augmentation (Optional): Adding document-level context to individual chunks to improve retrieval.
- Embedding: Computing vector representations for chunks (typically via
ellmer). - Storage: Saving chunks and embeddings (typically in
duckdb). - Retrieval: Finding relevant chunks using cosine similarity and BM25 ranking.
- Re-ranking (Optional): Using specialized models to refine the order of retrieved chunks.
- Prompt Generation: Injecting retrieved context into an LLM prompt.