{"id":47928337,"url":"https://github.com/icemap/learntoskip","last_synced_at":"2026-04-04T07:03:13.090Z","repository":{"id":348288799,"uuid":"1195234271","full_name":"Icemap/LearnToSkip","owner":"Icemap","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-31T14:11:44.000Z","size":1057,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-31T16:15:03.683Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Icemap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-29T12:14:04.000Z","updated_at":"2026-03-31T14:11:56.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Icemap/LearnToSkip","commit_stats":null,"previous_names":["icemap/learntoskip"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Icemap/LearnToSkip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icemap%2FLearnToSkip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icemap%2FLearnToSkip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icemap%2FLearnToSkip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icemap%2FLearnToSkip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Icemap","download_url":"https://codeload.github.com/Icemap/LearnToSkip/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icemap%2FLearnToSkip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31390695,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T04:26:24.776Z","status":"ssl_error","status_checked_at":"2026-04-04T04:23:34.147Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-04T07:03:11.458Z","updated_at":"2026-04-04T07:03:13.079Z","avatar_url":"https://github.com/Icemap.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LearnToSkip\n\nLightweight classifier-guided candidate pruning for HNSW index construction.\n\nDuring HNSW construction, the beam search evaluates far more candidates than it retains as neighbors. On SIFT1M with standard parameters (M=16, ef\\_construction=200), **99.2% of candidate distance evaluations are wasted**. LearnToSkip trains a depth-3 decision tree to predict which candidates will be discarded *before* computing their exact distances, achieving up to **3.3x single-threaded** and **3.6x multi-threaded** (4 threads) wall-clock speedup with sub-1.1% recall@10 loss.\n\n## Repository Structure\n\n```\nsrc/learn_to_skip/          # Core library\n  builders/                 # Index construction strategies (vanilla, learned skip, C++ skip)\n  classifiers/              # Classifier wrappers (decision tree, logistic, SVM, XGBoost)\n  experiments/              # Reproducible experiment scripts\n  features/                 # Feature extraction (random projection, encounter rank)\n  datasets/                 # Dataset registry and loaders\n  tracer/                   # HNSW construction tracing (records all candidate evaluations)\n  orchestrator/             # CLI runner for experiments and plots\n  adaptive/                 # Adaptive ef_construction\n  visualization/            # Plotting utilities\nhnswlib_fork/               # Forked hnswlib with skip injection (git submodule)\nbenchmark_cpp/              # C++ micro-benchmarks (tree inference vs L2 distance)\nresults/                    # Experiment output JSONs (checked in for reproducibility)\npaper/                      # LaTeX paper source\ntests/                      # Unit tests\n```\n\n## Setup\n\nRequires Python 3.12+ and [uv](https://docs.astral.sh/uv/).\n\n```bash\n# Clone with submodule\ngit clone --recurse-submodules git@github.com:Icemap/LearnToSkip.git\ncd LearnToSkip\n\n# Install all dependencies (including the forked hnswlib)\nuv sync\n```\n\nThe forked hnswlib is declared as a path dependency in `pyproject.toml` and installed automatically by `uv sync`. To force-reinstall it after modifying C++ code:\n\n```bash\nuv cache clean hnswlib \u0026\u0026 uv sync --reinstall-package hnswlib\n```\n\n## Data\n\nDatasets are downloaded automatically on first use and stored under `data/` (gitignored).\n\n| Dataset | Vectors | Dimensions | Distance | Source |\n|---------|---------|------------|----------|--------|\n| SIFT1M | 1,000,000 | 128 | L2 | [IRISA TEXMEX](http://corpus-texmex.irisa.fr/) |\n| Deep1M | 1,000,000 | 96 | Cosine | [VectorBench](https://github.com/harsha-simhadri/big-ann-benchmarks) |\n| GIST1M | 1,000,000 | 960 | L2 | [IRISA TEXMEX](http://corpus-texmex.irisa.fr/) |\n| GloVe-200 | 1,183,514 | 200 | Cosine | [Stanford GloVe](https://nlp.stanford.edu/projects/glove/) |\n| SIFT10K | 10,000 | 128 | L2 | Auto-generated (for quick tests) |\n\n## Running Experiments\n\n### Via Orchestrator (SIFT10K quick tests)\n\n```bash\n# Check experiment status\nuv run python -m learn_to_skip.orchestrator status\n\n# Run all base experiments in dependency order\nuv run python -m learn_to_skip.orchestrator run-all\n\n# Run a single experiment\nuv run python -m learn_to_skip.orchestrator run motivation\n\n# Force re-run\nuv run python -m learn_to_skip.orchestrator run-all --force\n```\n\n### Million-Scale Experiments (paper results)\n\nThese scripts produce the results reported in the paper:\n\n```bash\n# SIFT1M + Deep1M end-to-end benchmark\nuv run python src/learn_to_skip/experiments/sift1m_deep1m_benchmark.py\n\n# GIST1M (d=960) benchmark\nuv run python src/learn_to_skip/experiments/gist1m_benchmark.py\n\n# Heuristic baselines (rank-only, distance-only) with multi-threading\nuv run python src/learn_to_skip/experiments/heuristic_baselines_multithread.py\n\n# Alpha-pruning baseline (OptHNSW comparison)\nuv run python src/learn_to_skip/experiments/alpha_pruning_baseline.py\n\n# Combined alpha-pruning + learned tree\nuv run python src/learn_to_skip/experiments/combined_baseline.py\n\n# GloVe-200 + visited-set grid\nuv run python src/learn_to_skip/experiments/visited_grid_glove.py\n\n# Fallback, connectivity, adaptive threshold\nuv run python src/learn_to_skip/experiments/fallback_connectivity_adaptive.py\n\n# x86 co-location benchmark (run on x86 server)\nuv run python src/learn_to_skip/experiments/x86_colocation_benchmark.py\n```\n\nResults are written to `results/` as JSON files with merge-on-write semantics (existing data is preserved).\n\n## Generating Plots\n\n```bash\n# All figures\nuv run python -m learn_to_skip.orchestrator plot-all\n\n# Individual figures\nuv run python -m learn_to_skip.orchestrator plot fig1   # Waste ratio\nuv run python -m learn_to_skip.orchestrator plot fig2   # Speedup\nuv run python -m learn_to_skip.orchestrator plot fig3   # Recall-speedup Pareto\nuv run python -m learn_to_skip.orchestrator plot fig4   # Classifier ROC\nuv run python -m learn_to_skip.orchestrator plot fig5   # Threshold sensitivity\nuv run python -m learn_to_skip.orchestrator plot fig6   # Scalability\nuv run python -m learn_to_skip.orchestrator plot fig7   # Adaptive ef\n```\n\n## Tests\n\n```bash\nuv run pytest tests/ -v\n\n# Skip slow tests\nuv run pytest tests/ -v -m \"not slow\"\n```\n\n## Key Results\n\n### SIFT1M (d=128, L2, Apple M4)\n\n| Mode | Threshold | Skip Rate | Speedup | R@10 |\n|------|-----------|-----------|---------|------|\n| Vanilla (1T) | - | 0% | 1.00x | .996 |\n| Vanilla (10T) | - | 0% | 2.36x | .996 |\n| Universal | 0.5 | 91.3% | **3.31x** | .927 |\n| Universal | 0.7 | 77.6% | **2.19x** | .985 |\n| Universal | 0.8 | 62.9% | **1.73x** | .992 |\n| Multi-thread 4T | 0.7 | 77.6% | **3.60x** | .985 |\n\n### GIST1M (d=960, L2, Apple M4)\n\n| Mode | Threshold | Skip Rate | Speedup | R@10 |\n|------|-----------|-----------|---------|------|\n| Universal | 0.5 | 95.7% | **2.90x** | .870 |\n| Combined (alpha+tree) | 0.8 | 77.2% | **2.08x** | .966 |\n\n### Complementarity\n\nLearnToSkip composes with existing acceleration techniques:\n\n- **Stacked with reduced ef\\_c=100**: 2.66x speedup at 0.980 R@10\n- **Combined with alpha-pruning**: up to 5.45x at aggressive settings (0.915 R@10)\n- **Combined quality-preserving** (alpha=5, tau=0.8): 1.74x at 0.990 R@10\n\n## Forked hnswlib\n\nThe `hnswlib_fork/` submodule ([Icemap/hnswlib](https://github.com/Icemap/hnswlib)) extends the original [nmslib/hnswlib](https://github.com/nmslib/hnswlib) with:\n\n- `BaseCandidateSkipFunctor` interface in `searchBaseLayer()` — zero overhead when disabled (single pointer null-check)\n- `DecisionTreeSkipFunctor` with denormalized depth-3 tree and per-thread query projection buffers\n- `AlphaPruningSkipFunctor` implementing OptHNSW-style alpha-pruning baseline\n- Combined alpha-pruning + learned tree functor\n- Co-located projected vector storage (64 bytes/node) for cache-friendly access\n- SIMD-optimized 16-D L2 projection kernel (SSE on x86, NEON on ARM)\n- Multi-threaded construction support with thread-safe skip functors\n- Python bindings: `create_skip_functor()`, `add_items_with_skip()`, `enable_projection_storage()`, `get_construction_metrics()`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficemap%2Flearntoskip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficemap%2Flearntoskip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficemap%2Flearntoskip/lists"}