-
Notifications
You must be signed in to change notification settings - Fork 25.2k
ES|QL Reranker command #123074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ES|QL Reranker command #123074
Changes from 66 commits
612dbcc
b2c0e11
6818567
fae22df
4302a69
7787efe
9069561
89bdda4
5c19b29
b7d75a7
025aaf9
68426b9
6b1c04c
85325d1
763ccef
395db68
e5532f9
d311d1b
ec8c6f2
d4ab3fd
1e2b125
cd9c076
816993f
5d45936
694902e
8e000a1
6322546
e114548
4b88842
52fc536
84ff359
d86f5b2
d4d1d08
1fd0b14
b1d9f4a
ef688f7
b0129a3
54ce1eb
ca6e972
bac4f9a
4ef3f7e
7e021f4
78a7efb
0e918df
5eadd6f
3444c07
ca295fb
32dbb2c
69d551f
01c0529
cd813fd
84640cc
587d947
83ba8fb
2ce8ab1
ced6e5f
70f7ada
8e67202
c56a15e
ee00286
cffd345
d97701b
53d1d2e
05e0d45
dccaf4a
4cdfdfa
7ff6b27
279291b
0f10c3f
04c7516
5ab46d9
4e17324
c998b38
62e42a5
a151971
f5c6a4f
3de79f1
4099079
1a6161b
983ce28
6627bb1
8150a1f
79d5581
ea134a7
ef82268
ce38aa7
132825d
9dee9a5
d26cc76
9e47052
109a3dc
39fe811
d8fe1db
37e1d1c
4cad906
cf87127
45ebc85
a166961
e084062
63d83ec
65aac16
ef0e5c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 123074 | ||
summary: Adding ES|QL Reranker command in snapshot builds | ||
area: Ranking | ||
type: feature | ||
issues: [124337] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -357,7 +357,7 @@ private static void loadDataSetIntoEs( | |
} | ||
|
||
/** The semantic_text mapping type require an inference endpoint that needs to be setup before creating the index. */ | ||
public static void createInferenceEndpoint(RestClient client) throws IOException { | ||
public static void createInferenceEndpoints(RestClient client) throws IOException { | ||
Request request = new Request("PUT", "_inference/sparse_embedding/test_sparse_inference"); | ||
request.setJsonEntity(""" | ||
{ | ||
|
@@ -371,6 +371,21 @@ public static void createInferenceEndpoint(RestClient client) throws IOException | |
} | ||
"""); | ||
client.performRequest(request); | ||
|
||
request = new Request("PUT", "_inference/rerank/test_reranker"); | ||
request.setJsonEntity(""" | ||
{ | ||
"service": "test_reranking_service", | ||
"service_settings": { | ||
"model_id": "my_model", | ||
"api_key": "abc64" | ||
}, | ||
"task_settings": { | ||
"use_text_length": true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ Using the settings |
||
} | ||
} | ||
"""); | ||
client.performRequest(request); | ||
} | ||
|
||
public static void deleteInferenceEndpoint(RestClient client) throws IOException { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Note: | ||
afoucret marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// The "test_reranker" service scores the row from the inputText length and does not really score by relevance. | ||
// This makes the output more predictable which is helpful here. | ||
|
||
|
||
reranker using a single field | ||
afoucret marked this conversation as resolved.
Show resolved
Hide resolved
|
||
required_capability: rerank | ||
required_capability: match_function | ||
|
||
FROM books METADATA _score | ||
| WHERE title:"war and peace" AND author:"Tolstoy" | ||
| RERANK "war and peace" ON title WITH "test_reranker" | ||
| KEEP book_no, title, author, _score | ||
; | ||
|
||
book_no:keyword | title:text | author:text | _score:double | ||
5327 | War and Peace | Leo Tolstoy | 0.03846153989434242 | ||
4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.02222222276031971 | ||
9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo | 0.02083333395421505 | ||
2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy | 0.01515151560306549 | ||
; | ||
|
||
|
||
reranker using multiple fields | ||
required_capability: rerank | ||
required_capability: match_function | ||
|
||
FROM books METADATA _score | ||
| WHERE title:"war and peace" AND author:"Tolstoy" | ||
| RERANK "war and peace" ON title, author WITH "test_reranker" | ||
| KEEP book_no, title, author, _score | ||
; | ||
|
||
book_no:keyword | title:text | author:text | _score:double | ||
5327 | War and Peace | Leo Tolstoy | 0.02083333395421505 | ||
9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo | 0.014285714365541935 | ||
2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy | 0.011363636702299118 | ||
4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.009523809887468815 | ||
; | ||
|
||
|
||
reranker after a limit | ||
required_capability: rerank | ||
required_capability: match_function | ||
|
||
FROM books METADATA _score | ||
| WHERE title:"war and peace" AND author:"Tolstoy" | ||
| SORT _score DESC | ||
| LIMIT 3 | ||
| RERANK "war and peace" ON title WITH "test_reranker" | ||
| KEEP book_no, title, author, _score | ||
; | ||
|
||
book_no:keyword | title:text | author:text | _score:double | ||
5327 | War and Peace | Leo Tolstoy | 0.03846153989434242 | ||
4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.02222222276031971 | ||
9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo | 0.02083333395421505 | ||
; | ||
|
||
|
||
reranker before a limit | ||
required_capability: rerank | ||
required_capability: match_function | ||
|
||
FROM books METADATA _score | ||
| WHERE title:"war and peace" AND author:"Tolstoy" | ||
| RERANK "war and peace" ON title WITH "test_reranker" | ||
| KEEP book_no, title, author, _score | ||
| LIMIT 3 | ||
; | ||
|
||
book_no:keyword | title:text | author:text | _score:double | ||
5327 | War and Peace | Leo Tolstoy | 0.03846153989434242 | ||
4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.02222222276031971 | ||
9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo | 0.02083333395421505 | ||
; | ||
|
||
|
||
reranker add the _score column when missing | ||
required_capability: rerank | ||
required_capability: match_function | ||
|
||
FROM books | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ Added a case where the |
||
| WHERE title:"war and peace" AND author:"Tolstoy" | ||
| RERANK "war and peace" ON title WITH "test_reranker" | ||
| KEEP book_no, title, author, _score | ||
; | ||
|
||
|
||
book_no:keyword | title:text | author:text | _score:double | ||
5327 | War and Peace | Leo Tolstoy | 0.03846153989434242 | ||
4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.02222222276031971 | ||
9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo | 0.02083333395421505 | ||
2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy | 0.01515151560306549 | ||
; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ CSS support is tracked as a follow-up in the meta issue (#124337)