Skip to content

Commit

Permalink
Update reranking README (#1231)
Browse files Browse the repository at this point in the history
* update reranking tei

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
WenjiaoYue and pre-commit-ci[bot] authored Jan 24, 2025
1 parent ea9f48f commit 528eacd
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 37 deletions.
57 changes: 32 additions & 25 deletions comps/rerankings/src/README_tei.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# 🌟 Reranking Microservice with TEI

`Text Embeddings Inference (TEI)` is a comprehensive toolkit designed for efficient deployment and serving of open source text embeddings models.
It enable us to host our own reranker endpoint seamlessly.
It enables us to host our own reranker endpoint seamlessly.

This README provides set-up instructions and comprehensive details regarding the reranking microservice via TEI.

---

## 📦 1. Start Microservice with `docker run`
## 📦 1. Start Microservice with Docker

### 🔹 1.1 Start Reranking Service with TEI

Expand All @@ -20,7 +20,8 @@ This README provides set-up instructions and comprehensive details regarding the
export RERANK_MODEL_ID="BAAI/bge-reranker-base"
export volume=$PWD/data

docker run -d -p 6060:80 -v $volume:/data -e http_proxy=$http_proxy -e https_proxy=$https_proxy --pull always ghcr.io/huggingface/text-embeddings-inference:cpu-1.5 --model-id $RERANK_MODEL_ID --hf-api-token $HF_TOKEN
docker run -p 12005:80 -v $volume:/data --runtime=habana -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none -e MAX_WARMUP_SEQUENCE_LENGTH=512 --cap-add=sys_nice --ipc=host ghcr.io/huggingface/tei-gaudi:latest --model-id $RERANK_MODEL_ID --hf-api-token $HF_TOKEN --auto-truncate

```

- For Xeon CPU:
Expand All @@ -30,19 +31,20 @@ This README provides set-up instructions and comprehensive details regarding the
export RERANK_MODEL_ID="BAAI/bge-reranker-base"
export volume=$PWD/data

docker run -d -p 6060:80 -v $volume:/data -e http_proxy=$http_proxy -e https_proxy=$https_proxy --pull always ghcr.io/huggingface/tei-gaudi:1.5.2 --model-id $RERANK_MODEL_ID --hf-api-token $HF_TOKEN
docker run -d -p 12005:80 -v $volume:/data -e http_proxy=$http_proxy -e https_proxy=$https_proxy --pull always ghcr.io/huggingface/text-embeddings-inference:cpu-1.5 --model-id $RERANK_MODEL_ID --hf-api-token $HF_TOKEN --auto-truncate
```

2. **Verify the TEI Service**:

Run the following command to check if the service is up and running.

```bash
export ip_address=$(hostname -I | awk '{print $1}')
curl ip_address:6060/rerank \
-X POST \
-d '{"query":"What is Deep Learning?", "texts": ["Deep Learning is not...", "Deep learning is..."]}' \
-H 'Content-Type: application/json'
```
```bash
export host_ip=$(hostname -I | awk '{print $1}')
curl $host_ip:12005/rerank \
-X POST \
-d '{"query":"What is Deep Learning?", "texts": ["Deep Learning is not...", "Deep learning is..."]}' \
-H 'Content-Type: application/json'
```

### 🔹 1.2 Build Docker Image and Run Docker with CLI

Expand All @@ -60,8 +62,12 @@ This README provides set-up instructions and comprehensive details regarding the
2. Run the reranking microservice and connect it to the TEI service:

```bash
docker run -d --name="reranking-tei-server" -e LOGFLAG=True -p 8000:8000 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e TEI_RERANKING_ENDPOINT=$TEI_RERANKING_ENDPOINT -e HF_TOKEN=$HF_TOKEN -e RERANK_COMPONENT_NAME="OPEA_TEI_RERANKING" opea/reranking:comps
export TEI_RERANKING_PORT=12005
export HF_TOKEN=${your_hf_api_token}
export host_ip=$(hostname -I | awk '{print $1}')
export TEI_RERANKING_ENDPOINT="http://${host_ip}:${TEI_RERANKING_PORT}"

docker run -d --name="reranking-tei-server" -e LOGFLAG=True -p 10700:8000 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e TEI_RERANKING_ENDPOINT=$TEI_RERANKING_ENDPOINT -e HF_TOKEN=$HF_TOKEN -e RERANK_COMPONENT_NAME="OPEA_TEI_RERANKING" opea/reranking:comps
```

## 📦 2. Start Microservice with docker compose
Expand All @@ -74,11 +80,12 @@ Deploy both the TEI Reranking Service and the Reranking Microservice using Docke

```bash
export RERANK_MODEL_ID="BAAI/bge-reranker-base"
export TEI_RERANKING_PORT=12003
export RERANK_PORT=8000
export TEI_RERANKING_PORT=12005
export RERANK_PORT=10700
export host_ip=$(hostname -I | awk '{print $1}')
export TEI_RERANKING_ENDPOINT="http://${host_ip}:${TEI_RERANKING_PORT}"
export TAG=comps
export host_ip=${host_ip}

```

2. Navigate to the Docker Compose directory:
Expand All @@ -92,33 +99,33 @@ Deploy both the TEI Reranking Service and the Reranking Microservice using Docke
- For Gaudi HPU:

```bash
docker compose up reranking-tei -d
docker compose up reranking-tei-gaudi -d
```

- For Xeon CPU:

```bash
docker compose up reranking-tei-gaudi -d
docker compose up reranking-tei -d
```

## 📦 3. Consume Reranking Service

### 🔹 3.1 Check Service Status

Verify the reranking service is running:
- Verify the reranking service is running:

```bash
curl http://localhost:8000/v1/health_check \
-X GET \
-H 'Content-Type: application/json'
```
```bash
curl http://localhost:10700/v1/health_check \
-X GET \
-H 'Content-Type: application/json'
```

### 🔹 3.2 Use the Reranking Service API

- Execute reranking process by providing query and documents

```bash
curl http://localhost:8000/v1/reranking \
curl http://localhost:10700/v1/reranking \
-X POST \
-d '{"initial_query":"What is Deep Learning?", "retrieved_docs": [{"text":"Deep Learning is not..."}, {"text":"Deep learning is..."}]}' \
-H 'Content-Type: application/json'
Expand All @@ -127,7 +134,7 @@ curl http://localhost:8000/v1/health_check \
- You can add the parameter `top_n` to specify the return number of the reranker model, default value is 1.

```bash
curl http://localhost:8000/v1/reranking \
curl http://localhost:10700/v1/reranking \
-X POST \
-d '{"initial_query":"What is Deep Learning?", "retrieved_docs": [{"text":"Deep Learning is not..."}, {"text":"Deep learning is..."}], "top_n":2}' \
-H 'Content-Type: application/json'
Expand Down
22 changes: 10 additions & 12 deletions comps/rerankings/src/README_videoqna.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Then we could send the `top_n` videos to the downstream LVM.

---

## 📦 1. Start Microservice with `docker run`
## 📦 1. Start Microservice with Docker

### 🔹 1.1 Build Docker Image and Run Docker with CLI

Expand All @@ -25,10 +25,9 @@ Then we could send the `top_n` videos to the downstream LVM.
-f comps/rerankings/src/Dockerfile .
```

2. Run the reranking microservice and connect it to the TEI service:
2. Run the reranking microservice and connect it to the VideoQnA service:

```bash

docker run -d --name "reranking-videoqna-server" \
-p 10703:8000 \
--ipc=host \
Expand All @@ -39,7 +38,6 @@ Then we could send the `top_n` videos to the downstream LVM.
-e RERANK_COMPONENT_NAME="OPEA_VIDEO_RERANKING" \
-e FILE_SERVER_ENDPOINT=${FILE_SERVER_ENDPOINT} \
opea/reranking:comps

```

## 📦 2. Start Microservice with docker compose
Expand All @@ -53,9 +51,9 @@ Deploy both the Videoqna Reranking Service and the Reranking Microservice using
```bash
export TEI_RERANKING_PORT=12006
export RERANK_PORT=10703
export host_ip=$(hostname -I | awk '{print $1}')
export TEI_RERANKING_ENDPOINT="http://${host_ip}:${TEI_RERANKING_PORT}"
export TAG=comps
export host_ip=${host_ip}
```

2. Navigate to the Docker Compose directory:
Expand All @@ -74,13 +72,13 @@ Deploy both the Videoqna Reranking Service and the Reranking Microservice using

### 🔹 3.1 Check Service Status

Verify the reranking service is running:
- Verify the reranking service is running:

```bash
curl http://localhost:10703/v1/health_check \
-X GET \
-H 'Content-Type: application/json'
```
```bash
curl http://localhost:10703/v1/health_check \
-X GET \
-H 'Content-Type: application/json'
```

### 🔹 3.2 Use the Reranking Service API

Expand All @@ -93,7 +91,7 @@ curl http://localhost:10703/v1/health_check \
-H 'Content-Type: application/json'
```

- You can add the parameter `top_n` to specify the return number of the reranker model, default value is 1.
- You can add the parameter `top_n` to specify the return number of the reranker model, default value is 1.

```bash
curl http://localhost:10703/v1/reranking \
Expand Down

0 comments on commit 528eacd

Please sign in to comment.