Skip to content

fix(query): stop dropping zero-valued hybrid combination params - #819

Merged
vishal-bala merged 3 commits into
redis:mainfrom
hyeonsang010716:fix/hybrid-zero-combination-params
Nov 5, 2026
Merged

vishal-bala merged 3 commits into
redis:mainfrom
hyeonsang010716:fix/hybrid-zero-combination-params

Conversation

@hyeonsang010716

@hyeonsang010716 hyeonsang010716 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

build_combination_method checks linear_alpha, rrf_constant and rrf_window for truthiness, so an explicit 0 is treated as if it were never passed. HybridQuery(..., combination_method="LINEAR", linear_alpha=0.0) raises ValueError: No parameters provided for combination method. With yield_combined_score_as set it raises nothing and sends no weights at all, so the server applies its defaults. rrf_constant=0 is replaced by the server's default of 60 without any signal, because HybridQuery always sends a window.

Changes

Treat 0 as a provided value

The three checks in build_combination_method now compare against None, so a 0 reaches the server:

HybridQuery(..., combination_method="LINEAR", linear_alpha=0.0)
# COMBINE LINEAR 4 ALPHA 0.0 BETA 1.0

HybridQuery(..., combination_method="RRF", rrf_constant=0)
# COMBINE RRF 4 WINDOW 20 CONSTANT 0

linear_alpha=0.0 scores by vector similarity only, the counterpart of linear_alpha=1.0. Redis rejects WINDOW 0, so rrf_window=0 now returns the server's WINDOW: Value below minimum error instead of silently running with a different window.

The linear_alpha docstring and the advanced queries notebook now say both searches still run at 0 and 1, so use VectorQuery or TextQuery when only one is needed.

Notes

build_base_query has similar truthiness checks on range_radius, range_epsilon and knn_ef_runtime. They are left out because they aren't combination params and need different handling: the server accepts RADIUS 0 but rejects EPSILON 0 and EF_RUNTIME 0.

Release Notes

HybridQuery now honours linear_alpha=0 and rrf_constant=0, including MCP search.params.linear_text_weight: 0 and rrf_constant: 0 on native hybrid search. These values were previously dropped, so affected queries will rank differently, and rrf_window=0 now returns a server error instead of being ignored.

Reviewer Brief

Start here: build_combination_method in redisvl/query/hybrid.py. It's the only production logic change, and sync, async and MCP hybrid search all go through it.

Where it could fail

  • redisvl/query/hybrid.py:337: a query or MCP config passing rrf_window=0 used to run and now gets a server error; nothing in the repo passes it.

Not verified: a full MCP server run with these values (only the query arguments it builds); Redis Cluster, Redis Software and Redis Cloud. The docs don't state whether 0 is accepted for ALPHA or CONSTANT, so that rests on the runs against Redis 8.4.8 and 8.10.3. The cost difference from VectorQuery and TextQuery wasn't measured; the runs only confirm both searches still execute at alpha 0 and 1.

Beyond CI: reverting each of the three checks on its own fails only the regression tests for that parameter; the tests also pass on redis-py 7.1.0 and 7.4.1.

Since the last brief: f91c0a4 consolidates the zero-value tests and makes the test_hybrid_query_alpha assertion two-sided; 3feccd1 documents that both searches run at alpha 0 and 1. No production logic changed.

Reviewed fd4bc4c · Claude Code (claude-opus-5-5) · lenses: correctness, security, design, tests, docs, Redis behaviour


Note

Medium Risk
Queries that previously passed 0 for combination params will rank differently now; rrf_window=0 may surface a Redis server error instead of being ignored silently.

Overview
HybridQuery no longer treats linear_alpha=0, rrf_constant=0, or rrf_window=0 as “unset.” In build_combination_method, rrf_window, rrf_constant, and linear_alpha are included when they are explicitly provided (checked with is not None) instead of being skipped because they are falsy. Those values are forwarded to Redis as ALPHA/BETA, CONSTANT, and WINDOW respectively, so linear all-vector weighting and RRF with constant 0 behave as configured instead of falling back to server defaults or raising “no parameters provided.”

Docs and docstrings clarify that at alpha 0 or 1 hybrid search still runs both text and vector legs—only the combined score is single-modality— and suggest TextQuery / VectorQuery when one leg is enough. Tests cover alpha=0.0, serialized RRF params at zero, and integration behavior for rrf_constant=0.

Reviewed by Cursor Bugbot for commit 3feccd1. Bugbot is set up for automated code reviews on this repo. Configure here.

build_combination_method checked linear_alpha, rrf_constant and
rrf_window for truthiness, so an explicit 0 was treated as unset.
linear_alpha=0 raised ValueError, or sent no weights when a score alias
was set, and rrf_constant=0 fell back to the server default of 60.

Compare against None so 0 reaches the server. Redis rejects WINDOW 0, so
rrf_window=0 now returns the server's error instead of being ignored.
@vishal-bala
vishal-bala self-requested a review November 5, 2026 09:45

@vishal-bala vishal-bala left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR! Just a few changes related to the tests mainly

Comment thread redisvl/query/hybrid.py Resolved
Comment thread tests/integration/test_hybrid.py Resolved
Comment thread tests/unit/test_hybrid_types.py Resolved
Comment thread tests/unit/test_hybrid_types.py Resolved
Comment thread tests/unit/test_hybrid_types.py Resolved
@vishal-bala vishal-bala added the auto:minor Increment the minor version when merged label Nov 5, 2026
Cover alpha=0 through test_hybrid_query_alpha and make its assertion
two-sided, so a score that is too low also fails. Merge the RRF zero
tests into one and drop cases that catch no additional revert.
An alpha of 0 or 1 only zeroes one side's score. Both searches still
run, so point to VectorQuery and TextQuery for single-sided searches.
@vishal-bala
vishal-bala self-requested a review November 5, 2026 11:34

@vishal-bala vishal-bala left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 👍

@vishal-bala
vishal-bala merged commit 930c14e into redis:main Nov 5, 2026
65 checks passed
@applied-ai-release-bot

Copy link
Copy Markdown

🚀 PR was released in v0.31.0 🚀

@applied-ai-release-bot applied-ai-release-bot Bot added the released This issue/pull request has been released. label Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto:minor Increment the minor version when merged released This issue/pull request has been released.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants