Skip to content

Commit 88c5b54

Browse files
misc: rename passage to text
1 parent c0209ff commit 88c5b54

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ docker run --gpus all -e HUGGING_FACE_HUB_TOKEN=$token -p 8080:80 -v $volume:/da
286286

287287
`text-embeddings-inference` v0.4.0 added support for CamemBERT, RoBERTa and XLM-RoBERTa Sequence Classification models.
288288
Re-rankers models are Sequence Classification cross-encoders models with a single class that scores the similarity
289-
between a query and a passage.
289+
between a query and a text.
290290

291291
See [this blogpost](https://blog.llamaindex.ai/boosting-rag-picking-the-best-embedding-reranker-models-42d079022e83) by
292292
the LlamaIndex team to understand how you can use re-rankers models in your RAG pipeline to improve
@@ -300,12 +300,12 @@ volume=$PWD/data # share a volume with the Docker container to avoid downloading
300300
docker run --gpus all -p 8080:80 -v $volume:/data --pull always ghcr.io/huggingface/text-embeddings-inference:0.5 --model-id $model --revision $revision
301301
```
302302

303-
And then you can rank the similarity between a query and a list of passages with:
303+
And then you can rank the similarity between a query and a list of texts with:
304304

305305
```bash
306306
curl 127.0.0.1:8080/rerank \
307307
-X POST \
308-
-d '{"query":"What is Deep Learning?", "passages": ["Deep Learning is not...", "Deep learning is..."]}' \
308+
-d '{"query":"What is Deep Learning?", "texts": ["Deep Learning is not...", "Deep learning is..."]}' \
309309
-H 'Content-Type: application/json'
310310
```
311311

docs/openapi.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@
898898
"example": "0",
899899
"minimum": 0
900900
},
901-
"passage": {
901+
"text": {
902902
"type": "string",
903903
"default": "null",
904904
"example": "Deep Learning is ...",
@@ -915,10 +915,10 @@
915915
"type": "object",
916916
"required": [
917917
"query",
918-
"passages"
918+
"texts"
919919
],
920920
"properties": {
921-
"passages": {
921+
"texts": {
922922
"type": "array",
923923
"items": {
924924
"type": "string"
@@ -936,7 +936,7 @@
936936
"default": "false",
937937
"example": "false"
938938
},
939-
"return_passages": {
939+
"return_text": {
940940
"type": "boolean",
941941
"default": "false",
942942
"example": "false"

docs/source/en/quick_tour.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ curl 127.0.0.1:8080/embed \
5656
## Re-rankers
5757

5858
Re-rankers models are Sequence Classification cross-encoders models with a single class that scores the similarity
59-
between a query and a passage.
59+
between a query and a text.
6060

6161
See [this blogpost](https://blog.llamaindex.ai/boosting-rag-picking-the-best-embedding-reranker-models-42d079022e83) by
6262
the LlamaIndex team to understand how you can use re-rankers models in your RAG pipeline to improve
@@ -73,12 +73,12 @@ docker run --gpus all -p 8080:80 -v $volume:/data --pull always ghcr.io/huggingf
7373
```
7474

7575
Once you have deployed a model you can use the `rerank` endpoint to rank the similarity between a query and a list
76-
of passages:
76+
of texts:
7777

7878
```bash
7979
curl 127.0.0.1:8080/rerank \
8080
-X POST \
81-
-d '{"query":"What is Deep Learning?", "passages": ["Deep Learning is not...", "Deep learning is..."], "raw_scores": false}' \
81+
-d '{"query":"What is Deep Learning?", "texts": ["Deep Learning is not...", "Deep learning is..."], "raw_scores": false}' \
8282
-H 'Content-Type: application/json'
8383
```
8484

router/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ pub(crate) struct RerankRequest {
280280
#[schema(example = "What is Deep Learning?")]
281281
pub query: String,
282282
#[schema(example = json!(["Deep Learning is ..."]))]
283-
pub passages: Vec<String>,
283+
pub texts: Vec<String>,
284284
#[serde(default)]
285285
#[schema(default = "false", example = "false")]
286286
pub truncate: bool,
@@ -289,7 +289,7 @@ pub(crate) struct RerankRequest {
289289
pub raw_scores: bool,
290290
#[serde(default)]
291291
#[schema(default = "false", example = "false")]
292-
pub return_passages: bool,
292+
pub return_text: bool,
293293
}
294294

295295
#[derive(Serialize, ToSchema)]
@@ -298,7 +298,7 @@ pub(crate) struct Rank {
298298
pub index: usize,
299299
#[schema(nullable = true, example = "Deep Learning is ...", default = "null")]
300300
#[serde(skip_serializing_if = "Option::is_none")]
301-
pub passage: Option<String>,
301+
pub text: Option<String>,
302302
#[schema(example = "1.0")]
303303
pub score: f32,
304304
}

router/src/server.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,14 @@ async fn rerank(
330330

331331
// Closure for rerank
332332
let rerank_inner = move |query: String,
333-
passage: String,
333+
text: String,
334334
truncate: bool,
335335
raw_scores: bool,
336336
infer: Infer| async move {
337337
let permit = infer.try_acquire_permit().map_err(ErrorResponse::from)?;
338338

339339
let response = infer
340-
.predict((query, passage), truncate, raw_scores, permit)
340+
.predict((query, text), truncate, raw_scores, permit)
341341
.await
342342
.map_err(ErrorResponse::from)?;
343343

@@ -355,7 +355,7 @@ async fn rerank(
355355
let (compute_chars, compute_tokens, tokenization_time, queue_time, inference_time, response) = {
356356
metrics::increment_counter!("te_request_count", "method" => "batch");
357357

358-
let batch_size = req.passages.len();
358+
let batch_size = req.texts.len();
359359
if batch_size > info.max_client_batch_size {
360360
let message = format!(
361361
"batch size {batch_size} > maximum allowed batch size {}",
@@ -374,12 +374,12 @@ async fn rerank(
374374
let query_chars = req.query.chars().count();
375375
let mut compute_chars = query_chars * batch_size;
376376

377-
for passage in &req.passages {
378-
compute_chars += passage.chars().count();
377+
for text in &req.texts {
378+
compute_chars += text.chars().count();
379379
let local_infer = infer.clone();
380380
futures.push(rerank_inner(
381381
req.query.clone(),
382-
passage.clone(),
382+
text.clone(),
383383
req.truncate,
384384
req.raw_scores,
385385
local_infer.0,
@@ -401,15 +401,15 @@ async fn rerank(
401401
total_tokenization_time += r.1.as_nanos() as u64;
402402
total_queue_time += r.2.as_nanos() as u64;
403403
total_inference_time += r.3.as_nanos() as u64;
404-
let passage = if req.return_passages {
405-
Some(req.passages[index].clone())
404+
let text = if req.return_text {
405+
Some(req.texts[index].clone())
406406
} else {
407407
None
408408
};
409409

410410
ranks.push(Rank {
411411
index,
412-
passage,
412+
text,
413413
score: r.4,
414414
})
415415
}

0 commit comments

Comments
 (0)