|
2 | 2 |
|
3 | 3 | 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. |
4 | 4 |
|
5 | | - |
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 |
44 | 6 |
|
45 | | - ```bash |
46 | | - source GenAIExamples/DocSum/docker_compose/set_env.sh |
47 | | - ``` |
| 7 | +1. [Architecture](#architecture) |
| 8 | +2. [Deployment Options](#deployment-options) |
48 | 9 |
|
49 | | -### Deploy using Docker |
| 10 | +## Architecture |
50 | 11 |
|
51 | | -#### Deploy on Gaudi |
| 12 | +The architecture of the Document Summarization Application is illustrated below: |
52 | 13 |
|
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 | + |
80 | 15 |
|
81 | 16 | 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. |
82 | 17 |
|
@@ -134,99 +69,12 @@ flowchart LR |
134 | 69 |
|
135 | 70 | ``` |
136 | 71 |
|
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) | |
0 commit comments