Model API¶
RelationalTransformer¶
- class relational_transformers.RelationalTransformer(model_name_or_path, *, task='classification', backend='torch', device=None, revision=None, compile=False, providers=None)¶
Load and run an RT-J checkpoint.
- Parameters:
model_name_or_path (str | Path) – Hugging Face repository, local checkpoint directory, or ONNX file.
task (str) –
"classification"(default) or"regression".backend (str) –
"torch","triton","onnx", or"meta".device (str | torch.device | None) – PyTorch device. Auto-selects CUDA, MPS, then CPU.
revision (str | None)
compile (bool)
- get_model_kwargs()¶
Return dimensions without materializing weights (especially useful on meta).
- Return type:
dict
RTJModel¶
- class relational_transformers.RTJModel(num_blocks=12, d_model=512, d_text=384, num_heads=8, d_ff=2048, legacy_attn=False, *, device=None)¶
The RT-J backbone and published decoder heads.
- Parameters:
num_blocks (int)
d_model (int)
d_text (int)
num_heads (int)
d_ff (int)
legacy_attn (bool)
- forward(batch, output='target_scores')¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Parameters:
batch (RelationalBatch)
output (str)
- Return type:
ModelOutput