DonutWeightLoader class

Loads pretrained weights into a Donut model.

Supports loading from a directory with safetensors files or from an in-memory weight map.

Weight name mapping follows the HuggingFace Donut naming convention:

Encoder weights:

  • encoder.model.patch_embed.proj.weight → PatchEmbed.proj
  • encoder.model.layers.{i}.blocks.{j}.attn.* → WindowAttention
  • encoder.model.layers.{i}.downsample.* → PatchMerging

Decoder weights:

  • decoder.model.decoder.embed_tokens.weight → token embeddings
  • decoder.model.decoder.embed_positions.weight → position embeddings
  • decoder.model.decoder.layers.{i}.* → decoder layers
  • decoder.model.lm_head.weight → output projection

Constructors

DonutWeightLoader({required SwinEncoder encoder, required BartDecoder decoder})

Properties

decoder BartDecoder
final
encoder SwinEncoder
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

loadFromDirectory(String directory) Future<void>
Load weights from a directory.
loadFromMap(Map<String, Tensor> weights) → void
Load weights from an in-memory map.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited