not run

#1
by asdgad - opened

%%writefile 2.js
import { pipeline } from '@huggingface/transformers';

// Allocate pipeline
const pipe = await pipeline('text-generation', 'onnx-community/Qwen1.5-0.5B-ONNX', { dtype: "fp16" });

// Define the list of messages
const messages = [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "what is ai?" },
];

// Generate a response
const output = await pipe(messages, { max_new_tokens: 51, do_sample: false });
console.log(output[0].generated_text.at(-1).content);

(node:8269) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///content/2.js is not specified and it doesn't parse as CommonJS.
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
To eliminate this warning, add "type": "module" to /content/package.json.
(Use node --trace-warnings ... to show where the warning was created)
file:///content/node_modules/@huggingface/transformers/dist/transformers.node.mjs:8208
? Object.values(model_inputs.past_key_values)[0].dims.at(-2)
^

TypeError: Cannot read properties of undefined (reading 'dims')
at Function.decoder_prepare_inputs_for_generation [as _prepare_inputs_for_generation] (file:///content/node_modules/@huggingface/transformers/dist/transformers.node.mjs:8208:57)
at Function.prepare_inputs_for_generation (file:///content/node_modules/@huggingface/transformers/dist/transformers.node.mjs:8885:21)
at Function.generate (file:///content/node_modules/@huggingface/transformers/dist/transformers.node.mjs:9174:33)
at async Function._call (file:///content/node_modules/@huggingface/transformers/dist/transformers.node.mjs:22715:54)
at async file:///content/2.js:13:16

Node.js v20.19.0

ONNX Community org
Felladrin changed discussion status to closed

Sign up or log in to comment