You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<|im_start|>system
You are a helpful assistant<|im_end|>
<|im_start|>Evert
Hey, can you see my name?<|im_end|>
<|im_start|>assistant
Yes I can, your name is Evert.<|im_end|>
<|im_start|>assistant
I get the following error:
error: Uncaught Error: The text contains a special token that is not allowed: <|im_start|>
at module.exports.__wbindgen_error_new (file:///Users/evert/Library/Caches/deno/npm/registry.npmjs.org/tiktoken/1.0.10/tiktoken_bg.cjs:418:17)
at <anonymous> (wasm://wasm/00b9ab1a:1:100710)
at <anonymous> (wasm://wasm/00b9ab1a:1:314157)
at Tiktoken.encode (file:///Users/evert/Library/Caches/deno/npm/registry.npmjs.org/tiktoken/1.0.10/tiktoken_bg.cjs:270:18)
at file:///Users/evert/Sites/chat-nvc-telegram-bot/src/tokenizer.ts:42:21
You'd think that that might imply that the wasm already contains those special tokens. However, when I try to encode that string without adding those special tokens manually, then the output is this:
Never mind, apparently I had to call const encoded = tik.encode(input, "all") instead of const encoded = tik.encode(input).
I'm still a little confused why I need to do that though. And whether "all" is really the best option. Should I use "all" or should I use ["<|im_start|>", "<|im_end|>", "<|im_sep|>"] ?
The reason why all is optional here is to mimic the same behaviour as seen in the official openai/tiktoken library, where it is assumed that we're encoding user input directly.
all will include other special tokens as well, which may not be desired, depending on the input being received. Namely:
Using:
And then trying to encode this string:
I get the following error:
You'd think that that might imply that the wasm already contains those special tokens. However, when I try to encode that string without adding those special tokens manually, then the output is this:
Which doesn't line up with what I get in the tiktokenizer demo on vercel:
The text was updated successfully, but these errors were encountered: