-
Notifications
You must be signed in to change notification settings - Fork 751
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
RangeError: offset is out of bounds #8
Comments
Edit: Nevermind, the error looks to be when you create the session. The error looks to be coming from onnxruntime-web. Could you perhaps provide more steps to see if I can reproduce it on my side? Or, could you provide the full code you are using? It's quite difficult to determine the root cause from the above error message. The only thing I can think of right now is you are loading the model multiple times, leading to an out of memory error? |
Here is my minimal reproducible example within a typescript web worker:
Here are my logs after running 5 times in a row:
|
Okay yes, it looks like you are creating multiple versions of the model, leading to an out of memory error. The current Caching API caches the model, but does not force you to only create one instance of the model. If you move your Alternatively, you can follow what I did in my worker example (https://github.com/xenova/transformers.js/blob/main/assets/js/worker.js), I use a singleton class to ensure that only one pipeline is created. Something like this should work: import { pipeline, env } from "@xenova/transformers";
env.remoteModels = false;
env.localURL = "/models";
const pipe = await pipeline("text2text-generation", "flan-t5-base");
onmessage = async (event: MessageEvent) => {
const completion: string[] = await pipe(
"Summarize: The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct."
);
console.log(completion);
return completion[0];
}; |
Ah, that makes a lot of sense. Closing this one. Thank you! |
@xenova the above solution worked great. However, with this same pipeline, I seem to be seeing this error come up fairly often:
Any ideas? I don't think it has to do with context window size, since my input is fairly small and has worked on bigger. |
This occurs when the tokenizer produces undefined tokens (most likely due to unknown characters). Could you send the input you used? Also, could you open a new issue with that? Since it is probably a real bug. |
Yes I'll open a new issue, thanks. |
I am running the flan-t5 model for text2text-generation (e.g.
await pipeline("text2text-generation", "flan-t5-base");
) in a service worker. Inference runs without an issue for the first several runs, but eventually I get this error:I ran with the same input params 5 times in a row and still get the error, so it doesn't seem like it's an issue with an invalid input value.
The text was updated successfully, but these errors were encountered: