Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/netsaur/packages/tokenizers/mod.ts>Tokenizer

Powerful Powerful Machine Learning library with GPU, CPU and WASM backends
Latest
class Tokenizer
import { Tokenizer } from "https://deno.land/x/netsaur@0.4.2/packages/tokenizers/mod.ts";

Tokenizer class

Constructors

new
Tokenizer(id: number)

Methods

decode(ids: Uint32Array, skipSpecialTokens?): string

Decode a sentence from its encoded tokens to a string

encode(sentence: string): Uint32Array

Encode a sentence to tokens

getVocab(withAddedTokens?): any

Get the vocab

getVocabSize(withAddedTokens?): number

Get the vocab size

idToToken(id: number): string

Get the token from an id

save(): string

Save the tokenizer as json

save(pretty: boolean): string

Save the tokenizer as json

tokenToId(token: string): number

Get the id from a token

Static Methods

fromJSON(json: string): Tokenizer

Load a tokenizer from json data