You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/search/rank-eval.asciidoc
+150-61
Original file line number
Diff line number
Diff line change
@@ -3,35 +3,87 @@
3
3
4
4
experimental["The ranking evaluation API is experimental and may be changed or removed completely in a future release, as well as change in non-backwards compatible ways on minor versions updates. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features."]
5
5
6
-
The ranking evaluation API allows to evaluate the quality of ranked search
6
+
Allows you to evaluate the quality of ranked search results over a set of
7
+
typical search queries.
8
+
9
+
10
+
[[search-rank-eval-api-request]]
11
+
==== {api-request-title}
12
+
13
+
`GET /<index>/_rank_eval`
14
+
15
+
`POST /<index>/_rank_eval`
16
+
17
+
18
+
[[search-rank-eval-api-desc]]
19
+
==== {api-description-title}
20
+
21
+
The ranking evaluation API allows you to evaluate the quality of ranked search
7
22
results over a set of typical search queries. Given this set of queries and a
8
23
list of manually rated documents, the `_rank_eval` endpoint calculates and
9
24
returns typical information retrieval metrics like _mean reciprocal rank_,
10
25
_precision_ or _discounted cumulative gain_.
11
26
12
-
[float]
13
-
==== Overview
27
+
Search quality evaluation starts with looking at the users of your search
28
+
application, and the things that they are searching for. Users have a specific
29
+
_information need_, for example they are looking for gift in a web shop or want
30
+
to book a flight for their next holiday. They usually enter some search terms
31
+
into a search box or some other web form. All of this information, together with
32
+
meta information about the user (for example the browser, location, earlier
33
+
preferences and so on) then gets translated into a query to the underlying
34
+
search system.
14
35
15
-
Search quality evaluation starts with looking at the users of your search application, and the things that they are searching for.
16
-
Users have a specific _information need_, e.g. they are looking for gift in a web shop or want to book a flight for their next holiday.
17
-
They usually enter some search terms into a search box or some other web form.
18
-
All of this information, together with meta information about the user (e.g. the browser, location, earlier preferences etc...) then gets translated into a query to the underlying search system.
36
+
The challenge for search engineers is to tweak this translation process from
37
+
user entries to a concrete query in such a way, that the search results contain
38
+
the most relevant information with respect to the users information need. This
39
+
can only be done if the search result quality is evaluated constantly across a
40
+
representative test suite of typical user queries, so that improvements in the
41
+
rankings for one particular query doesn't negatively effect the ranking for
42
+
other types of queries.
19
43
20
-
The challenge for search engineers is to tweak this translation process from user entries to a concrete query in such a way, that the search results contain the most relevant information with respect to the users information need.
21
-
This can only be done if the search result quality is evaluated constantly across a representative test suite of typical user queries, so that improvements in the rankings for one particular query doesn't negatively effect the ranking for other types of queries.
44
+
In order to get started with search quality evaluation, three basic things are
45
+
needed:
22
46
23
-
In order to get started with search quality evaluation, three basic things are needed:
47
+
. A collection of documents you want to evaluate your query performance against,
48
+
usually one or more indices.
49
+
. A collection of typical search requests that users enter into your system.
50
+
. A set of document ratings that judge the documents relevance with respect to a
51
+
search request.
52
+
53
+
It is important to note that one set of document ratings is needed per test
54
+
query, and that the relevance judgements are based on the information need of
55
+
the user that entered the query.
24
56
25
-
. a collection of documents you want to evaluate your query performance against, usually one or more indices
26
-
. a collection of typical search requests that users enter into your system
27
-
. a set of document ratings that judge the documents relevance with respect to a search request+
28
-
It is important to note that one set of document ratings is needed per test query, and that
29
-
the relevance judgements are based on the information need of the user that entered the query.
57
+
The ranking evaluation API provides a convenient way to use this information in
58
+
a ranking evaluation request to calculate different search evaluation metrics.
59
+
This gives a first estimation of your overall search quality and give you a
60
+
measurement to optimize against when fine-tuning various aspect of the query
61
+
generation in your application.
30
62
31
-
The ranking evaluation API provides a convenient way to use this information in a ranking evaluation request to calculate different search evaluation metrics. This gives a first estimation of your overall search quality and give you a measurement to optimize against when fine-tuning various aspect of the query generation in your application.
32
63
33
-
[float]
34
-
==== Ranking evaluation request structure
64
+
[[search-rank-eval-api-path-params]]
65
+
==== {api-path-parms-title}
66
+
67
+
`<index>`::
68
+
(Required, string) Comma-separated list or wildcard expression of index names
In its most basic form, a request to the `_rank_eval` endpoint has two sections:
37
89
@@ -51,10 +103,13 @@ GET /my_index/_rank_eval
51
103
<2> definition of the evaluation metric to calculate
52
104
<3> a specific metric and its parameters
53
105
54
-
The request section contains several search requests typical to your application, along with the document ratings for each particular search request, e.g.
106
+
The request section contains several search requests typical to your
107
+
application, along with the document ratings for each particular search request.
55
108
56
109
[source,js]
57
110
-----------------------------
111
+
GET /my_index/_rank_eval
112
+
{
58
113
"requests": [
59
114
{
60
115
"id": "amsterdam_query", <1>
@@ -77,20 +132,30 @@ The request section contains several search requests typical to your application
77
132
]
78
133
}
79
134
]
135
+
}
80
136
-----------------------------
81
137
// NOTCONSOLE
82
138
83
139
<1> the search requests id, used to group result details later
84
140
<2> the query that is being evaluated
85
-
<3> a list of document ratings, each entry containing the documents `_index` and `_id` together with
86
-
the rating of the documents relevance with regards to this search request
141
+
<3> a list of document ratings, each entry containing the documents `_index` and
142
+
`_id` together with the rating of the documents relevance with regards to this
143
+
search request
87
144
88
-
A document `rating` can be any integer value that expresses the relevance of the document on a user defined scale. For some of the metrics, just giving a binary rating (e.g. `0` for irrelevant and `1` for relevant) will be sufficient, other metrics can use a more fine grained scale.
145
+
A document `rating` can be any integer value that expresses the relevance of the
146
+
document on a user defined scale. For some of the metrics, just giving a binary
147
+
rating (for example `0` for irrelevant and `1` for relevant) will be sufficient,
148
+
other metrics can use a more fine grained scale.
89
149
90
-
[float]
91
-
==== Template based ranking evaluation
92
150
93
-
As an alternative to having to provide a single query per test request, it is possible to specify query templates in the evaluation request and later refer to them. Queries with similar structure that only differ in their parameters don't have to be repeated all the time in the `requests` section this way. In typical search systems where user inputs usually get filled into a small set of query templates, this helps making the evaluation request more succinct.
151
+
===== Template based ranking evaluation
152
+
153
+
As an alternative to having to provide a single query per test request, it is
154
+
possible to specify query templates in the evaluation request and later refer to
155
+
them. Queries with similar structure that only differ in their parameters don't
156
+
have to be repeated all the time in the `requests` section this way. In typical
157
+
search systems where user inputs usually get filled into a small set of query
158
+
templates, this helps making the evaluation request more succinct.
94
159
95
160
[source,js]
96
161
--------------------------------
@@ -129,23 +194,30 @@ GET /my_index/_rank_eval
129
194
<3> a reference to a previously defined template
130
195
<4> the parameters to use to fill the template
131
196
132
-
[float]
133
-
==== Available evaluation metrics
134
197
135
-
The `metric` section determines which of the available evaluation metrics is going to be used.
136
-
Currently, the following metrics are supported:
198
+
===== Available evaluation metrics
199
+
200
+
The `metric` section determines which of the available evaluation metrics is
201
+
going to be used. The following metrics are supported:
137
202
138
203
[float]
139
204
[[k-precision]]
140
205
===== Precision at K (P@k)
141
206
142
-
This metric measures the number of relevant results in the top k search results. Its a form of the well known https://en.wikipedia.org/wiki/Information_retrieval#Precision[Precision] metric that only looks at the top k documents. It is the fraction of relevant documents in those first k
143
-
search. A precision at 10 (P@10) value of 0.6 then means six out of the 10 top hits are relevant with respect to the users information need.
144
-
145
-
P@k works well as a simple evaluation metric that has the benefit of being easy to understand and explain.
146
-
Documents in the collection need to be rated either as relevant or irrelevant with respect to the current query.
147
-
P@k does not take into account where in the top k results the relevant documents occur, so a ranking of ten results that
148
-
contains one relevant result in position 10 is equally good as a ranking of ten results that contains one relevant result in position 1.
207
+
This metric measures the number of relevant results in the top k search results.
that only looks at the top k documents. It is the fraction of relevant documents
211
+
in those first k search. A precision at 10 (P@10) value of 0.6 then means six
212
+
out of the 10 top hits are relevant with respect to the users information need.
213
+
214
+
P@k works well as a simple evaluation metric that has the benefit of being easy
215
+
to understand and explain. Documents in the collection need to be rated either
216
+
as relevant or irrelevant with respect to the current query. P@k does not take
217
+
into account where in the top k results the relevant documents occur, so a
218
+
ranking of ten results that contains one relevant result in position 10 is
219
+
equally good as a ranking of ten results that contains one relevant result in
220
+
position 1.
149
221
150
222
[source,js]
151
223
--------------------------------
@@ -182,13 +254,15 @@ in the query. Defaults to 10.
182
254
If set to 'true', unlabeled documents are ignored and neither count as relevant or irrelevant. Set to 'false' (the default), they are treated as irrelevant.
In contrast to the two metrics above, https://en.wikipedia.org/wiki/Discounted_cumulative_gain[discounted cumulative gain] takes both, the rank and the rating of the search results, into account.
takes both, the rank and the rating of the search results, into account.
229
306
230
-
The assumption is that highly relevant documents are more useful for the user when appearing at the top of the result list. Therefore, the DCG formula reduces the contribution that high ratings for documents on lower search ranks have on the overall DCG metric.
307
+
The assumption is that highly relevant documents are more useful for the user
308
+
when appearing at the top of the result list. Therefore, the DCG formula reduces
309
+
the contribution that high ratings for documents on lower search ranks have on
310
+
the overall DCG metric.
231
311
232
312
[source,js]
233
313
--------------------------------
@@ -260,23 +340,31 @@ in the query. Defaults to 10.
260
340
|`normalize` | If set to `true`, this metric will calculate the https://en.wikipedia.org/wiki/Discounted_cumulative_gain#Normalized_DCG[Normalized DCG].
Expected Reciprocal Rank (ERR) is an extension of the classical reciprocal rank for the graded relevance case
267
-
(Olivier Chapelle, Donald Metzler, Ya Zhang, and Pierre Grinspan. 2009. http://olivier.chapelle.cc/pub/err.pdf[Expected reciprocal rank for graded relevance].)
268
-
269
-
It is based on the assumption of a cascade model of search, in which a user scans through ranked search
270
-
results in order and stops at the first document that satisfies the information need. For this reason, it
271
-
is a good metric for question answering and navigation queries, but less so for survey oriented information
272
-
needs where the user is interested in finding many relevant documents in the top k results.
273
-
274
-
The metric models the expectation of the reciprocal of the position at which a user stops reading through
275
-
the result list. This means that relevant document in top ranking positions will contribute much to the
276
-
overall score. However, the same document will contribute much less to the score if it appears in a lower rank,
277
-
even more so if there are some relevant (but maybe less relevant) documents preceding it.
278
-
In this way, the ERR metric discounts documents which are shown after very relevant documents. This introduces
279
-
a notion of dependency in the ordering of relevant documents that e.g. Precision or DCG don't account for.
347
+
Expected Reciprocal Rank (ERR) is an extension of the classical reciprocal rank
348
+
for the graded relevance case (Olivier Chapelle, Donald Metzler, Ya Zhang, and
349
+
Pierre Grinspan. 2009.
350
+
http://olivier.chapelle.cc/pub/err.pdf[Expected reciprocal rank for graded relevance].)
351
+
352
+
It is based on the assumption of a cascade model of search, in which a user
353
+
scans through ranked search results in order and stops at the first document
354
+
that satisfies the information need. For this reason, it is a good metric for
355
+
question answering and navigation queries, but less so for survey oriented
356
+
information needs where the user is interested in finding many relevant
357
+
documents in the top k results.
358
+
359
+
The metric models the expectation of the reciprocal of the position at which a
360
+
user stops reading through the result list. This means that relevant document in
361
+
top ranking positions will contribute much to the overall score. However, the
362
+
same document will contribute much less to the score if it appears in a lower
363
+
rank, even more so if there are some relevant (but maybe less relevant)
364
+
documents preceding it. In this way, the ERR metric discounts documents which
365
+
are shown after very relevant documents. This introduces a notion of dependency
366
+
in the ordering of relevant documents that e.g. Precision or DCG don't account
0 commit comments