Skip to content

Commit c7f06d5

Browse files
authored
Refine documents for DocSum (#1802)
Signed-off-by: Xinyao <xinyao.wang@intel.com>
1 parent 0967fca commit c7f06d5

6 files changed

Lines changed: 669 additions & 1006 deletions

File tree

DocSum/README.md

Lines changed: 15 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -2,81 +2,16 @@
22

33
Large Language Models (LLMs) have revolutionized the way we interact with text. These models can be used to create summaries of news articles, research papers, technical documents, legal documents, multimedia documents, and other types of documents. Suppose you have a set of documents (PDFs, Notion pages, customer questions, multimedia files, etc.) and you want to summarize the content. In this example use case, we utilize LangChain to implement summarization strategies and facilitate LLM inference using Text Generation Inference.
44

5-
![Architecture](./assets/img/docsum_architecture.png)
6-
7-
## Deploy Document Summarization Service
8-
9-
The Document Summarization service can be effortlessly deployed on either Intel Gaudi2 or Intel Xeon Scalable Processors.
10-
Based on whether you want to use Docker or Kubernetes, follow the instructions below. Currently we support deploying Document Summarization services with docker compose.
11-
12-
### Required Models
13-
14-
Default model is "Intel/neural-chat-7b-v3-3". Change "LLM_MODEL_ID" environment variable in commands below if you want to use another model.
15-
16-
```bash
17-
export LLM_MODEL_ID="Intel/neural-chat-7b-v3-3"
18-
```
19-
20-
When using gated models, you also need to provide [HuggingFace token](https://huggingface.co/docs/hub/security-tokens) to "HUGGINGFACEHUB_API_TOKEN" environment variable.
21-
22-
### Setup Environment Variable
23-
24-
To set up environment variables for deploying Document Summarization services, follow these steps:
25-
26-
1. Set the required environment variables:
27-
28-
```bash
29-
# Example: host_ip="192.168.1.1"
30-
export host_ip="External_Public_IP"
31-
# Example: no_proxy="localhost, 127.0.0.1, 192.168.1.1"
32-
export no_proxy="Your_No_Proxy"
33-
export HUGGINGFACEHUB_API_TOKEN="Your_Huggingface_API_Token"
34-
```
35-
36-
2. If you are in a proxy environment, also set the proxy-related environment variables:
37-
38-
```bash
39-
export http_proxy="Your_HTTP_Proxy"
40-
export https_proxy="Your_HTTPs_Proxy"
41-
```
42-
43-
3. Set up other environment variables:
5+
## Table of contents
446

45-
```bash
46-
source GenAIExamples/DocSum/docker_compose/set_env.sh
47-
```
7+
1. [Architecture](#architecture)
8+
2. [Deployment Options](#deployment-options)
489

49-
### Deploy using Docker
10+
## Architecture
5011

51-
#### Deploy on Gaudi
12+
The architecture of the Document Summarization Application is illustrated below:
5213

53-
Follow the instructions provided in the [Gaudi Guide](./docker_compose/intel/hpu/gaudi/README.md) to build Docker images from source. Once the images are built, run the following command to start the services:
54-
55-
```bash
56-
cd GenAIExamples/DocSum/docker_compose/intel/hpu/gaudi/
57-
docker compose -f compose.yaml up -d
58-
```
59-
60-
Find the corresponding [compose.yaml](./docker_compose/intel/hpu/gaudi/compose.yaml).
61-
62-
> Notice: Currently only the **Habana Driver 1.16.x** is supported for Gaudi.
63-
64-
#### Deploy on Xeon
65-
66-
Follow the instructions provided in the [Xeon Guide](./docker_compose/intel/cpu/xeon/README.md) to build Docker images from source. Once the images are built, run the following command to start the services:
67-
68-
```bash
69-
cd GenAIExamples/DocSum/docker_compose/intel/cpu/xeon/
70-
docker compose -f compose.yaml up -d
71-
```
72-
73-
Find the corresponding [compose.yaml](./docker_compose/intel/cpu/xeon/compose.yaml).
74-
75-
### Deploy DocSum on Kubernetes using Helm Chart
76-
77-
Refer to the [DocSum helm chart](./kubernetes/helm/README.md) for instructions on deploying DocSum on Kubernetes.
78-
79-
### Workflow of the deployed Document Summarization Service
14+
![Architecture](./assets/img/docsum_architecture.png)
8015

8116
The DocSum example is implemented using the component-level microservices defined in [GenAIComps](https://github.com/opea-project/GenAIComps). The flow chart below shows the information flow between different microservices for this example.
8217

@@ -134,99 +69,12 @@ flowchart LR
13469
13570
```
13671

137-
## Consume Document Summarization Service
138-
139-
Two ways of consuming Document Summarization Service:
140-
141-
1. Use cURL command on terminal
142-
143-
Text:
144-
145-
```bash
146-
curl -X POST http://${host_ip}:8888/v1/docsum \
147-
-H "Content-Type: application/json" \
148-
-d '{"type": "text", "messages": "Text Embeddings Inference (TEI) is a toolkit for deploying and serving open source text embeddings and sequence classification models. TEI enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE and E5."}'
149-
150-
# Use English mode (default).
151-
curl http://${host_ip}:8888/v1/docsum \
152-
-H "Content-Type: multipart/form-data" \
153-
-F "type=text" \
154-
-F "messages=Text Embeddings Inference (TEI) is a toolkit for deploying and serving open source text embeddings and sequence classification models. TEI enables high-performance extraction for the most popular models, including FlagEmbedding, Ember, GTE and E5." \
155-
-F "max_tokens=32" \
156-
-F "language=en" \
157-
-F "stream=true"
158-
159-
# Use Chinese mode.
160-
curl http://${host_ip}:8888/v1/docsum \
161-
-H "Content-Type: multipart/form-data" \
162-
-F "type=text" \
163-
-F "messages=2024年9月26日,北京——今日,英特尔正式发布英特尔® 至强® 6性能核处理器(代号Granite Rapids),为AI、数据分析、科学计算等计算密集型业务提供卓越性能。" \
164-
-F "max_tokens=32" \
165-
-F "language=zh" \
166-
-F "stream=true"
167-
168-
# Upload file
169-
curl http://${host_ip}:8888/v1/docsum \
170-
-H "Content-Type: multipart/form-data" \
171-
-F "type=text" \
172-
-F "messages=" \
173-
-F "files=@/path to your file (.txt, .docx, .pdf)" \
174-
-F "max_tokens=32" \
175-
-F "language=en" \
176-
-F "stream=true"
177-
```
178-
179-
> Audio and Video file uploads are not supported in docsum with curl request, please use the Gradio-UI.
180-
181-
Audio:
182-
183-
```bash
184-
curl -X POST http://${host_ip}:8888/v1/docsum \
185-
-H "Content-Type: application/json" \
186-
-d '{"type": "audio", "messages": "UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"}'
187-
188-
curl http://${host_ip}:8888/v1/docsum \
189-
-H "Content-Type: multipart/form-data" \
190-
-F "type=audio" \
191-
-F "messages=UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA" \
192-
-F "max_tokens=32" \
193-
-F "language=en" \
194-
-F "stream=true"
195-
```
196-
197-
Video:
198-
199-
```bash
200-
curl -X POST http://${host_ip}:8888/v1/docsum \
201-
-H "Content-Type: application/json" \
202-
-d '{"type": "video", "messages": "convert your video to base64 data type"}'
203-
204-
curl http://${host_ip}:8888/v1/docsum \
205-
-H "Content-Type: multipart/form-data" \
206-
-F "type=video" \
207-
-F "messages=convert your video to base64 data type" \
208-
-F "max_tokens=32" \
209-
-F "language=en" \
210-
-F "stream=true"
211-
```
212-
213-
2. Access via frontend
214-
215-
To access the frontend, open the following URL in your browser: http://{host_ip}:5173.
216-
217-
By default, the UI runs on port 5173 internally.
218-
219-
## Troubleshooting
220-
221-
1. If you get errors like "Access Denied", [validate micro service](https://github.com/opea-project/GenAIExamples/tree/main/DocSum/docker_compose/intel/cpu/xeon/README.md#validate-microservices) first. A simple example:
222-
223-
```bash
224-
curl http://${host_ip}:8008/generate \
225-
-X POST \
226-
-d '{"inputs":"What is Deep Learning?","parameters":{"max_tokens":17, "do_sample": true}}' \
227-
-H 'Content-Type: application/json'
228-
```
229-
230-
2. (Docker only) If all microservices work well, check the port ${host_ip}:8888, the port may be allocated by other users, you can modify the `compose.yaml`.
231-
232-
3. (Docker only) If you get errors like "The container name is in use", change container name in `compose.yaml`.
72+
## Deployment Options
73+
74+
The table below lists currently available deployment options. They outline in detail the implementation of this example on selected hardware.
75+
76+
| Category | Deployment Option | Description |
77+
| ---------------------- | ---------------------- | -------------------------------------------------------------- |
78+
| On-premise Deployments | Docker Compose (Xeon) | [DocSum deployment on Xeon](./docker_compose/intel/cpu/xeon) |
79+
| | Docker Compose (Gaudi) | [DocSum deployment on Gaudi](./docker_compose/intel/hpu/gaudi) |
80+
| | Docker Compose (ROCm) | [DocSum deployment on AMD ROCm](./docker_compose/amd/gpu/rocm) |

DocSum/README_miscellaneous.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Table of Contents
2+
3+
1. [Build MegaService Docker Image](#build-megaservice-docker-image)
4+
2. [Build UI Docker Image](#build-ui-docker-image)
5+
3. [Generate a HuggingFace Access Token](#generate-a-huggingface-access-token)
6+
4. [Troubleshooting](#troubleshooting)
7+
8+
## Build MegaService Docker Image
9+
10+
To construct the Megaservice of DocSum, the [GenAIExamples](https://github.com/opea-project/GenAIExamples.git) repository is utilized. Build MegaService Docker image via command below:
11+
12+
```bash
13+
git clone https://github.com/opea-project/GenAIExamples.git
14+
cd GenAIExamples/DocSum
15+
docker build --no-cache -t opea/docsum:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f Dockerfile .
16+
```
17+
18+
## Build UI Docker Image
19+
20+
Build frontend Docker image via below command:
21+
22+
```bash
23+
cd GenAIExamples/DocSum/ui
24+
docker build -t opea/docsum-ui:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f ./docker/Dockerfile .
25+
```
26+
27+
## Generate a HuggingFace Access Token
28+
29+
Some HuggingFace resources, such as certain models, are only accessible if the developer has an access token. If you don't have a HuggingFace access token, you can create one by registering at [HuggingFace](https://huggingface.co/) and following [these steps](https://huggingface.co/docs/transformers.js/en/guides/private#step-1-generating-a-user-access-token).
30+
31+
## Troubleshooting
32+
33+
1. If you get errors like "Access Denied", [validate micro service](https://github.com/opea-project/GenAIExamples/tree/main/DocSum/docker_compose/intel/cpu/xeon/README.md#validate-microservices) first. A simple example:
34+
35+
```bash
36+
http_proxy=""
37+
curl http://${host_ip}:8008/generate \
38+
-X POST \
39+
-d '{"inputs":" ### System: Please translate the following Golang codes into Python codes. ### Original codes: '\'''\'''\''Golang \npackage main\n\nimport \"fmt\"\nfunc main() {\n fmt.Println(\"Hello, World!\");\n '\'''\'''\'' ### Translated codes:","parameters":{"max_tokens":17, "do_sample": true}}' \
40+
-H 'Content-Type: application/json'
41+
```
42+
43+
2. (Docker only) If all microservices work well, check the port ${host_ip}:7777, the port may be allocated by other users, you can modify the `compose.yaml`.
44+
3. (Docker only) If you get errors like "The container name is in use", change container name in `compose.yaml`.

0 commit comments

Comments
 (0)