Legal NER for NDA (Applicable Law Clause)

Description

This is a NER model, aimed to be run only after detecting the APPLIC_LAW clause with a proper classifier (use legmulticlf_mnda_sections_paragraph_other for that purpose). It will extract the following entities: LAW , and LAW_LOCATION.

Predicted Entities

LAW, LAW_LOCATION

Download Copy S3 URI

How to use

document_assembler = nlp.DocumentAssembler()\
        .setInputCol("text")\
        .setOutputCol("document")
        
sentence_detector = nlp.SentenceDetector()\
        .setInputCols(["document"])\
        .setOutputCol("sentence")

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

embeddings = nlp.RoBertaEmbeddings.pretrained("roberta_embeddings_legal_roberta_base","en") \
        .setInputCols(["sentence", "token"]) \
        .setOutputCol("embeddings")\
        .setMaxSentenceLength(512)\
        .setCaseSensitive(True)

ner_model = legal.NerModel.pretrained("legner_nda_applicable_law", "en", "legal/models")\
        .setInputCols(["sentence", "token", "embeddings"])\
        .setOutputCol("ner")

ner_converter = nlp.NerConverter()\
        .setInputCols(["sentence", "token", "ner"])\
        .setOutputCol("ner_chunk")

nlpPipeline = nlp.Pipeline(stages=[
        document_assembler,
        sentence_detector,
        tokenizer,
        embeddings,
        ner_model,
        ner_converter])

empty_data = spark.createDataFrame([[""]]).toDF("text")

model = nlpPipeline.fit(empty_data)

text = ["""This Agreement will be governed and construed in accordance with the laws of the State of Utah without regard to the conflicts of laws or principles thereof."""]

result = model.transform(spark.createDataFrame([text]).toDF("text"))

Results

+-------------+------------+
|chunk        |ner_label   |
+-------------+------------+
|laws         |LAW         |
|State of Utah|LAW_LOCATION|
|laws         |LAW         |
+-------------+------------+

Model Information

Model Name: legner_nda_applicable_law
Compatibility: Legal NLP 1.0.0+
License: Licensed
Edition: Official
Input Labels: [sentence, token, embeddings]
Output Labels: [ner]
Language: en
Size: 16.3 MB

References

In-house annotations on the Non-disclosure Agreements

Benchmarking

label         precision  recall  f1-score  support 
LAW           0.97       0.97    0.97      70      
LAW_LOCATION  0.92       0.94    0.93      51      
micro-avg     0.95       0.96    0.95      121     
macro-avg     0.95       0.96    0.95      121     
weighted-avg  0.95       0.96    0.95      121