Transformer JS compatibility

#1

Trying to run this on-edge using Transformers.js.

I was getting this error

inference.js:5 
        
        
       GET http://localhost:3000/models/minuva/MiniLMv2-toxic-jigsaw-onnx/tokenizer.json net::ERR_ABORTED 404 (Not Found)
getFile @ @xenova_transformers.js?v=2edaa251:15437
getModelFile @ @xenova_transformers.js?v=2edaa251:15577
await in getModelFile
getModelJSON @ @xenova_transformers.js?v=2edaa251:15653
loadTokenizer @ @xenova_transformers.js?v=2edaa251:19167
from_pretrained @ @xenova_transformers.js?v=2edaa251:22363
loadItems @ @xenova_transformers.js?v=2edaa251:30852
pipeline @ @xenova_transformers.js?v=2edaa251:30817
run @ inference.js:5
onSubmit @ CreateOrJoinRoom.tsx?t=1723985512560:136
callCallback2 @ chunk-CNOMH75O.js?v=2edaa251:3674
invokeGuardedCallbackDev @ chunk-CNOMH75O.js?v=2edaa251:3699
invokeGuardedCallback @ chunk-CNOMH75O.js?v=2edaa251:3733
invokeGuardedCallbackAndCatchFirstError @ chunk-CNOMH75O.js?v=2edaa251:3736
executeDispatch @ chunk-CNOMH75O.js?v=2edaa251:7016
processDispatchQueueItemsInOrder @ chunk-CNOMH75O.js?v=2edaa251:7036
processDispatchQueue @ chunk-CNOMH75O.js?v=2edaa251:7045
dispatchEventsForPlugins @ chunk-CNOMH75O.js?v=2edaa251:7053
(anonymous) @ chunk-CNOMH75O.js?v=2edaa251:7177
batchedUpdates$1 @ chunk-CNOMH75O.js?v=2edaa251:18909
batchedUpdates @ chunk-CNOMH75O.js?v=2edaa251:3579
dispatchEventForPluginEventSystem @ chunk-CNOMH75O.js?v=2edaa251:7176
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ chunk-CNOMH75O.js?v=2edaa251:5478
dispatchEvent @ chunk-CNOMH75O.js?v=2edaa251:5472
dispatchDiscreteEvent @ chunk-CNOMH75O.js?v=2edaa251:5449
Show 22 more frames
Show lessUnderstand this error
inference.js:5 
        
        
       GET http://localhost:3000/models/minuva/MiniLMv2-toxic-jigsaw-onnx/tokenizer_config.json net::ERR_ABORTED 404 (Not Found)
getFile @ @xenova_transformers.js?v=2edaa251:15437
getModelFile @ @xenova_transformers.js?v=2edaa251:15577
await in getModelFile
getModelJSON @ @xenova_transformers.js?v=2edaa251:15653
loadTokenizer @ @xenova_transformers.js?v=2edaa251:19168
from_pretrained @ @xenova_transformers.js?v=2edaa251:22363
loadItems @ @xenova_transformers.js?v=2edaa251:30852
pipeline @ @xenova_transformers.js?v=2edaa251:30817
run @ inference.js:5
onSubmit @ CreateOrJoinRoom.tsx?t=1723985512560:136
callCallback2 @ chunk-CNOMH75O.js?v=2edaa251:3674
invokeGuardedCallbackDev @ chunk-CNOMH75O.js?v=2edaa251:3699
invokeGuardedCallback @ chunk-CNOMH75O.js?v=2edaa251:3733
invokeGuardedCallbackAndCatchFirstError @ chunk-CNOMH75O.js?v=2edaa251:3736
executeDispatch @ chunk-CNOMH75O.js?v=2edaa251:7016
processDispatchQueueItemsInOrder @ chunk-CNOMH75O.js?v=2edaa251:7036
processDispatchQueue @ chunk-CNOMH75O.js?v=2edaa251:7045
dispatchEventsForPlugins @ chunk-CNOMH75O.js?v=2edaa251:7053
(anonymous) @ chunk-CNOMH75O.js?v=2edaa251:7177
batchedUpdates$1 @ chunk-CNOMH75O.js?v=2edaa251:18909
batchedUpdates @ chunk-CNOMH75O.js?v=2edaa251:3579
dispatchEventForPluginEventSystem @ chunk-CNOMH75O.js?v=2edaa251:7176
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ chunk-CNOMH75O.js?v=2edaa251:5478
dispatchEvent @ chunk-CNOMH75O.js?v=2edaa251:5472
dispatchDiscreteEvent @ chunk-CNOMH75O.js?v=2edaa251:5449
Show 22 more frames
Show lessUnderstand this error
inference.js:5 
        
        
       GET http://localhost:3000/models/minuva/MiniLMv2-toxic-jigsaw-onnx/config.json net::ERR_ABORTED 404 (Not Found)
getFile @ @xenova_transformers.js?v=2edaa251:15437
getModelFile @ @xenova_transformers.js?v=2edaa251:15577
await in getModelFile
getModelJSON @ @xenova_transformers.js?v=2edaa251:15653
loadConfig @ @xenova_transformers.js?v=2edaa251:22432
from_pretrained @ @xenova_transformers.js?v=2edaa251:22462
from_pretrained @ @xenova_transformers.js?v=2edaa251:22475
from_pretrained @ @xenova_transformers.js?v=2edaa251:26171
loadItems @ @xenova_transformers.js?v=2edaa251:30852
pipeline @ @xenova_transformers.js?v=2edaa251:30817
run @ inference.js:5
onSubmit @ CreateOrJoinRoom.tsx?t=1723985512560:136
callCallback2 @ chunk-CNOMH75O.js?v=2edaa251:3674
invokeGuardedCallbackDev @ chunk-CNOMH75O.js?v=2edaa251:3699
invokeGuardedCallback @ chunk-CNOMH75O.js?v=2edaa251:3733
invokeGuardedCallbackAndCatchFirstError @ chunk-CNOMH75O.js?v=2edaa251:3736
executeDispatch @ chunk-CNOMH75O.js?v=2edaa251:7016
processDispatchQueueItemsInOrder @ chunk-CNOMH75O.js?v=2edaa251:7036
processDispatchQueue @ chunk-CNOMH75O.js?v=2edaa251:7045
dispatchEventsForPlugins @ chunk-CNOMH75O.js?v=2edaa251:7053
(anonymous) @ chunk-CNOMH75O.js?v=2edaa251:7177
batchedUpdates$1 @ chunk-CNOMH75O.js?v=2edaa251:18909
batchedUpdates @ chunk-CNOMH75O.js?v=2edaa251:3579
dispatchEventForPluginEventSystem @ chunk-CNOMH75O.js?v=2edaa251:7176
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ chunk-CNOMH75O.js?v=2edaa251:5478
dispatchEvent @ chunk-CNOMH75O.js?v=2edaa251:5472
dispatchDiscreteEvent @ chunk-CNOMH75O.js?v=2edaa251:5449
Show 24 more frames
Show lessUnderstand this error
inference.js:5 
        
        
       GET http://localhost:3000/models/minuva/MiniLMv2-toxic-jigsaw-onnx/onnx/model_quantized.onnx net::ERR_ABORTED 404 (Not Found)
getFile @ @xenova_transformers.js?v=2edaa251:15437
getModelFile @ @xenova_transformers.js?v=2edaa251:15577
await in getModelFile
constructSession @ @xenova_transformers.js?v=2edaa251:23099
from_pretrained @ @xenova_transformers.js?v=2edaa251:23506
from_pretrained @ @xenova_transformers.js?v=2edaa251:26183
await in from_pretrained
loadItems @ @xenova_transformers.js?v=2edaa251:30852
pipeline @ @xenova_transformers.js?v=2edaa251:30817
run @ inference.js:5
onSubmit @ CreateOrJoinRoom.tsx?t=1723985512560:136
callCallback2 @ chunk-CNOMH75O.js?v=2edaa251:3674
invokeGuardedCallbackDev @ chunk-CNOMH75O.js?v=2edaa251:3699
invokeGuardedCallback @ chunk-CNOMH75O.js?v=2edaa251:3733
invokeGuardedCallbackAndCatchFirstError @ chunk-CNOMH75O.js?v=2edaa251:3736
executeDispatch @ chunk-CNOMH75O.js?v=2edaa251:7016
processDispatchQueueItemsInOrder @ chunk-CNOMH75O.js?v=2edaa251:7036
processDispatchQueue @ chunk-CNOMH75O.js?v=2edaa251:7045
dispatchEventsForPlugins @ chunk-CNOMH75O.js?v=2edaa251:7053
(anonymous) @ chunk-CNOMH75O.js?v=2edaa251:7177
batchedUpdates$1 @ chunk-CNOMH75O.js?v=2edaa251:18909
batchedUpdates @ chunk-CNOMH75O.js?v=2edaa251:3579
dispatchEventForPluginEventSystem @ chunk-CNOMH75O.js?v=2edaa251:7176
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ chunk-CNOMH75O.js?v=2edaa251:5478
dispatchEvent @ chunk-CNOMH75O.js?v=2edaa251:5472
dispatchDiscreteEvent @ chunk-CNOMH75O.js?v=2edaa251:5449
Show 22 more frames
Show lessUnderstand this error
inference.js:5 
        
        
       GET https://huggingface.co/minuva/MiniLMv2-toxic-jigsaw-onnx/resolve/main/onnx/model_quantized.onnx 404 (Not Found)
getFile @ @xenova_transformers.js?v=2edaa251:15437
getModelFile @ @xenova_transformers.js?v=2edaa251:15596
await in getModelFile
constructSession @ @xenova_transformers.js?v=2edaa251:23099
from_pretrained @ @xenova_transformers.js?v=2edaa251:23506
from_pretrained @ @xenova_transformers.js?v=2edaa251:26183
await in from_pretrained
loadItems @ @xenova_transformers.js?v=2edaa251:30852
pipeline @ @xenova_transformers.js?v=2edaa251:30817
run @ inference.js:5
onSubmit @ CreateOrJoinRoom.tsx?t=1723985512560:136
callCallback2 @ chunk-CNOMH75O.js?v=2edaa251:3674
invokeGuardedCallbackDev @ chunk-CNOMH75O.js?v=2edaa251:3699
invokeGuardedCallback @ chunk-CNOMH75O.js?v=2edaa251:3733
invokeGuardedCallbackAndCatchFirstError @ chunk-CNOMH75O.js?v=2edaa251:3736
executeDispatch @ chunk-CNOMH75O.js?v=2edaa251:7016
processDispatchQueueItemsInOrder @ chunk-CNOMH75O.js?v=2edaa251:7036
processDispatchQueue @ chunk-CNOMH75O.js?v=2edaa251:7045
dispatchEventsForPlugins @ chunk-CNOMH75O.js?v=2edaa251:7053
(anonymous) @ chunk-CNOMH75O.js?v=2edaa251:7177
batchedUpdates$1 @ chunk-CNOMH75O.js?v=2edaa251:18909
batchedUpdates @ chunk-CNOMH75O.js?v=2edaa251:3579
dispatchEventForPluginEventSystem @ chunk-CNOMH75O.js?v=2edaa251:7176
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ chunk-CNOMH75O.js?v=2edaa251:5478
dispatchEvent @ chunk-CNOMH75O.js?v=2edaa251:5472
dispatchDiscreteEvent @ chunk-CNOMH75O.js?v=2edaa251:5449
Show 22 more frames
Show lessUnderstand this error
@xenova_transformers.js?v=2edaa251:15458 Uncaught (in promise) Error: Could not locate file: "https://huggingface.co/minuva/MiniLMv2-toxic-jigsaw-onnx/resolve/main/onnx/model_quantized.onnx".
    at handleError (@xenova_transformers.js?v=2edaa251:15458:9)
    at getModelFile (@xenova_transformers.js?v=2edaa251:15598:16)
    at async constructSession (@xenova_transformers.js?v=2edaa251:23099:16)
    at async Promise.all (:3000/index 1)
    at async BertForSequenceClassification.from_pretrained (@xenova_transformers.js?v=2edaa251:23504:14)
    at async AutoModelForSequenceClassification.from_pretrained (@xenova_transformers.js?v=2edaa251:26183:14)
    at async Promise.all (:3000/index 1)
    at async loadItems (@xenova_transformers.js?v=2edaa251:30857:3)
    at async pipeline (@xenova_transformers.js?v=2edaa251:30817:19)
    at async run (inference.js:5:18)

Which made me think that the folder structure matters, in order to make it compatible with the library.

Here are other models with similar folder structures, which work with Transformers.js: https://huggingface.co/models?pipeline_tag=text-classification&library=transformers.js&sort=trending

Please correct me if I'm wrong.

SaadBazaz changed pull request title from hfjs-compatibility to Transformer JS compatibility
Publish this branch
This branch is in draft mode, publish it to be able to merge.

Sign up or log in to comment