CamemBERT Sequence Classification Large - French Allociné (camembert_large_sequence_classifier_allocine)

Description

CamemBertForSequenceClassification can load CamemBERT model with sequence classification/regression head on top (a linear layer on top of the pooled output) e.g. for multi-class document classification tasks.

camembert_large_sequence_classifier_allocine is a fine-tuned CamemBERT model on French Allociné dataset that is ready to be used for Sequence Classification sentiment analysis task abd it achieves state-of-the-art performance.

We used TFCamembertForSequenceClassification in Transformers to train this model and used CamemBertForSequenceClassification annotator in Spark NLP 🚀 for prediction at scale!

Download Copy S3 URI

How to use

                
document_assembler = DocumentAssembler()\ 
    .setInputCol("text")\ 
    .setOutputCol("document")

tokenizer = Tokenizer()\ 
    .setInputCols(['document'])\ 
    .setOutputCol('token') 

sequenceClassifier = CamemBertForSequenceClassification.pretrained("camembert_large_sequence_classifier_allocine", "fr")\ 
    .setInputCols(["document", "token"])\ 
    .setOutputCol("class")\ 
    .setCaseSensitive(True)\ 
    .setMaxSentenceLength(512) 

pipeline = Pipeline(stages=[
    document_assembler,
    tokenizer,
    sequenceClassifier
])

example = spark.createDataFrame([['I really liked that movie!']]).toDF("text")
result = pipeline.fit(example).transform(example)

val document_assembler = new DocumentAssembler()
  .setInputCol("text")
  .setOutputCol("document")

val tokenizer = new Tokenizer()
    .setInputCols("document")
    .setOutputCol("token")

val sequenceClassifier = CamemBertForSequenceClassification.pretrained("camembert_large_sequence_classifier_allocine", "fr")
    .setInputCols("document", "token")
    .setOutputCol("class")
    .setCaseSensitive(true)
    .setMaxSentenceLength(512)

val pipeline = new Pipeline().setStages(Array(document_assembler, tokenizer, sequenceClassifier))

val example = Seq("I really liked that movie!").toDS.toDF("text")

val result = pipeline.fit(example).transform(example)
import nlu
nlu.load("fr.classify.camembert.large").predict("""I really liked that movie!""")

Model Information

Model Name: camembert_large_sequence_classifier_allocine
Compatibility: Spark NLP 4.2.5+
License: Open Source
Edition: Official
Input Labels: [token, document]
Output Labels: [class]
Language: fr
Size: 1.3 GB
Case sensitive: true
Max sentence length: 512

References

https://huggingface.co/datasets/allocine