huggingface / 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.56k stars 715 forks source link

Unknown model class "new", attempting to construct from base class. #736

Open ksemba opened 5 months ago

ksemba commented 5 months ago

System Info

nodejs version: 21.7.2 I'm building a nodejs app, not a web app for the browser. I'm running my app using npx tsx app.ts.

Package.json: { "name": "ai-innovation", "version": "0.1.0", "private": true, "type": "module", "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint", "test": "jest --config jest.config.mjs" }, "dependencies": { "@grpc/grpc-js": "^1.10.6", "@opentelemetry/api": "^1.8.0", "@opentelemetry/exporter-metrics-otlp-http": "^0.51.0", "@opentelemetry/exporter-prometheus": "^0.51.0", "@opentelemetry/exporter-trace-otlp-http": "^0.51.0", "@opentelemetry/instrumentation-grpc": "^0.51.0", "@opentelemetry/sdk-metrics": "^1.24.0", "@opentelemetry/sdk-node": "^0.51.0", "@opentelemetry/sdk-trace-node": "^1.24.0", "@supabase/ssr": "^0.3.0", "@supabase/supabase-js": "^2.42.5", "@xenova/transformers": "^2.17.1", "axios": "^1.6.8", "base64-stream": "^1.0.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.1", "dotenv": "^16.4.5", "next": "14.2.2", "openai": "^4.38.2", "react": "^18", "react-dom": "^18", "reflect-metadata": "^0.2.2", "winston": "^3.13.0", "zlib": "^1.0.5" }, "devDependencies": { "@swc/core": "^1.3.58", "@swc/helpers": "^0.5.1", "@types/base64-stream": "^1.0.5", "@types/jest": "^29.5.12", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", "eslint": "^8", "eslint-config-next": "14.2.2", "jest": "^29.7.0", "postcss": "^8", "tailwindcss": "^3.4.1", "ts-jest": "^29.1.2", "ts-node": "^10.9.2", "tsx": "^4.7.2", "typescript": "^5" }, "ts-node": { "esm": true, "swc": true } }

Environment/Platform

Description

I copy-pasted the code from here: https://huggingface.co/Alibaba-NLP/gte-large-en-v1.5 for the JavaScript library and ran it locally. It always prints this output: Unknown model class "new", attempting to construct from base class. Model type for 'new' not found, assuming encoder-only architecture. Please report this at https://github.com/xenova/transformers.js/issues/new/choose.

But it also generates the correct similarities so the code doesn't seem to be broken

Reproduction

  1. Copy transformers.js example code from https://huggingface.co/Alibaba-NLP/gte-large-en-v1.5 into an app.ts file
  2. Run this file using npx tsx app.ts
xenova commented 5 months ago

Hi there 👋 This is because (for some reason), the model authors decided to choose "new" for the model type in the config.json (see here). Luckily, because it's BERT-like (encoder-only), the model runs correctly since that's selected by the default in transformers.js.

Basically, you can ignore the warning, but thanks for letting us know! :)

josiahbryan commented 4 months ago

How can we silence the warning and/or get it fixed? This is cluttering up my logs and is super annoying