Skip to main content

One vLLM plugin for transparent RAIF token savings — install it and existing OpenAI clients get RAIF on tools & response_format with no proxy and no client changes.

Project description

raif-vllm

One vLLM plugin for transparent RAIF token savings. Install it and existing OpenAI clients get RAIF on tools and response_formatno proxy, no client changes, no vLLM fork. The fine-tuned model emits compact RAIF-G; the plugin decodes it to JSON at the request/response boundary.

Install

raif-vllm is not yet on PyPI; install it from the repo (it pulls raif-format >=0.6 from PyPI automatically):

pip install "raif-vllm @ git+https://github.com/skrrt-sh/raif-vllm.git"
# or, from a checkout:  pip install -e .

vLLM itself is provided by the serving host (it pins CUDA/torch); target vllm>=0.19,<0.20 — v0.19 is the last CUDA-12 vLLM and carries the hooks the plugin needs. pip install "raif-vllm[vllm]" pulls a compatible engine for local experiments.

Serve

VLLM_PLUGINS=raif vllm serve unsloth/Llama-3.2-3B-Instruct \
  --enable-lora --lora-modules raif=skrrt-sh/raif-llama-3.2-3b-lora \
  --max-lora-rank 32 --max-model-len 8192 \
  --chat-template raif_llama32.jinja \
  --reasoning-parser raif \
  --enable-auto-tool-choice --tool-call-parser raif
  • VLLM_PLUGINS=raif runs the entry point, which registers the raif reasoning + tool parsers and installs the render_chat inject hook (the seam that adds the compact <schema> cue before chat-templating).
  • --tool-call-parser raif decodes the tools path into tool_calls; --reasoning-parser raif decodes the response_format path into message.content.
  • --chat-template raif_llama32.jinja (in chat_templates/) is load-bearing: it renders messages only and ignores the tools variable, so the served prompt matches training. Without it the LoRA echoes the verbose OpenAI tool-def JSON.

What a plain OpenAI client gets

from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")

# tools -> JSON tool_calls
client.chat.completions.create(model="raif", tools=[...], tool_choice="auto",
    messages=[{"role": "user", "content": "Weather in Oslo?"}])

# response_format -> JSON content (use non-streaming — see below)
client.chat.completions.create(model="raif",
    response_format={"type": "json_schema", "json_schema": {...}},
    messages=[{"role": "user", "content": "..."}])
OpenAI path Behavior
plain chat passthrough, untouched
tools RAIF-G → JSON tool_calls (streaming + non-streaming)
response_format (json_schema / json_object) RAIF-G → JSON message.content
plain chat streaming passthrough

Known limitation: streaming response_format

Streaming a response_format request is not decoded — the client receives raw RAIF-G. (vLLM's streaming seam passes the parser no schema, and the shared is_reasoning_end flag must stay True so the tools streaming path keeps working.) Use non-streaming response_format for structured output — it decodes fully. Tool-call streaming is unaffected. See docs/vllm_e2e_results.md.

More

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

raif_vllm-0.1.0.tar.gz (37.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

raif_vllm-0.1.0-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file raif_vllm-0.1.0.tar.gz.

File metadata

  • Download URL: raif_vllm-0.1.0.tar.gz
  • Upload date:
  • Size: 37.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for raif_vllm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ad7842a3f45ef8ecff584a46ee49364ac453fea20ffbea54e1cf52385779e2d7
MD5 e6923d7c3f12f0e71354ab6606e10225
BLAKE2b-256 9b0870eaf45c818696d66dfc73df237d850387334c647180f4454eae241964eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for raif_vllm-0.1.0.tar.gz:

Publisher: release.yml on skrrt-sh/raif-vllm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file raif_vllm-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: raif_vllm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for raif_vllm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3872ebc4c7db86974b845811ec943b5d4665a6353a1f30d3f4d3b7e467e0bd2
MD5 b79a4fccc87dd8544161a7349c7175a0
BLAKE2b-256 5334e908a402a9ff5a2b43591bb2d57e58e1f98e5713a80957f7fbf7d6caf99c

See more details on using hashes here.

Provenance

The following attestation bundles were made for raif_vllm-0.1.0-py3-none-any.whl:

Publisher: release.yml on skrrt-sh/raif-vllm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page