xenova / transformers.js

State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!
https://huggingface.co/docs/transformers.js
Apache License 2.0
11.14k stars 692 forks source link

Pipeline tries to download all the possible weights even when the dtype is specified: utils/hub.js could not locate file #941

Open DavidGOrtega opened 1 week ago

DavidGOrtega commented 1 week ago

System Info

tranformers v2.17.2 node v18.20.3

Environment/Platform

Description

For some reason, specifying the dtype is still downloading all the other weights. This approach has some issues:

file:///***/node_modules/@xenova/transformers/src/utils/hub.js:238
    throw Error(`${message}: "${remoteURL}".`);
          ^

Error: Could not locate file: "https://huggingface.co/intfloat/multilingual-e5-large/resolve/main/onnx/model_quantized.onnx".
    at handleError (file:///***/node_modules/@xenova/transformers/src/utils/hub.js:238:11)
    at getModelFile (file:///***/node_modules/@xenova/transformers/src/utils/hub.js:471:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async constructSession (file:///***/node_modules/@xenova/transformers/src/models.js:123:18)
    at async Promise.all (index 1)
    at async XLMRobertaModel.from_pretrained (file:///***/node_modules/@xenova/transformers/src/models.js:793:20)
    at async AutoModel.from_pretrained (file:///***/node_modules/@xenova/transformers/src/models.js:5519:20)
    at async Promise.all (index 1)
    at async loadItems (file:///***/node_modules/@xenova/transformers/src/pipelines.js:3279:5)
    at async pipeline (file:///***/node_modules/@xenova/transformers/src/pipelines.js:3219:21)

Reproduction



import { pipeline, env } from '@xenova/transformers';

const run = async () => {
  const model = 'intfloat/multilingual-e5-large';
  const extractor = await pipeline('feature-extraction', model, { pooling: 'mean', normalize: true,  dtype: 'fp32' });

  const texts = ['Hello world.', 'Example sentence.'];
  const embeddings = await extractor(texts);
  console.log(embeddings, model);
}

run();
xenova commented 1 week ago

Hi there 👋 Please note that the dtype option is only available in @huggingface/transformers (Transformers.js v3) instead of @xenova/transformers.