Update README.md
This commit is contained in:
parent
698a3d155e
commit
aaab3794b6
80
README.md
80
README.md
|
@ -23,7 +23,7 @@ model-index:
|
|||
metrics:
|
||||
- name: Test WER
|
||||
type: wer
|
||||
value: 12.90
|
||||
value: 12.77
|
||||
---
|
||||
|
||||
# Wav2Vec2-Large-XLSR-53-German
|
||||
|
@ -123,30 +123,30 @@ processor = Wav2Vec2Processor.from_pretrained("maxidl/wav2vec2-large-xlsr-german
|
|||
model = Wav2Vec2ForCTC.from_pretrained("maxidl/wav2vec2-large-xlsr-german")
|
||||
model.to("cuda")
|
||||
|
||||
chars_to_ignore_regex = '[\,\?\.\!\-\;\:\"\“]'
|
||||
chars_to_ignore_regex = '[\\,\\?\\.\\!\\-\\;\\:\\"\\“]'
|
||||
resampler = torchaudio.transforms.Resample(48_000, 16_000)
|
||||
|
||||
# Preprocessing the datasets.
|
||||
# We need to read the aduio files as arrays
|
||||
def speech_file_to_array_fn(batch):
|
||||
batch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
|
||||
speech_array, sampling_rate = torchaudio.load(batch["path"])
|
||||
batch["speech"] = resampler(speech_array).squeeze().numpy()
|
||||
return batch
|
||||
\tbatch["sentence"] = re.sub(chars_to_ignore_regex, '', batch["sentence"]).lower()
|
||||
\tspeech_array, sampling_rate = torchaudio.load(batch["path"])
|
||||
\tbatch["speech"] = resampler(speech_array).squeeze().numpy()
|
||||
\treturn batch
|
||||
|
||||
test_dataset = test_dataset.map(speech_file_to_array_fn)
|
||||
|
||||
# Preprocessing the datasets.
|
||||
# We need to read the audio files as arrays
|
||||
def evaluate(batch):
|
||||
inputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
|
||||
\tinputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)
|
||||
|
||||
with torch.no_grad():
|
||||
logits = model(inputs.input_values.to("cuda"), attention_mask=inputs.attention_mask.to("cuda")).logits
|
||||
\twith torch.no_grad():
|
||||
\t\tlogits = model(inputs.input_values.to("cuda"), attention_mask=inputs.attention_mask.to("cuda")).logits
|
||||
|
||||
pred_ids = torch.argmax(logits, dim=-1)
|
||||
batch["pred_strings"] = processor.batch_decode(pred_ids)
|
||||
return batch
|
||||
\tpred_ids = torch.argmax(logits, dim=-1)
|
||||
\tbatch["pred_strings"] = processor.batch_decode(pred_ids)
|
||||
\treturn batch
|
||||
|
||||
result = test_dataset.map(evaluate, batched=True, batch_size=8) # batch_size=8 -> requires ~14.5GB GPU memory
|
||||
|
||||
|
@ -176,7 +176,7 @@ print("Total (chunk_size=1000), WER: {:2f}".format(100 * chunked_wer(result["pre
|
|||
# Total (chunk=1000), WER: 12.768981
|
||||
```
|
||||
|
||||
**Test Result**: WER: 12.90 %
|
||||
**Test Result**: WER: 12.77 %
|
||||
|
||||
|
||||
## Training
|
||||
|
@ -187,32 +187,32 @@ The model was trained for 50k steps, taking around 30 hours on a single A100.
|
|||
|
||||
The arguments used for training this model are:
|
||||
```
|
||||
python run_finetuning.py \
|
||||
--model_name_or_path="facebook/wav2vec2-large-xlsr-53" \
|
||||
--dataset_config_name="de" \
|
||||
--output_dir=./wav2vec2-large-xlsr-german \
|
||||
--preprocessing_num_workers="16" \
|
||||
--overwrite_output_dir \
|
||||
--num_train_epochs="20" \
|
||||
--per_device_train_batch_size="64" \
|
||||
--per_device_eval_batch_size="32" \
|
||||
--learning_rate="1e-4" \
|
||||
--warmup_steps="500" \
|
||||
--evaluation_strategy="steps" \
|
||||
--save_steps="5000" \
|
||||
--eval_steps="5000" \
|
||||
--logging_steps="1000" \
|
||||
--save_total_limit="3" \
|
||||
--freeze_feature_extractor \
|
||||
--activation_dropout="0.055" \
|
||||
--attention_dropout="0.094" \
|
||||
--feat_proj_dropout="0.04" \
|
||||
--layerdrop="0.04" \
|
||||
--mask_time_prob="0.08" \
|
||||
--gradient_checkpointing="1" \
|
||||
--fp16 \
|
||||
--do_train \
|
||||
--do_eval \
|
||||
--dataloader_num_workers="16" \
|
||||
python run_finetuning.py \\
|
||||
--model_name_or_path="facebook/wav2vec2-large-xlsr-53" \\
|
||||
--dataset_config_name="de" \\
|
||||
--output_dir=./wav2vec2-large-xlsr-german \\
|
||||
--preprocessing_num_workers="16" \\
|
||||
--overwrite_output_dir \\
|
||||
--num_train_epochs="20" \\
|
||||
--per_device_train_batch_size="64" \\
|
||||
--per_device_eval_batch_size="32" \\
|
||||
--learning_rate="1e-4" \\
|
||||
--warmup_steps="500" \\
|
||||
--evaluation_strategy="steps" \\
|
||||
--save_steps="5000" \\
|
||||
--eval_steps="5000" \\
|
||||
--logging_steps="1000" \\
|
||||
--save_total_limit="3" \\
|
||||
--freeze_feature_extractor \\
|
||||
--activation_dropout="0.055" \\
|
||||
--attention_dropout="0.094" \\
|
||||
--feat_proj_dropout="0.04" \\
|
||||
--layerdrop="0.04" \\
|
||||
--mask_time_prob="0.08" \\
|
||||
--gradient_checkpointing="1" \\
|
||||
--fp16 \\
|
||||
--do_train \\
|
||||
--do_eval \\
|
||||
--dataloader_num_workers="16" \\
|
||||
--group_by_length
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue