# Serve projected inputs with vLLM

> Build an embedding prompt on the client and send it through the completions API.

---

LLMS index: [llms.txt](/Sage-SciPerception/llms.txt)

---

The inference client builds the entire prompt in the language model's embedding space. It renders the native GLM chat template, looks up text embedding rows, projects the scientific features, and replaces the designated payload spans. vLLM receives the result as `prompt_embeds` on `/v1/completions`.

## Serve the matching backbone {#serve}

Use the model snapshot declared by `base_model` in the selected checkpoint. The client needs that same snapshot locally for the tokenizer and input embedding table. The example uses eight-way tensor parallelism. Set it for the hardware serving the backbone.

```bash
vllm serve /path/to/matching-base-model \
  --served-model-name sage-sciperception \
  --tensor-parallel-size 8 \
  --enable-prompt-embeds \
  --no-enable-prefix-caching \
  --generation-config vllm \
  --host 127.0.0.1 --port 8000
```

## Send a crystal prompt {#crystal}

Prepare a tensor of shape `[num_atoms, 64]` with the CHGNet 0.3.0 states described in the [JARVIS task guide](/docs/tasks/cif-jarvis/). Preserve atom order. Use the checkpoint from the [CPU chapter](/book/02-quickstart-cpu/) and pass the feature file to [the crystal client](https://github.com/InternLM/Sage-SciPerception/blob/main/examples/vllm_cif.py).

```bash
python -m pip install transformers
python examples/vllm_cif.py \
  --component ./checkpoints/projectors/glm-5.3-flash/cif/jarvis \
  --base-model /path/to/matching-base-model \
  --features /path/to/cif_features.pt \
  --api-base http://127.0.0.1:8000/v1 \
  --model sage-sciperception
```

The client sends the matrix serialized with PyTorch and encoded as Base64. The default question asks for formation energy per atom in eV/atom. Use `--question` to pass another question.

## Build a session for variable-length inputs {#session}

[`evalkit.glm_prompt_embeds`](https://github.com/InternLM/Sage-SciPerception/blob/main/evalkit/src/evalkit/glm_prompt_embeds.py) provides two adapters. `GlmProjectorPrompt` takes a fixed question and payload layout at construction and reuses their text embeddings. `GlmProjectorSession` reuses the projector, tokenizer and embedding lookup while rendering the question and payload spans for each request.

For multiple objects, concatenate the feature rows in object order and pass their lengths as `payload_tokens`, for example `[3, 5]` for eight rows. If the checkpoint uses `atom_numbering`, the chat prompt renders numbered payload positions. To supply labels for those positions, pass `payload_labels` grouped per object. Follow the checkpoint configuration for `discrete` or `side` inputs. If the projector needs `counts`, the adapter uses the per-object lengths unless the caller supplies counts explicitly.

The [evaluation chapter](/book/04-end-to-end-eval/) shows how to save generation results and score them alongside frozen references.
