load_projector API
load_projector.py and modeling_projector.py live at the root of the repository and provide both a CLI downloader and Python loading helpers.
CLI downloader
| Argument / option | Default | Description |
|---|---|---|
projector_id | — (required) | Component ID in backbone/modality/task form from the root HF config.json (e.g., glm-5.3-flash/cif/jarvis). |
--repo-id | internlm/Sage-SciPerception | Hugging Face repository ID. |
--revision | main | Branch, tag, or commit revision to resolve from. |
--local-dir | None | Optional target directory where the root config.json and component files are materialized. |
The command prints the resolved local component directory path to stdout.
Python functions (load_projector.py)
download_projector
Downloads the root config.json at revision, looks up index["projectors"][projector_id], and pins the subsequent config.json and weights downloads to the exact resolved snapshot (index_path.parent.name). When local_dir is provided, the root config.json is also written under local_dir. Returns the component directory Path.
load_projector
Reads config.json from directory, instantiates the module with modeling_projector.build(config["projector"], config["output_dim"]), loads config["weights"] via safetensors.torch.load_file(..., device="cpu") with strict=True, moves the module to device, sets .requires_grad_(False).eval(), and returns (model, config).
Module helpers (modeling_projector.py)
| Helper | Description |
|---|---|
build(spec, output_dim, *, train_core=False, train_side_only=False) -> nn.Module | Instantiates AtomProjector, AtomSetProjector, or LeadProjector from config["projector"] and attaches optional heads (task_head, readout, side, graph, context). |
load_initial(model, state) | Loads an initial non-auxiliary core state dict into an AtomProjector, verifying that any optional prefix (graph., task_head., side., context., readout.) is either completely present or completely absent. |