Legal NER for NDA (Non-compete Clause)

Description

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

Predicted Entities

NON_COMPETE_COUNTRY, NON_COMPETE_TERM

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_non_compete", "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 = ["""The employee shall not engage in any business activities that compete with the company in France for a period of two years after leaving the company."""]

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

Results

+---------+-------------------+
|chunk    |ner_label          |
+---------+-------------------+
|France   |NON_COMPETE_COUNTRY|
|two years|NON_COMPETE_TERM   |
+---------+-------------------+

Model Information

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

References

In-house annotations on the Non-disclosure Agreements

Benchmarking

label                precision  recall  f1-score  support 
NON_COMPETE_COUNTRY  1.00       1.00    1.00      8       
NON_COMPETE_TERM     1.00       1.00    1.00      15      
micro-avg            1.00       1.00    1.00      23      
macro-avg            1.00       1.00    1.00      23      
weighted-avg         1.00       1.00    1.00      23