lIlBrother
commited on
Commit
•
b854123
1
Parent(s):
97afca9
Init: 모델 최초 커밋
Browse files- README.md +89 -1
- config.json +112 -0
- preprocessor_config.json +10 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +6 -0
- tokenizer_config.json +13 -0
- vocab.json +74 -0
README.md
CHANGED
@@ -1,3 +1,91 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- ko # Example: fr
|
4 |
+
license: apache-2.0 # Example: apache-2.0 or any license from https://hf.co/docs/hub/repositories-licenses
|
5 |
+
library_name: transformers # Optional. Example: keras or any library from https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Libraries.ts
|
6 |
+
tags:
|
7 |
+
- audio
|
8 |
+
- automatic-speech-recognition
|
9 |
+
datasets:
|
10 |
+
- KsponSpeech
|
11 |
+
metrics:
|
12 |
+
- wer # Example: wer. Use metric id from https://hf.co/metrics
|
13 |
---
|
14 |
+
|
15 |
+
# ko-42maru-wav2vec2-conformer-del-1s
|
16 |
+
|
17 |
+
## Table of Contents
|
18 |
+
- [ko-42maru-wav2vec2-conformer-del-1s](#ko-42maru-wav2vec2-conformer-del-1s)
|
19 |
+
- [Table of Contents](#table-of-contents)
|
20 |
+
- [Model Details](#model-details)
|
21 |
+
- [Evaluation](#evaluation)
|
22 |
+
- [How to Get Started With the Model](#how-to-get-started-with-the-model)
|
23 |
+
|
24 |
+
## Model Details
|
25 |
+
- **Model Description:**
|
26 |
+
해당 모델은 wav2vec2-conformer base architecture에 scratch pre-training 되었습니다. <br />
|
27 |
+
Wav2Vec2ConformerForCTC를 이용하여 KsponSpeech에 대한 Fine-Tuning 모델입니다. <br />
|
28 |
+
|
29 |
+
- Dataset use [AIHub KsponSpeech](https://www.aihub.or.kr/aihubdata/data/view.do?currMenu=115&topMenu=100&aihubDataSe=realm&dataSetSn=123) <br />
|
30 |
+
Datasets는 해당 Data를 전처리하여 임의로 만들어 사용하였습니다. <br />
|
31 |
+
del-1s의 의미는 1초 이하의 데이터 필터링을 의미합니다. <br />
|
32 |
+
해당 모델은 **음성전사를 자체 커스텀한 42maru** 기준의 데이터로 학습된 모델입니다. (숫자와 영어는 한글 표기법을 따름) <br />
|
33 |
+
|
34 |
+
- **Developed by:** TADev (@lIlBrother, @ddobokki, @jp42maru)
|
35 |
+
- **Language(s):** Korean
|
36 |
+
- **License:** apache-2.0
|
37 |
+
- **Parent Model:** See the [wav2vec2-conformer](https://huggingface.co/docs/transformers/model_doc/wav2vec2-conformer) for more information about the pre-trained base model. (해당 모델은 wav2vec2-conformer base architecture에 scratch pre-training 되었습니다.)
|
38 |
+
|
39 |
+
## Evaluation
|
40 |
+
Just using `load_metric("wer")` and `load_metric("wer")` in huggingface `datasets` library <br />
|
41 |
+
|
42 |
+
## How to Get Started With the Model
|
43 |
+
```python
|
44 |
+
from transformers import (
|
45 |
+
AutoConfig,
|
46 |
+
AutoFeatureExtractor,
|
47 |
+
AutoModelForCTC,
|
48 |
+
AutoTokenizer,
|
49 |
+
Wav2Vec2ProcessorWithLM,
|
50 |
+
)
|
51 |
+
from transformers.pipelines import AutomaticSpeechRecognitionPipeline
|
52 |
+
import librosa
|
53 |
+
|
54 |
+
# 모델과 토크나이저, 예측을 위한 각 모듈들을 불러옵니다.
|
55 |
+
config = AutoConfig.from_pretrained(model_config_path)
|
56 |
+
model = AutoModelForCTC.from_pretrained(
|
57 |
+
model_name_or_path,
|
58 |
+
config=config,
|
59 |
+
)
|
60 |
+
feature_extractor = AutoFeatureExtractor.from_pretrained(model_name_or_path)
|
61 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
|
62 |
+
beamsearch_decoder = build_ctcdecoder(
|
63 |
+
labels=list(tokenizer.encoder.keys()),
|
64 |
+
kenlm_model_path=None,
|
65 |
+
)
|
66 |
+
processor = Wav2Vec2ProcessorWithLM(
|
67 |
+
feature_extractor=feature_extractor, tokenizer=tokenizer, decoder=beamsearch_decoder
|
68 |
+
)
|
69 |
+
|
70 |
+
# 실제 예측을 위한 파이프라인에 정의된 모듈들을 삽입.
|
71 |
+
asr_pipeline = AutomaticSpeechRecognitionPipeline(
|
72 |
+
model=model,
|
73 |
+
tokenizer=processor.tokenizer,
|
74 |
+
feature_extractor=processor.feature_extractor,
|
75 |
+
decoder=processor.decoder,
|
76 |
+
device=-1,
|
77 |
+
)
|
78 |
+
|
79 |
+
# 음성파일을 불러오고 beamsearch 파라미터를 특정하여 예측을 수행합니다.
|
80 |
+
raw_data, _ = librosa.load(audio_path, sr=16000)
|
81 |
+
kwargs = {"decoder_kwargs": {"beam_width": 100}}
|
82 |
+
pred = asr_pipeline(inputs=raw_data, **kwargs)["text"]
|
83 |
+
# 모델이 자소 분리 유니코드 텍스트로 나오므로, 일반 String으로 변환해줄 필요가 있습니다.
|
84 |
+
result = unicodedata.normalize("NFC", pred)
|
85 |
+
print(result)
|
86 |
+
# 안녕하세요 하나둘셋 테스트입니다.
|
87 |
+
```
|
88 |
+
*Beam-100 Result (WER)*:
|
89 |
+
| "clean" | "other" |
|
90 |
+
| ------- | ------- |
|
91 |
+
| 21.52 | 25.72 |
|
config.json
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "test42/wav2vec2-conformer-del-1s",
|
3 |
+
"activation_dropout": 0.1,
|
4 |
+
"adapter_kernel_size": 3,
|
5 |
+
"adapter_stride": 2,
|
6 |
+
"add_adapter": false,
|
7 |
+
"apply_spec_augment": true,
|
8 |
+
"architectures": [
|
9 |
+
"Wav2Vec2ConformerForCTC"
|
10 |
+
],
|
11 |
+
"attention_dropout": 0.1,
|
12 |
+
"bos_token_id": 1,
|
13 |
+
"classifier_proj_size": 256,
|
14 |
+
"codevector_dim": 256,
|
15 |
+
"conformer_conv_dropout": 0.1,
|
16 |
+
"contrastive_logits_temperature": 0.1,
|
17 |
+
"conv_bias": false,
|
18 |
+
"conv_depthwise_kernel_size": 31,
|
19 |
+
"conv_dim": [
|
20 |
+
512,
|
21 |
+
512,
|
22 |
+
512,
|
23 |
+
512,
|
24 |
+
512,
|
25 |
+
512,
|
26 |
+
512
|
27 |
+
],
|
28 |
+
"conv_kernel": [
|
29 |
+
10,
|
30 |
+
3,
|
31 |
+
3,
|
32 |
+
3,
|
33 |
+
3,
|
34 |
+
2,
|
35 |
+
2
|
36 |
+
],
|
37 |
+
"conv_stride": [
|
38 |
+
5,
|
39 |
+
2,
|
40 |
+
2,
|
41 |
+
2,
|
42 |
+
2,
|
43 |
+
2,
|
44 |
+
2
|
45 |
+
],
|
46 |
+
"ctc_loss_reduction": "mean",
|
47 |
+
"ctc_zero_infinity": true,
|
48 |
+
"diversity_loss_weight": 0.1,
|
49 |
+
"do_stable_layer_norm": true,
|
50 |
+
"eos_token_id": 2,
|
51 |
+
"feat_extract_activation": "gelu",
|
52 |
+
"feat_extract_norm": "layer",
|
53 |
+
"feat_proj_dropout": 0.0,
|
54 |
+
"feat_quantizer_dropout": 0.0,
|
55 |
+
"final_dropout": 0.1,
|
56 |
+
"hidden_act": "gelu",
|
57 |
+
"hidden_dropout": 0.1,
|
58 |
+
"hidden_dropout_prob": 0.1,
|
59 |
+
"hidden_size": 768,
|
60 |
+
"initializer_range": 0.02,
|
61 |
+
"intermediate_size": 3072,
|
62 |
+
"layer_norm_eps": 1e-05,
|
63 |
+
"layerdrop": 0.0,
|
64 |
+
"mask_feature_length": 64,
|
65 |
+
"mask_feature_min_masks": 0,
|
66 |
+
"mask_feature_prob": 0.05,
|
67 |
+
"mask_time_length": 10,
|
68 |
+
"mask_time_min_masks": 2,
|
69 |
+
"mask_time_prob": 0.05,
|
70 |
+
"max_source_positions": 5000,
|
71 |
+
"model_type": "wav2vec2-conformer",
|
72 |
+
"num_adapter_layers": 3,
|
73 |
+
"num_attention_heads": 12,
|
74 |
+
"num_codevector_groups": 2,
|
75 |
+
"num_codevectors_per_group": 320,
|
76 |
+
"num_conv_pos_embedding_groups": 16,
|
77 |
+
"num_conv_pos_embeddings": 128,
|
78 |
+
"num_feat_extract_layers": 7,
|
79 |
+
"num_hidden_layers": 12,
|
80 |
+
"num_negatives": 100,
|
81 |
+
"output_hidden_size": 768,
|
82 |
+
"pad_token_id": 0,
|
83 |
+
"position_embeddings_type": "relative",
|
84 |
+
"proj_codevector_dim": 256,
|
85 |
+
"rotary_embedding_base": 10000,
|
86 |
+
"tdnn_dilation": [
|
87 |
+
1,
|
88 |
+
2,
|
89 |
+
3,
|
90 |
+
1,
|
91 |
+
1
|
92 |
+
],
|
93 |
+
"tdnn_dim": [
|
94 |
+
512,
|
95 |
+
512,
|
96 |
+
512,
|
97 |
+
512,
|
98 |
+
1500
|
99 |
+
],
|
100 |
+
"tdnn_kernel": [
|
101 |
+
5,
|
102 |
+
3,
|
103 |
+
3,
|
104 |
+
1,
|
105 |
+
1
|
106 |
+
],
|
107 |
+
"torch_dtype": "float32",
|
108 |
+
"transformers_version": "4.20.1",
|
109 |
+
"use_weighted_layer_sum": false,
|
110 |
+
"vocab_size": 72,
|
111 |
+
"xvector_output_dim": 512
|
112 |
+
}
|
preprocessor_config.json
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"do_normalize": true,
|
3 |
+
"feature_extractor_type": "Wav2Vec2FeatureExtractor",
|
4 |
+
"feature_size": 1,
|
5 |
+
"padding_side": "right",
|
6 |
+
"padding_value": 0.0,
|
7 |
+
"processor_class": "Wav2Vec2Processor",
|
8 |
+
"return_attention_mask": true,
|
9 |
+
"sampling_rate": 16000
|
10 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d2763291f92b8e5e90fbbf27f44f290dcc24cdf5f4ff8ca14596a0e6fa6a0c0f
|
3 |
+
size 719408199
|
special_tokens_map.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"eos_token": "</s>",
|
4 |
+
"pad_token": "<pad>",
|
5 |
+
"unk_token": "<unk>"
|
6 |
+
}
|
tokenizer_config.json
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"do_lower_case": false,
|
4 |
+
"eos_token": "</s>",
|
5 |
+
"name_or_path": "test42/wav2vec2-conformer-del-1s",
|
6 |
+
"pad_token": "<pad>",
|
7 |
+
"processor_class": "Wav2Vec2Processor",
|
8 |
+
"replace_word_delimiter_char": " ",
|
9 |
+
"special_tokens_map_file": null,
|
10 |
+
"tokenizer_class": "Wav2Vec2CTCTokenizer",
|
11 |
+
"unk_token": "<unk>",
|
12 |
+
"word_delimiter_token": "|"
|
13 |
+
}
|
vocab.json
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"<pad>": 0,
|
3 |
+
"<unk>": 1,
|
4 |
+
"<s>": 2,
|
5 |
+
"</s>": 3,
|
6 |
+
"|": 4,
|
7 |
+
"\u1171": 5,
|
8 |
+
"\u11b4": 6,
|
9 |
+
"\u1165": 7,
|
10 |
+
"\u11ae": 8,
|
11 |
+
"\u110c": 9,
|
12 |
+
"\u116a": 10,
|
13 |
+
"\u110e": 11,
|
14 |
+
"\u11b3": 12,
|
15 |
+
"\u11bf": 13,
|
16 |
+
"\u116b": 14,
|
17 |
+
"\u11c1": 15,
|
18 |
+
"\u1163": 16,
|
19 |
+
"\u11aa": 17,
|
20 |
+
"\u110d": 18,
|
21 |
+
"\u1173": 19,
|
22 |
+
"\u11ba": 20,
|
23 |
+
"\u1169": 21,
|
24 |
+
"\u1174": 22,
|
25 |
+
"\u1112": 23,
|
26 |
+
"\u11c2": 24,
|
27 |
+
"\u11ab": 25,
|
28 |
+
"\u11b5": 26,
|
29 |
+
"\u1167": 27,
|
30 |
+
"\u11b6": 28,
|
31 |
+
"\u1168": 29,
|
32 |
+
"\u1161": 30,
|
33 |
+
"\u11ad": 31,
|
34 |
+
"\u1170": 32,
|
35 |
+
"\u11bd": 33,
|
36 |
+
"\u11b8": 34,
|
37 |
+
"\u11b1": 35,
|
38 |
+
"\u1109": 36,
|
39 |
+
"\u11bb": 37,
|
40 |
+
"\u11af": 38,
|
41 |
+
"\u116d": 39,
|
42 |
+
"\u1103": 40,
|
43 |
+
"\u11a9": 41,
|
44 |
+
"\u1175": 42,
|
45 |
+
"\u1101": 43,
|
46 |
+
"\u1111": 44,
|
47 |
+
"\u1162": 45,
|
48 |
+
"\u1110": 46,
|
49 |
+
"\u1164": 47,
|
50 |
+
"\u1108": 48,
|
51 |
+
"\u116e": 49,
|
52 |
+
"\u1104": 50,
|
53 |
+
"\u1102": 51,
|
54 |
+
"\u116f": 52,
|
55 |
+
"\u110a": 53,
|
56 |
+
"\u1105": 54,
|
57 |
+
"\u11b7": 55,
|
58 |
+
"\u1106": 56,
|
59 |
+
"\u11b9": 57,
|
60 |
+
"\u116c": 58,
|
61 |
+
"\u1100": 59,
|
62 |
+
"\u11ac": 60,
|
63 |
+
"\u1107": 61,
|
64 |
+
"\u1166": 62,
|
65 |
+
"\u11b0": 63,
|
66 |
+
"\u11bc": 64,
|
67 |
+
"\u11b2": 65,
|
68 |
+
"\u11be": 66,
|
69 |
+
"\u110b": 67,
|
70 |
+
"\u11c0": 68,
|
71 |
+
"\u11a8": 69,
|
72 |
+
"\u110f": 70,
|
73 |
+
"\u1172": 71
|
74 |
+
}
|