PANhuihuihuihui/legal

legal research

Jupyter Notebook

1

61 commits

updated May 10, 2022

See the code

README

leagal bert pretraining in HKLII

Table of content

TODO

@ 3.25

  • 与 Xiangwei 对接pretrain的下游任务
  • 训练代码优化
    • cls 的训练代码: 查看标准,实现和训练
    • 加入法研杯的训练数据,new mbert.
    • Roberta 训练策略
    • 梯度累计 增大batch size
  • 继续整理Ben那边的任务, 标注到下游任务

Backgroud

  • HKLII dataset stat(summary of token length of in each paragraph)

    stat valuevalue
    count2.851737e+06
    mean83.66615
    std73.47763
    min8.0
    25%34
    50%65
    75%112
    max11819
  • HKLII + caill

    stat valuevalue
    count2.883591e+06
    mean87.13742
    std949.2628
    min8.0
    25%34
    50%66
    75%114
    max17415
  • Datasets format

Install

cd huggface
conda env create -f environment.yml

Usage

config the model and run

  • local
    python train.py
    
  • distributed mode
    CUDA_VISIBLE_DEVICES={your devices} python -m torch.distributed.launch  --nproc_per_node={\# your divce} train.py
    
    eg:
    CUDA_VISIBLE_DEVICES=0,2,3 python -m torch.distributed.launch  --nproc_per_node=3 train.py
    

Experiment

pertraining

Model nameMethodPerplexity (before)Perplexity (after)Vocb size
custom-legalbertmask18.3703770044.56732000
legal-bert-basemask11.0553.37630522
multilingual bertmask15.64682.850105879
multilingual bert (caill added)mask15.72273.04105879
custom-legalbertmask+clstodotodotodo
legal-bert-basemask+clstodotodotodo
multilingual bertmask+clstodotodotodo

because in HKLII datasets it is possible to have chinese and english in same document multilingual

Finetune on downstream task

  1. HKLII

    Model nameMethodTaskPerplexity (after)Vocb size
    custom-legalbertmasktodotodotodo
    legal-bert-basemasktodotodotodo
    multilingual bertmask
    custom-legalbertmask+cls
    legal-bert-basemask+cls
    multilingual bertmask+cls
  2. 法研杯

    Model nameMethodTaskPerplexity (after)Vocb size
    custom-legalbertmasktrainingtrainingtraining
    legal-bert-basemasktrainingtrainingtraining
    multilingual bertmask
    custom-legalbertmask+cls
    legal-bert-basemask+cls
    multilingual bertmask+cls

License

MIT © Huijie Pan

PANhuihuihuihui/legal

legal research

Jupyter Notebook

1

61 commits

updated May 10, 2022

See the code

README

leagal bert pretraining in HKLII

Table of content

TODO

@ 3.25

  • 与 Xiangwei 对接pretrain的下游任务
  • 训练代码优化
    • cls 的训练代码: 查看标准,实现和训练
    • 加入法研杯的训练数据,new mbert.
    • Roberta 训练策略
    • 梯度累计 增大batch size
  • 继续整理Ben那边的任务, 标注到下游任务

Backgroud

  • HKLII dataset stat(summary of token length of in each paragraph)

    stat valuevalue
    count2.851737e+06
    mean83.66615
    std73.47763
    min8.0
    25%34
    50%65
    75%112
    max11819
  • HKLII + caill

    stat valuevalue
    count2.883591e+06
    mean87.13742
    std949.2628
    min8.0
    25%34
    50%66
    75%114
    max17415
  • Datasets format

Install

cd huggface
conda env create -f environment.yml

Usage

config the model and run

  • local
    python train.py
    
  • distributed mode
    CUDA_VISIBLE_DEVICES={your devices} python -m torch.distributed.launch  --nproc_per_node={\# your divce} train.py
    
    eg:
    CUDA_VISIBLE_DEVICES=0,2,3 python -m torch.distributed.launch  --nproc_per_node=3 train.py
    

Experiment

pertraining

Model nameMethodPerplexity (before)Perplexity (after)Vocb size
custom-legalbertmask18.3703770044.56732000
legal-bert-basemask11.0553.37630522
multilingual bertmask15.64682.850105879
multilingual bert (caill added)mask15.72273.04105879
custom-legalbertmask+clstodotodotodo
legal-bert-basemask+clstodotodotodo
multilingual bertmask+clstodotodotodo

because in HKLII datasets it is possible to have chinese and english in same document multilingual

Finetune on downstream task

  1. HKLII

    Model nameMethodTaskPerplexity (after)Vocb size
    custom-legalbertmasktodotodotodo
    legal-bert-basemasktodotodotodo
    multilingual bertmask
    custom-legalbertmask+cls
    legal-bert-basemask+cls
    multilingual bertmask+cls
  2. 法研杯

    Model nameMethodTaskPerplexity (after)Vocb size
    custom-legalbertmasktrainingtrainingtraining
    legal-bert-basemasktrainingtrainingtraining
    multilingual bertmask
    custom-legalbertmask+cls
    legal-bert-basemask+cls
    multilingual bertmask+cls

License

MIT © Huijie Pan