(attention_num=12)
return weight_map
build params map from paddle-paddle's ERNIE to transformer's BERT
    :return:
build params map from paddle-paddle's ERNIE to transformer's BERT
    :return:
build params map from paddle - paddle s ERNIE to transformer s BERT : return :
def build_params_map(attention_num=12):
    """
    build params map from paddle-paddle's ERNIE to transformer's BERT
    :return:
    """
    weight_map = collections.OrderedDict({
        'word_emb.weight': "bert.embeddings.word_embeddings.weight",
        'pos_emb.weight': "bert.embeddings.position_embeddings.weight",
        'sent_emb.weight': "bert.embeddings.token_type_embeddings.weight",
        'ln.weight': 'bert.embeddings.LayerNorm.gamma',
        'ln.bias': 'bert.embeddings.LayerNorm.beta',
    })
    # add attention layers
    for i in range(attention_num):
        weight_map[f'encoder_stack.block.{i}.attn.q.weight'] = f'bert.encoder.layer.{i}.attention.self.query.weight'
        weight_map[f'encoder_stack.block.{i}.attn.q.bias'] = f'bert.encoder.layer.{i}.attention.self.query.bias'
        weight_map[f'encoder_stack.block.{i}.attn.k.weight'] = f'bert.encoder.layer.{i}.attention.self.key.weight'
        weight_map[f'encoder_stack.block.{i}.attn.k.bias'] = f'bert.encoder.layer.{i}.attention.self.key.bias'
        weight_map[f'encoder_stack.block.{i}.attn.v.weight'] = f'bert.encoder.layer.{i}.attention.self.value.weight'
        weight_map[f'encoder_stack.block.{i}.attn.v.bias'] = f'bert.encoder.layer.{i}.attention.self.value.bias'
        weight_map[f'encoder_stack.block.{i}.attn.o.weight'] = f'bert.encoder.layer.{i}.attention.output.dense.weight'
        weight_map[f'encoder_stack.block.{i}.attn.o.bias'] = f'bert.encoder.layer.{i}.attention.output.dense.bias'
        weight_map[f'encoder_stack.block.{i}.ln1.weight'] = f'bert.encoder.layer.{i}.attention.output.LayerNorm.gamma'
        weight_map[f'encoder_stack.block.{i}.ln1.bias'] = f'bert.encoder.layer.{i}.attention.output.LayerNorm.beta'
        weight_map[f'encoder_stack.block.{i}.ffn.i.weight'] = f'bert.encoder.layer.{i}.intermediate.dense.weight'
        weight_map[f'encoder_stack.block.{i}.ffn.i.bias'] = f'bert.encoder.layer.{i}.intermediate.dense.bias'
        weight_map[f'encoder_stack.block.{i}.ffn.o.weight'] = f'bert.encoder.layer.{i}.output.dense.weight'
        weight_map[f'encoder_stack.block.{i}.ffn.o.bias'] = f'bert.encoder.layer.{i}.output.dense.bias'
        weight_map[f'encoder_stack.block.{i}.ln2.weight'] = f'bert.encoder.layer.{i}.output.LayerNorm.gamma'
        weight_map[f'encoder_stack.block.{i}.ln2.bias'] = f'bert.encoder.layer.{i}.output.LayerNorm.beta'
    # add pooler
    weight_map.update(
        {
            'pooler.weight': 'bert.pooler.dense.weight',
            'pooler.bias': 'bert.pooler.dense.bias',
            'mlm.weight': 'cls.predictions.transform.dense.weight',
            'mlm.bias': 'cls.predictions.transform.dense.bias',
            'mlm_ln.weight': 'cls.predictions.transform.LayerNorm.gamma',
            'mlm_ln.bias': 'cls.predictions.transform.LayerNorm.beta',
            'mlm_bias': 'cls.predictions.bias'
        }
    )
    return weight_map
def build_params_map ( attention_num = 12 ) : weight_map = collections . OrderedDict ( { 'word_emb.weight' : "bert.embeddings.word_embeddings.weight" , 'pos_emb.weight' : "bert.embeddings.position_embeddings.weight" , 'sent_emb.weight' : "bert.embeddings.token_type_embeddings.weight" , 'ln.weight' : 'bert.embeddings.LayerNorm.gamma' , 'ln.bias' : 'bert.embeddings.LayerNorm.beta' , } ) # add attention layers for i in range ( attention_num ) : weight_map [ f'encoder_stack.block.{i}.attn.q.weight' ] = f'bert.encoder.layer.{i}.attention.self.query.weight' weight_map [ f'encoder_stack.block.{i}.attn.q.bias' ] = f'bert.encoder.layer.{i}.attention.self.query.bias' weight_map [ f'encoder_stack.block.{i}.attn.k.weight' ] = f'bert.encoder.layer.{i}.attention.self.key.weight' weight_map [ f'encoder_stack.block.{i}.attn.k.bias' ] = f'bert.encoder.layer.{i}.attention.self.key.bias' weight_map [ f'encoder_stack.block.{i}.attn.v.weight' ] = f'bert.encoder.layer.{i}.attention.self.value.weight' weight_map [ f'encoder_stack.block.{i}.attn.v.bias' ] = f'bert.encoder.layer.{i}.attention.self.value.bias' weight_map [ f'encoder_stack.block.{i}.attn.o.weight' ] = f'bert.encoder.layer.{i}.attention.output.dense.weight' weight_map [ f'encoder_stack.block.{i}.attn.o.bias' ] = f'bert.encoder.layer.{i}.attention.output.dense.bias' weight_map [ f'encoder_stack.block.{i}.ln1.weight' ] = f'bert.encoder.layer.{i}.attention.output.LayerNorm.gamma' weight_map [ f'encoder_stack.block.{i}.ln1.bias' ] = f'bert.encoder.layer.{i}.attention.output.LayerNorm.beta' weight_map [ f'encoder_stack.block.{i}.ffn.i.weight' ] = f'bert.encoder.layer.{i}.intermediate.dense.weight' weight_map [ f'encoder_stack.block.{i}.ffn.i.bias' ] = f'bert.encoder.layer.{i}.intermediate.dense.bias' weight_map [ f'encoder_stack.block.{i}.ffn.o.weight' ] = f'bert.encoder.layer.{i}.output.dense.weight' weight_map [ f'encoder_stack.block.{i}.ffn.o.bias' ] = f'bert.encoder.layer.{i}.output.dense.bias' weight_map [ f'encoder_stack.block.{i}.ln2.weight' ] = f'bert.encoder.layer.{i}.output.LayerNorm.gamma' weight_map [ f'encoder_stack.block.{i}.ln2.bias' ] = f'bert.encoder.layer.{i}.output.LayerNorm.beta' # add pooler weight_map . update ( { 'pooler.weight' : 'bert.pooler.dense.weight' , 'pooler.bias' : 'bert.pooler.dense.bias' , 'mlm.weight' : 'cls.predictions.transform.dense.weight' , 'mlm.bias' : 'cls.predictions.transform.dense.bias' , 'mlm_ln.weight' : 'cls.predictions.transform.LayerNorm.gamma' , 'mlm_ln.bias' : 'cls.predictions.transform.LayerNorm.beta' , 'mlm_bias' : 'cls.predictions.bias' } ) return weight_map