Skip to content

Code search demo: ask a codebase in plain English (EmbeddingGemma 2, Neural Engine) - #33

Merged
Alex-Wengg merged 3 commits into
mainfrom
feat/code-search-demo
Oct 9, 2026
Merged

Alex-Wengg merged 3 commits into
mainfrom
feat/code-search-demo

Conversation

@Alex-Wengg

@Alex-Wengg Alex-Wengg commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Adds code search on EmbeddingGemma 2: CodeSearch (Swift declaration chunker), CodeSearchCheck (timing + known-answer eval), CodeSearchDemo (Play / Pause / Replay show; demo.sh with macmon + live log).

  • FluidAudio: 5,617 functions and types (483 files, 125k lines) indexed in 16 s at 64 tokens per chunk (28.5 s at 128); ~700 searches/s.
  • The demo's eight plain-English questions all return a right function first; grep -ril for the exact phrase finds 0 files for seven of them.
  • Known-answer eval (16 questions): 11/16 first at 128 tokens, 14/16 in the top 5 at 64. File + symbol in the document title beat either alone.
  • Demo: live lists while indexing (functions) and during search speed (question → answer), syntax-coloured code, area tags.
  • EmbeddingGemma2Manager.embed([texts], maxTokens:) truncates before packing, so short chunks pack several per Neural Engine call.

Checked locally: release build, swift-format lint, demo end to end (--autostart). Chunker unit tests run in CI.

🤖 Generated with Claude Code

…n the Neural Engine

CodeSearch: CodeChunker splits Swift sources into declaration chunks with
a line scanner (func / init / subscript / type, doc comment and
attributes included, Type.member names, 40 lines max); each is embedded
as "title: <file> <symbol> | text: <code>" (the model card's code-retrieval
document format), queries with the code-retrieval prefix.

EmbeddingGemma2Manager.embed([texts]) takes maxTokens: truncating chunks
to 128 tokens lets two pack per 256-token Neural Engine call.

CodeSearchCheck: index timing and a 16-question known-answer eval over
FluidAudio. File + symbol title beat symbol-only or file-only; 128 tokens:
11/16 first, 12/16 top 5, 28 s for 5,617 chunks; 64 tokens: 9/16, 14/16,
~16 s.

CodeSearchDemo: Play / Pause / Replay show — index FluidAudio (or
--repo=), eight example questions (all right first; exact-phrase grep
finds 0 files for seven), the matching code shown, then 30 s of search
speed (712 searches/s against 5,617 functions). demo.sh adds macmon and
the live log.

Tests: chunker names, owners, kinds, lines, doc comments, document format.

Question set and the maxTokens idea from an earlier code-search draft.
Syntax-coloured code (Xcode-dark palette: keywords, types, calls, strings, numbers, comments,
attributes), area tags per result (ASR / TTS / Diarizer / VAD / Shared / CLI / Tests), Type.member
in two colours, gradient score bars, tinted tiles. While indexing the list streams functions as
they are embedded and the preview flashes the latest; during search speed it streams question →
answer. 64-token chunks by default (15.9 s for 5,617 functions, all eight examples still answered
by a right function), faster typing and ~1.6 s per example.
The comparison searched the indexed chunks (40 trimmed lines each); it now searches every indexed
file's full text, so it matches grep -ril (0 files for seven of the eight examples, 1 for the
other, same as grep on FluidAudio).
@Alex-Wengg
Alex-Wengg merged commit e974b38 into main Oct 9, 2026
1 check passed
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