Lingua Server — Docker Compose Deployment#
Reference docker compose recipe for the Lingua FastAPI server.
The PyTorch service uses XPU by default. Select the backend by starting
the corresponding service; use LINGUA_DEVICE to choose the hardware.
The deployment uses two backend-specific Dockerfiles:
Dockerfile.pytorchfor PyTorch / IPEX / XPUDockerfile.ovfor OpenVINO
These are alternative backends. Start only the server that matches your requirements; you do not need to run both services.
The compose file defines two services:
lingua-pytorchon host port8001lingua-ovon host port8002(start explicitly; override withLINGUA_OV_PORT)
The server uses the llmlingua2 (LLMLingua-2) compression mode.
Each image carries only the standalone server file and its runtime deps.
The PyTorch image installs torch + IPEX + llmlingua + fastapi + uvicorn.
The OpenVINO image installs CPU torch + OpenVINO + optimum[openvino].
Neither image installs the adaptive-token-compressor library — clients reach
the running container over HTTP via LinguaHTTPBackend(lingua_url=...).
Quick start#
cd deployment/lingua
docker compose up -d --build lingua-pytorch
Default: --device xpu, --port 8001. The library client default
(LinguaHTTPBackend(lingua_url="http://localhost:8001/compress"))
matches out of the box — no config change required.
To start the OpenVINO service:
docker compose up -d --build lingua-ov
Current backend/mode support status:
PyTorch +
llmlingua2: supportedOpenVINO +
llmlingua2: supported
Startup mode: llmlingua2.
Override variables (no .env file needed)#
All variables have :-default fallbacks in docker-compose.yaml. Pass
inline on the command line:
# CPU fallback
LINGUA_DEVICE=cpu docker compose up -d --build lingua-pytorch
# OpenVINO backend on XPU (maps to OV GPU)
LINGUA_DEVICE=xpu docker compose up -d --build lingua-ov
# Select XPU index (PyTorch xpu:<index>; OpenVINO prefers GPU.<index>)
LINGUA_DEVICE=xpu LINGUA_XPU_INDEX=1 docker compose up -d --build lingua-pytorch
# Different port
LINGUA_PORT=9000 docker compose up -d --build lingua-pytorch
# Pin model independently
LINGUA_MODEL_NAME_ID=microsoft/llmlingua-2-bert-base-multilingual-cased-meetingbank \
docker compose up -d --build lingua-pytorch
# Combine
LINGUA_DEVICE=cpu LINGUA_PORT=9000 docker compose up -d --build lingua-pytorch
Variable |
Default |
Notes |
|---|---|---|
|
|
Host bind address for the published port. Setting it to |
|
|
Container always listens on |
|
|
Host port for the |
|
|
|
|
|
XPU index when |
|
(empty) |
HF model ID. If empty, defaults to |
|
|
First-run downloads allowed. Set |
|
|
Mainland China mirror; unset/override for upstream HF. |
|
(unset) |
Build-time + runtime proxies. |
|
|
GPU passthrough; detect on host with |
Verify#
curl http://localhost:8001/health
# → {
# "status":"ok",
# "mode":"llmlingua2",
# "supports_request_mode_override":true,
# "supported_modes":["llmlingua2"],
# "initialized_modes":{
# "llmlingua2":{
# "model_name_id":"...",
# "device":"xpu:0",
# "execution_devices":"n/a"
# }
# }
# }
curl -X POST http://localhost:8001/compress \
-H 'Content-Type: application/json' \
-d '{"text":"...","rate":0.5}'
# → {"compressed_prompt":"...","compression_time_ms":12.3,...}
For OV backend, the startup logs include explicit device mapping and resolved runtime info, e.g.:
Backend=ov Requested device=xpuOpenVINO requested device=xpu mapped device=GPU.0(orGPUfallback for index0)OV[GPU.0] name: Intel(R) ...(device name may vary by runtime)OpenVINO execution devices: ['GPU']/GPU.0(runtime-specific)Model runtime device: ov:GPU.0(orov:GPU)
Test that the digit_neighbor_radius patch is active:
curl -X POST http://localhost:8001/compress \
-H 'Content-Type: application/json' \
-d '{"text":"price is 99.5 USD nearby","rate":0.3,"force_reserve_digit":true,"digit_neighbor_radius":3}'
# → compressed_prompt should retain "99.5" and surrounding words
Stop & cleanup#
docker compose --profile pytorch down # stop / remove the PyTorch service/container
docker compose --profile ov down # stop / remove the OpenVINO service/container
docker compose --profile pytorch --profile ov down -v # remove both services and the HF model cache volume
See also#
Bare-metal install (without docker):
src/adaptive_token_compressor/model_servers/lingua/README.mdusespip install adaptive-token-compressor[lingua-server-xpu|-cpu|-ov]+python -m adaptive_token_compressor.model_servers.lingua.apply_patch+python -m adaptive_token_compressor.model_servers.linguaCompanion vLLM tool predictor: tool-predictor-deployment.md