Skip to content

load_projector API

CLI and Python helpers in load_projector.py and modeling_projector.py.

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

python load_projector.py <projector_id> [--repo-id REPO_ID] [--revision REVISION] [--local-dir PATH]
Argument / optionDefaultDescription
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-idinternlm/Sage-SciPerceptionHugging Face repository ID.
--revisionmainBranch, tag, or commit revision to resolve from.
--local-dirNoneOptional 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

download_projector(
    projector_id,
    repo_id="internlm/Sage-SciPerception",
    revision="main",
    local_dir=None,
    cache_dir=None,
) -> Path

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

load_projector(directory, device="cpu") -> tuple[nn.Module, dict]

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).

from load_projector import download_projector, load_projector

component_dir = download_projector("glm-5.3-flash/cif/jarvis", local_dir="./checkpoints")
projector, config = load_projector(component_dir, device="cpu")

Module helpers (modeling_projector.py)

HelperDescription
build(spec, output_dim, *, train_core=False, train_side_only=False) -> nn.ModuleInstantiates 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.