PaddingSide
Side on which padding tokens are inserted.
Union cases
| Name | Description |
|---|---|
Left | |
Right |
Instance members
| Name | Description |
|---|---|
this.IsLeft | |
this.IsRight |
TruncationSide
Side removed when a token sequence exceeds the target length.
Union cases
| Name | Description |
|---|---|
Left | |
Right |
Instance members
| Name | Description |
|---|---|
this.IsLeft | |
this.IsRight |
CollationLength
Target sequence length for padding and truncation.
Union cases
| Name | Description |
|---|---|
BatchMax maxLength | Pad to the longest sequence in the batch, optionally truncating first. |
Fixed int | Pad and truncate every sequence to this length. |
Instance members
| Name | Description |
|---|---|
this.IsBatchMax | |
this.IsFixed |
CollationOptions
Text collation policy.
Record fields
| Name | Description |
|---|---|
Length | |
PadTokenId | |
PaddingSide | |
TruncationSide |
CollationOptions module
Constructors for text collation policies.
| Function | Description |
|---|---|
create padTokenId length | Create a right-padded policy that truncates tokens from the right. |
create
create padTokenId length
Create a right-padded policy that truncates tokens from the right.
Parameters
padTokenId:int64length:CollationLength
Returns CollationOptions
EncodedBatch
A model-ready batch produced from text.
Record fields
| Name | Description |
|---|---|
AttentionMask | Boolean attention mask with shape [batch, sequence]. |
InputIds | Token IDs with shape [batch, sequence]. |
Lengths | Original token count for each batch item before truncation. |
Collation
Text-to-tensor collation.
| Function | Description |
|---|---|
batch tokenizer texts options device | Encode texts into a batch with mask and retained lengths. |
toTensor tokenizer text options device | Encode one text into a token tensor. Fixed length pads to that length; |
| batch-max pads only to the (possibly truncated) sequence itself. |
batch
batch tokenizer texts options device
Encode texts into a batch with mask and retained lengths.
Parameters
tokenizer:Tokenizertexts:string listoptions:CollationOptionsdevice:Device
Returns EncodedBatch
toTensor
toTensor tokenizer text options device
Encode one text into a token tensor. Fixed length pads to that length; batch-max pads only to the (possibly truncated) sequence itself.
Parameters
tokenizer:Tokenizertext:stringoptions:CollationOptionsdevice:Device
Returns Tensor