@@ -63,38 +63,30 @@ def create(
63
63
timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
64
64
) -> RerankCreateResponse :
65
65
"""
66
- Rank a list of documents according to their relevance to a query and your custom
67
- instructions about how to prioritize retrievals. We evaluated the model on
68
- instructions for recency, document type, source, and metadata, and it can
69
- generalize to other instructions as well.
70
-
71
- The total request cannot exceed 400,000 tokens. The combined length of the
72
- query, instruction and any document with its metadata must not exceed 8,000
73
- tokens. Email
66
+ Rank a list of documents according to their relevance to a query.
67
+
68
+ The total request cannot exceed 400,000 tokens. The combined length of any
69
+ document, instruction and the query must not exceed 4,000 tokens. Email
74
70
[rerank-feedback@contextual.ai](mailto:rerank-feedback@contextual.ai) with any
75
71
feedback or questions.
76
72
77
73
Args:
78
- documents: The texts to be reranked according to their relevance to the query and the
79
- optional instruction
74
+ documents: The texts to be reranked according to their relevance to the query
80
75
81
- model: The version of the reranker to use. Currently, we just have
82
- "ctxl-rerank-en-v1-instruct".
76
+ model: The version of the reranker to use. Currently, we just have "v1".
83
77
84
78
query: The string against which documents will be ranked for relevance
85
79
86
- instruction: Instructions that the reranker references when ranking retrievals. We evaluated
87
- the model on instructions for recency, document type, source, and metadata, and
88
- it can generalize to other instructions as well. Note that we do not guarantee
89
- that the reranker will follow these instructions exactly. Examples: "Prioritize
90
- internal sales documents over market analysis reports. More recent documents
91
- should be weighted higher. Enterprise portal content supersedes distributor
92
- communications." and "Emphasize forecasts from top-tier investment banks. Recent
93
- analysis should take precedence. Disregard aggregator sites and favor detailed
94
- research notes over news summaries."
80
+ instruction: Instructions that the reranker references when ranking retrievals. Note that we
81
+ do not guarantee that the reranker will follow these instructions exactly.
82
+ Examples: "Prioritize internal sales documents over market analysis reports.
83
+ More recent documents should be weighted higher. Enterprise portal content
84
+ supersedes distributor communications." and "Emphasize forecasts from top-tier
85
+ investment banks. Recent analysis should take precedence. Disregard aggregator
86
+ sites and favor detailed research notes over news summaries."
95
87
96
88
metadata: Metadata for documents being passed to the reranker. Must be the same length as
97
- the documents list. If a document does not have metadata, add an empty string.
89
+ the documents list.
98
90
99
91
top_n: The number of top-ranked results to return
100
92
@@ -163,38 +155,30 @@ async def create(
163
155
timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
164
156
) -> RerankCreateResponse :
165
157
"""
166
- Rank a list of documents according to their relevance to a query and your custom
167
- instructions about how to prioritize retrievals. We evaluated the model on
168
- instructions for recency, document type, source, and metadata, and it can
169
- generalize to other instructions as well.
170
-
171
- The total request cannot exceed 400,000 tokens. The combined length of the
172
- query, instruction and any document with its metadata must not exceed 8,000
173
- tokens. Email
158
+ Rank a list of documents according to their relevance to a query.
159
+
160
+ The total request cannot exceed 400,000 tokens. The combined length of any
161
+ document, instruction and the query must not exceed 4,000 tokens. Email
174
162
[rerank-feedback@contextual.ai](mailto:rerank-feedback@contextual.ai) with any
175
163
feedback or questions.
176
164
177
165
Args:
178
- documents: The texts to be reranked according to their relevance to the query and the
179
- optional instruction
166
+ documents: The texts to be reranked according to their relevance to the query
180
167
181
- model: The version of the reranker to use. Currently, we just have
182
- "ctxl-rerank-en-v1-instruct".
168
+ model: The version of the reranker to use. Currently, we just have "v1".
183
169
184
170
query: The string against which documents will be ranked for relevance
185
171
186
- instruction: Instructions that the reranker references when ranking retrievals. We evaluated
187
- the model on instructions for recency, document type, source, and metadata, and
188
- it can generalize to other instructions as well. Note that we do not guarantee
189
- that the reranker will follow these instructions exactly. Examples: "Prioritize
190
- internal sales documents over market analysis reports. More recent documents
191
- should be weighted higher. Enterprise portal content supersedes distributor
192
- communications." and "Emphasize forecasts from top-tier investment banks. Recent
193
- analysis should take precedence. Disregard aggregator sites and favor detailed
194
- research notes over news summaries."
172
+ instruction: Instructions that the reranker references when ranking retrievals. Note that we
173
+ do not guarantee that the reranker will follow these instructions exactly.
174
+ Examples: "Prioritize internal sales documents over market analysis reports.
175
+ More recent documents should be weighted higher. Enterprise portal content
176
+ supersedes distributor communications." and "Emphasize forecasts from top-tier
177
+ investment banks. Recent analysis should take precedence. Disregard aggregator
178
+ sites and favor detailed research notes over news summaries."
195
179
196
180
metadata: Metadata for documents being passed to the reranker. Must be the same length as
197
- the documents list. If a document does not have metadata, add an empty string.
181
+ the documents list.
198
182
199
183
top_n: The number of top-ranked results to return
200
184
0 commit comments