Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/netsaur/tokenizers/mod.ts>Tokenizer

Powerful machine learning, accelerated by WebGPU
Latest
class Tokenizer
import { Tokenizer } from "https://deno.land/x/netsaur@0.3.2-patch/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