---
title: 'Corpus2Skill: Hierarchical RAG Framework'
url: https://www.emergentmind.com/topics/corpus2skill
type: topic
---

# Corpus2Skill: Hierarchical RAG Framework

Searching arXiv for the cited Corpus2Skill-related papers to ground the article in current sources.
Corpus2Skill is a compile-then-navigate framework for retrieval-augmented generation (RAG) that transforms a raw document corpus into a hierarchical skill directory which a large language model (LLM) agent actively explores at query time, rather than treating retrieval as a single opaque top-\(k\) lookup step [2604.14572]. In the narrower sense, the term refers to the enterprise QA architecture introduced in "Don't Retrieve, Navigate: Distilling Enterprise Knowledge into Navigable Agent Skills for QA and RAG" [2604.14572]. In a broader sense, related contemporaneous work explicitly recasts trajectory distillation, test-time skill synthesis, and heterogeneous knowledge compilation as instances of a general "Corpus2Skill" problem: transforming corpora of documents, trajectories, manuals, logs, or mixed records into reusable procedural guidance for agents [2603.25158] [2605.16986] [2606.09316].

## 1. Definition and conceptual basis

Corpus2Skill replaces runtime dependence on a vector index with offline compilation of a corpus into a visible hierarchy of topic clusters and summaries [2604.14572]. The resulting artifact is a filesystem of `SKILL.md` and `INDEX.md` files that exposes corpus organization to the agent. At serve time, the agent begins from one-line skill descriptions, drills into progressively finer summaries, and retrieves full documents by identifier only when needed. The framework is therefore two-phase: an offline compile phase and an online serve phase.

The central claim of the framework is that flat retrieval gives the model no visibility into the overall corpus structure: it cannot see what topics remain unexplored, cannot backtrack systematically, and cannot combine evidence across separate branches [2604.14572]. By contrast, a hierarchical directory affords progressive disclosure, explicit backtracking, and cross-branch synthesis. The navigation cost is characterized as logarithmic: with branching factor \(p\) and \(N\) documents, the depth is \(L=\lceil \log_p N\rceil\), and only \(O(p\log_p N)\) summaries are inspected instead of \(O(N)\) [2604.14572].

This formulation treats the hierarchy itself as procedural scaffolding. The agent is not only given evidence; it is given a navigable map of where evidence is likely to reside. A plausible implication is that Corpus2Skill shifts part of the burden of inference from late-stage answer synthesis to earlier-stage search planning, which distinguishes it from conventional dense retrieval pipelines.

## 2. Offline compilation into a skill hierarchy

The offline pipeline begins with a corpus \(\mathcal{D}=\{d_1,\dots,d_N\}\) and builds a hierarchical skill forest in four stages [2604.14572]. First, raw documents such as `.md`, `.txt`, `.json`, and `.jsonl` are read, assigned deterministic IDs by content hash, truncated to a maximum length, and embedded with a sentence-embedding model such as Qwen3-Embedding-0.6B to produce vectors \(v_i\in\mathbb{R}^d\).

Second, the system performs iterative hierarchical clustering. At level \(\ell\), the current node embeddings \(\{x_1,\dots,x_n\}\) are normalized to unit norm, partitioned into \(m=\lceil n/p\rceil\) clusters with K-Means using Euclidean distance \(d(x,y)=\|x-y\|_2^2\), and summarized cluster by cluster [2604.14572]. Because the vectors are unit-norm, this Euclidean objective is equivalent to cosine similarity for ranking purposes. For each cluster \(C_j\), the compiler selects up to \(r\) representative texts, uses an LLM summarization prompt emphasizing topic area, question types, and key terms, embeds the resulting summary \(s_j\) into a new vector \(u_j\), and repeats until the number of top clusters is at most \(K\). The hierarchy depth is given as
$$
L=\bigl\lceil \log_p N\bigr\rceil.
$$

Third, each non-leaf node is labeled by an LLM prompt that outputs a filesystem-safe directory name of 2–5 words, such as `wix-payments-ecosystem` [2604.14572]. Fourth, the hierarchy is materialized on disk as a forest of \(K\) skills. Root clusters become skill directories with `SKILL.md`; sub-clusters become subdirectories with `INDEX.md`; and leaf documents are stored in a global `documents.json` referenced by document ID. The markdown files use YAML frontmatter containing fields such as `name`, `description`, `level`, and `num_documents`, which supports the progressive disclosure mechanism [2604.14572].

The compile phase is therefore not merely summarization. It is a corpus-to-filesystem compilation process whose output is directly consumable by an agentic runtime. This distinguishes Corpus2Skill from systems that summarize clusters only to reinsert them into a conventional retriever.

## 3. Serve-time navigation and decision process

At serve time, the agent has two tools: `view(path)` to read `SKILL.md` or `INDEX.md`, and `get_document(doc_id)` to load a full document [2604.14572]. Initially, only skill names and one-line descriptions are preloaded, approximately 200 tokens in total. Content is loaded only through explicit `view` calls.

A typical query proceeds in stages. The agent first takes a bird’s-eye view of the top-level skill descriptions and selects one or two relevant skills. It then views the corresponding `SKILL.md`, inspects the \(O(p)\) subgroup summaries, drills down to `INDEX.md`, selects one to three document IDs at the leaves, retrieves the full documents, and finally synthesizes a grounded answer [2604.14572]. The agent can return to higher levels if a branch proves unproductive, and it can visit multiple branches if evidence must be combined across topic areas.

The paper gives an idealized decision rule for selecting the next child node:
$$
c^*=\arg\max_{c\in\text{children}} \mathrm{Relevance}(q,\text{summary}_c),
$$
where relevance may be instantiated by embedding similarity,
$$
\mathrm{cos}(e_q,e_{s_c})=\frac{e_q^\top e_{s_c}}{\|e_q\|\|e_{s_c}\|},
$$
or approximated by the LLM’s own reasoning [2604.14572]. The important point is not the exact scoring function but the visibility of alternatives: the agent knows which subgroups remain unexplored and can backtrack explicitly.

A common misconception is that Corpus2Skill eliminates retrieval entirely. The more precise characterization is that it eliminates vector or graph database retrieval at runtime while preserving explicit document retrieval by identifier and relying on embeddings during offline compilation [2604.14572]. It is therefore a different serve-time retrieval regime, not an absence of retrieval.

## 4. Empirical evaluation on WixQA

The principal evaluation of Corpus2Skill is on WixQA, an enterprise customer-support benchmark for RAG [2604.14572]. The corpus contains 6,221 Wix support articles, and the query set contains 200 expert-written customer-support questions with gold answers and gold document IDs. With \(p=10\) and \(K=7\), the compilation produces a 3-level hierarchy with 6 top-level skills, 665 navigation files, a 13 MB document store, and an approximate compile time of 6.5 minutes [2604.14572].

The baselines include BM25, Dense retrieval using Qwen3 embeddings and FAISS, a Hybrid method based on reciprocal-rank fusion of BM25 and Dense, RAPTOR using UMAP, GMM, and BIC with collapsed-tree retrieval, and Agentic RAG with up to 10 iterative retrieval rounds across BM25, Dense, and Hybrid [2604.14572]. Evaluation uses lexical metrics including Token F1, BLEU, ROUGE-1, and ROUGE-2; LLM-judged Factuality and Context Recall normalized from 1 to 5; and cost metrics including input tokens and dollars per query.

Corpus2Skill achieves the highest quality across all metrics, albeit at higher cost [2604.14572]. Relative to the best flat baseline, the reported improvements are +27% Token F1, with 0.460 versus 0.363; +85% BLEU, with 0.137 versus 0.074; and +45% Context Recall, with 0.652 versus 0.450. The cost tradeoff is explicit: \$0.17 per query with 53 K input tokens, versus RAPTOR at \$0.012 and Agentic RAG at \$0.098 [2604.14572].

The failure analysis isolates where the system breaks down. Among the 31% of queries with low Factuality \(\le 0.4\) or Context Recall \(\le 0.2\), 61% are attributed to top-level navigation misses, 31% to partial navigation in which the gold document is retrieved but diluted by distractors, 5% to synthesis errors, and 3% to cases where no documents are retrieved [2604.14572]. An ablation reports that narrower top clusters reduce routing errors. This indicates that hierarchy design, especially top-level partitioning, is a dominant determinant of performance.

## 5. Relation to the broader corpus-to-skill literature

Related 2026 work broadens the meaning of Corpus2Skill from navigable document hierarchies to a general family of corpus-to-procedure compilation methods [2603.25158] [2605.16986] [2606.09316]. These systems differ in what counts as the corpus, how skills are represented, and whether adaptation happens offline, online, or at test time.

| System | Source corpus | Runtime use |
|---|---|---|
| Corpus2Skill [2604.14572] | Document corpus | Navigate `SKILL.md` / `INDEX.md`, then retrieve full docs |
| Trace2Skill [2603.25158] | Labeled execution traces | Load a single evolved skill folder, no retrieval index |
| SkillTTA [2605.16986] | Training trajectory pool | Retrieve top-\(k\) trajectories and synthesize a temporary `SKILL.md` |
| Anything2Skill [2606.09316] | Manuals, logs, trajectories, dialogues, mixed records | Dual retrieval of passages and skills from a SkillBank |

Trace2Skill distills a large pool of trajectories into a single, conflict-free skill directory via a three-stage pipeline: trajectory generation, parallel patch proposal by success and error analysts, and hierarchical consolidation under programmatic guardrails [2603.25158]. The skill representation is a standard `SKILL.md` plus auxiliary resources, and the evolved skill is deployed with no retrieval index and no parameter updates. The framework reports gains in spreadsheet, VisionQA, and math reasoning, including a +57.65 percentage point cross-model transfer result on WikiTableQuestions and 3–5 percentage point gains on math reasoning benchmarks [2603.25158].

SkillTTA moves the corpus-to-skill operation to test time [2605.16986]. Its training corpus is
$$
D=\{(x_i,m_i,\tau_i,y_i)\}_{i=1}^n,
$$
where \(x_i\) is the instruction, \(m_i\) metadata, \(\tau_i\) the full execution trajectory, and \(y_i\in\{T^+,T^-\}\) the success or failure label. For a test task \(T=(x_q,m_q)\), the method retrieves \(k\) nearest neighbors by cosine similarity over metadata embeddings produced by `text-embedding-3-large`, synthesizes a temporary textual skill \(s_q\) using a second LLM, and prepends it to the fixed solver prompt. No parameter updates are permitted at test time [2605.16986]. On SpreadsheetBench, task-specific skills improve Pass@1 from 0.397 to 0.505 relative to static Trace2Skill under GPT-5.5 synthesis; on BigCodeBench, Pass@1 improves from 0.517 to 0.651; and on ALFWorld, the method reaches 0.872 success with 8.88 steps, matching a heavier memory-learning baseline within four points while producing the shortest successful trajectories among reported methods [2605.16986].

Anything2Skill generalizes further to heterogeneous corpora \(\mathcal{K}=\{D_i\}_{i=1}^N\) and compiles them into a persistent SkillBank \(\mathcal{B}\) under a skill-tree prior \(\mathcal{T}\) [2606.09316]. Each record is broken into evidence windows, candidate skills are produced by a plan-and-expand operator, overlapping drafts are canonically compiled, and registry-level reconciliation predicts lifecycle actions such as Create, Strengthen, Revise, Merge, Split, Unchanged, or Discard. At inference, the agent performs dual retrieval:
$$
\mathcal C_q=\mathrm{Retrieve}_{\mathrm{RAG}}(q,\mathcal K),\qquad
\mathcal S_q=\mathrm{Retrieve}_{\mathrm{Skill}}(q,\mathcal B),
$$
and outputs \(y=A_\theta(q,\mathcal C_q,\mathcal S_q)\) [2606.09316]. On qsv and GitHub-CLI, Anything2Skill combined with RAG reaches 98.85% and 94.10% success rates, respectively, outperforming RAG-only agents [2606.09316].

Taken together, these systems suggest that "Corpus2Skill" now denotes a design space rather than only a single implementation. The common thread is the conversion of latent procedural information in corpora into explicit, agent-readable skills.

## 6. Limitations, misconceptions, and open problems

The original Corpus2Skill framework is explicit about its limitations [2604.14572]. Per-query cost is dominated by navigation token load, making the method better suited to high-value, multi-hop queries than to cheap, high-throughput retrieval. API constraints such as a maximum of 8 skills and 200 files per skill restrict tree shape. Hard single-path clustering means that documents covering multiple topics appear in only one branch, which can create blind spots. The system also lacks incremental updates: adding documents requires full recompilation.

These limitations frame several open problems. The paper proposes prompt caching or delta-updates to reduce repeated navigation costs, soft or multi-parent clustering to handle multi-topic documents, evaluation on larger and more diverse enterprise corpora, and tighter integration with evolving Skills APIs as file-count and size limits grow [2604.14572]. Related work points to adjacent extensions: semantic or AST-based conflict resolution for richer skill formats, human review of high-support merges, learned taxonomies, and retrieval hybrids for rare edge cases [2603.25158] [2606.09316].

Another misconception is that skill compilation necessarily replaces declarative retrieval. The broader literature indicates multiple coexistence patterns. Corpus2Skill emphasizes navigable summaries plus document retrieval [2604.14572]; Trace2Skill removes runtime retrieval in favor of a single consolidated skill [2603.25158]; SkillTTA performs one retrieval and one synthesis step per task [2605.16986]; and Anything2Skill couples compiled procedural skills with conventional RAG passages at inference [2606.09316]. The controversy is therefore not whether retrieval should exist, but where procedural abstraction should occur: offline in a persistent hierarchy, offline in a consolidated skill file, or online as a temporary task-specific skill.

In that broader sense, Corpus2Skill marks a shift in agent design from retrieving isolated evidence snippets toward compiling and exposing reusable procedural structure. The specific enterprise QA system shows that making the corpus organization visible can improve grounded answer quality on WixQA [2604.14572], while the adjacent trajectory- and knowledge-compilation systems show that the same corpus-to-skill principle extends to agent traces, manuals, logs, and mixed knowledge bases [2603.25158] [2605.16986] [2606.09316].

Source: https://www.emergentmind.com/topics/corpus2skill