Spanish BertForTokenClassification Cased model (from mrm8488)

Description

Pretrained BERT NER model, adapted from Hugging Face and curated to provide scalability and production-readiness using Spark NLP. bert-spanish-cased-finedtuned-ner is a Spanish model originally trained by mrm8488.

Download Copy S3 URI

How to use

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

sentenceDetector = SentenceDetector()\
    .setInputCols(["document"])\
    .setOutputCol("sentence")

tokenizer = Tokenizer() \
    .setInputCols("sentence") \
    .setOutputCol("token")
  
ner = BertForTokenClassification.pretrained("bert_ner_spanish_cased_finedtuned","es") \
    .setInputCols(["sentence", "token"]) \
    .setOutputCol("pos")
    
pipeline = Pipeline(stages=[documentAssembler, tokenizer, ner])

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 = new SentenceDetector()
    .setInputCols(Array("document"))
    .setOutputCol("sentence")

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

val ner = BertForTokenClassification.pretrained("bert_ner_spanish_cased_finedtuned","es") 
    .setInputCols(Array("sentence", "token")) 
    .setOutputCol("ner")

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

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

val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("es.ner.bert.cased").predict("""PUT YOUR STRING HERE.""")

Model Information

Model Name: bert_ner_spanish_cased_finedtuned
Compatibility: Spark NLP 4.0.0+
License: Open Source
Edition: Official
Input Labels: [document, token]
Output Labels: [ner]
Language: es
Size: 410.2 MB
Case sensitive: true
Max sentence length: 128

References

https://huggingface.co/mrm8488/bert-spanish-cased-finedtuned-ner