Compress Server Deployment#

The Compress Server is the FastAPI service that serves model-based text compression to HarnessCompressor and ContextCompressor. Two deployment options are available:

Bare-Metal Installation#

Alternative to the recommended Docker Compose deployment above, for hosts where Docker is not available. Runs the same server without Docker, from the adaptive-token-compressor package. Pick one extra per virtualenv, matching the runtime you launch with (--runtime pytorch|ov). The package is installed from source, so run the pip install commands below from the repository root.

Install (PyTorch runtime — XPU)#

pip install --extra-index-url https://download.pytorch.org/whl/xpu \
            --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/ \
            ".[compress-server-pytorch-xpu]"

Install (PyTorch runtime — CPU)#

For CPU-only hosts, use the lighter compress-server-pytorch-cpu extra (no IPEX / XPU wheels):

pip install --index-url https://download.pytorch.org/whl/cpu \
            --extra-index-url https://pypi.org/simple \
            ".[compress-server-pytorch-cpu]"

Install (OpenVINO runtime — CPU or GPU)#

pip install --index-url https://download.pytorch.org/whl/cpu \
            --extra-index-url https://pypi.org/simple \
            ".[compress-server-ov]"

Apply the neighbor-protection patch (one-time, required)#

The neighbor-protection patch modifies LLMLingua-2’s source to enable the digit_neighbor_radius request field. After installing an extra, run once:

python -m adaptive_token_compressor.model_servers.compress_server.apply_patch

Diagnostic / CI check (no apply):

python -m adaptive_token_compressor.model_servers.compress_server.apply_patch --check
echo $?    # 0 = patched, 1 = not patched

Run#

python -m adaptive_token_compressor.model_servers.compress_server    # default --runtime pytorch --device xpu --port 8001
python -m adaptive_token_compressor.model_servers.compress_server --runtime pytorch --device cpu
python -m adaptive_token_compressor.model_servers.compress_server --runtime ov            # ov default device: gpu
python -m adaptive_token_compressor.model_servers.compress_server --runtime ov --device cpu
python -m adaptive_token_compressor.model_servers.compress_server --model_name_id microsoft/llmlingua-2-xlm-roberta-large-meetingbank

The server binds localhost by default (--host). Every flag also reads the COMPRESS_SERVER_* variable of the same name (e.g., COMPRESS_SERVER_DEVICE, COMPRESS_SERVER_PORT, COMPRESS_SERVER_MODEL_NAME_ID); the /health and /compress checks in the Verify section above apply unchanged.

Models are downloaded from the HuggingFace Hub on first use; the endpoint defaults to the https://hf-mirror.com mirror — pass --hf_endpoint or set HF_ENDPOINT=https://huggingface.co for upstream.

Compatible client#

from adaptive_token_compressor.core.backends import TokenPruneBackend

backend = TokenPruneBackend(compress_server_url="http://localhost:8001/compress", timeout=60.0)
result = backend.compress(
    text="...",
    rate=0.6,
    force_reserve_digit=True,
    digit_neighbor_radius=3,
)

See also#