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 and other types of text. Suppose you have a set of documents (PDFs, Notion pages, customer questions, 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.
The architecture for document summarization will be illustrated/described below:
The Document Summarization service can be effortlessly deployed on either Intel Gaudi2 or Intel Xeon Scalable Processors. Based on whether you want to use Docker or Kubernetes, follow the instructions below.
Currently we support two ways of deploying Document Summarization services with docker compose:
-
Start services using the docker image on
docker hub
:docker pull opea/docsum:latest
-
Start services using the docker images
built from source
: Guide
We set default model as "Intel/neural-chat-7b-v3-3", change "LLM_MODEL_ID" in "docker_compose/set_env.sh" if you want to use other models.
export LLM_MODEL_ID="Intel/neural-chat-7b-v3-3"
If use gated models, you also need to provide huggingface token to "HUGGINGFACEHUB_API_TOKEN" environment variable.
To set up environment variables for deploying Document Summarization services, follow these steps:
-
Set the required environment variables:
# Example: host_ip="192.168.1.1" export host_ip="External_Public_IP" # Example: no_proxy="localhost, 127.0.0.1, 192.168.1.1" export no_proxy="Your_No_Proxy" export HUGGINGFACEHUB_API_TOKEN="Your_Huggingface_API_Token"
-
If you are in a proxy environment, also set the proxy-related environment variables:
export http_proxy="Your_HTTP_Proxy" export https_proxy="Your_HTTPs_Proxy"
-
Set up other environment variables:
source ./docker_compose/set_env.sh
Find the corresponding compose.yaml.
cd GenAIExamples/DocSum/docker_compose/intel/hpu/gaudi/
docker compose -f compose.yaml up -d
Notice: Currently only the Habana Driver 1.16.x is supported for Gaudi.
Refer to the Gaudi Guide to build docker images from source.
Find the corresponding compose.yaml.
cd GenAIExamples/DocSum/docker_compose/intel/cpu/xeon/
docker compose up -d
Refer to the Xeon Guide for more instructions on building docker images from source.
Refer to Kubernetes deployment
Refer to Kubernetes deployment
Install Helm (version >= 3.15) first. Refer to the Helm Installation Guide for more information.
Refer to the DocSum helm chart for instructions on deploying DocSum into Kubernetes on Xeon & Gaudi.
The workflow of the Document Summarization Service, from user's input query to the application's output response, is as follows:
flowchart LR
subgraph DocSum
direction LR
A[User] <--> |Input query| B[DocSum Gateway]
B <--> |Post| Megaservice
subgraph Megaservice["Megaservice"]
direction TB
C([ Microservice : llm-docsum-tgi <br>9000]) -. Post .-> D{{TGI Service<br>8008}}
end
Megaservice --> |Output| E[Response]
end
subgraph Legend
X([Micsrservice])
Y{{Service from industry peers}}
Z[Gateway]
end
Two ways of consuming Document Summarization Service:
-
Use cURL command on terminal
curl http://${host_ip}:8888/v1/docsum \ -H "Content-Type: application/json" \ -d '{"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."}'
-
Access via frontend
To access the frontend, open the following URL in your browser: http://{host_ip}:5173.
By default, the UI runs on port 5173 internally.
-
If you get errors like "Access Denied", validate micro service first. A simple example:
http_proxy="" curl http://${your_ip}:8008/generate \ -X POST \ -d '{"inputs":"What is Deep Learning?","parameters":{"max_new_tokens":17, "do_sample": true}}' \ -H 'Content-Type: application/json'
-
(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
. -
(Docker only) If you get errors like "The container name is in use", change container name in
compose.yaml
.