谷歌ALBERT模型V2+中文版来了,GitHub热榜第二

新闻 前端
比BERT模型参数小18倍,性能还超越了它。这就是谷歌前不久发布的轻量级BERT模型——ALBERT。

 本文经AI新媒体量子位(公众号ID:QbitAI)授权转载,转载请联系出处。

比BERT模型参数小18倍,性能还超越了它。

这就是谷歌前不久发布的轻量级BERT模型——ALBERT

不仅如此,还横扫各大“性能榜”,在SQuAD和RACE测试上创造了新的SOTA。

而最近,谷歌开源了中文版本和Version 2,项目还登上了GitHub热榜第二

<span><span><span><i style=谷歌ALBERT模型V2+中文版来了,GitHub热榜第二">

ALBERT 2性能再次提升

在这个版本中,“no dropout”、“additional training data”、“long training time”策略将应用到所有的模型。

与初代ALBERT性能相比结果如下。

<span><span><span><i style=谷歌ALBERT模型V2+中文版来了,GitHub热榜第二">

从性能的比较来说,对于ALBERT-base、ALBERT-large和ALBERT-xlarge,v2版要比v1版好得多。

说明采用上述三个策略的重要性。

平均来看,ALBERT-xxlarge比v1略差一些,原因有以下2点:

额外训练了1.5M步(两个模型的唯一区别就是训练1.5M和3M步);
对于v1,在BERT、Roberta和XLnet给出的参数集中做了一点超参数搜索;对于v2,只是采用除RACE之外的V1参数,其中使用的学习率为1e-5和0 ALBERT DR。

总的来说,Albert是BERT的轻量版, 使用减少参数的技术,允许大规模的配置,克服以前的内存限制。

<span><span><span><i style=谷歌ALBERT模型V2+中文版来了,GitHub热榜第二">

Albert使用了一个单模型设置,在 GLUE 基准测试中的性能:

<span><span><span><i style=谷歌ALBERT模型V2+中文版来了,GitHub热榜第二">

Albert-xxl使用了一个单模型设置,在SQuaD和RACE基准测试中的性能:

<span><span><span><i style=谷歌ALBERT模型V2+中文版来了,GitHub热榜第二">

中文版下载地址

Base
https://storage.googleapis.com/albert_models/albert_base_zh.tar.gz

Large
https://storage.googleapis.com/albert_models/albert_large_zh.tar.gz

XLarge
https://storage.googleapis.com/albert_models/albert_xlarge_zh.tar.gz

Xxlarge
https://storage.googleapis.com/albert_models/albert_xxlarge_zh.tar.gz

ALBERT v2下载地址

Base
[Tar File]:
https://storage.googleapis.com/albert_models/albert_base_v2.tar.gz
[TF-Hub]:
https://tfhub.dev/google/albert_base/2

Large
[Tar File]:
https://storage.googleapis.com/albert_models/albert_large_v2.tar.gz
[TF-Hub]:
https://tfhub.dev/google/albert_large/2

XLarge
[Tar File]:
https://storage.googleapis.com/albert_models/albert_xlarge_v2.tar.gz
[TF-Hub]:
https://tfhub.dev/google/albert_xlarge/2

Xxlarge
[Tar File]:
https://storage.googleapis.com/albert_models/albert_xxlarge_v2.tar.gz
[TF-Hub]:
https://tfhub.dev/google/albert_xxlarge/2

预训练模型

可以使用 TF-Hub 模块:

Base
[Tar File]:
https://storage.googleapis.com/albert_models/albert_base_v1.tar.gz
[TF-Hub]:
https://tfhub.dev/google/albert_base/1

Large
[Tar File]:
https://storage.googleapis.com/albert_models/albert_large_v1.tar.gz
[TF-Hub]:
https://tfhub.dev/google/albert_large/1

XLarge
[Tar File]:
https://storage.googleapis.com/albert_models/albert_xlarge_v1.tar.gz
[TF-Hub]:
https://tfhub.dev/google/albert_xlarge/1

Xxlarge
[Tar File]:
https://storage.googleapis.com/albert_models/albert_xxlarge_v1.tar.gz
[TF-Hub]:
https://tfhub.dev/google/albert_xxlarge/1

TF-Hub模块使用示例:

  1. tags=set()ifis_training:tags.add("train")albert_module=hub.Module("https://tfhub.dev/google/albert_base/1",tags=tags,trainable=True)albert_inputs=dict(input_ids=input_ids,input_mask=input_mask,segment_ids=segment_ids)albert_outputs=albert_module(inputs=albert_inputs,signature="tokens",as_dict=True)#Ifyouwanttousethetoken-leveloutput,use#albert_outputs["sequence_output"]instead.output_layer=albert_outputs["pooled_output"

预训练说明

要预训练ALBERT,可以使用run_pretraining.py:

  1. pipinstall-ralbert/requirements.txtpython-malbert.run_pretraining\--input_file=...\--output_dir=...\--init_checkpoint=...\--albert_config_file=...\--do_train\--do_eval\--train_batch_size=4096\--eval_batch_size=64\--max_seq_length=512\--max_predictions_per_seq=20\--optimizer='lamb'\--learning_rate=.00176\--num_train_steps=125000\--num_warmup_steps=3125\--save_checkpoints_steps=5000 

GLUE上的微调

要对 GLUE 进行微调和评估,可以参阅该项目中的run_glue.sh文件。

底层的用例可能希望直接使用run_classifier.py脚本。

run_classifier.py可对各个 GLUE 基准测试任务进行微调和评估。

比如 MNLI:

  1. pipinstall-ralbert/requirements.txtpython-malbert.run_classifier\--vocab_file=...\--data_dir=...\--output_dir=...\--init_checkpoint=...\--albert_config_file=...\--spm_model_file=...\--do_train\--do_eval\--do_predict\--do_lower_case\--max_seq_length=128\--optimizer=adamw\--task_name=MNLI\--warmup_step=1000\--learning_rate=3e-5\--train_step=10000\--save_checkpoints_steps=100\--train_batch_size=128 

可以在run_glue.sh中找到每个GLUE任务的default flag。

从TF-Hub模块开始微调模型:

  1. albert_hub_module_handle==https://tfhub.dev/google/albert_base/1 

在评估之后,脚本应该报告如下输出:

  1. *****Evalresults*****global_step=...loss=...masked_lm_accuracy=...masked_lm_loss=...sentence_order_accuracy=...sentence_order_loss=... 

在SQuAD上微调

要对 SQuAD v1上的预训练模型进行微调和评估,请使用 run SQuAD v1.py 脚本:

  1. pipinstall-ralbert/requirements.txtpython-malbert.run_squad_v1\--albert_config_file=...\--vocab_file=...\--output_dir=...\--train_file=...\--predict_file=...\--train_feature_file=...\--predict_feature_file=...\--predict_feature_left_file=...\--init_checkpoint=...\--spm_model_file=...\--do_lower_case\--max_seq_length=384\--doc_stride=128\--max_query_length=64\--do_train=true\--do_predict=true\--train_batch_size=48\--predict_batch_size=8\--learning_rate=5e-5\--num_train_epochs=2.0\--warmup_proportion=.1\--save_checkpoints_steps=5000\--n_best_size=20\--max_answer_length=30 

对于 SQuAD v2,使用 run SQuAD v2.py 脚本:

  1. pipinstall-ralbert/requirements.txtpython-malbert.run_squad_v2\--albert_config_file=...\--vocab_file=...\--output_dir=...\--train_file=...\--predict_file=...\--train_feature_file=...\--predict_feature_file=...\--predict_feature_left_file=...\--init_checkpoint=...\--spm_model_file=...\--do_lower_case\--max_seq_length=384\--doc_stride=128\--max_query_length=64\--do_train\--do_predict\--train_batch_size=48\--predict_batch_size=8\--learning_rate=5e-5\--num_train_epochs=2.0\--warmup_proportion=.1\--save_checkpoints_steps=5000\--n_best_size=20\--max_answer_length=30 

传送门

GitHub项目地址:
https://github.com/google-research/ALBERT

 

责任编辑:张燕妮 来源: 量子位
相关推荐

2022-06-02 15:10:35

AI数据模型

2019-09-02 14:58:03

深度学习编程人工智能

2023-02-28 12:56:15

AIChatGPT

2009-03-05 09:41:54

谷歌浏览器中文版

2024-02-21 15:05:30

2019-12-04 15:00:04

GitHub 技术开源

2019-06-30 15:10:45

GitHub中文版程序员

2009-11-18 09:36:22

谷歌操作系统Chrome OS

2023-03-22 07:51:11

2023-05-16 20:04:35

QQMidjourney机器人

2022-12-12 10:28:40

ChatGPTAI

2023-05-26 14:10:00

模型AI

2009-08-18 16:19:57

Google Insi

2010-05-28 18:07:47

TortoiseSVN

2019-11-18 09:44:51

GitHub代码开发者

2019-12-26 15:31:17

腾讯框架开源

2023-10-10 07:19:07

Github开源库系统

2019-08-20 15:22:40

GitHub代码开发者

2023-10-20 12:45:00

AI数据

2023-08-04 13:22:46

AI开源
点赞
收藏

51CTO技术栈公众号