Closed purezhanghan closed 10 months ago
From your logs (Headers is not defined
), it would appear as though you are using Node 16 or older, which reached EOL earlier this year. Please upgrade to a more up-to-date version (at least 18).
From your logs (
Headers is not defined
), it would appear as though you are using Node 16 or older, which reached EOL earlier this year. Please upgrade to a more up-to-date version (at least 18).
It's working! Upgraded from 16.5 to 20.10, thanks for the help.
Was trying to follow the instruction of this page to load local custom model, but failed to find local path https://huggingface.co/docs/transformers.js/custom_usage
the code snippet ` import { env, AutoTokenizer, AutoModelForSequenceClassification } from '@xenova/transformers';
env.useFS = true; env.localModelPath = '/path/to/local/file' env.allowRemoteModels = false;
let tokenizer = await AutoTokenizer.from_pretrained('tinybert'); let model = await AutoModelForSequenceClassification.from_pretrained('tinybert');
let inputs = await tokenizer('I love transformers!'); let { logits } = await model(inputs); ` here is the file structure: models └── tinybert ├── config.json ├── onnx │ ├── model.onnx │ └── model_quantized.onnx ├── ort_config.json ├── special_tokens_map.json ├── tokenizer.json ├── tokenizer_config.json └── vocab.txt
error: (node:36959) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time (Use
node --trace-warnings ...
to show where the warning was created) Unable to load from local path "/Users/hzhang14/pete/2023_H1_spam/models/tinybert/tokenizer.json": "ReferenceError: Headers is not defined" Unable to load from local path "/Users/hzhang14/pete/2023_H1_spam/models/tinybert/tokenizer_config.json": "ReferenceError: Headers is not defined" file:///Users/hzhang14/pete/2023_H1_spam/node_modules/@xenova/transformers/src/utils/hub.js:462 throw Error(\
local_files_only=true` or `env.allowRemoteModels=false` and file was not found locally at "${localPath}".`); ^Error:
local_files_only=true
orenv.allowRemoteModels=false
and file was not found locally at "/Users/hzhang14/pete/2023_H1_spam/models/tinybert/tokenizer.json". at getModelFile (file:///Users/hzhang14/pete/2023_H1_spam/node_modules/@xenova/transformers/src/utils/hub.js:462:27) at async getModelJSON (file:///Users/hzhang14/pete/2023_H1_spam/node_modules/@xenova/transformers/src/utils/hub.js:575:18) at async Promise.all (index 0) at async loadTokenizer (file:///Users/hzhang14/pete/2023_H1_spam/node_modules/@xenova/transformers/src/tokenizers.js:52:16) at async Function.from_pretrained (file:///Users/hzhang14/pete/2023_H1_spam/node_modules/@xenova/transformers/src/tokenizers.js:3890:48) at async file:///Users/hzhang14/pete/2023_H1_spam/js/test.mjs:9:17