Model

Reflection-based parameter discovery, serialization, and deserialization for F# record models.

FunctionDescription
loadFromDict model tensors nameMap modeLoad tensors from a dictionary into the model, matching by parameter name.
When nameMap is Some, dictionary keys are translated before matching.
loadInto model filePath modeLoad tensors from a .safetensors file into the model in place.
Shape and dtype are validated from the header before any tensor data is read.
Only the tensors that match both shape and dtype are loaded into memory.
namedParams modelReturn all named tensors in the model via reflection.
save model filePathSave all model tensors to a .safetensors file.
trainableVars modelReturn all tensors that require gradients.

loadFromDict

loadFromDict model tensors nameMap mode

Load tensors from a dictionary into the model, matching by parameter name. When nameMap is Some, dictionary keys are translated before matching.

Parameters

  • model : 'T
  • tensors : Map<string, Tensor>
  • nameMap : Map<string, string> option
  • mode : LoadMode

Returns LoadReport


loadInto

loadInto model filePath mode

Load tensors from a .safetensors file into the model in place. Shape and dtype are validated from the header before any tensor data is read. Only the tensors that match both shape and dtype are loaded into memory.

Parameters

  • model : 'T
  • filePath : string
  • mode : LoadMode

Returns LoadReport


namedParams

namedParams model

Return all named tensors in the model via reflection.

Parameters

  • model : 'T

Returns (string * Tensor) list


save

save model filePath

Save all model tensors to a .safetensors file.

Parameters

  • model : 'T
  • filePath : string

trainableVars

trainableVars model

Return all tensors that require gradients.

Parameters

  • model : 'T

Returns Tensor list