预训练模型
可以运用 TF-Hub 模块:
Base
[Tar File]:
https://storage.谷歌apis.com/albert_models/albert_base_v1.tar.gz
[TF-Hub]:
https://tfhub.dev/谷歌/albert_base/1
Large
[Tar File]:
https://storage.谷歌apis.com/albert_models/albert_large_v1.tar.gz
[TF-Hub]:
https://tfhub.dev/谷歌/albert_large/1
XLarge
[Tar File]:
https://storage.谷歌apis.com/albert_models/albert_xlarge_v1.tar.gz
[TF-Hub]:
https://tfhub.dev/谷歌/albert_xlarge/1
Xxlarge
[Tar File]:
https://storage.谷歌apis.com/albert_models/albert_xxlarge_v1.tar.gz
[TF-Hub]:
https://tfhub.dev/谷歌/albert_xxlarge/1
TF-Hub模块运用示例:
tags=set()ifis_training:tags.add("train")albert_module=hub.Module("https://tfhub.dev/谷歌/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:
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:
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模块末尾微调模型:
albert_hub_module_handle==https://tfhub.dev/谷歌/albert_base/1
在评价之后,脚本应该报告如下输入:
*****Evalresults*****global_step=...loss=...masked_lm_accuracy=...masked_lm_loss=...sentence_order_accuracy=...sentence_order_loss=...
在SQuAD上微调要对 SQuAD v1上的预训练模型停止微谐和评价,请运用 run SQuAD v1.py 脚本:
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 脚本:
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/谷歌-research/ALBERT
【编辑引荐】
NeurIPS 2019:谷歌提出改良机器学习散布外异常检测新办法
机器学习毕业生末尾忧虑找任务了!毕业生和企业,终究谁更挑剔?
华为印度高管正告谷歌:我们简直曾经预备好交流你
实测两款GitHub开源插件,坑都帮你踩过了
2019年12月份Github抢手开源项目排行
(责任编辑:admin)