English Legal BERT Embedding Small Uncased model(Uncased, Contracts)

Description

Pretrained BERT Embedding model, adapted from Hugging Face and curated to provide scalability and production-readiness using Spark NLP. bert-small-finetuned-legal-contracts-larger20-5-1 is a English model originally trained by muhtasham.

Download Copy S3 URI

How to use

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

tokenizer = Tokenizer() \
    .setInputCols("document") \
    .setOutputCol("token")
  
embeddings = BertEmbeddings.pretrained("bert_embeddings_bert_small_finetuned_legal_contracts_larger20_5_1","en") \
    .setInputCols(["document", "token"]) \
    .setOutputCol("embeddings")
    
pipeline = Pipeline(stages=[documentAssembler, tokenizer, embeddings])

data = spark.createDataFrame([["I love Spark NLP"]]).toDF("text")

result = pipeline.fit(data).transform(data)
import nlu
nlu.load("en.embed.bert.contracts.large_small_finetuned_legal").predict("""I love Spark NLP""")

Model Information

Model Name: bert_embeddings_bert_small_finetuned_legal_contracts_larger20_5_1
Compatibility: Spark NLP 4.2.7+
License: Open Source
Edition: Official
Input Labels: [sentence]
Output Labels: [bert_sentence]
Language: en
Size: 108.1 MB
Case sensitive: true
Max sentence length: 128

References

  • https://huggingface.co/muhtasham/bert-small-finetuned-legal-contracts-larger20-5-1