Skip to content

Add search_mode, direction scores and a settings echo to semsim search - #1482

Draft
kevinschaper wants to merge 1 commit into
mainfrom
feat/semsim-search-levers
Draft

kevinschaper wants to merge 1 commit into
mainfrom
feat/semsim-search-levers

Conversation

@kevinschaper

Copy link
Copy Markdown
Member

Closes #1476. Part of #1474. First in a stack of draft PRs; each later one is based on the one before it.

Summary

This is the groundwork the other ranking settings build on. Requests that don't set the new parameter behave exactly as before, on either backend.

  • search_mode (hybrid default, or full) on GET /semsim/search/{termset}/{group} and POST /semsim/search. The engine already supported it; the API hard-coded hybrid. Hybrid prefilters candidates with a set Jaccard that drops richly annotated entities before they're scored. Full scores every entity in the group.
  • Both direction scores on every result: subject_to_object_score and object_to_subject_score, next to score. They're derived from each result's similarity payload, so they mean the same thing on either backend.
  • search_settings on every result: the engine that served the request, plus metric, directionality and search mode. This uses per-result fields rather than a wrapper object, which would have broken the current list response. It's redundant across a page, but compatible.
  • Routing. A ducksim-only setting with a non-default value is served by ducksim, since semsimian can't honour it, and the echo reports engine: ducksim. The table of ducksim-only settings in semsim.py is the one place the later PRs extend.
  • The schema change is in similarity.yaml, with model.py and model.ts regenerated by make model.

Testing

  • The backend suite passes: 769 passed, 16 skipped. New tests cover full-mode ranking, both direction scores under every directionality, the settings echo, routing to ducksim, and the default path calling the backend exactly as before.
  • Checked against monarch-kg 2026-10-07 with five common neurodevelopmental terms plus inverted nipples:
    • Defaults are unchanged.
    • search_mode=full&directionality=object_to_subject puts SLC35A2-CDG (MONDO:0010478) third, in the group of 22 diseases that tie for first. The default leaves it out of the top 50.

https://claude.ai/code/session_01RmR3yV2ogn7Rx7bJnXXouU

Search gains `search_mode` (hybrid, the default, or full). Every result now
carries both direction averages and the settings the search ran with. A
request that sets a ducksim-only setting to a non-default value is served by
ducksim, since semsimian can't honour it. Requests that set none behave
exactly as before on either backend.

Part of #1476.

Claude-Session: https://claude.ai/code/session_01RmR3yV2ogn7Rx7bJnXXouU
@netlify

netlify Bot commented Oct 23, 2026

Copy link
Copy Markdown

✅ Deploy Preview for monarch-app ready!

Name Link
🔨 Latest commit 618584e
🔍 Latest deploy log https://app.netlify.com/projects/monarch-app/deploys/6adbd56b152e54391807bc4e
😎 Deploy Preview https://deploy-preview-1482--monarch-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.22%. Comparing base (8233707) to head (618584e).

Files with missing lines Patch % Lines
backend/src/monarch_py/service/semsim_results.py 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1482      +/-   ##
==========================================
+ Coverage   85.08%   85.22%   +0.14%     
==========================================
  Files         131      132       +1     
  Lines        7548     7628      +80     
==========================================
+ Hits         6422     6501      +79     
- Misses       1126     1127       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
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.

semsim API: search_mode, both direction scores, settings echo, and routing to ducksim

1 participant