From 48d4e533964bd2843df0a90b6c5e7c45c817a8d4 Mon Sep 17 00:00:00 2001 From: "chen, suyue" Date: Tue, 10 Sep 2024 15:23:10 +0800 Subject: [PATCH] unify default reranking model with BAAI/bge-reranker-base (#623) Signed-off-by: chensuyue Signed-off-by: ZePan110 --- README.md | 4 ++-- comps/dataprep/redis/README.md | 2 +- comps/dataprep/redis/langchain/config.py | 2 +- comps/embeddings/README.md | 8 ++++---- comps/embeddings/langchain/local_embedding.py | 2 +- comps/embeddings/llama_index/embedding_tei.py | 2 +- comps/embeddings/llama_index/local_embedding.py | 2 +- comps/reranks/README.md | 2 +- comps/reranks/langchain-mosec/mosec-docker/Dockerfile | 2 +- comps/reranks/tei/local_reranking.py | 2 +- tests/test_embeddings_langchain-mosec.sh | 2 +- tests/test_embeddings_langchain.sh | 4 ++-- tests/test_embeddings_llama_index.sh | 4 ++-- tests/test_reranks_langchain-mosec.sh | 2 +- tests/test_reranks_tei.sh | 4 ++-- 15 files changed, 22 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index e1b48a08c..ecaf6c35d 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ The initially supported `Microservices` are described in the below table. More ` Embedding LangChain/LlamaIndex - BAAI/bge-large-en-v1.5 + BAAI/bge-base-en-v1.5 TEI-Gaudi Gaudi2 Embedding on Gaudi2 @@ -76,7 +76,7 @@ The initially supported `Microservices` are described in the below table. More ` Reranking LangChain/LlamaIndex - BAAI/bge-reranker-large + BAAI/bge-reranker-base TEI-Gaudi Gaudi2 Reranking on Gaudi2 diff --git a/comps/dataprep/redis/README.md b/comps/dataprep/redis/README.md index 440eb0d45..c9fb1deaf 100644 --- a/comps/dataprep/redis/README.md +++ b/comps/dataprep/redis/README.md @@ -49,7 +49,7 @@ First, you need to start a TEI service. ```bash your_port=6006 -model="BAAI/bge-large-en-v1.5" +model="BAAI/bge-base-en-v1.5" revision="refs/pr/5" docker run -p $your_port:80 -v ./data:/data --name tei_server -e http_proxy=$http_proxy -e https_proxy=$https_proxy --pull always ghcr.io/huggingface/text-embeddings-inference:cpu-1.2 --model-id $model --revision $revision ``` diff --git a/comps/dataprep/redis/langchain/config.py b/comps/dataprep/redis/langchain/config.py index 75715912c..2d722a84a 100644 --- a/comps/dataprep/redis/langchain/config.py +++ b/comps/dataprep/redis/langchain/config.py @@ -5,7 +5,7 @@ # Embedding model -EMBED_MODEL = os.getenv("EMBED_MODEL", "BAAI/bge-large-en-v1.5") +EMBED_MODEL = os.getenv("EMBED_MODEL", "BAAI/bge-base-en-v1.5") # Redis Connection Information REDIS_HOST = os.getenv("REDIS_HOST", "localhost") diff --git a/comps/embeddings/README.md b/comps/embeddings/README.md index 8ac6dfe0c..56dc922df 100644 --- a/comps/embeddings/README.md +++ b/comps/embeddings/README.md @@ -43,7 +43,7 @@ First, you need to start a TEI service. ```bash your_port=8090 -model="BAAI/bge-large-en-v1.5" +model="BAAI/bge-base-en-v1.5" docker run -p $your_port:80 -v ./data:/data --name tei_server -e http_proxy=$http_proxy -e https_proxy=$https_proxy --pull always ghcr.io/huggingface/text-embeddings-inference:cpu-1.5 --model-id $model ``` @@ -64,7 +64,7 @@ cd langchain # run with llama_index cd llama_index export TEI_EMBEDDING_ENDPOINT="http://localhost:$yourport" -export TEI_EMBEDDING_MODEL_NAME="BAAI/bge-large-en-v1.5" +export TEI_EMBEDDING_MODEL_NAME="BAAI/bge-base-en-v1.5" python embedding_tei.py ``` @@ -86,7 +86,7 @@ First, you need to start a TEI service. ```bash your_port=8090 -model="BAAI/bge-large-en-v1.5" +model="BAAI/bge-base-en-v1.5" docker run -p $your_port:80 -v ./data:/data --name tei_server -e http_proxy=$http_proxy -e https_proxy=$https_proxy --pull always ghcr.io/huggingface/text-embeddings-inference:cpu-1.5 --model-id $model ``` @@ -103,7 +103,7 @@ Export the `TEI_EMBEDDING_ENDPOINT` for later usage: ```bash export TEI_EMBEDDING_ENDPOINT="http://localhost:$yourport" -export TEI_EMBEDDING_MODEL_NAME="BAAI/bge-large-en-v1.5" +export TEI_EMBEDDING_MODEL_NAME="BAAI/bge-base-en-v1.5" ``` ### 2.2 Build Docker Image diff --git a/comps/embeddings/langchain/local_embedding.py b/comps/embeddings/langchain/local_embedding.py index 32f8944a9..6a0a1a630 100644 --- a/comps/embeddings/langchain/local_embedding.py +++ b/comps/embeddings/langchain/local_embedding.py @@ -40,5 +40,5 @@ def embedding(input: TextDoc) -> EmbedDoc: if __name__ == "__main__": - embeddings = HuggingFaceEmbeddings(model_name="BAAI/bge-large-en-v1.5") + embeddings = HuggingFaceEmbeddings(model_name="BAAI/bge-base-en-v1.5") opea_microservices["opea_service@local_embedding"].start() diff --git a/comps/embeddings/llama_index/embedding_tei.py b/comps/embeddings/llama_index/embedding_tei.py index cf14f7790..943bd7535 100644 --- a/comps/embeddings/llama_index/embedding_tei.py +++ b/comps/embeddings/llama_index/embedding_tei.py @@ -31,7 +31,7 @@ def embedding(input: TextDoc) -> EmbedDoc: if __name__ == "__main__": - tei_embedding_model_name = os.getenv("TEI_EMBEDDING_MODEL_NAME", "BAAI/bge-large-en-v1.5") + tei_embedding_model_name = os.getenv("TEI_EMBEDDING_MODEL_NAME", "BAAI/bge-base-en-v1.5") tei_embedding_endpoint = os.getenv("TEI_EMBEDDING_ENDPOINT", "http://localhost:8090") embeddings = TextEmbeddingsInference(model_name=tei_embedding_model_name, base_url=tei_embedding_endpoint) logger.info("TEI Gaudi Embedding initialized.") diff --git a/comps/embeddings/llama_index/local_embedding.py b/comps/embeddings/llama_index/local_embedding.py index 143d7bb07..17ee6e89a 100644 --- a/comps/embeddings/llama_index/local_embedding.py +++ b/comps/embeddings/llama_index/local_embedding.py @@ -31,5 +31,5 @@ def embedding(input: TextDoc) -> EmbedDoc: if __name__ == "__main__": - embeddings = HuggingFaceInferenceAPIEmbedding(model_name="BAAI/bge-large-en-v1.5") + embeddings = HuggingFaceInferenceAPIEmbedding(model_name="BAAI/bge-base-en-v1.5") opea_microservices["opea_service@local_embedding"].start() diff --git a/comps/reranks/README.md b/comps/reranks/README.md index 9b5dc9042..c1ea8bb7a 100644 --- a/comps/reranks/README.md +++ b/comps/reranks/README.md @@ -19,7 +19,7 @@ export HF_TOKEN=${your_hf_api_token} export LANGCHAIN_TRACING_V2=true export LANGCHAIN_API_KEY=${your_langchain_api_key} export LANGCHAIN_PROJECT="opea/reranks" -export RERANK_MODEL_ID="BAAI/bge-reranker-large" +export RERANK_MODEL_ID="BAAI/bge-reranker-base" revision=refs/pr/4 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.2 --model-id $RERANK_MODEL_ID --revision $revision --hf-api-token $HF_TOKEN diff --git a/comps/reranks/langchain-mosec/mosec-docker/Dockerfile b/comps/reranks/langchain-mosec/mosec-docker/Dockerfile index dcf38aee5..895b20909 100644 --- a/comps/reranks/langchain-mosec/mosec-docker/Dockerfile +++ b/comps/reranks/langchain-mosec/mosec-docker/Dockerfile @@ -18,7 +18,7 @@ RUN pip3 install intel-extension-for-pytorch==2.2.0 RUN pip3 install transformers sentence-transformers RUN pip3 install llmspec mosec -RUN cd /home/user/ && export HF_ENDPOINT=https://hf-mirror.com && huggingface-cli download --resume-download BAAI/bge-reranker-large --local-dir /home/user/bge-reranker-large +RUN cd /home/user/ && export HF_ENDPOINT=https://hf-mirror.com && huggingface-cli download --resume-download BAAI/bge-reranker-base --local-dir /home/user/bge-reranker-large USER user ENV EMB_MODEL="/home/user/bge-reranker-large/" diff --git a/comps/reranks/tei/local_reranking.py b/comps/reranks/tei/local_reranking.py index 284cca7e6..fca2e68e6 100644 --- a/comps/reranks/tei/local_reranking.py +++ b/comps/reranks/tei/local_reranking.py @@ -41,5 +41,5 @@ def reranking(input: SearchedDoc) -> RerankedDoc: if __name__ == "__main__": - reranker_model = CrossEncoder(model_name="BAAI/bge-reranker-large", max_length=512) + reranker_model = CrossEncoder(model_name="BAAI/bge-reranker-base", max_length=512) opea_microservices["opea_service@local_reranking"].start() diff --git a/tests/test_embeddings_langchain-mosec.sh b/tests/test_embeddings_langchain-mosec.sh index 95858118b..9a30b33ce 100644 --- a/tests/test_embeddings_langchain-mosec.sh +++ b/tests/test_embeddings_langchain-mosec.sh @@ -33,7 +33,7 @@ function build_docker_images() { function start_service() { mosec_endpoint=5001 - model="BAAI/bge-large-en-v1.5" + model="BAAI/bge-base-en-v1.5" unset http_proxy docker run -d --name="test-comps-embedding-langchain-mosec-endpoint" -p $mosec_endpoint:8000 opea/embedding-langchain-mosec-endpoint:comps export MOSEC_EMBEDDING_ENDPOINT="http://${ip_address}:${mosec_endpoint}" diff --git a/tests/test_embeddings_langchain.sh b/tests/test_embeddings_langchain.sh index 6c6241226..3dbbcdcd0 100644 --- a/tests/test_embeddings_langchain.sh +++ b/tests/test_embeddings_langchain.sh @@ -21,10 +21,10 @@ function build_docker_images() { function start_service() { tei_endpoint=5001 - model="BAAI/bge-large-en-v1.5" + model="BAAI/bge-base-en-v1.5" revision="refs/pr/5" unset http_proxy - docker run -d --name="test-comps-embedding-tei-endpoint" -p $tei_endpoint:80 -v ./data:/data --pull always ghcr.io/huggingface/text-embeddings-inference:cpu-1.2 --model-id $model --revision $revision + docker run -d --name="test-comps-embedding-tei-endpoint" -p $tei_endpoint:80 -v ./data:/data --pull always ghcr.io/huggingface/text-embeddings-inference:cpu-1.5 --model-id $model export TEI_EMBEDDING_ENDPOINT="http://${ip_address}:${tei_endpoint}" tei_service_port=5002 docker run -d --name="test-comps-embedding-tei-server" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -p ${tei_service_port}:6000 --ipc=host -e TEI_EMBEDDING_ENDPOINT=$TEI_EMBEDDING_ENDPOINT opea/embedding-tei:comps diff --git a/tests/test_embeddings_llama_index.sh b/tests/test_embeddings_llama_index.sh index 81eac442b..19eb55304 100644 --- a/tests/test_embeddings_llama_index.sh +++ b/tests/test_embeddings_llama_index.sh @@ -22,9 +22,9 @@ function build_docker_images() { function start_service() { tei_endpoint=5001 - model="BAAI/bge-large-en-v1.5" + model="BAAI/bge-base-en-v1.5" revision="refs/pr/5" - docker run -d --name="test-comps-embedding-tei-llama-index-endpoint" -p $tei_endpoint:80 -v ./data:/data -e http_proxy=$http_proxy -e https_proxy=$https_proxy --pull always ghcr.io/huggingface/text-embeddings-inference:cpu-1.2 --model-id $model --revision $revision + docker run -d --name="test-comps-embedding-tei-llama-index-endpoint" -p $tei_endpoint:80 -v ./data:/data -e http_proxy=$http_proxy -e https_proxy=$https_proxy --pull always ghcr.io/huggingface/text-embeddings-inference:cpu-1.5 --model-id $model export TEI_EMBEDDING_ENDPOINT="http://${ip_address}:${tei_endpoint}" tei_service_port=5010 docker run -d --name="test-comps-embedding-tei-llama-index-server" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -p ${tei_service_port}:6000 --ipc=host -e TEI_EMBEDDING_ENDPOINT=$TEI_EMBEDDING_ENDPOINT opea/embedding-tei-llama-index:comps diff --git a/tests/test_reranks_langchain-mosec.sh b/tests/test_reranks_langchain-mosec.sh index d34957a4c..1339c0df9 100644 --- a/tests/test_reranks_langchain-mosec.sh +++ b/tests/test_reranks_langchain-mosec.sh @@ -33,7 +33,7 @@ function build_docker_images() { function start_service() { mosec_endpoint=5006 - model="BAAI/bge-reranker-large" + model="BAAI/bge-reranker-base" unset http_proxy docker run -d --name="test-comps-reranking-langchain-mosec-endpoint" -p $mosec_endpoint:8000 opea/reranking-langchain-mosec-endpoint:comps export MOSEC_RERANKING_ENDPOINT="http://${ip_address}:${mosec_endpoint}" diff --git a/tests/test_reranks_tei.sh b/tests/test_reranks_tei.sh index 0b146d81e..fa087357c 100644 --- a/tests/test_reranks_tei.sh +++ b/tests/test_reranks_tei.sh @@ -21,10 +21,10 @@ function start_service() { tei_endpoint=5006 # Remember to set HF_TOKEN before invoking this test! export HF_TOKEN=${HF_TOKEN} - model=BAAI/bge-reranker-large + model=BAAI/bge-reranker-base revision=refs/pr/4 volume=$PWD/data - docker run -d --name="test-comps-reranking-tei-endpoint" -p $tei_endpoint:80 -v $volume:/data --pull always ghcr.io/huggingface/text-embeddings-inference:cpu-1.2 --model-id $model --revision $revision + docker run -d --name="test-comps-reranking-tei-endpoint" -p $tei_endpoint:80 -v $volume:/data --pull always ghcr.io/huggingface/text-embeddings-inference:cpu-1.5 --model-id $model export TEI_RERANKING_ENDPOINT="http://${ip_address}:${tei_endpoint}" tei_service_port=5007