transformers.js icon indicating copy to clipboard operation
transformers.js copied to clipboard

Vercel Deployment Issues - Onyruntime Errors With Xenova

Open Jonneal3 opened this issue 11 months ago • 4 comments

System Info

Mac m2 Chrome "@xenova/transformers": "^2.16.0",

Environment/Platform

  • [X] Website/web-app
  • [ ] Browser extension
  • [ ] Server-side (e.g., Node.js, Deno, Bun)
  • [ ] Desktop app (e.g., Electron)
  • [X] Other (e.g., VSCode extension)

Description

Screenshot 2024-03-15 at 4 15 22 PM

Im getting these errors for xenova (local embeddings) when deployment to vercel...I found another post where on github where some users were shoing soluations but those did not work for me.

Anyone else having these

Reproduction

I cant reporduce t. Its on vercel everytiem when using the most updated veriosn - "@xenova/transformers": "^2.16.0",

Jonneal3 avatar Mar 15 '24 20:03 Jonneal3

Did you add this custom webpack config on next.config.js file?

I find that it should at least have these two things:

/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    serverComponentsExternalPackages: ["sharp", "onnxruntime-node"],
  },
  webpack: (config) => {
    // Ignore node-specific modules when bundling for the browser
    // https://webpack.js.org/configuration/resolve/#resolvealias
    config.resolve.alias = {
      ...config.resolve.alias,
      sharp$: false,
      "onnxruntime-node$": false,
    };
    return config;
  },
}

I myself encounter more issues beyond this (something to do with importing the onnxruntime-node that required me to patch a few lines of the transformers.js package. Still checking if that's only on my project, but let me know if you run into other issues. I'll be happy to share. I was able to run inference on a Next.js route (node runtime) deployed on Vercel.

kvnang avatar Mar 16 '24 03:03 kvnang

@kvnang Thanks a bunch man! I will check that out tomorrow first thing and get back to you. Yeah this has been a pesky one. I had to just remove it from my retrieval flow for now until i could figure it out! Will check in next day or two

Jonneal3 avatar Mar 18 '24 02:03 Jonneal3

@kvnang I tried your added script to nextconfig and it worked! Cant believe i didnt see that anywhere! Thanks so much for the help!

Jonneal3 avatar Mar 19 '24 20:03 Jonneal3

Did you add this custom webpack config on next.config.js file?

I find that it should at least have these two things:

/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    serverComponentsExternalPackages: ["sharp", "onnxruntime-node"],
  },
  webpack: (config) => {
    // Ignore node-specific modules when bundling for the browser
    // https://webpack.js.org/configuration/resolve/#resolvealias
    config.resolve.alias = {
      ...config.resolve.alias,
      sharp$: false,
      "onnxruntime-node$": false,
    };
    return config;
  },
}

I myself encounter more issues beyond this (something to do with importing the onnxruntime-node that required me to patch a few lines of the transformers.js package. Still checking if that's only on my project, but let me know if you run into other issues. I'll be happy to share. I was able to run inference on a Next.js route (node runtime) deployed on Vercel.

I am running into this issue specifically when using ClipEmbedding with Vercel.

https://github.com/neondatabase/examples/tree/main/ai/llamaindex/reverse-image-search-nextjs is my minimal reproducible.

rishi-raj-jain avatar Jun 27 '24 21:06 rishi-raj-jain