LEAP
LEAP builds skills through two pipelines: Branch A distills a skill from raw data, while Branch B combines multiple skills into…
Designs multiscale chunking for RAG by embedding small units for retrieval precision and returning larger context for synthesis. Use when fixed-size chunks either lose surrounding context or dilute relevance in long documents, manuals, filings, or codebases. Covers
Claude Code
$ npx -y skills add agentsope/SkillAlchemy --skill agentsop-multiscale-chunking --agent claude-code
Codex
$ npx skills add agentsope/SkillAlchemy --skill agentsop-multiscale-chunking -a codex -y
Cursor
$ npx skills add agentsope/SkillAlchemy --skill agentsop-multiscale-chunking -a cursor -y
Gemini CLI
$ npx skills add agentsope/SkillAlchemy --skill agentsop-multiscale-chunking -a gemini-cli -y
GitHub Copilot
$ npx skills add agentsope/SkillAlchemy --skill agentsop-multiscale-chunking -a github-copilot -y
OpenCode
$ npx skills add agentsope/SkillAlchemy --skill agentsop-multiscale-chunking -a opencode -y
Windsurf
$ npx skills add agentsope/SkillAlchemy --skill agentsop-multiscale-chunking -a windsurf -y
name: agentsop-multiscale-chunking version: 0.1.0 description: >- Designs multiscale chunking for RAG by embedding small units for retrieval precision and returning larger context for synthesis. Use when fixed-size chunks either lose surrounding context or dilute relevance in long documents, manuals, filings, or codebases. Covers sentence-window and parent-child or auto-merging strategies, base chunk sizing, and evaluation. Do not use when a single chunk scale already meets retrieval and generation needs.
> Overlay on top of [[llamaindex]]. The base skill teaches the 5-layer RAG > pipeline and lists `DecoupleChunkScope` as one optimization knob among many. > This overlay zooms in on that single knob and turns it into a standalone > recipe: **how to resolve the chunk paradox when one chunk size is provably > not enough.** Third-person analytical view for an agent writing / reviewing > RAG ingestion code — not an end-user tutorial.
---
Activate this overlay when **all three** RAG preconditions hold and the chunk paradox has actually surfaced:
1. The corpus is **long documents** — prose manuals, financial filings, legal contracts, research papers, codebases — where a single answer-bearing fact sits inside a larger context that the LLM needs to interpret it. 2. A **chunk-size sweep has stalled**: small chunks (128–256) win retrieval precision but the LLM answers from fragments; large chunks (1024–2048) give rich context but recall on specific queries drops because the embedding becomes a "topic average". The official failure-mode checklist documents both poles as *separate* failures — #2 (wrong chunk from too-small) and #6 (context overflow / dilution from too-large) (cited in [[llamaindex]] R3). 3. Faithfulness or relevancy is **plateauing below target** and bumping `chunk_size` only moves the failure from one pole to the other.
Concrete triggers:
"incomplete answers" (this is anti-pattern A1 in [[llamaindex]]).
Do **not** activate when:
---
> **Decouple the embed-unit from the return-unit. Embed small for retrieval > precision; return large for generation context.**
The naive assumption is that the unit you index *is* the unit you feed the LLM. That single identity is the source of the paradox: it forces one chunk size to serve two opposing jobs.
NAIVE (one unit, two jobs) MULTI-SCALE (two units, one job each)
───────────────────────── ─────────────────────────────────────
[ chunk ] embed unit → small (precision job)
/ \ │
embed it feed it match
(wants (wants │
small) large) return unit → large (context job)
↓ ↓ ▲
CONFLICT — pick one, expand from
lose the other match → parent / windowThree load-bearing sub-principles:
1. **A Node is a graph node, not a chunk.** In LlamaIndex a `Node` carries `relationships` (PREV/NEXT/PARENT/CHILD). Those links are exactly what let you store a small node for matching and *resolve* it to a larger node for return ([[llamaindex]] Principle 2). Multi-scale chunking is "build a chunk-graph", not "split into chunks".
2. **Two geometries of expansion.** Once embed ≠ return, you must choose *how* the small match expands into the large return:
(sentence-window). The expansion is *positional*.
(auto-merging / parent-child). The expansion is *hierarchical*.
3. **Match the geometry to the document, not to taste.** Flat narrative prose → horizontal. Documents with real structure (headings, sections, tables of contents) → vertical. This is the central dilemma case (§5.1).
The overlay's promise: this *strictly dominates* a compromise chunk size when the sweep frontier is non-flat — you no longer average two bad sizes.
---
A three-gate protocol. Do **not** skip Gate 0 — multi-scale chunking is only justified once a single chunk size has been proven insufficient.
Run the canonical sweep from [[llamaindex]] OP-02 *before* reaching for any multi-scale machinery:
from llama_index.core.evaluation import (
FaithfulnessEvaluator, RelevancyEvaluator,
)
# 1. ~20 eval QA pairs via DatasetGenerator.from_documents(docs)
# 2. sweep:
for cs in (128, 256, 512, 1024, 2048): # overlap = 0.1–0.2 × cs
idx = build_index(docs, chunk_size=cs, overlap=int(0.15 * cs))
record(cs, faithfulness=eval_f(idx), relevancy=eval_r(idx), p95=latency(idx))and **stop**. LlamaIndex's own Uber 10-K study peaked at **1024** for prose; code lands at **80–160** tokens (§5.2).
no single winner) → proceed to Gate 1. *Do not compromise on a middle size.*
| Document shape | Strategy | Geometry | |---|---|---| | F
Turn people, methods, and experience into installable, reusable agent skills. SkillAlchemy is an open-world agent skill creation system that turns underspecified skill briefs and open-world sources into installable, reusable agent skills.
LEAP builds skills through two pipelines: Branch A distills a skill from raw data, while Branch B combines multiple skills into…
Lens — Add a cognitive lens to any problem. It accepts a task description and produces an enhanced description that surfaces…
Cross-framework enhancement overlay for choosing a multi-agent topology BEFORE writing any agent. A binary-question rubric — is…
SOP for terminal-based, git-native AI pair programming with Aider (git work-tree + tree-sitter repo-map + edit-format +…
Screens biomedical / life-science papers for signs of data fabrication, image manipulation, and statistical anomalies, using the…
Universal discipline for any LM-driven loop — agent retries, plan-act-observe, multi-agent handoffs, optimiser passes, test-fix…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.