hybrid search with a Disjunction Max bm25 #1337
-
Hi, I'm trying to use hybrid search with a Disjunction Max bm25 query. Although the code works fine with either only bm25 or embeddings, the combined hybrid one does not work:
The error message reads:
Any ideas why? |
Beta Was this translation helpful? Give feedback.
Answered by
rebasedming
Jul 8, 2024
Replies: 1 comment 3 replies
-
Hi! I just responded in Slack but I'll reply here as well. I'm having trouble replicating. The following code works: -- Create BM25 index over test table
CALL paradedb.create_bm25_test_table(
schema_name => 'public',
table_name => 'mock_items'
);
CALL paradedb.create_bm25(
index_name => 'search_idx',
schema_name => 'public',
table_name => 'mock_items',
key_field => 'id',
text_fields => '{description: {tokenizer: {type: "en_stem"}}, category: {}}',
numeric_fields => '{rating: {}}'
);
-- Create mock embeddings
ALTER TABLE mock_items ADD COLUMN embedding vector(3);
UPDATE mock_items m
SET embedding = ('[' ||
((m.id + 1) % 10 + 1)::integer || ',' ||
((m.id + 2) % 10 + 1)::integer || ',' ||
((m.id + 3) % 10 + 1)::integer || ']')::vector;
-- Hybrid search with disjunction max
SELECT * FROM search_idx.rank_hybrid(
bm25_query => paradedb.disjunction_max(disjuncts => ARRAY[paradedb.parse('description:keyboard'), paradedb.parse('description:bluetooth')]),
similarity_query => '''[1,2,3]'' <-> embedding',
bm25_weight => 0.9,
similarity_weight => 0.1
) LIMIT 5; Could you check to see what's different/confirm this works for you? |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
philippemnoel
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! I just responded in Slack but I'll reply here as well.
I'm having trouble replicating. The following code works: