Laws Spanish Named Entity Recognition (from `hackathon-pln-es`)

Description

Pretrained RobertaForTokenClassification model, adapted from Hugging Face and curated to provide scalability and production-readiness using Spark NLP. jurisbert-finetuning-ner is a Spanish model orginally trained by hackathon-pln-es.

Predicted Entities

TRAT_INTL, LEY

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 = RoBertaForTokenClassification.pretrained("roberta_ner_jurisbert_finetuning_ner","es") \
    .setInputCols(["sentence", "token"]) \
    .setOutputCol("ner")

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

data = spark.createDataFrame([["Me encanta Spark PNL"]]).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 = RoBertaForTokenClassification.pretrained("roberta_ner_jurisbert_finetuning_ner","es") 
    .setInputCols(Array("sentence", "token")) 
    .setOutputCol("ner")

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

val data = Seq("Me encanta Spark PNL").toDF("text")

val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("es.ner.roberta.finetuning_").predict("""Me encanta Spark PNL""")

Model Information

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

References

https://huggingface.co/hackathon-pln-es/jurisbert-finetuning-ner