English RobertaForTokenClassification Base Cased model (from mrm8488)

Description

Pretrained RobertaForTokenClassification model, adapted from Hugging Face and curated to provide scalability and production-readiness using Spark NLP. codebert-base-finetuned-stackoverflow-ner is a English model originally trained by mrm8488.

Predicted Entities

Value, Application, Variable, --MEDIA, Output_Block, User_Interface_Element, --, User_Name, HTML_XML_Tag, Language, Version, Data_Type, MAIN, Operating_System, Function, Error_Name, Code_Block, ----, Website, Keyboard_IP, File_Type, Device, File_Name, -, Licence, Data_Structure, Class, Library, Organization, Algorithm

Download Copy S3 URI

How to use

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

sentenceDetector = SentenceDetectorDLModel.pretrained("sentence_detector_dl", "xx")\
       .setInputCols(["document"])\
       .setOutputCol("sentence")

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

tokenClassifier = BertForTokenClassification.pretrained("roberta_ner_codebert_base_finetuned_stackoverflow_ner","en") \
    .setInputCols(["sentence", "token"]) \
    .setOutputCol("ner")

pipeline = Pipeline(stages=[documentAssembler, sentenceDetector, tokenizer, tokenClassifier])

data = spark.createDataFrame([["PUT YOUR STRING HERE"]]).toDF("text")

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

val sentenceDetector = SentenceDetectorDLModel.pretrained("sentence_detector_dl", "xx")
       .setInputCols(Array("document"))
       .setOutputCol("sentence")

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

val tokenClassifier = BertForTokenClassification.pretrained("roberta_ner_codebert_base_finetuned_stackoverflow_ner","en") 
    .setInputCols(Array("sentence", "token")) 
    .setOutputCol("ner")

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

val data = Seq("PUT YOUR STRING HERE").toDF("text")

val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("en.ner.roberta.base_finetuned.by_mrm8488").predict("""PUT YOUR STRING HERE""")

Model Information

Model Name: roberta_ner_codebert_base_finetuned_stackoverflow_ner
Compatibility: Spark NLP 4.1.0+
License: Open Source
Edition: Official
Input Labels: [document, token]
Output Labels: [ner]
Language: en
Size: 466.8 MB
Case sensitive: true
Max sentence length: 128

References

  • https://huggingface.co/mrm8488/codebert-base-finetuned-stackoverflow-ner