pub struct Model {
pub spec: LayaSpec,
pub tensors: Tensors,
pub graph: LayaGraph,
pub index: Option<Index>,
pub metadata: Option<Map<String, Value>>,
/* private fields */
}Expand description
A loaded compat model: its spec, its tensors and the graph bound to them.
Fields§
§spec: LayaSpecBoth configs.
tensors: TensorsThe weights, mapped.
graph: LayaGraphThe graph, with every weight bound and checked.
index: Option<Index>The .kime index, when loaded from one.
metadata: Option<Map<String, Value>>__metadata__ of the source safetensors, kept so unpacking gives the same file back.
Implementations§
Source§impl Model
impl Model
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, Error>
pub fn open(path: impl AsRef<Path>) -> Result<Self, Error>
Opens a Laya checkpoint directory or a .kime file. Tensor data is mapped, not read, and
the .kime model hash is not checked here, see Model::verify.
§Errors
Error::Io for a missing file, Error::Format for a malformed one and
Error::Mismatch when the tensors do not match the config.
Sourcepub fn file(&self, name: &str) -> Option<&[u8]>
pub fn file(&self, name: &str) -> Option<&[u8]>
A carried file, such as tokenizer/tokenizer.json.
Sourcepub fn file_names(&self) -> Vec<&str>
pub fn file_names(&self) -> Vec<&str>
Names of the carried files.
Sourcepub fn verify(&self) -> Result<(), Error>
pub fn verify(&self) -> Result<(), Error>
Checks the .kime model hash against the data. A directory has no hash and always passes.
§Errors
Error::Format if the data has changed since it was packed.