package kaun

  1. Overview
  2. Docs

Module Bert.TokenizerSource

Sourcetype t

BERT tokenizer instance

Sourceval create : ?vocab_file:string -> ?model_id:string -> unit -> t

Create a WordPiece tokenizer for BERT. Either provide a vocab_file path or a model_id to download from HuggingFace (defaults to bert-base-uncased)

Sourceval create_wordpiece : ?vocab_file:string -> ?model_id:string -> unit -> t

Alias for create

Sourceval encode_to_array : t -> string -> int array

Encode text to token IDs with CLS and SEP tokens

Sourceval encode : t -> string -> inputs

Encode text directly to input tensors ready for forward pass

Sourceval encode_batch : t -> ?max_length:int -> ?padding:bool -> string list -> (int32, Rune.int32_elt) Rune.t

Encode multiple texts with padding and special tokens

Sourceval decode : t -> int array -> string

Decode token IDs back to text