⚡ Bolt: optimize synthetic embedding generation and vector normalization#200
⚡ Bolt: optimize synthetic embedding generation and vector normalization#200hackerxj2010 wants to merge 1 commit into
Conversation
Optimized synthetic embedding generation and vector math in `@jeanbot/ai`. - Replaced per-dimension hashing with a single SHA-256 hash and a Mulberry32 PRNG. - Replaced `toFixed(8)` with a faster `round8` utility using `Math.round`. - Optimized `normalizeVector` with a single pass and inverse multiplication. - Removed redundant normalization calls in the generation pipeline. - Added a benchmark script and unit tests to verify performance and correctness. Throughput increased from ~102 to ~4500 embeddings/sec (~45x gain). Co-authored-by: hackerxj2010 <198651211+hackerxj2010@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Optimized synthetic embedding generation and vector math in the
@jeanbot/aipackage.🎯 Why: The original implementation was bottlenecked by excessive hashing (one SHA-256 per dimension) and slow string-based rounding (
toFixed(8)) in hot loops.📊 Impact:
🔬 Measurement:
packages/ai/src/benchmark.ts.packages/ai/src/index.test.ts(determinism and normalization).🛡️ Note: Uses the modern
crypto.hashAPI (available in Node.js 22.22.1+ provided in the environment).PR created automatically by Jules for task 14641192464108532705 started by @hackerxj2010