English RobertaForSequenceClassification Cased model (from Kaveh8)

Description

Pretrained RobertaForSequenceClassification model, adapted from Hugging Face and curated to provide scalability and production-readiness using Spark NLP. autonlp-imdb_rating-625417974 is a English model originally trained by Kaveh8.

Predicted Entities

1, 4, 3, 2, 5

Download Copy S3 URI

How to use

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

tokenizer = Tokenizer() \
    .setInputCols("document") \
    .setOutputCol("token")

roberta_classifier = RoBertaForSequenceClassification.pretrained("roberta_classifier_autonlp_imdb_rating_625417974","en") \
    .setInputCols(["document", "token"]) \
    .setOutputCol("class")

pipeline = Pipeline(stages=[documentAssembler, tokenizer, roberta_classifier])

data = spark.createDataFrame([["I love you!"], ["I feel lucky to be here."]]).toDF("text")

result = pipeline.fit(data).transform(data)
val documentAssembler = new DocumentAssembler()
    .setInputCols("text")
    .setOutputCols("document")

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

val roberta_classifier = RoBertaForSequenceClassification.pretrained("roberta_classifier_autonlp_imdb_rating_625417974","en")
    .setInputCols(Array("document", "token"))
    .setOutputCol("class")

val pipeline = new Pipeline().setStages(Array(documentAssembler, tokenizer, roberta_classifier))

val data = Seq("I love you!").toDS.toDF("text")

val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("en.classify.roberta.imdb.by_kaveh8").predict("""I feel lucky to be here.""")

Model Information

Model Name: roberta_classifier_autonlp_imdb_rating_625417974
Compatibility: Spark NLP 4.2.4+
License: Open Source
Edition: Official
Input Labels: [document, token]
Output Labels: [class]
Language: en
Size: 428.0 MB
Case sensitive: true
Max sentence length: 128

References

  • https://huggingface.co/Kaveh8/autonlp-imdb_rating-625417974