feat(embed): Phase 1 — static token embedding engine#354
Merged
Conversation
Dual-backend code embedding for Brain Mode: 1. Hashing trick (tokens.rs) — zero-dep, 256-dim, fast. Good for dedup/near-duplicate detection. 2. Pre-trained nomic-embed-code (token_vocab.rs) — real 768-dim vectors from the 7B code model, vendored as 30MB int8 blob. ~94.5% recall@10 vs full model per CBM benchmarks. Tokenizer handles camelCase/snake_case/acronym splitting for better vocab coverage (calculateHash → [calculate, hash]). Vendored from CBM (Apache-2.0): code_vectors.bin (40,856 tokens × 768 dims, int8 quantized), code_tokens.txt, LICENSE, NOTICE. 36 tests covering both backends, tokenizer, and quality checks. 695 total tests pass (0 failures). Phase 1 of cora-code Brain Mode roadmap. See: cora-code-dev skill, Phase 0-5 plan.
- Remove premature pub use re-exports (will add in Phase 3) - Add #![allow(dead_code)] — API not yet consumed by commands - Fix test import path for tokenize_code - Run cargo fmt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 1: Static Token Embedding (Brain Mode Roadmap)
Dual-backend code embedding for Brain Mode.
What's included
src/embed/tokens.rssrc/embed/token_vocab.rssrc/embed/mod.rsvendored/nomic/scripts/extract_code_tokens.pyTHIRD_PARTY.mdArchitecture
Tokenizer improvements
calculateHash→ [calculate,hash]hello_world→ [hello,world]HTTPServer→ [HTTP,Server]->,::,+=as single tokensTrade-offs
Testing
Roadmap context
Phase 0 (rename) ✅ → Phase 1 (this PR) → Phase 2 (tree-sitter + knowledge graph) → Phase 3 (brain mode commands) → Phase 4 (uteke integration) → Phase 5 (Voyage-4-Nano ONNX)