Skip to content
Back to skills

Rag Chunking Evaluator

ASecurity

Analyze document structures to recommend optimal chunking strategies and overlap ratios for RAG pipelines.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 27, 2026
ai-agentspythongobashapi

Works with

  • api

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned September 27, 2026

npx -y skills add RMAzrim/opencode-artes --skill rag-chunking-evaluator --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Rag Chunking Evaluator?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Rag Chunking Evaluator
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/rmazrim-rag-chunking-evaluator/badge)](https://www.skillsdirectory.com/skills/rmazrim-rag-chunking-evaluator)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: RAG Chunking Evaluator
description: Analyze document structures to recommend optimal chunking strategies and overlap ratios for RAG pipelines.
metadata:
  source: skills/rag-chunking-evaluator/rag-chunking-evaluator.md
---

# RAG Chunking Evaluator

## Prerequisites & Dependencies
- Python 3.10+ with `pip install langchain openai tiktoken`
- Access to an LLM API key (OpenAI, Anthropic, or similar) for generating test embeddings
- A sample document corpus (PDFs, txt files, web pages) to analyze
- Optional: `pip install mlflow` for experiment tracking

## Execution Steps
1. Load the document corpus and split into individual pages or sections
2. Tokenize each section using `tiktoken` with the target model's encoder (e.g., `gpt-4o` or `gpt-4-turbo`)
3. Experiment with chunking strategies:
   - **Fixed-size chunks**: constant token count (e.g., 256, 512, 1024 tokens)
   - **Recursive character splitting**: break on paragraphs, sentences, words with overlap
   - **Section-aware splitting**: respect headings, tables, and code blocks as natural boundaries
4. For each strategy, generate embeddings via the LLM API and index into a vector store (Chroma, Pinecone, Qdrant)
5. Retrieve test queries and measure retrieval metrics:
   - **Recall@k**: percentage of relevant documents found in top-k results
   - **Precision@k**: percentage of retrieved documents that are relevant
   - **Answer accuracy**: end-to-end QA correctness using the retrieved context
6. Tune overlap ratios (typically 10–25% of chunk size) to minimize information loss at boundaries
7. Document the optimal strategy and produce a config file (`chunk_size`, `overlap`, `splitter_type`) for production RAG pipelines

```python
# Example: Recursive chunking with tiktoken and overlap
import tiktoken
from langchain.text_splitter import RecursiveCharacterTextSplitter

enc = tiktoken.get_encoding("cl100k_base")  # gpt-4o encoding

def count_tokens(text):
    return len(enc.encode(text))

def chunk_documents(documents, chunk_size=512, chunk_overlap=60):
    splitter = RecursiveCharacterTextSplitter(
        chunk_size=chunk_size,
        chunk_overlap=chunk_overlap,
        separators=["\n\n", "\n", " ", ""],
    )
    chunks = []
    for doc in documents:
        chunks.extend(splitter.split_text(doc))
    return chunks

documents = [
    """Artificial Intelligence (AI) refers to the simulation of human intelligence processes by computer systems. These processes include learning, reasoning, and self-correction. ...""",
    """Machine Learning (ML) is a subset of AI that focuses on the development of algorithms that allow computers to learn from data ...""",
]

chunks = chunk_documents(documents, chunk_size=300, chunk_overlap=50)
print(f"Total chunks generated: {len(chunks)}")
for i, c in enumerate(chunks[:3]):
    print(f"Chunk {i}: {count_tokens(c)} tokens – {c[:60]}...")
```

```bash
pip install langchain openai tiktoken
python rag_chunking.py
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.