0

I'm trying to run a sentiment analysis function using the @xenova/transformers package in a NextJS project with Webpack, but I'm encountering the following error:

Module parse failed: Unexpected character '�' (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders (Source code omitted for this binary file)

and this is my code

    import { pipeline } from "@xenova/transformers";

export const sentimentAnalysis = async () => {
  // Load the sentiment-analysis pipeline
  const pipe = await pipeline("sentiment-analysis");

  // Run the model
  const out = await pipe("I love transformers!");
  console.log(out);
  return out;
};

I'm using Webpack for bundling, and it seems to choke on binary files (probably model files) that @xenova/transformers tries to load. I haven't added any custom loaders for .bin, .onnx, or similar file types.

What loader or configuration do I need in my Webpack setup to support @xenova/transformers? Is there a recommended way to run this package with Webpack (or is it better suited for non-bundled environments like pure Node.js or browser)?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.