Anush008 / fastembed-js

Library to generate vector embeddings in NodeJS
https://www.npmjs.com/package/fastembed/
MIT License
64 stars 5 forks source link

Error: Load model from 'path/to/model' #12

Closed anilbandrapalli closed 7 months ago

anilbandrapalli commented 7 months ago

Hi,

I am using node version 18.14.2 and i tried to load the model then i am getting this error

/home/user/poc/node_modules/fastembed/node_modules/onnxruntime-node/dist/backend.js:24
            __classPrivateFieldGet(this, _OnnxruntimeSessionHandler_inferenceSession, "f").loadModel(pathOrBuffer, options);

Error: Load model from local_cache/fast-bge-small-en-v1.5/model_optimized.onnx failed:Protobuf parsing failed.
    at new OnnxruntimeSessionHandler (/home/user/poc/node_modules/fastembed/node_modules/onnxruntime-node/dist/backend.js:24:92)
    at /home/user/poc/node_modules/fastembed/node_modules/onnxruntime-node/dist/backend.js:64:29
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)

Here is my code snippet

let embeddingModel;
(async () => {
  //default model i am trying to load here 
    embeddingModel = await FlagEmbedding.init();
  }
})();

NodeJS : 18.14.2 OS: ubuntu 22.04

Kindly guide me in this

Anush008 commented 7 months ago

Can you try again after deleting the local_cache directory?

anilbandrapalli commented 7 months ago

Hi @Anush008, i tried the step you mentioned. after that model has been downloaded and asking for tokenizer.json , tokenizer_config.json and special_tokens_map.json file . I downloaded manually and ran the application. still showing same issue

Anush008 commented 7 months ago

Why manual downloads? Was the download not complete? Those files are a part of the download.

anilbandrapalli commented 7 months ago

download was proper only . but extracting only model and config.json

anilbandrapalli commented 7 months ago

After download, if i manually extract every thing , it is working fine.

I have one more doubt. are the embedded documents in same order as we input data to embed?

Anush008 commented 7 months ago

The order is maintained. Yes.

anilbandrapalli commented 7 months ago

Thank your help