Skip to content

Add code signal detection and dynamic symbol boosting#79

Merged
m1rl0k merged 21 commits into
testfrom
code-signal-symbols-with-embeddings
Dec 19, 2025
Merged

Add code signal detection and dynamic symbol boosting#79
m1rl0k merged 21 commits into
testfrom
code-signal-symbols-with-embeddings

Conversation

@m1rl0k

@m1rl0k m1rl0k commented Dec 18, 2025

Copy link
Copy Markdown
Collaborator

Introduces code signal detection in repo_search to analyze queries for code-like patterns and extract symbols, using both regex and embedding-based heuristics. Dynamically boosts symbol and implementation matching based on detected code intent, and passes extracted symbols to hybrid_search for improved targeting. Updates Dockerfile to download reranker and tokenizer models at build time, and modifies hybrid_search to incorporate symbols from CODE_SIGNAL_SYMBOLS environment variable.

Default repo search to snippets on.

Introduces code signal detection in repo_search to analyze queries for code-like patterns and extract symbols, using both regex and embedding-based heuristics. Dynamically boosts symbol and implementation matching based on detected code intent, and passes extracted symbols to hybrid_search for improved targeting. Updates Dockerfile to download reranker and tokenizer models at build time, and modifies hybrid_search to incorporate symbols from CODE_SIGNAL_SYMBOLS environment variable.

Default repo search to snippets on.
@augmentcode

augmentcode Bot commented Dec 18, 2025

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR improves repo search relevance by detecting “code-like” intent in queries and dynamically boosting symbol/implementation (and filename) matches.

Changes:

  • Added code-signal detection in repo_search using regex patterns plus an embedding-centroid heuristic to score code intent and extract likely symbols.
  • Applies dynamic environment-based boost multipliers when code intent is detected (symbol matching and implementation preference).
  • Passes extracted symbol hints to hybrid_search via CODE_SIGNAL_SYMBOLS, and updates hybrid_search.py to incorporate those hints into query lists.
  • Changed repo_search default to include_snippet=true.
  • Implemented filename-based score boosting in the recursive reranker and added a server-side fallback boost when reranking isn’t used.
  • Documented FNAME_BOOST behavior in docs/CONFIGURATION.md.
  • Updated Dockerfile.indexer to download reranker ONNX + tokenizer at build time and set default model path env vars.
  • Updated tests to avoid loading real embedding models and added unit tests for filename boosting.

Technical Notes: Code-intent centroids are lazily initialized and cached; symbol hints are capped before being forwarded to hybrid search to limit query expansion.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Comment augment review to trigger a new review at any time.

Comment thread scripts/mcp_indexer_server.py Outdated
signal_score = signal_score * (1 - blend_weight) + embedding_score * blend_weight
except Exception:
pass
elif use_embedding and signal_score < 0.1:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In _detect_code_signals, use_embedding is referenced but not defined, which will raise NameError and silently disable the embedding-only fallback (the caller catches all exceptions). Consider wiring this branch to an explicit flag/env var (with a default) or removing it to avoid detection unexpectedly no-op’ing.

🤖 Was this useful? React with 👍 or 👎

Improves code symbol detection and matching by extracting full identifiers (including private/dunder and various case styles) for more accurate symbol-based boosts in hybrid_search.py. Increases default symbol boost weights, prevents double-counting, and tunes boost multipliers in mcp_indexer_server.py to be more aggressive for code-like queries, aligning with symbol-aware search. Also updates regex patterns and logic for private and snake_case identifiers.
Enhances the hybrid search algorithm by increasing the score when multiple query tokens match the filename, both in the lexical scoring and in the result ranking stages. This change improves the ranking of files whose names closely match the user's query, making results more relevant for queries that target specific filenames.
Added logic to increase the score of all chunks from files whose filenames strongly correlate with query tokens. This improves hybrid search results by surfacing relevant files even if individual chunks do not contain all query terms.
Adds filename-query correlation boosting to hybrid_search.py to enhance relevance when query tokens match filename tokens. In rerank_recursive.py, increases blend_with_initial to 0.45 in RecursiveReranker and blends ONNX reranker scores with initial hybrid search scores for better preservation of hybrid search signals such as filename correlation and symbol matching.
This commit simplifies hybrid search scoring by removing enhanced symbol and filename correlation boosts, as well as full identifier extraction and matching logic. Symbol and filename boosts are now lighter and more configurable, and ONNX reranker blending is simplified to use only ONNX scores. These changes aim to reduce overfitting to code symbol queries and improve generalization.
Refines the condition for using code signal embedding in mcp_indexer_server.py to check the CODE_SIGNAL_EMBEDDING environment variable for common truthy values. Also adds a missing import of the re module in rerank_recursive.py.
The repo_search function now includes the optional fname_boost value in the components dictionary and the why_parts list if present. This provides more detailed scoring information in search results.
Extracted filename boost logic into helper functions for improved robustness and maintainability. Added unit tests to cover various path extraction and tokenization scenarios, ensuring correct boost calculation and fallback behavior.
Adds documentation for the HYBRID_FNAME_BOOST setting, explaining how filename-based boosting works in search, its default value, and usage examples.
Introduces a fallback mechanism to apply a filename-query correlation boost to search results when the learning reranker is disabled, fails, or is not used. This ensures relevant results receive a score boost based on filename token matches, improving result ranking consistency.
Updated context answer-related tests to mock the embedding model, preventing the need to load the real model during test execution. Also fixed a test data structure in test_server_helpers.py to use a dictionary for 'components' instead of a list.
@Context-Engine-AI Context-Engine-AI deleted a comment from augmentcode Bot Dec 18, 2025
Renames the filename boost environment variable from HYBRID_FNAME_BOOST and RERANK_FNAME_BOOST to FNAME_BOOST across the codebase and documentation. Updates the default boost value from 0.25/0.12 to 0.15 for consistency. Adjusts related documentation and tests to reflect the new variable name and default value.
@m1rl0k

m1rl0k commented Dec 18, 2025

Copy link
Copy Markdown
Collaborator Author

augment review

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestions posted.

Comment augment review to trigger a new review at any time.

_match_count = len(_q_toks & _fname_toks)
if _match_count >= 2:
_boost = float(_fname_boost_factor) * _match_count
r["score"] = float(r.get("score", 0)) + _boost

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After increasing r["score"] with fname_boost, the list order may no longer reflect the updated scores. Consider re-sorting results after this loop so the boost actually affects ranking (and score/ordering don’t diverge).

🤖 Was this useful? React with 👍 or 👎

m1rl0k and others added 8 commits December 17, 2025 22:42
Enhances the filename boost logic to support robust tokenization and normalization, including handling of various naming conventions (camelCase, PascalCase, snake_case, etc.), acronym splitting, abbreviation normalization, and position-aware scoring. Updates the scoring algorithm to provide more accurate and context-aware boosts, and adds comprehensive tests to cover new tokenization and matching behaviors.
Expanded the documentation for filename/path boosting to detail tokenization, normalization, and scoring tiers. Increased penalties for test and documentation files and boosted implementation file preference in hybrid_search.py to ensure code files rank above tests and docs.
Introduces logic to detect when a user's query is seeking implementation code and dynamically increases the boost for implementation files. Also increases penalties for test and documentation files in such cases to improve search relevance.
Introduces query intent detection for the CLI path in hybrid_search.py, aligning its behavior with run_hybrid_search. Adjusts the test penalty if implementation intent is detected.
Replaces TEST_FILE_PENALTY with test_penalty_cli when applying penalties to test files in the recommendation scoring. Ensures the penalty value can be set via the CLI for greater flexibility.
Ensures that the fname_boost adjustment affects the final ranking by re-sorting the results list by updated score after applying the boost.
Adjusted RRF_K, DENSE_WEIGHT, and LEXICAL_WEIGHT in hybrid_search.py to improve score distribution and balance for repositories. Enhanced lexical_score function to boost filename matches more strongly. Updated .gitignore to exclude additional files and directories.
@m1rl0k m1rl0k merged commit f3bf6bb into test Dec 19, 2025
1 check passed
@m1rl0k m1rl0k deleted the code-signal-symbols-with-embeddings branch December 19, 2025 23:16
m1rl0k added a commit that referenced this pull request Mar 1, 2026
Add code signal detection and dynamic symbol boosting
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.

2 participants