Skip to content

Add vector-search-tool: MLX TurboQuant vector search example#482

Open
joelnishanth wants to merge 1 commit into
ml-explore:mainfrom
joelnishanth:add-vector-search-tool
Open

Add vector-search-tool: MLX TurboQuant vector search example#482
joelnishanth wants to merge 1 commit into
ml-explore:mainfrom
joelnishanth:add-vector-search-tool

Conversation

@joelnishanth

Copy link
Copy Markdown

Summary

Adds vector-search-tool — a CLI example demonstrating on-device vector search using mlx-turbovec-swift, a TurboQuant implementation with optional MLX GPU acceleration.

This complements embedder-tool (which embeds text and stores raw vectors as JSON) by showing compressed vector search: 768-dim embeddings shrink from 3,072 bytes to 384 bytes (4-bit) with >90% recall@10.

What it demonstrates

  • Integrating a third-party MLX-powered Swift package (mlx-turbovec-swift) alongside mlx-swift
  • TurboQuant indexing: random rotation → TQ+ calibration → Lloyd-Max quantization → LUT search
  • Optional --gpu flag to enable MLX GPU batch rotation via MLXBackend.enableGPU()
  • Structured JSON benchmark output (compression, latency, recall vs brute-force)

Usage

./mlx-run vector-search-tool --gpu --dim 768 --count 10000 --queries 100 --k 10

Or via SPM:

swift run vector-search-tool --count 1000 --queries 10

Changes

  • Tools/vector-search-tool/ — CLI tool + README
  • Package.swift — executable target with mlx-turbovec-swift + swift-argument-parser deps
  • Xcode scheme + CI build step
  • README index entry + ACKNOWLEDGMENTS

Testing

  • swift build --target vector-search-tool — PASS
  • xcodebuild -scheme vector-search-tool -skipMacroValidation — PASS
  • Smoke run: --count 500 --queries 10 --k 5 — PASS (R@1=1.0, 7.9× compression)

Joel Nishanth · offlyn.AI

Made with Cursor

Introduces a CLI tool that indexes synthetic vectors with TurboVec
(mlx-turbovec-swift), runs approximate top-k search, and reports
compression, latency, and recall vs brute-force cosine similarity.

- Tools/vector-search-tool with ArgumentParser CLI and README
- SPM executable target + Xcode scheme wired to mlx-turbovec-swift
- CI builds vector-search-tool alongside other tools

Co-authored-by: Cursor <cursoragent@cursor.com>
@davidkoski

Copy link
Copy Markdown
Collaborator

I like the idea and the tool but I don't want external dependencies like this. How about a section in the top level readme that links to examples that you host in your own repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants