RAG Patterns

Provide expert patterns for building RAG systems with pgvector, BM25, and RAGAS evaluation.

Updated Feb 25, 2026
One-click install
npx skills add https://github.com/HermeticOrmus/LibreMLOps-Claude-Code --skill rag-patterns-hermeticormus
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: RAG Patterns
Source: https://github.com/HermeticOrmus/LibreMLOps-Claude-Code/tree/main/plugins/rag-architecture/skills/rag-patterns
Command: npx skills add https://github.com/HermeticOrmus/LibreMLOps-Claude-Code --skill rag-patterns-hermeticormus

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires langchain, sentence-transformers, cohere, datasets, ragas, openai, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides expert patterns to build robust and high-performing Retrieval Augmented Generation (RAG) systems, ensuring accurate and relevant information retrieval for your LLM applications.

Core Features & Use Cases

  • Document Ingestion: Load, parse, and chunk various document types (PDF, TXT) while preserving metadata.
  • Embedding & Indexing: Store document embeddings efficiently using PostgreSQL with pgvector.
  • Hybrid Search: Combine keyword (BM25) and semantic (dense vector) search for superior retrieval accuracy.
  • Re-ranking: Enhance precision by re-ranking candidate documents using cross-encoders or APIs like Cohere.
  • Evaluation: Measure RAG system performance with RAGAS metrics for faithfulness, relevancy, and recall.
  • Use Case: Building a legal AI assistant that can accurately answer questions about complex contracts by retrieving and synthesizing information from a large corpus of legal documents.

Quick Start

Ingest documents from a list of file paths using the ingest_documents function.

Frequently Asked Questions about RAG Patterns

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

FAQPage Schema
How do I build a RAG pipeline with hybrid search and re-ranking?

Build a RAG pipeline by recursively chunking documents, indexing embeddings with pgvector, combining BM25 keyword search with dense vectors, and re-ranking candidates with cross-encoders or Cohere. This approach maximizes retrieval accuracy for complex queries before passing context to the LLM.

What is the best way to evaluate RAG system performance?

Evaluate RAG system performance using the RAGAS framework to measure faithfulness, relevancy, and recall. This provides quantitative metrics to assess how accurately your retrieval pipeline finds and synthesizes relevant information for the LLM.

How do I ingest and chunk PDF documents for semantic search?

Ingest and chunk PDF documents using recursive chunking techniques that preserve metadata. Loading and parsing documents with LangChain prepares the text into optimal segments for generating accurate dense vector embeddings.

Does pgvector work well for storing document embeddings in a RAG system?

Pgvector works efficiently for storing document embeddings in a RAG system, providing PostgreSQL integration for vector similarity searches. It handles dense vector indexing to support semantic retrieval alongside traditional database queries.

Why does my semantic search return irrelevant documents?

Semantic search returns irrelevant documents when relying solely on dense vectors, making hybrid search necessary. Combining BM25 keyword matching with dense vector retrieval and applying cross-encoder re-ranking significantly enhances precision and retrieval accuracy.

Can I use Cohere to re-rank candidate documents in LangChain?

You can use Cohere to re-rank candidate documents in LangChain, acting as a cross-encoder API to enhance precision. This re-ranking step refines initial retrieval results by scoring and ordering documents based on query relevance.