This is the multi-page printable view of this section.
Guides
- Inference with vLLM — Send projected scientific vectors to a language-model service.
- Training a projector — Train one projector with XTuner while the encoder and the language model stay frozen.
- Evaluation — Score saved predictions on CPU with EvalKit.
1 - Inference with vLLM
The serving path inserts projected scientific vectors into a language model’s full templated prompt embeddings and sends them to vLLM through prompt_embeds at /v1/completions. Scientific features and projection are prepared in the client; the language-model service generates the answer.
Start the language-model service
Install vLLM in a compatible inference environment. Run it on suitable GPUs and set tensor parallelism for that model and hardware. This command shows an eight-way deployment example:
Serve the language-model snapshot named in the selected checkpoint’s config.json. A different snapshot changes the embedding table the client reads from.
Generate from prepared crystal features
The crystal client renders the checkpoint’s native chat template, looks up text embeddings, inserts scientific vectors, and sends the completed prompt embeddings to the server.
Prepare cif_features.pt as a tensor of shape [num_atoms, 64], containing the real CHGNet 0.3.0 atom states specified in cif/jarvis, in atom order. Once the server is ready, run:
The local language-model directory supplies the tokenizer, configuration, and sharded input embedding table used by the server. The client reads the needed text embedding rows without loading the full language model.
Other tasks
Scientific feature extraction and task-adapted scientific models are separate dependencies; some adapted scientific weights are not yet included in the release. Match each task’s scientific_inputs before preparing predictions. The crystal example starts from prepared features, while other tasks require their corresponding input preparation and prompt assembly.
For a second worked path, including feature extraction from raw signals, see the NEU06 example.
References
2 - Training a projector
TrainKit trains a scientific projector with XTuner. XTuner owns the trainer, FSDP, packing, the scheduler, the losses and the optimizer; TrainKit adds the projector, the prompt and supervision mask, payload injection into the packed sequence, and an export that the inference example and EvalKit read unchanged.
TrainKit covers all nine published atom projector modalities through scip-train preflight (neu06-preflight remains available as a backward-compatible alias) and recipes/projector_sft.py, which support optional discrete, side, readout, task_head, output_scale and depth components as well as multi-object and atom_numbering prompts. recipes/neu06_projector.py remains available for strict NEU06 validation.
The worked example below is SciTS NEU06 sleep staging, the first published recipe. Training samples are published at internlm/Sage-SciPerception-Training.
Training reads a prepared sage-training-data-v1 export — a manifest, the rows of a split, and the frozen encoder states a row’s array_index names. Data preparation, signal processing and feature encoding are not part of the repository.
Training data
Training splits are curated from each task’s public scientific dataset and kept strictly disjoint from EvalKit’s held-out evaluation sets by subject, protein target, crystal geometry or composition, or year. Rather than feeding raw signals or biological sequences into training, each export stores frozen scientific encoder outputs or spectral representations paired with multi-turn instruction rows; language supervision loss is applied only to assistant response tokens while projected scientific payload positions are masked out.
Runnable two-row exports for all nine verified modalities are published at internlm/Sage-SciPerception-Training using the sage-training-data-v1 layout:
| Modality / task | Sample path & HF config | Upstream dataset | Representation (nodes.npy / extra) |
|---|---|---|---|
DNA (dna/splice) | samples/dna/splice (splice) | MAGICS-LAB DNABERT-2 GUE (splice/reconstructed) | [2, 3] DNABERT-2 splice readout |
RNA (rna/ncrna) | samples/rna/ncrna (ncrna) | BEACON (NoncodingRNAFamily) | [238, 640] RNA-FM states + side.npy ([2, 13]) |
EEG (eeg/neu06) | samples/eeg/neu06 (neu06) | PhysioNet Sleep-EDF (sleep-cassette) | [68, 512] REVE-Base patch states |
Crystal (cif/jarvis) | samples/cif/jarvis (jarvis) | JARVIS-DFT (jdft-3d-20221212) | [22, 64] CHGNet 0.3.0 atom states |
ECG (ecg/phu01) | samples/ecg/phu01 (phu01) | PTB-XL (1.0.3) | [720, 768] ST-MEM patch states |
Spectra (spectra/qm9s) | samples/spectra/qm9s (qm9s) | QM9S (DiffSpectra) | [694, 50] IR/Raman/UV patches + modality.npy |
Protein Struct (protein-struct/psr) | samples/protein-struct/psr (psr) | ATOM3D PSR (PSR-split-by-year) | [451, 384] ProteinMPNN v48-020 states |
Protein Seq (protein-seq/mpbind) | samples/protein-seq/mpbind (mpbind) | MPBind BA1 | [136, 1280] ESM-2 states + side.npy ([136, 2]) |
XRD (xrd/simxrd) | samples/xrd/simxrd (simxrd) | SimXRD-4M (OLtrain/OLval) | [220, 512] SimXRD residual CNN states |
Each two-row slice preserves real array_index and remapped offsets so you can run scip-train preflight end to end before preparing or requesting a full split (see Full training data or open an issue).
Install
Python 3.12. XTuner is pinned to a commit and loaded from a source checkout, so the recipe does not depend on which XTuner is installed:
Install XTuner’s own training dependencies at the same commit, following its installation guide. The recipe trains a frozen MoE base with tilewise FP8, so that guide’s Install GroupedGEMM and Install AdaptiveGEMM steps both apply, as does its flash-attn recommendation. Then add this repository’s packages:
CPU-only tests need neither XTuner nor GPUs:
Inputs
The default run reads no projector weights: only the component’s config.json, for the architecture, the output width and the prompt layout.
Replace $DATA with your own export to train on your own data.
Preflight
The preflight takes the recipe’s own DataloaderConfig and asks XTuner for the dataset, the sampler and the collator, so its numbers describe the configuration the run will use. It needs no GPUs:
sizing reports the pack count, the steps per epoch, the total steps, the warmup steps and the dropped tail packs; the full report is written to $RUN/preflight/preflight.json. scip-train neu06-preflight is kept as an alias of scip-train preflight and takes the same arguments.
global_batch_size must be divisible by the data-parallel size, which is world_size / sp_size — sixteen GPUs at SP8 give DP2, so the global batch must be even and 2 is its minimum. pack_max_length must be divisible by sp_size. round_up=False drops the tail pack instead of padding, so each epoch consumes packs // global_batch_size packs: a split that packs into fewer packs than the global batch reaches zero steps.
Packing works on chunks of rows independently. The sample sets --pack-chunk-size 1 so its two rows form two packs and fill one global batch. The full recipe uses a chunk size of 100000.
Train
The full recipe was run on two eight-GPU nodes. The public sample was checked with XTuner’s CPU preflight. Run the command once per node, with the same input paths and the preflight report available at $RUN on both nodes.
recipes/projector_sft.py is the general recipe and serves every published modality; use recipes/neu06_projector.py instead when you want the strict NEU06 checks.
For the full data, set these values in your training shell, then rerun the preflight and train commands above:
The recipe is scaled from a GLM multimodal SFT setup: SP8/EP8 with the deepep dispatcher, tilewise FP8 GEMM, torch.compile, the NoPE-MLA backends, chunked main CE (1024, token reduction), seven shared MTP depths at 0.1, Muon (lr 8e-6, weight_decay 0.1, swap_optimizer), constant LR after a 10% warmup, one epoch. The pack length and global batch come from the preflight. SCIP_LR is the only intended sweep knob and is written into every export.
Export and warm start
Each saved step writes projector.safetensors and a config.json whose training block records the learning rate, the sizing, the initialization and its seed, the manifest revision, the dataset.json and features.json the run read, and the encoder versions those files carry. Score an export with the evaluation guide.
To continue from a published projector instead of a fresh initialization, download its weights next to the config.json above and name the mode:
SCIP_PROJECTOR_SHA256 is optional and is checked against the file about to be loaded; the value above is the one the component lists on Hugging Face.
3 - Evaluation
EvalKit maintains versioned evaluation protocols, scoring, and the prediction generation loop. Scoring runs on CPU and needs neither torch, transformers, nor network access — only Python 3.12 and uv.
EvalKit registers all nine published task protocols, with SciTS NEU06 as the worked end-to-end example below.
Registered datasets
| Dataset ID | Task | Protocol | Optional runtime extras |
|---|---|---|---|
scits-neu06 | SciTS NEU06 | scits-neu06-v1 | none (stdlib) |
scits-phu01 | SciTS PHU01 | scits-classification-text-3dp-ecg100hz-v1 | none (stdlib) |
llm4mat-jarvis | JARVIS-DFT | llm4mat-jarvis-formation-energy-cif-v1 | none (stdlib) |
qm9s-allspectra | QM9S | diffspectra-compute-metrics-v1 | rdkit, myopic-mces, pulp (for molecular scoring) |
atom3d-psr | ATOM3D PSR | atom3d-psr-year-backbone-text-gdt-ts-v2 | scipy (lmdb only for raw LMDB input extraction) |
gue-splice | GUE splice | gue-splice-reconstructed-mcc-v1 | none (stdlib) |
beacon-ncrna | BEACON ncRNA | beacon-rna-bioinstructions-v1 | none (stdlib) |
mpbind-ba1 | MPBind | mpbind-ppi-reconstructed-ba1-sequence-sites-v1 | none (stdlib) |
simxrd-ol | SimXRD OL | simxrd-ol-crystal7-text-maxbin0.1deg-v1 | none (stdlib) |
Score saved predictions
Run from the repository root:
--dataset is accepted as an alias for --task, and --workers sets worker processes for datasets with parallel metrics such as qm9s-allspectra. The command prints a summary and writes summary.json and per-item scores.jsonl to --out-dir. The library entry point is evalkit.score.score_files(task, references, responses, *, only_responded=False, workers=1).
By default every frozen ID is scored, and an ID with no prediction counts as an empty answer. --only-responded scores only the IDs that have a prediction record, and marks the result as a subset.
Prediction file format
- Each JSONL line is one attempt, with
eval_id,content, and optionallystatus(ok,truncated,api_error). Other fields are ignored. For a repeatedeval_id, the last line wins. generation.runwrites arun_idinto every line and a<filename>.run.jsonnext to it, recording the run identity: task, ordered inputs, model, service address and model name, decoding parameters. A run with the same identity can resume and skip the IDs already written; a different identity writing to the same file is refused.- Only one generation process may use a path at a time, enforced by
<filename>.lock. A stale lock left by an abnormal exit must be removed by hand. - Older files without a
run_idstill score normally, but cannot be appended to; write the remaining items to a new file.
The scits-neu06-v1 protocol
| Item | Definition |
|---|---|
| Test set | The 1,024 rows of SciTS meta_data.jsonl whose task_id contains NEU06, with eval_id = "NEU06:" + id. Row count and the SHA-256 of [eval_id, label] are checked on load |
| Classes | Wake, N1, N2, N3, REM, with support 324, 101, 365, 94, 140 |
| Answer parsing | Take the body after the last </think>; if <answer>…</answer> is present, take the last one; strip the outer code fence. A line equal to a class name predicts that class |
| Validity | Valid when there is at least one line and every line is a class name. Validity is reported separately and does not clear the prediction: N2 plus a line unsure is invalid but still predicts N2 |
| Missing and status | A missing ID scores as an empty answer; status is reported only and does not affect parsing |
| Macro-F1 | The mean F1 over the reference classes present in the scored rows; TP/FP/FN count label-set membership |
| Accuracy | The predicted label set equals the reference set |
Parsing and scoring follow the rules used for the Sage-SciPerception v0.1.0 published scores.
Reproduce from raw EEG
The NEU06 example covers the full path: REVE-base feature extraction, generation against a vLLM server, and scoring. It lists every input with its source, revision, and license, and reports both the released run and a rerun:
| Run | Macro-F1 (%) | Accuracy (%) |
|---|---|---|
| Released (v0.1.0) | 72.01 | 76.46 |
| Rerun | 71.82 | 76.46 |
Both runs cover all 1,024 items. They are separate runs, and per-item predictions of the released run are not available.
Add a dataset or a model
| Module | Responsibility |
|---|---|
datasets/base.py | The small base class EvalDataset: name, protocol, load, metadata, score_items, score aligned by eval_id, and shared answer_span |
datasets/<suite>.py | One module (or package such as datasets/qm9s/) per upstream dataset or benchmark suite, holding references, questions, parsing and metrics; tasks within a suite register by task ID |
datasets/__init__.py | The DATASETS registry |
contract.py, score.py, cli.py | Prediction file reading, score dispatch, result writing, and scip-eval score |
generation.py | The generation loop: concurrency, OpenAI-compatible /completions requests recording http_status, run-bound appends and resume |
glm_prompt_embeds.py | The vLLM prompt_embeds adapters (GlmProjectorPrompt and reusable variable-length GlmProjectorSession) for GLM plus a projector payload across the nine atom projector modalities, with multi-object support, atom_numbering/payload_labels and optional discrete/side/counts passthrough; needs torch, transformers and safetensors at run time |
A new dataset or task: implement an EvalDataset subclass in a suite module, register it in datasets/__init__.py, and add fixtures under tests/. Dispatch and the CLI need no change.
A new model: a model called the same way needs only different weights, configuration and service name in the calling script. A different calling convention adds an adapter module that assembles the request and states the model identity, combined with generation.completion or your own transport into a generate(eval_id) passed to generation.run.