nearest-neighbor-chain

Decompose symmetric pairwise similarity matrices into greedy nearest-neighbor semantic chains.

Updated Apr 20, 2026
One-click install
npx skills add https://github.com/thistleknot/skills --skill nearest-neighbor-chain
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nearest-neighbor-chain
Source: https://github.com/thistleknot/skills/tree/main/nearest-neighbor-chain
Command: npx skills add https://github.com/thistleknot/skills --skill nearest-neighbor-chain

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It turns a pairwise similarity matrix into an ordered set of semantic chains that expose topic boundaries, reducing the effort needed to consolidate or segment related documents.

Core Features & Use Cases

  • Greedy nearest-neighbor chain decomposition: walks above-threshold pairs sorted by descending similarity and extends chains only at their endpoints, producing ragged chains that act as semantic threads.
  • Threshold-controlled grouping: uses a cutoff τ so weak connections become singletons and prevent over-merging.
  • Topic-boundary prescriptions: supports score-range outcomes such as MERGE, migrate, or xref for downstream consolidation and cross-referencing.

Quick Start

Use nearest-neighbor-chain on your documents’ correlation matrix to generate ordered semantic chains using a chosen τ cutoff for topic segmentation and consolidation planning.

Frequently Asked Questions about nearest-neighbor-chain

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

FAQPage Schema
How do I partition a corpus by semantic similarity to find topic boundaries?

Corpus partitioning by semantic similarity is done by decomposing a pairwise similarity matrix into greedy nearest-neighbor chains. Sorting above-threshold pairs by descending score and extending chains at endpoints preserves topic boundaries for document consolidation.

What is the best way to consolidate documents using a pairwise similarity matrix?

Document consolidation from a similarity matrix uses greedy nearest-neighbor chaining to group related items. Applying a cutoff threshold prevents weak connections from over-merging, leaving ungrouped items as singletons while preserving semantic threads for downstream merging.

Can I use a similarity threshold to prevent over-merging during topic segmentation?

A similarity threshold controls topic segmentation by filtering weak connections. Pairs scoring below the threshold cutoff become singletons, ensuring only strong pairwise scores indicate adjacency and preventing the over-merging of unrelated documents during chain decomposition.

How does endpoint extension work when building nearest-neighbor semantic chains?

Endpoint extension builds nearest-neighbor semantic chains by adding items only at the ends of existing chains without merging separate chains. This greedy process walks pairs sorted by descending similarity score, creating ragged chains that act as semantic threads for cross-referencing.

When should I use greedy chaining instead of other clustering methods for cross-referencing?

Greedy chaining is used for cross-referencing when strong pairwise scores indicate adjacency and ordered topic threads are needed. Unlike broad clustering, it exposes topic boundaries and supports score-range outcomes like MERGE, migrate, or xref for downstream consolidation planning.

Why do remaining items become singletons after similarity matrix decomposition?

Remaining items become singletons after similarity matrix decomposition because they fall below the threshold cutoff for strong pairwise adjacency. These ungrouped items represent isolated topics that lack sufficient similarity scores to join any greedy nearest-neighbor chain.