fasttext Node.js

65 views
Skip to first unread message

Amila Deepal

unread,
Jun 15, 2023, 5:22:55 AM6/15/23
to fastText library
Dear All

I have downloaded the pretrained FastText model file, "cc.si.300.bin," and I am attempting to obtain sentence embeddings using Node.js. However, I am currently unable to retrieve the desired output from my code. I kindly request your assistance in resolving this issue.

Thank you in advance for your help.

Thank you. Regard

const path = require('path');
const FastText = require('FastText.js');
exports.get_embeddings = async (req, res, next) => {

 
    /*//const modelPath = '/cc.si.300.bin';
    var fastText = new FastText({
        loadModel: './cc.si.300.bin'          
    });*/

     var fastText = new FastText({
          bin: './node_modules/fasttext.js/lib/bin/win32/fastText.exe',
          loadModel: '/cc.si.300.bin' // must specifiy filename and ext
      });
     

      var sample="Our Twitter run by the band and crew to give you an inside look into our lives on the road. Get #FutureHearts now: http://smarturl.it/futurehearts";
       fastText.load().then(done => {
          return fastText.predict(sample);
      })
      .then(labels=> {
          console.log("TEXT:", sample, "\nPREDICT:",labels );
          sample="LBi Software provides precisely engineered, customer-focused #HRTECH solutions. Our flagship solution, LBi HR HelpDesk, is a SaaS #HR Case Management product.";
          return fastText.predict(sample);
      })
      .then(labels=> {
          console.log("TEXT:", sample, "\nPREDICT:",labels );
          fastText.unload();
      })
      .catch(error => {
          console.error(error);
      });


    res.status(200).json('received');


}
Reply all
Reply to author
Forward
0 new messages