avichr/Legal-heBERT

Model

Legal-HeBERT

8

9 commits

2 linked in READMEs

updated Jul 7, 2022

See the code

README

Legal-HeBERT

Legal-HeBERT is a BERT model for Hebrew legal and legislative domains. It is intended to improve the legal NLP research and tools development in Hebrew. We release two versions of Legal-HeBERT. The first version is a fine-tuned model of HeBERT applied on legal and legislative documents. The second version uses HeBERT's architecture guidlines to train a BERT model from scratch.
We continue collecting legal data, examining different architectural designs, and performing tagged datasets and legal tasks for evaluating and to development of a Hebrew legal tools.

Training Data

Our training datasets are:

NameHebrew DescriptionSize (GB)DocumentsSentencesWordsNotes
The Israeli Law Bookืกืคืจ ื”ื—ื•ืงื™ื ื”ื™ืฉืจืืœื™0.0523382933524851063
Judgments of the Supreme Courtืžืื’ืจ ืคืกืงื™ ื”ื“ื™ืŸ ืฉืœ ื‘ื™ืช ื”ืžืฉืคื˜ ื”ืขืœื™ื•ืŸ0.7212348579013879672415
custody courtsื”ื—ืœื˜ื•ืช ื‘ืชื™ ื”ื“ื™ืŸ ืœืžืฉืžื•ืจืช2.46169,7088,555,893213,050,492
Law memoranda, drafts of secondary legislation and drafts of support tests that have been distributed to the public for commentืชื–ื›ื™ืจื™ ื—ื•ืง, ื˜ื™ื•ื˜ื•ืช ื—ืงื™ืงืช ืžืฉื ื” ื•ื˜ื™ื•ื˜ื•ืช ืžื‘ื—ื ื™ ืชืžื™ื›ื” ืฉื”ื•ืคืฆื• ืœื”ืขืจื•ืช ื”ืฆื™ื‘ื•ืจ0.43,291294,7527,218,960
Supervisors of Land Registration judgmentsืžืื’ืจ ืคืกืงื™ ื“ื™ืŸ ืฉืœ ื”ืžืคืงื—ื™ื ืขืœ ืจื™ืฉื•ื ื”ืžืงืจืงืขื™ืŸ0.0255967,6391,785,446
Decisions of the Labor Court - Coronaืžืื’ืจ ื”ื—ืœื˜ื•ืช ื‘ื™ืช ื”ื“ื™ืŸ ืœืขื ื™ื™ืŸ ืฉื™ืจื•ืช ื”ืชืขืกื•ืงื” โ€“ ืงื•ืจื•ื ื”0.001146350560195
Decisions of the Israel Lands Councilื”ื—ืœื˜ื•ืช ืžื•ืขืฆืช ืžืงืจืงืขื™ ื™ืฉืจืืœ11811283162692aggregate file
Judgments of the Disciplinary Tribunal and the Israel Police Appeals Tribunalืคืกืงื™ ื“ื™ืŸ ืฉืœ ื‘ื™ืช ื”ื“ื™ืŸ ืœืžืฉืžืขืช ื•ื‘ื™ืช ื”ื“ื™ืŸ ืœืขืจืขื•ืจื™ื ืฉืœ ืžืฉื˜ืจืช ื™ืฉืจืืœ0.0254837241743419aggregate files
Disciplinary Appeals Committee in the Ministry of Healthื•ืขื“ืช ืขืจืจ ืœื“ื™ืŸ ืžืฉืžืขืชื™ ื‘ืžืฉืจื“ ื”ื‘ืจื™ืื•ืช0.00425221010429807465 files are scanned and didn't parser
Attorney General's Positionsืžืื’ืจ ื”ืชื™ื™ืฆื‘ื•ื™ื•ืช ื”ื™ื•ืขืฅ ื”ืžืฉืคื˜ื™ ืœืžืžืฉืœื”0.00828132724813877
Legal-Opinion of the Attorney Generalืžืื’ืจ ื—ื•ื•ืช ื“ืขืช ื”ื™ื•ืขืฅ ื”ืžืฉืคื˜ื™ ืœืžืžืฉืœื”0.002447132188053
total3.665389,13915,161,152309,976,419

We thank Yair Gardin for the referring to the governance data, Elhanan Schwarts for collecting and parsing The Israeli law book, and Jonathan Schler for collecting the judgments of the supreme court.

Training process

  • Vocabulary size: 50,000 tokens
  • 4 epochs (1M stepsยฑ)
  • lr=5e-5
  • mlm_probability=0.15
  • batch size = 32 (for each gpu)
  • NVIDIA GeForce RTX 2080 TI + NVIDIA GeForce RTX 3090 (1 week training)

Additional training settings:

Fine-tuned HeBERT model: The first eight layers were freezed (like Lee et al. (2019) suggest)
Legal-HeBERT trained from scratch: The training process is similar to HeBERT and inspired by Chalkidis et al. (2020)

How to use

The models can be found in huggingface hub and can be fine-tunned to any down-stream task:

# !pip install transformers==4.14.1
from transformers import AutoTokenizer, AutoModel

model_name = 'avichr/Legal-heBERT_ft' # for the fine-tuned HeBERT model 
model_name = 'avichr/Legal-heBERT' # for legal HeBERT model trained from scratch

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModel.from_pretrained(model_name)

from transformers import pipeline
fill_mask = pipeline(
    "fill-mask",
    model=model_name,
)
fill_mask("ื”ืงื•ืจื•ื ื” ืœืงื—ื” ืืช [MASK] ื•ืœื ื• ืœื ื ืฉืืจ ื“ื‘ืจ.")

Stay tuned!

We are still working on our models and the datasets. We will edit this page as we progress. We are open for collaborations.

If you used this model please cite us as :

Chriqui, Avihay, Yahav, Inbal and Bar-Siman-Tov, Ittai, Legal HeBERT: A BERT-based NLP Model for Hebrew Legal, Judicial and Legislative Texts (June 27, 2022). Available at: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4147127

@article{chriqui2021hebert,
  title={Legal HeBERT: A BERT-based NLP Model for Hebrew Legal, Judicial and Legislative Texts},
  author={Chriqui, Avihay, Yahav, Inbal and Bar-Siman-Tov, Ittai},
  journal={SSRN preprint:4147127},
  year={2022}
}

Contact us

Avichay Chriqui, The Coller AI Lab
Inbal yahav, The Coller AI Lab
Ittai Bar-Siman-Tov, the BIU Innovation Lab for Law, Data-Science and Digital Ethics

Thank you, ืชื•ื“ื”, ุดูƒุฑุง

bert
endpoints_compatible
fill-mask
pytorch
transformers

avichr/Legal-heBERT

Model

Legal-HeBERT

8

9 commits

2 linked in READMEs

updated Jul 7, 2022

See the code

README

Legal-HeBERT

Legal-HeBERT is a BERT model for Hebrew legal and legislative domains. It is intended to improve the legal NLP research and tools development in Hebrew. We release two versions of Legal-HeBERT. The first version is a fine-tuned model of HeBERT applied on legal and legislative documents. The second version uses HeBERT's architecture guidlines to train a BERT model from scratch.
We continue collecting legal data, examining different architectural designs, and performing tagged datasets and legal tasks for evaluating and to development of a Hebrew legal tools.

Training Data

Our training datasets are:

NameHebrew DescriptionSize (GB)DocumentsSentencesWordsNotes
The Israeli Law Bookืกืคืจ ื”ื—ื•ืงื™ื ื”ื™ืฉืจืืœื™0.0523382933524851063
Judgments of the Supreme Courtืžืื’ืจ ืคืกืงื™ ื”ื“ื™ืŸ ืฉืœ ื‘ื™ืช ื”ืžืฉืคื˜ ื”ืขืœื™ื•ืŸ0.7212348579013879672415
custody courtsื”ื—ืœื˜ื•ืช ื‘ืชื™ ื”ื“ื™ืŸ ืœืžืฉืžื•ืจืช2.46169,7088,555,893213,050,492
Law memoranda, drafts of secondary legislation and drafts of support tests that have been distributed to the public for commentืชื–ื›ื™ืจื™ ื—ื•ืง, ื˜ื™ื•ื˜ื•ืช ื—ืงื™ืงืช ืžืฉื ื” ื•ื˜ื™ื•ื˜ื•ืช ืžื‘ื—ื ื™ ืชืžื™ื›ื” ืฉื”ื•ืคืฆื• ืœื”ืขืจื•ืช ื”ืฆื™ื‘ื•ืจ0.43,291294,7527,218,960
Supervisors of Land Registration judgmentsืžืื’ืจ ืคืกืงื™ ื“ื™ืŸ ืฉืœ ื”ืžืคืงื—ื™ื ืขืœ ืจื™ืฉื•ื ื”ืžืงืจืงืขื™ืŸ0.0255967,6391,785,446
Decisions of the Labor Court - Coronaืžืื’ืจ ื”ื—ืœื˜ื•ืช ื‘ื™ืช ื”ื“ื™ืŸ ืœืขื ื™ื™ืŸ ืฉื™ืจื•ืช ื”ืชืขืกื•ืงื” โ€“ ืงื•ืจื•ื ื”0.001146350560195
Decisions of the Israel Lands Councilื”ื—ืœื˜ื•ืช ืžื•ืขืฆืช ืžืงืจืงืขื™ ื™ืฉืจืืœ11811283162692aggregate file
Judgments of the Disciplinary Tribunal and the Israel Police Appeals Tribunalืคืกืงื™ ื“ื™ืŸ ืฉืœ ื‘ื™ืช ื”ื“ื™ืŸ ืœืžืฉืžืขืช ื•ื‘ื™ืช ื”ื“ื™ืŸ ืœืขืจืขื•ืจื™ื ืฉืœ ืžืฉื˜ืจืช ื™ืฉืจืืœ0.0254837241743419aggregate files
Disciplinary Appeals Committee in the Ministry of Healthื•ืขื“ืช ืขืจืจ ืœื“ื™ืŸ ืžืฉืžืขืชื™ ื‘ืžืฉืจื“ ื”ื‘ืจื™ืื•ืช0.00425221010429807465 files are scanned and didn't parser
Attorney General's Positionsืžืื’ืจ ื”ืชื™ื™ืฆื‘ื•ื™ื•ืช ื”ื™ื•ืขืฅ ื”ืžืฉืคื˜ื™ ืœืžืžืฉืœื”0.00828132724813877
Legal-Opinion of the Attorney Generalืžืื’ืจ ื—ื•ื•ืช ื“ืขืช ื”ื™ื•ืขืฅ ื”ืžืฉืคื˜ื™ ืœืžืžืฉืœื”0.002447132188053
total3.665389,13915,161,152309,976,419

We thank Yair Gardin for the referring to the governance data, Elhanan Schwarts for collecting and parsing The Israeli law book, and Jonathan Schler for collecting the judgments of the supreme court.

Training process

  • Vocabulary size: 50,000 tokens
  • 4 epochs (1M stepsยฑ)
  • lr=5e-5
  • mlm_probability=0.15
  • batch size = 32 (for each gpu)
  • NVIDIA GeForce RTX 2080 TI + NVIDIA GeForce RTX 3090 (1 week training)

Additional training settings:

Fine-tuned HeBERT model: The first eight layers were freezed (like Lee et al. (2019) suggest)
Legal-HeBERT trained from scratch: The training process is similar to HeBERT and inspired by Chalkidis et al. (2020)

How to use

The models can be found in huggingface hub and can be fine-tunned to any down-stream task:

# !pip install transformers==4.14.1
from transformers import AutoTokenizer, AutoModel

model_name = 'avichr/Legal-heBERT_ft' # for the fine-tuned HeBERT model 
model_name = 'avichr/Legal-heBERT' # for legal HeBERT model trained from scratch

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModel.from_pretrained(model_name)

from transformers import pipeline
fill_mask = pipeline(
    "fill-mask",
    model=model_name,
)
fill_mask("ื”ืงื•ืจื•ื ื” ืœืงื—ื” ืืช [MASK] ื•ืœื ื• ืœื ื ืฉืืจ ื“ื‘ืจ.")

Stay tuned!

We are still working on our models and the datasets. We will edit this page as we progress. We are open for collaborations.

If you used this model please cite us as :

Chriqui, Avihay, Yahav, Inbal and Bar-Siman-Tov, Ittai, Legal HeBERT: A BERT-based NLP Model for Hebrew Legal, Judicial and Legislative Texts (June 27, 2022). Available at: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4147127

@article{chriqui2021hebert,
  title={Legal HeBERT: A BERT-based NLP Model for Hebrew Legal, Judicial and Legislative Texts},
  author={Chriqui, Avihay, Yahav, Inbal and Bar-Siman-Tov, Ittai},
  journal={SSRN preprint:4147127},
  year={2022}
}

Contact us

Avichay Chriqui, The Coller AI Lab
Inbal yahav, The Coller AI Lab
Ittai Bar-Siman-Tov, the BIU Innovation Lab for Law, Data-Science and Digital Ethics

Thank you, ืชื•ื“ื”, ุดูƒุฑุง

bert
endpoints_compatible
fill-mask
pytorch
transformers