138 Star 952 Fork 660

MindSpore/mindformers

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
run_tokcls_bert_base_chinese_cluener.yaml 5.62 KB
一键复制 编辑 原始数据 按行查看 历史
yiyison 提交于 2024-08-07 19:33 . 删除graph_kernel_flags相关信息
seed: 42
run_mode: 'train'
output_dir: './output' # path to save checkpoint/strategy
load_checkpoint: ''
src_strategy_path_or_dir: ''
auto_trans_ckpt: False # If true, auto transform load_checkpoint to load in distributed model
only_save_strategy: False
resume_training: False
# context
context:
mode: 0 #0--Graph Mode; 1--Pynative Mode
device_target: "Ascend"
enable_graph_kernel: False
max_call_depth: 10000
save_graphs: False
device_id: 0
# aicc
remote_save_url: "Please input obs url on AICC platform."
# runner
runner_config:
epochs: 3
batch_size: 24
sink_mode: False
sink_size: 2
runner_wrapper:
type: TrainOneStepCell
# parallel
use_parallel: False
parallel:
parallel_mode: 0 # 0-data parallel, 1-semi-auto parallel, 2-auto parallel, 3-hybrid parallel
gradients_mean: True
enable_alltoall: False
full_batch: False
search_mode: "sharding_propagation"
enable_parallel_optimizer: False
strategy_ckpt_save_file: "./ckpt_strategy.ckpt"
parallel_config:
data_parallel: 1
model_parallel: 1
expert_parallel: 1
pipeline_stage: 1
micro_batch_num: 1
gradient_aggregation_group: 4
micro_batch_interleave_num: 1
# moe
moe_config:
expert_num: 1
capacity_factor: 1.05
aux_loss_factor: 0.05
num_experts_chosen: 1
# recompute
recompute: False
parallel_optimizer_comm_recompute: False
mp_comm_recompute: True
recompute_slice_activation: False
# autotune
auto_tune: False
filepath_prefix: './autotune'
autotune_per_step: 10
# profile
profile: False
profile_start_step: 1
profile_stop_step: 10
init_start_profile: False
profile_communication: False
profile_memory: True
# Trainer
trainer:
type: TokenClassificationTrainer
model_name: tokcls_bert_base_chinese_cluener
# if True, do evaluate during the training process. if false, do nothing.
# note that the task trainer should support _evaluate_in_training function.
do_eval: False
# train dataset
train_dataset: &train_dataset
data_loader:
type: CLUENERDataLoader
dataset_dir: "./cluener/"
stage: "train"
column_names: ["text", "label_id"]
text_transforms:
type: TokenizeWithLabel
max_length: 128
padding: "max_length"
label_transforms:
type: LabelPadding
max_length: 128
padding_value: 0
tokenizer:
type: BertTokenizer
cls_token: '[CLS]'
mask_token: '[MASK]'
pad_token: '[PAD]'
sep_token: '[SEP]'
unk_token: '[UNK]'
is_tokenize_char: True
do_lower_case: False
checkpoint_name_or_path: tokcls_bert_base_chinese
input_columns: ["text", "label_id"]
output_columns: ["input_ids", "token_type_ids", "attention_mask", "label_id"]
column_order: ["input_ids", "token_type_ids", "attention_mask", "label_id"]
num_parallel_workers: 8
python_multiprocessing: False
drop_remainder: True
batch_size: 24
repeat: 1
numa_enable: False
prefetch_size: 30
seed: 2022
train_dataset_task:
type: TokenClassificationDataset
dataset_config: *train_dataset
# eval dataset
eval_dataset: &eval_dataset
data_loader:
type: CLUENERDataLoader
dataset_dir: "./cluener/"
stage: "dev"
column_names: ["text", "label_id"]
text_transforms:
type: TokenizeWithLabel
max_length: 128
padding: "max_length"
label_transforms:
type: LabelPadding
max_length: 128
padding_value: 0
tokenizer:
type: BertTokenizer
cls_token: '[CLS]'
mask_token: '[MASK]'
pad_token: '[PAD]'
sep_token: '[SEP]'
unk_token: '[UNK]'
is_tokenize_char: True
do_lower_case: False
checkpoint_name_or_path: tokcls_bert_base_chinese
input_columns: ["text", "label_id"]
output_columns: ["input_ids", "token_type_ids", "attention_mask", "label_id"]
column_order: ["input_ids", "token_type_ids", "attention_mask", "label_id"]
num_parallel_workers: 8
python_multiprocessing: False
drop_remainder: True
batch_size: 24
repeat: 1
numa_enable: False
prefetch_size: 30
seed: 2022
eval_dataset_task:
type: TokenClassificationDataset
dataset_config: *eval_dataset
# model
model:
model_config:
type: BertConfig
use_one_hot_embeddings: False
num_labels: 31
dropout_prob: 0.1
batch_size: 24
seq_length: 128 # length of input sentence
vocab_size: 21128 # size of vocab
embedding_size: 768 # size of text feature
num_layers: 12 # model depth
num_heads: 12 # number of attention heads
expand_ratio: 4
hidden_act: "gelu" # activation
post_layernorm_residual: True # select postlayernorm or prelayernorm
hidden_dropout_prob: 0.1
attention_probs_dropout_prob: 0.1
max_position_embeddings: 512
type_vocab_size: 2
initializer_range: 0.02
use_relative_positions: False
use_past: False
compute_dtype: "float32"
checkpoint_name_or_path: "tokcls_bert_base_chinese_cluener"
arch:
type: BertForTokenClassification
# lr schedule
lr_schedule:
type: linear
learning_rate: 0.00003 # 3e-5
warmup_ratio: 0.1
total_steps: -1 # -1 means it will load the total steps of the dataset
layer_scale: False
layer_decay: 0.65
# optimizer
optimizer:
type: adamw
weight_decay: 0.01
eps: 0.00000001 # 1e-8
lr_scale: False
lr_scale_factor: 256
# callbacks
callbacks:
- type: MFLossMonitor
- type: CheckpointMonitor
prefix: "mindformers"
save_checkpoint_steps: 100
integrated_save: True
async_save: False
eval_callbacks:
- type: ObsMonitor
# metric
metric:
type: EntityScore
# processor
processor:
type: BertProcessor
return_tensors: ms
tokenizer:
type: BertTokenizer
cls_token: '[CLS]'
mask_token: '[MASK]'
pad_token: '[PAD]'
sep_token: '[SEP]'
unk_token: '[UNK]'
is_tokenize_char: True
do_lower_case: False
checkpoint_name_or_path: tokcls_bert_base_chinese
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mindspore/mindformers.git
git@gitee.com:mindspore/mindformers.git
mindspore
mindformers
mindformers
dev

搜索帮助