add bert
This commit is contained in:
9
bert/chinese-roberta-wwm-ext-large/.gitattributes
vendored
Normal file
9
bert/chinese-roberta-wwm-ext-large/.gitattributes
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
57
bert/chinese-roberta-wwm-ext-large/README.md
Normal file
57
bert/chinese-roberta-wwm-ext-large/README.md
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
language:
|
||||
- zh
|
||||
tags:
|
||||
- bert
|
||||
license: "apache-2.0"
|
||||
---
|
||||
|
||||
# Please use 'Bert' related functions to load this model!
|
||||
|
||||
## Chinese BERT with Whole Word Masking
|
||||
For further accelerating Chinese natural language processing, we provide **Chinese pre-trained BERT with Whole Word Masking**.
|
||||
|
||||
**[Pre-Training with Whole Word Masking for Chinese BERT](https://arxiv.org/abs/1906.08101)**
|
||||
Yiming Cui, Wanxiang Che, Ting Liu, Bing Qin, Ziqing Yang, Shijin Wang, Guoping Hu
|
||||
|
||||
This repository is developed based on:https://github.com/google-research/bert
|
||||
|
||||
You may also interested in,
|
||||
- Chinese BERT series: https://github.com/ymcui/Chinese-BERT-wwm
|
||||
- Chinese MacBERT: https://github.com/ymcui/MacBERT
|
||||
- Chinese ELECTRA: https://github.com/ymcui/Chinese-ELECTRA
|
||||
- Chinese XLNet: https://github.com/ymcui/Chinese-XLNet
|
||||
- Knowledge Distillation Toolkit - TextBrewer: https://github.com/airaria/TextBrewer
|
||||
|
||||
More resources by HFL: https://github.com/ymcui/HFL-Anthology
|
||||
|
||||
## Citation
|
||||
If you find the technical report or resource is useful, please cite the following technical report in your paper.
|
||||
- Primary: https://arxiv.org/abs/2004.13922
|
||||
```
|
||||
@inproceedings{cui-etal-2020-revisiting,
|
||||
title = "Revisiting Pre-Trained Models for {C}hinese Natural Language Processing",
|
||||
author = "Cui, Yiming and
|
||||
Che, Wanxiang and
|
||||
Liu, Ting and
|
||||
Qin, Bing and
|
||||
Wang, Shijin and
|
||||
Hu, Guoping",
|
||||
booktitle = "Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: Findings",
|
||||
month = nov,
|
||||
year = "2020",
|
||||
address = "Online",
|
||||
publisher = "Association for Computational Linguistics",
|
||||
url = "https://www.aclweb.org/anthology/2020.findings-emnlp.58",
|
||||
pages = "657--668",
|
||||
}
|
||||
```
|
||||
- Secondary: https://arxiv.org/abs/1906.08101
|
||||
```
|
||||
@article{chinese-bert-wwm,
|
||||
title={Pre-Training with Whole Word Masking for Chinese BERT},
|
||||
author={Cui, Yiming and Che, Wanxiang and Liu, Ting and Qin, Bing and Yang, Ziqing and Wang, Shijin and Hu, Guoping},
|
||||
journal={arXiv preprint arXiv:1906.08101},
|
||||
year={2019}
|
||||
}
|
||||
```
|
||||
1
bert/chinese-roberta-wwm-ext-large/added_tokens.json
Normal file
1
bert/chinese-roberta-wwm-ext-large/added_tokens.json
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
28
bert/chinese-roberta-wwm-ext-large/config.json
Normal file
28
bert/chinese-roberta-wwm-ext-large/config.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"architectures": [
|
||||
"BertForMaskedLM"
|
||||
],
|
||||
"attention_probs_dropout_prob": 0.1,
|
||||
"bos_token_id": 0,
|
||||
"directionality": "bidi",
|
||||
"eos_token_id": 2,
|
||||
"hidden_act": "gelu",
|
||||
"hidden_dropout_prob": 0.1,
|
||||
"hidden_size": 1024,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 4096,
|
||||
"layer_norm_eps": 1e-12,
|
||||
"max_position_embeddings": 512,
|
||||
"model_type": "bert",
|
||||
"num_attention_heads": 16,
|
||||
"num_hidden_layers": 24,
|
||||
"output_past": true,
|
||||
"pad_token_id": 0,
|
||||
"pooler_fc_size": 768,
|
||||
"pooler_num_attention_heads": 12,
|
||||
"pooler_num_fc_layers": 3,
|
||||
"pooler_size_per_head": 128,
|
||||
"pooler_type": "first_token_transform",
|
||||
"type_vocab_size": 2,
|
||||
"vocab_size": 21128
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
||||
1
bert/chinese-roberta-wwm-ext-large/tokenizer.json
Normal file
1
bert/chinese-roberta-wwm-ext-large/tokenizer.json
Normal file
File diff suppressed because one or more lines are too long
1
bert/chinese-roberta-wwm-ext-large/tokenizer_config.json
Normal file
1
bert/chinese-roberta-wwm-ext-large/tokenizer_config.json
Normal file
@@ -0,0 +1 @@
|
||||
{"init_inputs": []}
|
||||
21128
bert/chinese-roberta-wwm-ext-large/vocab.txt
Normal file
21128
bert/chinese-roberta-wwm-ext-large/vocab.txt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -12,7 +12,6 @@ import monotonic_align
|
||||
from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d
|
||||
from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm
|
||||
|
||||
from GST import GST
|
||||
from commons import init_weights, get_padding
|
||||
from text import symbols, num_tones, num_languages
|
||||
|
||||
@@ -402,7 +401,7 @@ class ReferenceEncoder(nn.Module):
|
||||
outputs --- [N, ref_enc_gru_size]
|
||||
'''
|
||||
|
||||
def __init__(self, spec_channels):
|
||||
def __init__(self, spec_channels, gin_channels=0):
|
||||
|
||||
super().__init__()
|
||||
self.spec_channels = spec_channels
|
||||
@@ -421,6 +420,7 @@ class ReferenceEncoder(nn.Module):
|
||||
self.gru = nn.GRU(input_size=ref_enc_filters[-1] * out_channels,
|
||||
hidden_size=256 // 2,
|
||||
batch_first=True)
|
||||
self.proj = nn.Linear(128, gin_channels)
|
||||
|
||||
def forward(self, inputs, mask=None):
|
||||
N = inputs.size(0)
|
||||
@@ -438,7 +438,7 @@ class ReferenceEncoder(nn.Module):
|
||||
self.gru.flatten_parameters()
|
||||
memory, out = self.gru(out) # out --- [1, N, 128]
|
||||
|
||||
return out.squeeze(0)
|
||||
return self.proj(out.squeeze(0))
|
||||
|
||||
def calculate_channels(self, L, kernel_size, stride, pad, n_convs):
|
||||
for i in range(n_convs):
|
||||
@@ -515,7 +515,7 @@ class SynthesizerTrn(nn.Module):
|
||||
if n_speakers > 1:
|
||||
self.emb_g = nn.Embedding(n_speakers, gin_channels)
|
||||
else:
|
||||
self.ref_enc = ReferenceEncoder()
|
||||
self.ref_enc = ReferenceEncoder(spec_channels)
|
||||
|
||||
def forward(self, x, x_lengths, y, y_lengths, sid, tone, language, bert):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user