This README provides set-up instructions and comprehensive details regarding the reranking microservice with VideoQnA. This microservice is designed that do result rerank for VideoQnA use case. Local rerank is used rather than rerank model.
For the VideoQnA
usecase, during the data preparation phase, frames are extracted from videos and stored in a vector database.
To identify the most relevant video, we count the occurrences of each video source among the retrieved data with rerank function get_top_doc
.
This sorts the video as a descending list of names, ranked by their degree of match with the query.
Then we could send the top_n
videos to the downstream LVM.
-
Build the Docker image for the reranking microservice:
docker build --no-cache \ -t opea/reranking:comps \ --build-arg https_proxy=$https_proxy \ --build-arg http_proxy=$http_proxy \ --build-arg SERVICE=svideoqna \ -f comps/rerankings/src/Dockerfile .
-
Run the reranking microservice and connect it to the VideoQnA service:
docker run -d --name "reranking-videoqna-server" \ -p 10703:8000 \ --ipc=host \ -e no_proxy=${no_proxy} \ -e http_proxy=${http_proxy} \ -e https_proxy=${https_proxy} \ -e CHUNK_DURATION=${CHUNK_DURATION} \ -e RERANK_COMPONENT_NAME="OPEA_VIDEO_RERANKING" \ -e FILE_SERVER_ENDPOINT=${FILE_SERVER_ENDPOINT} \ opea/reranking:comps
Deploy both the Videoqna Reranking Service and the Reranking Microservice using Docker Compose.
🔹 Steps:
-
Set environment variables:
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
-
Navigate to the Docker Compose directory:
cd comps/rerankings/deployment/docker_compose
-
Start the services:
docker compose up reranking-videoqna -d
-
Verify the reranking service is running:
curl http://localhost:10703/v1/health_check \ -X GET \ -H 'Content-Type: application/json'
-
Execute reranking process by providing query and documents
curl http://localhost:10703/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'
-
You can add the parameter
top_n
to specify the return number of the reranker model, default value is 1.curl http://localhost:10703/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'
-
Port Mapping: Ensure the ports are correctly mapped to avoid conflicts with other services.
-
Environment Variables:
- Use http_proxy and https_proxy for proxy setup if necessary.
- CHUNK_DURATION: target chunk duration, should be aligned with VideoQnA dataprep. Default 10s.
-
Data Volume: The
-v ./data:/data
flag ensures the data directory is correctly mounted.