Repository navigation
Code search demo: ask a codebase in plain English (EmbeddingGemma 2, Neural Engine) - #33
Merged
Merged
Conversation
…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).
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.
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).grep -rilfor the exact phrase finds 0 files for seven of them.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