-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: null pointer passed to rust #69
Comments
Have the same problem. Input is a string with ~ 20.000 characters. My workaround is to EDIT: No that does not work. I just create a new encoder. If I |
I debugged this a bit and I can reproduce the error if I const encoding = get_encoding(encoding)
encoding.free()
encoding.encode(content) // <-- throws here with "null pointer passed to rust" Calling const encoding = get_encoding(encoding)
encoding.free()
encoding.free() // <-- throws here with "null pointer passed to rust" I get this error after I refactored my code. I had the issue that calling Oh my god 🤦♂️ while writing this I realized that I called |
Hi, |
I get the same error when I reuse the encoder after calling const encoder = get_encoding("cl100k_base"); // global encoder
while (true) { // get next batch of docs to encode
for (const doc of docs) {
encoded = encoder.encode(doc.content); // throws null ptr error after the first iteration of outer loop
}
encoder.free(); // free the encoder
} There's some good discussion related to I essentially ended up respawning the encoder after freeing it, which resolved the issue. For example: while (true) { // get next batch of docs to encode
const encoder = get_encoding("cl100k_base"); // spawn a new encoder
for (const doc of docs) {
encoded = encoder.encode(doc.content);
}
encoder.free(); // free the encoder
} |
TikToken was working fine encoding and decoding tokens for me then without any changes (just demoing what was working before) it failed with this error:
From the console:
In this case,
fullContext
is just a long string that is not null or undefined. What's very strange is it was just working fine yesterday and now does this. I tried fresh installs and everything but any tips would be appreciated.The text was updated successfully, but these errors were encountered: