-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DocIndexRetriever] enable the without-rerank flavor (#1223)
Signed-off-by: Li Gang <[email protected]> Co-authored-by: ligang <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
00b526c
commit a50e4e6
Showing
4 changed files
with
291 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
DocIndexRetriever/docker_compose/intel/cpu/xeon/compose_without_rerank.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
version: "3.8" | ||
|
||
services: | ||
redis-vector-db: | ||
image: redis/redis-stack:7.2.0-v9 | ||
container_name: redis-vector-db | ||
ports: | ||
- "6379:6379" | ||
- "8001:8001" | ||
dataprep-redis-service: | ||
image: ${REGISTRY:-opea}/dataprep-redis:${TAG:-latest} | ||
container_name: dataprep-redis-server | ||
depends_on: | ||
- redis-vector-db | ||
ports: | ||
- "6007:6007" | ||
- "6008:6008" | ||
- "6009:6009" | ||
environment: | ||
no_proxy: ${no_proxy} | ||
http_proxy: ${http_proxy} | ||
https_proxy: ${https_proxy} | ||
REDIS_URL: redis://redis-vector-db:6379 | ||
REDIS_HOST: redis-vector-db | ||
INDEX_NAME: ${INDEX_NAME:-rag-redis} | ||
TEI_EMBEDDING_ENDPOINT: http://tei-embedding-service:80 | ||
HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN} | ||
tei-embedding-service: | ||
image: ghcr.io/huggingface/text-embeddings-inference:cpu-1.5 | ||
container_name: tei-embedding-server | ||
ports: | ||
- "6006:80" | ||
volumes: | ||
- "/home/ligang/models:/data" | ||
shm_size: 1g | ||
environment: | ||
no_proxy: ${no_proxy} | ||
http_proxy: ${http_proxy} | ||
https_proxy: ${https_proxy} | ||
HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN} | ||
command: --model-id ${EMBEDDING_MODEL_ID} --auto-truncate | ||
embedding: | ||
image: ${REGISTRY:-opea}/embedding-tei:${TAG:-latest} | ||
container_name: embedding-tei-server | ||
ports: | ||
- "6000:6000" | ||
ipc: host | ||
depends_on: | ||
- tei-embedding-service | ||
environment: | ||
no_proxy: ${no_proxy} | ||
http_proxy: ${http_proxy} | ||
https_proxy: ${https_proxy} | ||
HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN} | ||
TEI_EMBEDDING_ENDPOINT: http://tei-embedding-service:80 | ||
restart: unless-stopped | ||
retriever: | ||
image: ${REGISTRY:-opea}/retriever-redis:${TAG:-latest} | ||
container_name: retriever-redis-server | ||
depends_on: | ||
- redis-vector-db | ||
ports: | ||
- "7000:7000" | ||
ipc: host | ||
environment: | ||
no_proxy: ${no_proxy} | ||
http_proxy: ${http_proxy} | ||
https_proxy: ${https_proxy} | ||
REDIS_URL: redis://redis-vector-db:6379 | ||
INDEX_NAME: ${INDEX_NAME:-rag-redis} | ||
HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN} | ||
TEI_EMBEDDING_ENDPOINT: http://tei-embedding-service:80 | ||
restart: unless-stopped | ||
doc-index-retriever-server: | ||
image: ${REGISTRY:-opea}/doc-index-retriever:${TAG:-latest} | ||
container_name: doc-index-retriever-server | ||
depends_on: | ||
- redis-vector-db | ||
- tei-embedding-service | ||
- embedding | ||
- retriever | ||
ports: | ||
- "8889:8889" | ||
environment: | ||
no_proxy: ${no_proxy} | ||
https_proxy: ${https_proxy} | ||
http_proxy: ${http_proxy} | ||
MEGA_SERVICE_HOST_IP: ${MEGA_SERVICE_HOST_IP:-0.0.0.0} | ||
EMBEDDING_SERVICE_HOST_IP: embedding | ||
EMBEDDING_SERVICE_PORT: ${EMBEDDING_SERVER_PORT:-6000} | ||
RETRIEVER_SERVICE_HOST_IP: retriever | ||
LOGFLAG: ${LOGFLAG} | ||
ipc: host | ||
restart: always | ||
command: --without-rerank | ||
|
||
networks: | ||
default: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 147 additions & 0 deletions
147
DocIndexRetriever/tests/test_compose_without_rerank_on_xeon.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
#!/bin/bash | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -e | ||
IMAGE_REPO=${IMAGE_REPO:-"opea"} | ||
IMAGE_TAG=${IMAGE_TAG:-"latest"} | ||
echo "REGISTRY=IMAGE_REPO=${IMAGE_REPO}" | ||
echo "TAG=IMAGE_TAG=${IMAGE_TAG}" | ||
export REGISTRY=${IMAGE_REPO} | ||
export TAG=${IMAGE_TAG} | ||
|
||
WORKPATH=$(dirname "$PWD") | ||
LOG_PATH="$WORKPATH/tests" | ||
ip_address=$(hostname -I | awk '{print $1}') | ||
|
||
function build_docker_images() { | ||
echo "Building Docker Images...." | ||
cd $WORKPATH/docker_image_build | ||
if [ ! -d "GenAIComps" ] ; then | ||
echo "Cloning GenAIComps repository" | ||
git clone https://github.com/opea-project/GenAIComps.git && cd GenAIComps && git checkout "${opea_branch:-"main"}" && cd ../ | ||
fi | ||
service_list="dataprep-redis embedding-tei retriever-redis doc-index-retriever" | ||
docker compose -f build.yaml build ${service_list} --no-cache > ${LOG_PATH}/docker_image_build.log | ||
|
||
docker pull ghcr.io/huggingface/text-embeddings-inference:cpu-1.5 | ||
docker pull redis/redis-stack:7.2.0-v9 | ||
docker images && sleep 1s | ||
|
||
echo "Docker images built!" | ||
} | ||
|
||
function start_services() { | ||
echo "Starting Docker Services...." | ||
cd $WORKPATH/docker_compose/intel/cpu/xeon | ||
export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5" | ||
export TEI_EMBEDDING_ENDPOINT="http://${ip_address}:6006" | ||
export REDIS_URL="redis://${ip_address}:6379" | ||
export INDEX_NAME="rag-redis" | ||
export HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN} | ||
export MEGA_SERVICE_HOST_IP=${ip_address} | ||
export EMBEDDING_SERVICE_HOST_IP=${ip_address} | ||
export RETRIEVER_SERVICE_HOST_IP=${ip_address} | ||
|
||
# Start Docker Containers | ||
docker compose -f compose_without_rerank.yaml up -d | ||
sleep 5m | ||
echo "Docker services started!" | ||
} | ||
|
||
function validate() { | ||
local CONTENT="$1" | ||
local EXPECTED_RESULT="$2" | ||
local SERVICE_NAME="$3" | ||
|
||
if echo "$CONTENT" | grep -q "$EXPECTED_RESULT"; then | ||
echo "[ $SERVICE_NAME ] Content is as expected: $CONTENT." | ||
echo 0 | ||
else | ||
echo "[ $SERVICE_NAME ] Content does not match the expected result: $CONTENT" | ||
echo 1 | ||
fi | ||
} | ||
|
||
function validate_megaservice() { | ||
echo "===========Ingest data==================" | ||
local CONTENT=$(http_proxy="" curl -X POST "http://${ip_address}:6007/v1/dataprep" \ | ||
-H "Content-Type: multipart/form-data" \ | ||
-F 'link_list=["https://opea.dev/"]') | ||
local EXIT_CODE=$(validate "$CONTENT" "Data preparation succeeded" "dataprep-redis-service-xeon") | ||
echo "$EXIT_CODE" | ||
local EXIT_CODE="${EXIT_CODE:0-1}" | ||
echo "return value is $EXIT_CODE" | ||
if [ "$EXIT_CODE" == "1" ]; then | ||
docker logs dataprep-redis-server | tee -a ${LOG_PATH}/dataprep-redis-service-xeon.log | ||
return 1 | ||
fi | ||
|
||
# Curl the Mega Service | ||
echo "================Testing retriever service: Text Request ================" | ||
cd $WORKPATH/tests | ||
local CONTENT=$(http_proxy="" curl http://${ip_address}:8889/v1/retrievaltool -X POST -H "Content-Type: application/json" -d '{ | ||
"text": "Explain the OPEA project?" | ||
}') | ||
# local CONTENT=$(python test.py --host_ip ${ip_address} --request_type text) | ||
local EXIT_CODE=$(validate "$CONTENT" "OPEA" "doc-index-retriever-service-xeon") | ||
echo "$EXIT_CODE" | ||
local EXIT_CODE="${EXIT_CODE:0-1}" | ||
echo "return value is $EXIT_CODE" | ||
if [ "$EXIT_CODE" == "1" ]; then | ||
echo "=============Embedding container log==================" | ||
docker logs embedding-tei-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log | ||
echo "=============Retriever container log==================" | ||
docker logs retriever-redis-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log | ||
echo "=============Doc-index-retriever container log==================" | ||
docker logs doc-index-retriever-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log | ||
exit 1 | ||
fi | ||
|
||
echo "================Testing retriever service: ChatCompletion Request================" | ||
cd $WORKPATH/tests | ||
local CONTENT=$(python test.py --host_ip ${ip_address} --request_type chat_completion) | ||
local EXIT_CODE=$(validate "$CONTENT" "OPEA" "doc-index-retriever-service-xeon") | ||
echo "$EXIT_CODE" | ||
local EXIT_CODE="${EXIT_CODE:0-1}" | ||
echo "return value is $EXIT_CODE" | ||
if [ "$EXIT_CODE" == "1" ]; then | ||
echo "=============Embedding container log==================" | ||
docker logs embedding-tei-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log | ||
echo "=============Retriever container log==================" | ||
docker logs retriever-redis-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log | ||
echo "=============Doc-index-retriever container log==================" | ||
docker logs doc-index-retriever-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log | ||
exit 1 | ||
fi | ||
} | ||
|
||
function stop_docker() { | ||
cd $WORKPATH/docker_compose/intel/cpu/xeon | ||
container_list=$(cat compose.yaml | grep container_name | cut -d':' -f2) | ||
for container_name in $container_list; do | ||
cid=$(docker ps -aq --filter "name=$container_name") | ||
echo "Stopping container $container_name" | ||
if [[ ! -z "$cid" ]]; then docker rm $cid -f && sleep 1s; fi | ||
done | ||
} | ||
|
||
function main() { | ||
|
||
stop_docker | ||
build_docker_images | ||
echo "Dump current docker ps" | ||
docker ps | ||
start_time=$(date +%s) | ||
start_services | ||
end_time=$(date +%s) | ||
duration=$((end_time-start_time)) | ||
echo "Mega service start duration is $duration s" | ||
validate_megaservice | ||
|
||
stop_docker | ||
echo y | docker system prune | ||
|
||
} | ||
|
||
main |