Skip to content

fix(searching_tool): normalize guard, runtime param overrides, 1D query safety#13

Open
agentksimha wants to merge 3 commits intohumanai-foundation:mainfrom
agentksimha:main
Open

fix(searching_tool): normalize guard, runtime param overrides, 1D query safety#13
agentksimha wants to merge 3 commits intohumanai-foundation:mainfrom
agentksimha:main

Conversation

@agentksimha
Copy link
Copy Markdown

Four targeted fixes for silent bugs and missing runtime flexibility.

Problem

  • metric='ip' without L2-normalization returns wrong similarity rankings with no indication anything is wrong
  • nprobe (IVFPQ) and efSearch (HNSW) were fixed at build time with no way to tune them per-query at search time
  • Passing a 1D query vector caused inconsistent output shapes across the three return paths in search()

Changes

  • Add normalize(X) utility for L2-normalization before indexing
  • Add _warn_if_unnormalized() called in all three build functions — samples up to 64 rows, zero overhead at scale
  • Add nprobe= and efsearch= optional overrides to search(); original values saved and restored in a finally block so the bundle is never left in a dirty state
  • Add 1D shape guard at the top of search(); was_1d flag ensures output shape always matches input

No breaking changes — all new params are optional with None defaults.

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.

1 participant