- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1k
 
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
System Info
transformer.js version: 2.14.0
Framework: React (18.2.0)
Browser: Chrome (120.0.6099.218)
Node.js version: 20.2.0
Environment/Platform
- Website/web-app
 - Browser extension
 - Server-side (e.g., Node.js, Deno, Bun)
 - Desktop app (e.g., Electron)
 - Other (e.g., VSCode extension)
 
Description
I am attempting to use the crossencoder-distilcamembert-mmarcoFR model as a re-ranker in React, following the provided model card and inference code. The original Python code using the transformers library functions as expected, but when translating it to React using transformer.js, I encounter a TypeError related to the PreTrainedTokenizer constructor.
Model Information
- Original model: crossencoder-distilcamembert-mmarcoFR
 - ONNX model: crossencoder-distilcamembert-mmarcoFR_ONNX
 
Python code from the model card
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model = AutoModelForSequenceClassification.from_pretrained('antoinelouis/crossencoder-distilcamembert-mmarcoFR')
tokenizer = AutoTokenizer.from_pretrained('antoinelouis/crossencoder-distilcamembert-mmarcoFR')
pairs = [('Query', 'Paragraph1'), ('Query', 'Paragraph2') , ('Query', 'Paragraph3')]
features = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt')
model.eval()
with torch.no_grad():
    scores = model(**features).logits
print(scores)
Reproduction
- Use the provided React code to load the model and tokenizer.
 - Attempt to tokenize a nested array as shown in the code snippet.
 - Observe the encountered error.
 
Code Snippet
useEffect(() => {
    const classifySequence = async () => {
        const modelName = "Oblix/crossencoder-camembert-base-mmarcoFR_ONNX";
        const model = await AutoModelForSequenceClassification.from_pretrained(modelName);
        const tokenizer = await AutoTokenizer.from_pretrained(modelName);
        const pairs = [
            ["Quelle est la capitale de la France?", "La capitale de la France est Paris"]
        ];
        try {
            const input = await tokenizer(pairs, {
                padding: true,
                truncation: true
            });
            const output = await model(input);
            console.log(output);
        } catch (error) {
            console.error("Error:", error);
        }
    };
    classifySequence();
}, []);
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
