AGENT SKILL

composition-and-filtering

This skill teaches a Researcher to compose Faiss indexes, preserve external IDs and child lifetimes, apply selectors and per-search parameters, and choose safe shard, replica, refinement, and IVF inspection workflows.

License 许可
MIT
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
composition-and-filtering
license
MIT
metadata
{ "disco-role": "operating" }
description
This skill teaches a Researcher to compose Faiss indexes, preserve external IDs and child lifetimes, apply selectors and per-search parameters, and choose safe shard, replica, refinement, and IVF inspection workflows.
disable-model-invocation
true

02 资源文件 4

03 SKILL.md 正文

Composition and filtering

Use this branch when a working Faiss index must be wrapped, filtered, refined, sharded, replicated, assigned external IDs, deleted by ID, or inspected through IVF metadata. It owns composition order, label translation, selector routing, child ownership, direct-map prerequisites, and per-query parameter overrides. It does not choose the base index family, codec, persistence format, or optional accelerator.

Route first

Operating procedure

  1. Draw the data-flow before constructing anything. The outermost wrapper sees caller vectors and queries; each IndexPreTransform applies its transform chain in order; IndexIDMap/IndexIDMap2 translates inner positions to caller IDs; IVF performs coarse assignment then list scanning; IndexRefine asks its base index for candidates and its refine index for final distances. Search parameters must be wrapped to match that same nesting order.

  2. Make the ID policy explicit. Use add_with_ids(x, ids) for stable external labels; do not call add() on an IndexIDMap*. IndexIDMap2 adds an external-ID reverse map and supports external-ID reconstruct when the wrapped index can reconstruct. A selector passed at the outer ID map is translated to inner positions. Verify that IDs are unique in a logical corpus; shards with successive_ids=False do not prevent cross-shard ID collisions.

  3. Keep child objects alive. Python wrappers retain constructor children and children added through add_shard/addIndex in referenced_objects for the supported classes. Still retain references yourself when assigning raw pointer fields, replacing quantizers, or using custom extensions. Never delete or mutate a quantizer, transform, selector backing array, or refine child while a search can use it. own_fields is a C++ ownership flag, not a substitute for understanding Python SWIG references.

  4. Choose composition order deliberately. Put a transform outside the index whose stored/search space it should change. Put an ID map outside the storage whose results need external labels. Put refinement outside the candidate index and add the same vectors to base and refine storage through the refinement wrapper. For a transformed refinement search, use SearchParametersPreTransform(index_params=...) when the inner parameter object must cross the transform; use IndexRefineSearchParameters for k_factor and base_index_params.

  5. For IVF filtering, create an IDSelector in the same ID namespace as the parameter recipient. Use IDSelectorRange for a contiguous interval, IDSelectorBatch for a set, IDSelectorBitmap for a dense bounded mask, and IDSelectorAnd/Or/XOr/Not for boolean composition. Put the selector in SearchParametersIVF(sel=selector) (or the appropriate base parameter class), not in a global mutable setting. Check support for the concrete index: selector behavior is not a promise that every backend or wrapper accepts every selector type.

  6. Override IVF search per call with SearchParametersIVF: nprobe controls lists, max_codes bounds work, max_lists_num limits fast-scan list visits, ensure_topk_full softens small post-selector budgets, and max_empty_result_buckets trades range-search recall for early stopping. quantizer_params routes parameters to a parameterized coarse quantizer. Compare against an unfiltered/unbounded baseline before interpreting a recall change.

  7. Use direct maps only for a declared need. IndexIVF.reconstruct(id) and update_vectors require a maintained direct map; call make_direct_map() or set_direct_map_type(...) before those operations. Direct maps add memory and impose ID/merge constraints; search_and_reconstruct can avoid a direct map for supported IVF paths. An ID map does not make an arbitrary lossy or non-reconstructable child reconstructable.

  8. Select shards versus replicas by semantics: shards partition stored vectors and merge candidates; replicas hold the same logical corpus and distribute query work. Keep dimensions, metrics, training state, and ID policy aligned. For implicit shard IDs, use successive_ids=True; for explicit IDs use successive_ids=False and prove global uniqueness. Do not use replicas to deduplicate conflicting IDs or to merge independently trained incompatible indexes.

  9. For advanced IVF tooling, prefer read-only inspection of nlist, list sizes, quantizer state, direct_map.type, and ntotal. Preassigned add/search and quantizer replacement are expert-only operations: validate dimensions, list assignments, ownership, and trained state first. Do not expose raw inverted-list mutation, network/RPC, or destructive merge operations in a default smoke.

  10. Run the bundled deterministic check from any directory:

    python /path/to/composition-and-filtering/scripts/smoke_composition.py --help
    python /path/to/composition-and-filtering/scripts/smoke_composition.py
    

    It validates external-ID translation/deletion, a transformed refinement chain, a selector route, and safe IVF metadata inspection. It is a CPU smoke, not a performance or backend certification.

Recovery routing

Start with troubleshooting.md for stale or translated labels, deleted-child crashes, incorrect parameter nesting, empty filtered results, failed reconstruction, shard collisions, or refinement mismatches. Route a wrong base family or metric to the index-selection sibling, codec/training errors to training-and-compression, persistence/merge/evaluation to persistence-and-evaluation, and backend/network behavior to accelerated-and-interoperable.

Bundled references

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351