Class HfCheckpoint
java.lang.Object
ai.beestream.jitnn.nn.models.HfCheckpoint
A Hugging Face model directory:
config.json and the weights in model.safetensors
or in shards listed by model.safetensors.index.json. Weights are looked up with or
without the architecture prefix (bert., transformer., model.), and old
LayerNorm names (gamma, beta) are accepted for weight and bias.
The model classes use it in their fromHuggingFace factories; it also serves custom models.-
Method Summary
Modifier and TypeMethodDescriptionMap<?, ?> config()The parsedconfig.json.floatconfigFloat(String key, float otherwise) Config valuekeyas a float, orotherwisewhen absent.intThe first ofkeyspresent in the config, as an int; throws when none is.configString(String key, String otherwise) Config valuekeyas a string, orotherwisewhen absent or null.The directory the checkpoint was read from.float[]Weightnameas FP32 values, checking its shape.booleanTrue when the checkpoint holds weightname(under any accepted spelling).voidCopies weightnameinto parametertargetof the same shape.voidloadConcatenated(Tensor target, String... names) Copies the concatenation, along the first axis, ofnamesintotarget.voidloadTransposed(Tensor target, String name) Copies the transpose of 2-D weightnameintotarget(GPT-2's Conv1D layers store [in, out]).static HfCheckpointOpens a model directory.unused()Weights of the checkpoint that noloadcall read, e.g. a head the model does not have.
-
Method Details
-
open
Opens a model directory.- Throws:
IOException
-
directory
The directory the checkpoint was read from. -
config
The parsedconfig.json. -
configInt
The first ofkeyspresent in the config, as an int; throws when none is. -
configFloat
Config valuekeyas a float, orotherwisewhen absent. -
configString
-
has
True when the checkpoint holds weightname(under any accepted spelling). -
floats
Weightnameas FP32 values, checking its shape. -
load
-
loadTransposed
-
loadConcatenated
-
unused
-