-
Notifications
You must be signed in to change notification settings - Fork 338
Add EdgeCraftRag as a GenAIExample #1072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 51 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
098e948
add EdgeCraftRag as a GenAIExample
Yongbozzz 16b8fb0
Inject commit for the release docker image (#1060)
ZePan110 9f07eb2
Add nightly image build and publish action (#1067)
chensuyue cc71786
Use docker stop instead of docker compose stop to avoid container cle…
chensuyue cf6b6b3
add EdgeCraftRag as a GenAIExample
Yongbozzz 4cddd06
resolve Dockerfile warning
Yongbozzz d1ee894
Update nightly image build jobs (#1070)
chensuyue 7807806
resolve pre-commit.ci check error
Yongbozzz 2bcab88
Inject commit for the release docker image (#1060)
ZePan110 98a05bd
Update nightly image build jobs (#1070)
chensuyue 2ab4df0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1a39a85
[Doc] Fix broken build instruction (#1063)
xiguiw 9d303cc
Merge branch 'main' into ecrag_v1
Yongbozzz cdbf9d6
remove register_microservice in api
Yongbozzz a897d93
resolve conflict
Yongbozzz 5e36665
Merge branch 'main' into ecrag_v1
Yongbozzz d9adc75
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 6231a46
Merge branch 'main' into ecrag_v1
lvliang-intel c8e83a1
update code according to comments
Yongbozzz 221adf6
resolve conflit
Yongbozzz 0ed9937
Merge branch 'main' into ecrag_v1
Yongbozzz 219dbf0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1cde2b6
adjust variables in UI
Yongbozzz ec64c99
Merge branch 'ecrag_v1' of https://github.com/Yongbozzz/GenAIExamples…
Yongbozzz 85daf8f
Merge branch 'opea-project:main' into ecrag_v1
Yongbozzz 80b0584
add EdgeCraftRag as a GenAIExample
Yongbozzz 043db19
remove register_microservice in api
Yongbozzz 5942875
Inject commit for the release docker image (#1060)
ZePan110 78c6316
Use docker stop instead of docker compose stop to avoid container cle…
chensuyue f76343c
add EdgeCraftRag as a GenAIExample
Yongbozzz d0daf4a
Update nightly image build jobs (#1070)
chensuyue 02cc436
resolve pre-commit.ci check error
Yongbozzz ba450e9
Inject commit for the release docker image (#1060)
ZePan110 de38b34
Update nightly image build jobs (#1070)
chensuyue 54bc0e5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e24a734
update code according to comments
Yongbozzz f5caf6a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3efb091
adjust variables in UI
Yongbozzz 2dcf455
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a5911b8
code enhancement idocker compose
Yongbozzz c761c76
resolve conflict
Yongbozzz 028de18
resolve DCO issue
Yongbozzz e850bc2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0811e34
Merge branch 'main' into ecrag_v1
Yongbozzz 584cfff
resolve CI issue
Yongbozzz 0acfe0b
remove test file to support CI
Yongbozzz 3dd013d
Merge branch 'main' into ecrag_v1
Yongbozzz 756c60b
fix CI issue
Yongbozzz 70b489d
Merge branch 'main' into ecrag_v1
Yongbozzz 9e42fc9
Merge branch 'ecrag_v1' of https://github.com/Yongbozzz/GenAIExamples…
Yongbozzz 14d649f
Merge branch 'main' into ecrag_v1
Yongbozzz 4b0be32
file name change according to comment
Yongbozzz 56eee8c
Merge branch 'ecrag_v1' of https://github.com/Yongbozzz/GenAIExamples…
Yongbozzz 54c339a
resolve comment
Yongbozzz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,2 @@ | ||
| ModelIn | ||
| modelin |
This file contains hidden or 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,28 @@ | ||
| # Copyright (C) 2024 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| FROM python:3.11-slim | ||
|
|
||
| SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
|
||
| RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ | ||
| libgl1-mesa-glx \ | ||
| libjemalloc-dev | ||
|
|
||
| RUN useradd -m -s /bin/bash user && \ | ||
| mkdir -p /home/user && \ | ||
| chown -R user /home/user/ | ||
|
|
||
| COPY ./edgecraftrag /home/user/edgecraftrag | ||
| COPY ./chatqna.py /home/user/chatqna.py | ||
|
|
||
| WORKDIR /home/user/edgecraftrag | ||
| RUN pip install --no-cache-dir -r requirements.txt | ||
|
|
||
| WORKDIR /home/user | ||
|
|
||
| USER user | ||
|
|
||
| RUN echo 'ulimit -S -n 999999' >> ~/.bashrc | ||
|
|
||
| ENTRYPOINT ["python", "chatqna.py"] |
This file contains hidden or 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,35 @@ | ||
| FROM python:3.11-slim | ||
|
|
||
| SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
|
||
| RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ | ||
| libgl1-mesa-glx \ | ||
| libjemalloc-dev | ||
|
|
||
| RUN apt-get update && apt-get install -y gnupg wget | ||
| RUN wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | \ | ||
| gpg --yes --dearmor --output /usr/share/keyrings/intel-graphics.gpg | ||
| RUN echo "deb [arch=amd64,i386 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu jammy client" | \ | ||
| tee /etc/apt/sources.list.d/intel-gpu-jammy.list | ||
| RUN apt-get update | ||
| RUN apt-get install -y \ | ||
| intel-opencl-icd intel-level-zero-gpu level-zero intel-level-zero-gpu-raytracing \ | ||
| intel-media-va-driver-non-free libmfx1 libmfxgen1 libvpl2 \ | ||
| libegl-mesa0 libegl1-mesa libegl1-mesa-dev libgbm1 libgl1-mesa-dev libgl1-mesa-dri \ | ||
| libglapi-mesa libgles2-mesa-dev libglx-mesa0 libigdgmm12 libxatracker2 mesa-va-drivers \ | ||
| mesa-vdpau-drivers mesa-vulkan-drivers va-driver-all vainfo hwinfo clinfo | ||
|
|
||
| RUN useradd -m -s /bin/bash user && \ | ||
| mkdir -p /home/user && \ | ||
| chown -R user /home/user/ | ||
|
|
||
| COPY ./edgecraftrag /home/user/edgecraftrag | ||
|
|
||
| WORKDIR /home/user/edgecraftrag | ||
| RUN pip install --no-cache-dir -r requirements.txt | ||
|
|
||
| WORKDIR /home/user/ | ||
|
|
||
| USER user | ||
|
|
||
| ENTRYPOINT ["python", "-m", "edgecraftrag.server"] |
This file contains hidden or 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,23 @@ | ||
| FROM python:3.11-slim | ||
|
|
||
| RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ | ||
| libgl1-mesa-glx \ | ||
| libjemalloc-dev | ||
|
|
||
| RUN useradd -m -s /bin/bash user && \ | ||
| mkdir -p /home/user && \ | ||
| chown -R user /home/user/ | ||
|
|
||
| COPY ./ui /home/user/ui | ||
| COPY ./edgecraftrag /home/user/edgecraftrag | ||
|
|
||
| WORKDIR /home/user/edgecraftrag | ||
| RUN pip install --no-cache-dir -r requirements.txt | ||
|
|
||
| WORKDIR /home/user/ui | ||
|
|
||
| USER user | ||
|
|
||
| RUN echo 'ulimit -S -n 999999' >> ~/.bashrc | ||
|
|
||
| ENTRYPOINT ["python", "ecragui.py"] | ||
This file contains hidden or 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,274 @@ | ||
| # Edge Craft Retrieval-Augmented Generation | ||
|
|
||
| Edge Craft RAG (EC-RAG) is a customizable, tunable and production-ready | ||
| Retrieval-Augmented Generation system for edge solutions. It is designed to | ||
| curate the RAG pipeline to meet hardware requirements at edge with guaranteed | ||
| quality and performance. | ||
|
|
||
| ## Quick Start Guide | ||
|
|
||
| ### Run Containers with Docker Compose | ||
|
|
||
| ```bash | ||
| cd GenAIExamples/EdgeCraftRAG/docker_compose/Intel/Arc | ||
|
|
||
| export MODEL_PATH="your model path for all your models" | ||
| export DOC_PATH="your doc path for uploading a dir of files" | ||
| export HOST_IP="your host ip" | ||
| export UI_SERVICE_PORT="port for UI service" | ||
|
|
||
| # Optional for vllm endpoint | ||
| export vLLM_ENDPOINT="http://${HOST_IP}:8008" | ||
|
|
||
| # If you have a proxy configured, uncomment below line | ||
| # export no_proxy=$no_proxy,${HOST_IP},edgecraftrag,edgecraftrag-server | ||
| # If you have a HF mirror configured, it will be imported to the container | ||
| # export HF_ENDPOINT="your HF mirror endpoint" | ||
|
|
||
| # By default, the ports of the containers are set, uncomment if you want to change | ||
| # export MEGA_SERVICE_PORT=16011 | ||
| # export PIPELINE_SERVICE_PORT=16011 | ||
|
|
||
| docker compose up -d | ||
| ``` | ||
|
|
||
| ### (Optional) Build Docker Images for Mega Service, Server and UI by your own | ||
|
|
||
| ```bash | ||
| cd GenAIExamples/EdgeCraftRAG | ||
|
|
||
| docker build --build-arg http_proxy=$HTTP_PROXY --build-arg https_proxy=$HTTPS_PROXY --build-arg no_proxy=$NO_PROXY -t opea/edgecraftrag:latest -f Dockerfile . | ||
| docker build --build-arg http_proxy=$HTTP_PROXY --build-arg https_proxy=$HTTPS_PROXY --build-arg no_proxy=$NO_PROXY -t opea/edgecraftrag-server:latest -f Dockerfile.server . | ||
| docker build --build-arg http_proxy=$HTTP_PROXY --build-arg https_proxy=$HTTPS_PROXY --build-arg no_proxy=$NO_PROXY -t opea/edgecraftrag-ui:latest -f Dockerfile.ui . | ||
| ``` | ||
|
|
||
| ### ChatQnA with LLM Example (Command Line) | ||
|
|
||
| ```bash | ||
| cd GenAIExamples/EdgeCraftRAG | ||
|
|
||
| # Activate pipeline test_pipeline_local_llm | ||
| curl -X POST http://${HOST_IP}:16010/v1/settings/pipelines -H "Content-Type: application/json" -d @tests/test_pipeline_local_llm.json | jq '.' | ||
|
|
||
| # Will need to wait for several minutes | ||
| # Expected output: | ||
| # { | ||
| # "idx": "3214cf25-8dff-46e6-b7d1-1811f237cf8c", | ||
| # "name": "rag_test", | ||
| # "comp_type": "pipeline", | ||
| # "node_parser": { | ||
| # "idx": "ababed12-c192-4cbb-b27e-e49c76a751ca", | ||
| # "parser_type": "simple", | ||
| # "chunk_size": 400, | ||
| # "chunk_overlap": 48 | ||
| # }, | ||
| # "indexer": { | ||
| # "idx": "46969b63-8a32-4142-874d-d5c86ee9e228", | ||
| # "indexer_type": "faiss_vector", | ||
| # "model": { | ||
| # "idx": "7aae57c0-13a4-4a15-aecb-46c2ec8fe738", | ||
| # "type": "embedding", | ||
| # "model_id": "BAAI/bge-small-en-v1.5", | ||
| # "model_path": "/home/user/models/bge_ov_embedding", | ||
| # "device": "auto" | ||
| # } | ||
| # }, | ||
| # "retriever": { | ||
| # "idx": "3747fa59-ff9b-49b6-a8e8-03cdf8c979a4", | ||
| # "retriever_type": "vectorsimilarity", | ||
| # "retrieve_topk": 30 | ||
| # }, | ||
| # "postprocessor": [ | ||
| # { | ||
| # "idx": "d46a6cae-ba7a-412e-85b7-d334f175efaa", | ||
| # "postprocessor_type": "reranker", | ||
| # "model": { | ||
| # "idx": "374e7471-bd7d-41d0-b69d-a749a052b4b0", | ||
| # "type": "reranker", | ||
| # "model_id": "BAAI/bge-reranker-large", | ||
| # "model_path": "/home/user/models/bge_ov_reranker", | ||
| # "device": "auto" | ||
| # }, | ||
| # "top_n": 2 | ||
| # } | ||
| # ], | ||
| # "generator": { | ||
| # "idx": "52d8f112-6290-4dd3-bc28-f9bd5deeb7c8", | ||
| # "generator_type": "local", | ||
| # "model": { | ||
| # "idx": "fa0c11e1-46d1-4df8-a6d8-48cf6b99eff3", | ||
| # "type": "llm", | ||
| # "model_id": "qwen2-7b-instruct", | ||
| # "model_path": "/home/user/models/qwen2-7b-instruct/INT4_compressed_weights", | ||
| # "device": "auto" | ||
| # } | ||
| # }, | ||
| # "status": { | ||
| # "active": true | ||
| # } | ||
| # } | ||
|
|
||
| # Prepare data from local directory | ||
| curl -X POST http://${HOST_IP}:16010/v1/data -H "Content-Type: application/json" -d '{"local_path":"#REPLACE WITH YOUR LOCAL DOC DIR#"}' | jq '.' | ||
|
|
||
| # Validate Mega Service | ||
| curl -X POST http://${HOST_IP}:16011/v1/chatqna -H "Content-Type: application/json" -d '{"messages":"#REPLACE WITH YOUR QUESTION HERE#", "top_n":5, "max_tokens":512}' | jq '.' | ||
| ``` | ||
|
|
||
| ### ChatQnA with LLM Example (UI) | ||
|
|
||
| Open your browser, access http://${HOST_IP}:8082 | ||
|
|
||
| > Your browser should be running on the same host of your console, otherwise you will need to access UI with your host domain name instead of ${HOST_IP}. | ||
|
|
||
| ### (Optional) Launch vLLM with OpenVINO service | ||
|
|
||
| ```bash | ||
| # 1. export LLM_MODEL | ||
| export LLM_MODEL="your model id" | ||
| # 2. Uncomment below code in 'GenAIExamples/EdgeCraftRAG/docker_compose/Intel/Arc/compose.yaml' | ||
| # vllm-service: | ||
| # image: vllm:openvino | ||
| # container_name: vllm-openvino-server | ||
| # depends_on: | ||
| # - vllm-service | ||
| # ports: | ||
| # - "8008:80" | ||
| # environment: | ||
| # no_proxy: ${no_proxy} | ||
| # http_proxy: ${http_proxy} | ||
| # https_proxy: ${https_proxy} | ||
| # vLLM_ENDPOINT: ${vLLM_ENDPOINT} | ||
| # LLM_MODEL: ${LLM_MODEL} | ||
| # entrypoint: /bin/bash -c "\ | ||
| # cd / && \ | ||
| # export VLLM_CPU_KVCACHE_SPACE=50 && \ | ||
| # python3 -m vllm.entrypoints.openai.api_server \ | ||
| # --model '${LLM_MODEL}' \ | ||
| # --host 0.0.0.0 \ | ||
| # --port 80" | ||
| ``` | ||
|
|
||
| ## Advanced User Guide | ||
|
|
||
| ### Pipeline Management | ||
|
|
||
| #### Create a pipeline | ||
|
|
||
| ```bash | ||
| curl -X POST http://${HOST_IP}:16010/v1/settings/pipelines -H "Content-Type: application/json" -d @examples/test_pipeline.json | jq '.' | ||
| ``` | ||
|
|
||
| It will take some time to prepare the embedding model. | ||
|
|
||
| #### Upload a text | ||
|
|
||
| ```bash | ||
| curl -X POST http://${HOST_IP}:16010/v1/data -H "Content-Type: application/json" -d @examples/test_data.json | jq '.' | ||
| ``` | ||
|
|
||
| #### Provide a query to retrieve context with similarity search. | ||
|
|
||
| ```bash | ||
| curl -X POST http://${HOST_IP}:16010/v1/retrieval -H "Content-Type: application/json" -d @examples/test_query.json | jq '.' | ||
| ``` | ||
|
|
||
| #### Create the second pipeline test2 | ||
|
|
||
| ```bash | ||
| curl -X POST http://${HOST_IP}:16010/v1/settings/pipelines -H "Content-Type: application/json" -d @examples/test_pipeline2.json | jq '.' | ||
| ``` | ||
|
|
||
| #### Check all pipelines | ||
|
|
||
| ```bash | ||
| curl -X GET http://${HOST_IP}:16010/v1/settings/pipelines -H "Content-Type: application/json" | jq '.' | ||
| ``` | ||
|
|
||
| #### Compare similarity retrieval (test1) and keyword retrieval (test2) | ||
|
|
||
| ```bash | ||
| # Activate pipeline test1 | ||
| curl -X PATCH http://${HOST_IP}:16010/v1/settings/pipelines/test1 -H "Content-Type: application/json" -d '{"active": "true"}' | jq '.' | ||
| # Similarity retrieval | ||
| curl -X POST http://${HOST_IP}:16010/v1/retrieval -H "Content-Type: application/json" -d '{"messages":"number"}' | jq '.' | ||
|
|
||
| # Activate pipeline test2 | ||
| curl -X PATCH http://${HOST_IP}:16010/v1/settings/pipelines/test2 -H "Content-Type: application/json" -d '{"active": "true"}' | jq '.' | ||
| # Keyword retrieval | ||
| curl -X POST http://${HOST_IP}:16010/v1/retrieval -H "Content-Type: application/json" -d '{"messages":"number"}' | jq '.' | ||
|
|
||
| ``` | ||
|
|
||
| ### Model Management | ||
|
|
||
| #### Load a model | ||
|
|
||
| ```bash | ||
| curl -X POST http://${HOST_IP}:16010/v1/settings/models -H "Content-Type: application/json" -d @examples/test_model_load.json | jq '.' | ||
| ``` | ||
|
|
||
| It will take some time to load the model. | ||
|
|
||
| #### Check all models | ||
|
|
||
| ```bash | ||
| curl -X GET http://${HOST_IP}:16010/v1/settings/models -H "Content-Type: application/json" | jq '.' | ||
| ``` | ||
|
|
||
| #### Update a model | ||
|
|
||
| ```bash | ||
| curl -X PATCH http://${HOST_IP}:16010/v1/settings/models/BAAI/bge-reranker-large -H "Content-Type: application/json" -d @examples/test_model_update.json | jq '.' | ||
| ``` | ||
|
|
||
| #### Check a certain model | ||
|
|
||
| ```bash | ||
| curl -X GET http://${HOST_IP}:16010/v1/settings/models/BAAI/bge-reranker-large -H "Content-Type: application/json" | jq '.' | ||
| ``` | ||
|
|
||
| #### Delete a model | ||
|
|
||
| ```bash | ||
| curl -X DELETE http://${HOST_IP}:16010/v1/settings/models/BAAI/bge-reranker-large -H "Content-Type: application/json" | jq '.' | ||
| ``` | ||
|
|
||
| ### File Management | ||
|
|
||
| #### Add a text | ||
|
|
||
| ```bash | ||
| curl -X POST http://${HOST_IP}:16010/v1/data -H "Content-Type: application/json" -d @examples/test_data.json | jq '.' | ||
| ``` | ||
|
|
||
| #### Add files from existed file path | ||
|
|
||
| ```bash | ||
| curl -X POST http://${HOST_IP}:16010/v1/data -H "Content-Type: application/json" -d @examples/test_data_dir.json | jq '.' | ||
| curl -X POST http://${HOST_IP}:16010/v1/data -H "Content-Type: application/json" -d @examples/test_data_file.json | jq '.' | ||
| ``` | ||
|
|
||
| #### Check all files | ||
|
|
||
| ```bash | ||
| curl -X GET http://${HOST_IP}:16010/v1/data/files -H "Content-Type: application/json" | jq '.' | ||
| ``` | ||
|
|
||
| #### Check one file | ||
|
|
||
| ```bash | ||
| curl -X GET http://${HOST_IP}:16010/v1/data/files/test2.docx -H "Content-Type: application/json" | jq '.' | ||
| ``` | ||
|
|
||
| #### Delete a file | ||
|
|
||
| ```bash | ||
| curl -X DELETE http://${HOST_IP}:16010/v1/data/files/test2.docx -H "Content-Type: application/json" | jq '.' | ||
| ``` | ||
|
|
||
| #### Update a file | ||
|
|
||
| ```bash | ||
| curl -X PATCH http://${HOST_IP}:16010/v1/data/files/test.pdf -H "Content-Type: application/json" -d @examples/test_data_file.json | jq '.' | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.