CoolFace
Modelpublic

microsoft/Multilingual-MiniLM-L12-H384

sourceHugging Facemitupdated 4y agoView on Hugging Face
111likes89kdownloads
README.md107 linesDownload Raw Back to root
1---2language: 3- multilingual4- en 5- ar 6- bg 7- de 8- el 9- es 10- fr 11- hi 12- ru 13- sw 14- th 15- tr 16- ur 17- vi 18- zh19thumbnail: https://huggingface.co/front/thumbnails/microsoft.png20tags:21- text-classification22license: mit23---24 25## MiniLM: Small and Fast Pre-trained Models for Language Understanding and Generation26 27MiniLM is a distilled model from the paper "[MiniLM: Deep Self-Attention Distillation for Task-Agnostic Compression of Pre-Trained Transformers](https://arxiv.org/abs/2002.10957)".28 29Please find the information about preprocessing, training and full details of the MiniLM in the [original MiniLM repository](https://github.com/microsoft/unilm/blob/master/minilm/).30 31Please note: This checkpoint uses `BertModel` with `XLMRobertaTokenizer` so `AutoTokenizer` won't work with this checkpoint!32 33### Multilingual Pretrained Model34- Multilingual-MiniLMv1-L12-H384: 12-layer, 384-hidden, 12-heads, 21M Transformer parameters, 96M embedding parameters35 36Multilingual MiniLM uses the same tokenizer as XLM-R. But the Transformer architecture of our model is the same as BERT. We provide the fine-tuning code on XNLI based on [huggingface/transformers](https://github.com/huggingface/transformers). Please replace `run_xnli.py` in transformers with [ours](https://github.com/microsoft/unilm/blob/master/minilm/examples/run_xnli.py) to fine-tune multilingual MiniLM.  37 38We evaluate the multilingual MiniLM on cross-lingual natural language inference benchmark (XNLI) and cross-lingual question answering benchmark (MLQA).39 40#### Cross-Lingual Natural Language Inference - [XNLI](https://arxiv.org/abs/1809.05053)41 42We evaluate our model on cross-lingual transfer from English to other languages. Following [Conneau et al. (2019)](https://arxiv.org/abs/1911.02116), we select the best single model on the joint dev set of all the languages.43 44| Model                                                                                       | #Layers | #Hidden | #Transformer Parameters | Average | en   | fr   | es   | de   | el   | bg   | ru   | tr   | ar   | vi   | th   | zh   | hi   | sw   | ur   |45|---------------------------------------------------------------------------------------------|---------|---------|-------------------------|---------|------|------|------|------|------|------|------|------|------|------|------|------|------|------|------|46| [mBERT](https://github.com/google-research/bert)                                            | 12      | 768     | 85M                     | 66.3    | 82.1 | 73.8 | 74.3 | 71.1 | 66.4 | 68.9 | 69.0 | 61.6 | 64.9 | 69.5 | 55.8 | 69.3 | 60.0 | 50.4 | 58.0 |47| [XLM-100](https://github.com/facebookresearch/XLM#pretrained-cross-lingual-language-models) | 16      | 1280    | 315M                    | 70.7    | 83.2 | 76.7 | 77.7 | 74.0 | 72.7 | 74.1 | 72.7 | 68.7 | 68.6 | 72.9 | 68.9 | 72.5 | 65.6 | 58.2 | 62.4 |48| [XLM-R Base](https://arxiv.org/abs/1911.02116)                                              | 12      | 768     | 85M                     | 74.5    | 84.6 | 78.4 | 78.9 | 76.8 | 75.9 | 77.3 | 75.4 | 73.2 | 71.5 | 75.4 | 72.5 | 74.9 | 71.1 | 65.2 | 66.5 |49| **mMiniLM-L12xH384**                                                                        | 12      | 384     | 21M                     | 71.1    | 81.5 | 74.8 | 75.7 | 72.9 | 73.0 | 74.5 | 71.3 | 69.7 | 68.8 | 72.1 | 67.8 | 70.0 | 66.2 | 63.3 | 64.2 |50 51This example code fine-tunes **12**-layer multilingual MiniLM on XNLI.52 53```bash54# run fine-tuning on XNLI55DATA_DIR=/{path_of_data}/56OUTPUT_DIR=/{path_of_fine-tuned_model}/57MODEL_PATH=/{path_of_pre-trained_model}/58 59python ./examples/run_xnli.py --model_type minilm \60 --output_dir ${OUTPUT_DIR} --data_dir ${DATA_DIR} \61 --model_name_or_path microsoft/Multilingual-MiniLM-L12-H384 \62 --tokenizer_name xlm-roberta-base \63 --config_name ${MODEL_PATH}/multilingual-minilm-l12-h384-config.json \64 --do_train \65 --do_eval \66 --max_seq_length 128 \67 --per_gpu_train_batch_size 128 \68 --learning_rate 5e-5 \69 --num_train_epochs 5 \70 --per_gpu_eval_batch_size 32 \71 --weight_decay 0.001 \72 --warmup_steps 500 \73 --save_steps 1500 \74 --logging_steps 1500 \75 --eval_all_checkpoints \76 --language en \77 --fp16 \78 --fp16_opt_level O279```80 81#### Cross-Lingual Question Answering - [MLQA](https://arxiv.org/abs/1910.07475)82 83Following [Lewis et al. (2019b)](https://arxiv.org/abs/1910.07475), we adopt SQuAD 1.1 as training data and use MLQA English development data for early stopping.84 85| Model F1 Score                                                                             | #Layers | #Hidden | #Transformer Parameters | Average | en   | es   | de   | ar   | hi   | vi   | zh   |86|--------------------------------------------------------------------------------------------|---------|---------|-------------------------|---------|------|------|------|------|------|------|------|87| [mBERT](https://github.com/google-research/bert)                                           | 12      | 768     | 85M                     | 57.7    | 77.7 | 64.3 | 57.9 | 45.7 | 43.8 | 57.1 | 57.5 |88| [XLM-15](https://github.com/facebookresearch/XLM#pretrained-cross-lingual-language-models) | 12      | 1024    | 151M                    | 61.6    | 74.9 | 68.0 | 62.2 | 54.8 | 48.8 | 61.4 | 61.1 |89| [XLM-R Base](https://arxiv.org/abs/1911.02116) (Reported)                                  | 12      | 768     | 85M                     | 62.9    | 77.8 | 67.2 | 60.8 | 53.0 | 57.9 | 63.1 | 60.2 |90| [XLM-R Base](https://arxiv.org/abs/1911.02116) (Our fine-tuned)                            | 12      | 768     | 85M                     | 64.9    | 80.3 | 67.0 | 62.7 | 55.0 | 60.4 | 66.5 | 62.3 |91| **mMiniLM-L12xH384**                                                                       | 12      | 384     | 21M                     | 63.2    | 79.4 | 66.1 | 61.2 | 54.9 | 58.5 | 63.1 | 59.0 |92 93### Citation94 95If you find MiniLM useful in your research, please cite the following paper:96 97``` latex98@misc{wang2020minilm,99    title={MiniLM: Deep Self-Attention Distillation for Task-Agnostic Compression of Pre-Trained Transformers},100    author={Wenhui Wang and Furu Wei and Li Dong and Hangbo Bao and Nan Yang and Ming Zhou},101    year={2020},102    eprint={2002.10957},103    archivePrefix={arXiv},104    primaryClass={cs.CL}105}106```107