()
| 28 | } |
| 29 | |
| 30 | async load() { |
| 31 | console.log("Loading simple tokenizer..."); |
| 32 | this.encoder = await (await fetch("weights/tokenization/simple_tokens.json")).json(); |
| 33 | this.decoder = Object.keys(this.encoder).reduce((acc, x) => ({ ...acc, [this.encoder[x]]: x }), {}); |
| 34 | this.vocab_size = Object.keys(this.encoder).length; |
| 35 | } |
| 36 | |
| 37 | encode(str) { |
| 38 | return str.split("").map((x) => this.encoder[x]); |
nothing calls this directly
no outgoing calls
no test coverage detected