Skip to content
This repository was archived by the owner on Jun 22, 2025. It is now read-only.

Commit d98fae6

Browse files
Add redis-finance to dataprep (opea-project#1384)
* [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * redis finance code Signed-off-by: minmin-intel <[email protected]> * add two new packages Signed-off-by: minmin-intel <[email protected]> * fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * debug ci error Signed-off-by: minmin-intel <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix errors Signed-off-by: minmin-intel <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add readme and rename test script to run ci on gaudi Signed-off-by: minmin-intel <[email protected]> --------- Signed-off-by: minmin-intel <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 41dbba1 commit d98fae6

File tree

11 files changed

+1339
-0
lines changed

11 files changed

+1339
-0
lines changed

comps/dataprep/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,7 @@ For details, please refer to this [readme](src/README_opensearch.md)
5656
## Dataprep Microservice with neo4j
5757

5858
For details, please refer to this [readme](src/README_neo4j_llamaindex.md)
59+
60+
## Dataprep Microservice for financial domain data
61+
62+
For details, please refer to this [readme](src/README_finance.md)

comps/dataprep/deployment/docker_compose/compose.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,32 @@ services:
286286
COLLECTION_NAME: ${INDEX_NAME}
287287
restart: unless-stopped
288288

289+
dataprep-redis-finance:
290+
image: ${REGISTRY:-opea}/dataprep:${TAG:-latest}
291+
container_name: dataprep-redis-server-finance
292+
depends_on:
293+
redis-vector-db:
294+
condition: service_healthy
295+
redis-kv-store:
296+
condition: service_healthy
297+
tei-embedding-serving:
298+
condition: service_healthy
299+
ports:
300+
- "${DATAPREP_PORT:-11108}:5000"
301+
environment:
302+
no_proxy: ${no_proxy}
303+
http_proxy: ${http_proxy}
304+
https_proxy: ${https_proxy}
305+
DATAPREP_COMPONENT_NAME: ${DATAPREP_COMPONENT_NAME}
306+
REDIS_URL_VECTOR: ${REDIS_URL_VECTOR}
307+
REDIS_URL_KV: ${REDIS_URL_KV}
308+
TEI_EMBEDDING_ENDPOINT: ${TEI_EMBEDDING_ENDPOINT}
309+
LLM_ENDPOINT: ${LLM_ENDPOINT}
310+
LLM_MODEL: ${LLM_MODEL}
311+
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
312+
HF_TOKEN: ${HF_TOKEN}
313+
LOGFLAG: true
314+
289315
networks:
290316
default:
291317
driver: bridge

comps/dataprep/src/README_finance.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Dataprep microservice for financial domain data
2+
3+
## 1. Overview
4+
5+
We currently support ingestion of PDFs and URL links. The data should be financial domain, such as SEC filings and earnings call transcripts. If the data is not financial domain, you may encounter accuracy problems or errors.
6+
7+
The dataprep microservice saves financial documents into two databases:
8+
9+
1. One vector database of text chunks and tables
10+
2. One KV store of full-length documents
11+
12+
Each unique company has its own index within the vector database and KV store, and metadata such as year, quarter, doc_title, doc_type and source are stored to enable metadata filtering to improve retrieval precision and recall. A company list is maintained so that when a new document comes, the document will either be mapped to an existing company or be added as a new company.
13+
14+
An LLM is used in processing the documents, including extracting metadata and generating summaries for text chunks and tables, and deciding if the document is about an existing company in the knowledge base or not. The default LLM to be used is `meta-llama/Llama-3.3-70B-Instruct`.
15+
16+
## 2. Deploy with docker
17+
18+
### 2.1 Start Redis vector database and Redis KV store
19+
20+
```bash
21+
docker run --name redis-db -p 6379:6379 -p 8001:8001 -d redis/redis-stack:7.2.0-v9
22+
docker run --name redis-kv -p 6380:6379 -p 8002:8001 -d redis/redis-stack:7.2.0-v9
23+
```
24+
25+
### 2.2 Start Embedding Service
26+
27+
First, you need to start a TEI service.
28+
29+
```bash
30+
your_port=6006
31+
model="BAAI/bge-base-en-v1.5"
32+
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
33+
```
34+
35+
Then you need to test your TEI service using the following commands:
36+
37+
```bash
38+
curl localhost:$your_port/embed \
39+
-X POST \
40+
-d '{"inputs":"What is Deep Learning?"}' \
41+
-H 'Content-Type: application/json'
42+
```
43+
44+
### 2.3 Start vllm endpoint
45+
46+
First build vllm-gaudi docker image.
47+
48+
```bash
49+
cd $WORKDIR
50+
git clone https://github.com/HabanaAI/vllm-fork.git
51+
# get the latest release tag of vllm gaudi
52+
VLLM_VER=$(git describe --tags "$(git rev-list --tags --max-count=1)")
53+
echo "Check out vLLM tag ${VLLM_VER}"
54+
git checkout ${VLLM_VER}
55+
docker build --no-cache -f Dockerfile.hpu -t opea/vllm-gaudi:latest --shm-size=128g . --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy
56+
```
57+
58+
Then launch vllm on Gaudi.
59+
60+
```bash
61+
export vllm_port=8086
62+
export vllm_volume=$HF_CACHE_DIR
63+
export max_length=16384
64+
export model="meta-llama/Llama-3.3-70B-Instruct"
65+
export HF_TOKEN=<your-hf-token>
66+
docker run -d --runtime=habana --rm --name "vllm-gaudi-server" -e HABANA_VISIBLE_DEVICES=all -p $vllm_port:8000 -v $vllm_volume:/data -e HF_TOKEN=$HF_TOKEN -e HUGGING_FACE_HUB_TOKEN=$HF_TOKEN -e HF_HOME=/data -e OMPI_MCA_btl_vader_single_copy_mechanism=none -e PT_HPU_ENABLE_LAZY_COLLECTIVES=true -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e VLLM_SKIP_WARMUP=true --cap-add=sys_nice --ipc=host opea/vllm-gaudi:comps --model ${model} --max-seq-len-to-capture $max_length --tensor-parallel-size 4
67+
```
68+
69+
### 2.4 Build Docker Image for dataprep microservice
70+
71+
```bash
72+
cd ../../ # go to GenAIComps
73+
docker build -t opea/dataprep:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/dataprep/src/Dockerfile .
74+
```
75+
76+
### 2.5 Start dataprep microservice
77+
78+
```bash
79+
export ip_address=$(hostname -I | awk '{print $1}')
80+
export REDIS_URL_VECTOR="redis://${ip_address}:6379"
81+
export REDIS_URL_KV="redis://${ip_address}:6380"
82+
export LLM_MODEL="meta-llama/Llama-3.3-70B-Instruct"
83+
export LLM_ENDPOINT="http://${ip_address}:8086"
84+
export TEI_EMBEDDING_ENDPOINT="http://${your_ip}:6006"
85+
export DATAPREP_COMPONENT_NAME="OPEA_DATAPREP_REDIS_FIANANCE"
86+
export HUGGINGFACEHUB_API_TOKEN=<your-hf-token>
87+
```
88+
89+
```bash
90+
docker run -d --name="dataprep-redis-server-finance" -p 6007:5000 --runtime=runc --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e REDIS_URL_VECTOR=$REDIS_URL_VECTOR -e REDIS_URL_KV=$REDIS_URL_KV -e LLM_MODEL=$LLM_MODEL -e LLM_ENDPOINT=$LLM_ENDPOINT -e TEI_EMBEDDING_ENDPOINT=$TEI_EMBEDDING_ENDPOINT -e HUGGINGFACEHUB_API_TOKEN=$HUGGINGFACEHUB_API_TOKEN -e HF_TOKEN=$HUGGINGFACEHUB_API_TOKEN -e DATAPREP_COMPONENT_NAME=$DATAPREP_COMPONENT_NAME opea/dataprep:latest
91+
```
92+
93+
### 2.6 Check the status of dataprep microservice
94+
95+
```bash
96+
docker container logs -f dataprep-redis-server-finance
97+
```
98+
99+
## 3. Consume Microservice
100+
101+
See example python script [here](../../../tests/dataprep/test_redis_finance.py).

0 commit comments

Comments
 (0)