初始化项目,由ModelHub XC社区提供模型
Model: Plim/xls-r-300m-fr Source: Original Platform
This commit is contained in:
27
.gitattributes
vendored
Normal file
27
.gitattributes
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
checkpoint-*/
|
||||
|
||||
.ipynb_checkpoints/
|
||||
|
||||
wandb
|
||||
121
README.md
Normal file
121
README.md
Normal file
@@ -0,0 +1,121 @@
|
||||
---
|
||||
language:
|
||||
- fr
|
||||
license: apache-2.0
|
||||
tags:
|
||||
- automatic-speech-recognition
|
||||
- mozilla-foundation/common_voice_7_0
|
||||
- generated_from_trainer
|
||||
- robust-speech-event
|
||||
- hf-asr-leaderboard
|
||||
datasets:
|
||||
- mozilla-foundation/common_voice_7_0
|
||||
model-index:
|
||||
- name: XLS-R-300M - French
|
||||
results:
|
||||
- task:
|
||||
name: Automatic Speech Recognition
|
||||
type: automatic-speech-recognition
|
||||
dataset:
|
||||
name: Common Voice 7
|
||||
type: mozilla-foundation/common_voice_7_0
|
||||
args: fr
|
||||
metrics:
|
||||
- name: Test WER
|
||||
type: wer
|
||||
value: 24.56
|
||||
- name: Test CER
|
||||
type: cer
|
||||
value: 7.3
|
||||
- task:
|
||||
name: Automatic Speech Recognition
|
||||
type: automatic-speech-recognition
|
||||
dataset:
|
||||
name: Robust Speech Event - Dev Data
|
||||
type: speech-recognition-community-v2/dev_data
|
||||
args: fr
|
||||
metrics:
|
||||
- name: Test WER
|
||||
type: wer
|
||||
value: 63.62
|
||||
- name: Test CER
|
||||
type: cer
|
||||
value: 17.2
|
||||
- task:
|
||||
name: Automatic Speech Recognition
|
||||
type: automatic-speech-recognition
|
||||
dataset:
|
||||
name: Robust Speech Event - Test Data
|
||||
type: speech-recognition-community-v2/eval_data
|
||||
args: fr
|
||||
metrics:
|
||||
- name: Test WER
|
||||
type: wer
|
||||
value: 66.45
|
||||
---
|
||||
---
|
||||
|
||||
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
||||
should probably proofread and complete it, then remove this comment. -->
|
||||
|
||||
## Model description
|
||||
|
||||
This model is a fine-tuned version of [facebook/wav2vec2-xls-r-300m](https://huggingface.co/facebook/wav2vec2-xls-r-300m) on the MOZILLA-FOUNDATION/COMMON_VOICE_7_0 - FR dataset.
|
||||
|
||||
## Training procedure
|
||||
|
||||
### Training hyperparameters
|
||||
|
||||
The following hyperparameters were used during training:
|
||||
- learning_rate: 7.5e-05
|
||||
- train_batch_size: 16
|
||||
- eval_batch_size: 16
|
||||
- seed: 42
|
||||
- gradient_accumulation_steps: 8
|
||||
- total_train_batch_size: 128
|
||||
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
||||
- lr_scheduler_type: linear
|
||||
- lr_scheduler_warmup_steps: 2000
|
||||
- num_epochs: 2.0
|
||||
- mixed_precision_training: Native AMP
|
||||
|
||||
### Training results
|
||||
|
||||
| Training Loss | Epoch | Step | Validation Loss | Wer |
|
||||
|:-------------:|:-----:|:----:|:---------------:|:------:|
|
||||
| 3.495 | 0.16 | 500 | 3.3883 | 1.0 |
|
||||
| 2.9095 | 0.32 | 1000 | 2.9152 | 1.0000 |
|
||||
| 1.8434 | 0.49 | 1500 | 1.0473 | 0.7446 |
|
||||
| 1.4298 | 0.65 | 2000 | 0.5729 | 0.5130 |
|
||||
| 1.1937 | 0.81 | 2500 | 0.3795 | 0.3450 |
|
||||
| 1.1248 | 0.97 | 3000 | 0.3321 | 0.3052 |
|
||||
| 1.0835 | 1.13 | 3500 | 0.3038 | 0.2805 |
|
||||
| 1.0479 | 1.3 | 4000 | 0.2910 | 0.2689 |
|
||||
| 1.0413 | 1.46 | 4500 | 0.2798 | 0.2593 |
|
||||
| 1.014 | 1.62 | 5000 | 0.2727 | 0.2512 |
|
||||
| 1.004 | 1.78 | 5500 | 0.2646 | 0.2471 |
|
||||
| 0.9949 | 1.94 | 6000 | 0.2619 | 0.2457 |
|
||||
|
||||
It achieves the best result on STEP 6000 on the validation set:
|
||||
- Loss: 0.2619
|
||||
- Wer: 0.2457
|
||||
|
||||
### Framework versions
|
||||
|
||||
- Transformers 4.17.0.dev0
|
||||
- Pytorch 1.10.2+cu102
|
||||
- Datasets 1.18.2.dev0
|
||||
- Tokenizers 0.11.0
|
||||
|
||||
### Evaluation Commands
|
||||
1. To evaluate on `mozilla-foundation/common_voice_7` with split `test`
|
||||
|
||||
```bash
|
||||
python eval.py --model_id Plim/xls-r-300m-fr --dataset mozilla-foundation/common_voice_7_0 --config fr --split test
|
||||
```
|
||||
|
||||
2. To evaluate on `speech-recognition-community-v2/dev_data`
|
||||
|
||||
```bash
|
||||
python eval.py --model_id Plim/xls-r-300m-fr --dataset speech-recognition-community-v2/dev_data --config fr --split validation --chunk_length_s 5.0 --stride_length_s 1.0
|
||||
```
|
||||
14
all_results.json
Normal file
14
all_results.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"epoch": 2.0,
|
||||
"eval_loss": 0.26187804341316223,
|
||||
"eval_runtime": 722.142,
|
||||
"eval_samples": 15941,
|
||||
"eval_samples_per_second": 22.075,
|
||||
"eval_steps_per_second": 1.381,
|
||||
"eval_wer": 0.24574541380398318,
|
||||
"train_loss": 1.788894365302016,
|
||||
"train_runtime": 52105.5599,
|
||||
"train_samples": 395042,
|
||||
"train_samples_per_second": 15.163,
|
||||
"train_steps_per_second": 0.118
|
||||
}
|
||||
107
config.json
Normal file
107
config.json
Normal file
@@ -0,0 +1,107 @@
|
||||
{
|
||||
"_name_or_path": "facebook/wav2vec2-xls-r-300m",
|
||||
"activation_dropout": 0.1,
|
||||
"adapter_kernel_size": 3,
|
||||
"adapter_stride": 2,
|
||||
"add_adapter": false,
|
||||
"apply_spec_augment": true,
|
||||
"architectures": [
|
||||
"Wav2Vec2ForCTC"
|
||||
],
|
||||
"attention_dropout": 0.0,
|
||||
"bos_token_id": 1,
|
||||
"classifier_proj_size": 256,
|
||||
"codevector_dim": 768,
|
||||
"contrastive_logits_temperature": 0.1,
|
||||
"conv_bias": true,
|
||||
"conv_dim": [
|
||||
512,
|
||||
512,
|
||||
512,
|
||||
512,
|
||||
512,
|
||||
512,
|
||||
512
|
||||
],
|
||||
"conv_kernel": [
|
||||
10,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
2,
|
||||
2
|
||||
],
|
||||
"conv_stride": [
|
||||
5,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2
|
||||
],
|
||||
"ctc_loss_reduction": "mean",
|
||||
"ctc_zero_infinity": false,
|
||||
"diversity_loss_weight": 0.1,
|
||||
"do_stable_layer_norm": true,
|
||||
"eos_token_id": 2,
|
||||
"feat_extract_activation": "gelu",
|
||||
"feat_extract_dropout": 0.0,
|
||||
"feat_extract_norm": "layer",
|
||||
"feat_proj_dropout": 0.0,
|
||||
"feat_quantizer_dropout": 0.0,
|
||||
"final_dropout": 0.0,
|
||||
"hidden_act": "gelu",
|
||||
"hidden_dropout": 0.0,
|
||||
"hidden_size": 1024,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 4096,
|
||||
"layer_norm_eps": 1e-05,
|
||||
"layerdrop": 0.0,
|
||||
"mask_feature_length": 64,
|
||||
"mask_feature_min_masks": 0,
|
||||
"mask_feature_prob": 0.25,
|
||||
"mask_time_length": 10,
|
||||
"mask_time_min_masks": 2,
|
||||
"mask_time_prob": 0.75,
|
||||
"model_type": "wav2vec2",
|
||||
"num_adapter_layers": 3,
|
||||
"num_attention_heads": 16,
|
||||
"num_codevector_groups": 2,
|
||||
"num_codevectors_per_group": 320,
|
||||
"num_conv_pos_embedding_groups": 16,
|
||||
"num_conv_pos_embeddings": 128,
|
||||
"num_feat_extract_layers": 7,
|
||||
"num_hidden_layers": 24,
|
||||
"num_negatives": 100,
|
||||
"output_hidden_size": 1024,
|
||||
"pad_token_id": 45,
|
||||
"proj_codevector_dim": 768,
|
||||
"tdnn_dilation": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"tdnn_dim": [
|
||||
512,
|
||||
512,
|
||||
512,
|
||||
512,
|
||||
1500
|
||||
],
|
||||
"tdnn_kernel": [
|
||||
5,
|
||||
3,
|
||||
3,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"torch_dtype": "float32",
|
||||
"transformers_version": "4.17.0.dev0",
|
||||
"use_weighted_layer_sum": false,
|
||||
"vocab_size": 46,
|
||||
"xvector_output_dim": 512
|
||||
}
|
||||
128
eval.py
Executable file
128
eval.py
Executable file
@@ -0,0 +1,128 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import re
|
||||
from typing import Dict
|
||||
|
||||
from datasets import Audio, Dataset, load_dataset, load_metric
|
||||
|
||||
from transformers import AutoFeatureExtractor, pipeline
|
||||
|
||||
|
||||
def log_results(result: Dataset, args: Dict[str, str]):
|
||||
"""DO NOT CHANGE. This function computes and logs the result metrics."""
|
||||
|
||||
log_outputs = args.log_outputs
|
||||
dataset_id = "_".join(args.dataset.split("/") + [args.config, args.split])
|
||||
|
||||
# load metric
|
||||
wer = load_metric("wer")
|
||||
cer = load_metric("cer")
|
||||
|
||||
# compute metrics
|
||||
wer_result = wer.compute(references=result["target"], predictions=result["prediction"])
|
||||
cer_result = cer.compute(references=result["target"], predictions=result["prediction"])
|
||||
|
||||
# print & log results
|
||||
result_str = f"WER: {wer_result}\n" f"CER: {cer_result}"
|
||||
print(result_str)
|
||||
|
||||
with open(f"{dataset_id}_eval_results.txt", "w") as f:
|
||||
f.write(result_str)
|
||||
|
||||
# log all results in text file. Possibly interesting for analysis
|
||||
if log_outputs is not None:
|
||||
pred_file = f"log_{dataset_id}_predictions.txt"
|
||||
target_file = f"log_{dataset_id}_targets.txt"
|
||||
|
||||
with open(pred_file, "w") as p, open(target_file, "w") as t:
|
||||
|
||||
# mapping function to write output
|
||||
def write_to_file(batch, i):
|
||||
p.write(f"{i}" + "\n")
|
||||
p.write(batch["prediction"] + "\n")
|
||||
t.write(f"{i}" + "\n")
|
||||
t.write(batch["target"] + "\n")
|
||||
|
||||
result.map(write_to_file, with_indices=True)
|
||||
|
||||
|
||||
def normalize_text(text: str) -> str:
|
||||
"""DO ADAPT FOR YOUR USE CASE. this function normalizes the target text."""
|
||||
|
||||
chars_to_ignore_regex = '[^a-zàâäçéèêëîïôöùûüÿ\'’ ]' # noqa: W605 IMPORTANT: this should correspond to the chars that were ignored during training
|
||||
|
||||
text = re.sub(chars_to_ignore_regex, "", text.lower()).replace('’', "'")
|
||||
|
||||
# In addition, we can normalize the target text, e.g. removing new lines characters etc...
|
||||
# note that order is important here!
|
||||
token_sequences_to_ignore = ["\n\n", "\n", " ", " "]
|
||||
|
||||
for t in token_sequences_to_ignore:
|
||||
text = " ".join(text.split(t))
|
||||
|
||||
return text
|
||||
|
||||
|
||||
def main(args):
|
||||
# load dataset
|
||||
dataset = load_dataset(args.dataset, args.config, split=args.split, use_auth_token=True)
|
||||
|
||||
# for testing: only process the first two examples as a test
|
||||
# dataset = dataset.select(range(10))
|
||||
|
||||
# load processor
|
||||
feature_extractor = AutoFeatureExtractor.from_pretrained(args.model_id)
|
||||
sampling_rate = feature_extractor.sampling_rate
|
||||
|
||||
# resample audio
|
||||
dataset = dataset.cast_column("audio", Audio(sampling_rate=sampling_rate))
|
||||
|
||||
# load eval pipeline
|
||||
asr = pipeline("automatic-speech-recognition", model=args.model_id)
|
||||
|
||||
# map function to decode audio
|
||||
def map_to_pred(batch):
|
||||
prediction = asr(
|
||||
batch["audio"]["array"], chunk_length_s=args.chunk_length_s, stride_length_s=args.stride_length_s
|
||||
)
|
||||
|
||||
batch["prediction"] = prediction["text"]
|
||||
batch["target"] = normalize_text(batch["sentence"])
|
||||
return batch
|
||||
|
||||
# run inference on all examples
|
||||
result = dataset.map(map_to_pred, remove_columns=dataset.column_names)
|
||||
|
||||
# compute and log_results
|
||||
# do not change function below
|
||||
log_results(result, args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_argument(
|
||||
"--model_id", type=str, required=True, help="Model identifier. Should be loadable with 🤗 Transformers"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--dataset",
|
||||
type=str,
|
||||
required=True,
|
||||
help="Dataset name to evaluate the `model_id`. Should be loadable with 🤗 Datasets",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--config", type=str, required=True, help="Config of the dataset. *E.g.* `'en'` for Common Voice"
|
||||
)
|
||||
parser.add_argument("--split", type=str, required=True, help="Split of the dataset. *E.g.* `'test'`")
|
||||
parser.add_argument(
|
||||
"--chunk_length_s", type=float, default=None, help="Chunk length in seconds. Defaults to 5 seconds."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--stride_length_s", type=float, default=None, help="Stride of the audio chunks. Defaults to 1 second."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--log_outputs", action="store_true", help="If defined, write outputs to log file for analysis."
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
main(args)
|
||||
9
eval_results.json
Normal file
9
eval_results.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"epoch": 2.0,
|
||||
"eval_loss": 0.26187804341316223,
|
||||
"eval_runtime": 722.142,
|
||||
"eval_samples": 15941,
|
||||
"eval_samples_per_second": 22.075,
|
||||
"eval_steps_per_second": 1.381,
|
||||
"eval_wer": 0.24574541380398318
|
||||
}
|
||||
31882
log_mozilla-foundation_common_voice_7_0_fr_test_predictions.txt
Normal file
31882
log_mozilla-foundation_common_voice_7_0_fr_test_predictions.txt
Normal file
File diff suppressed because it is too large
Load Diff
31882
log_mozilla-foundation_common_voice_7_0_fr_test_targets.txt
Normal file
31882
log_mozilla-foundation_common_voice_7_0_fr_test_targets.txt
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,2 @@
|
||||
WER: 0.24561764914155493
|
||||
CER: 0.07285207821118034
|
||||
9
preprocessor_config.json
Normal file
9
preprocessor_config.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"do_normalize": true,
|
||||
"feature_extractor_type": "Wav2Vec2FeatureExtractor",
|
||||
"feature_size": 1,
|
||||
"padding_side": "right",
|
||||
"padding_value": 0,
|
||||
"return_attention_mask": true,
|
||||
"sampling_rate": 16000
|
||||
}
|
||||
3
pytorch_model.bin
Normal file
3
pytorch_model.bin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:fae4b50fea64734470da322cdd4b51d1e72024c521098f4fce28c513870e1017
|
||||
size 1262112241
|
||||
37
run.sh
Normal file
37
run.sh
Normal file
@@ -0,0 +1,37 @@
|
||||
export WANDB_PROJECT="xls-r-300-fr"
|
||||
python run_speech_recognition_ctc.py \
|
||||
--activation_dropout="0.1" \
|
||||
--dataset_name="mozilla-foundation/common_voice_7_0" \
|
||||
--dataset_config_name="fr" \
|
||||
--eval_steps="500" \
|
||||
--evaluation_strategy="steps" \
|
||||
--feat_proj_dropout="0.0" \
|
||||
--freeze_feature_encoder \
|
||||
--fp16 \
|
||||
--gradient_accumulation_steps="8" \
|
||||
--gradient_checkpointing \
|
||||
--group_by_length \
|
||||
--layerdrop="0.0" \
|
||||
--learning_rate="7.5e-5" \
|
||||
--length_column_name="input_length" \
|
||||
--load_best_model_at_end \
|
||||
--logging_steps="100" \
|
||||
--mask_feature_length="64" \
|
||||
--mask_feature_prob="0.25" \
|
||||
--mask_time_length="10" \
|
||||
--mask_time_prob="0.75" \
|
||||
--model_name_or_path="facebook/wav2vec2-xls-r-300m" \
|
||||
--num_train_epochs="2.0" \
|
||||
--output_dir="./" \
|
||||
--overwrite_output_dir \
|
||||
--per_device_train_batch_size="16" \
|
||||
--per_device_eval_batch_size="16" \
|
||||
--preprocessing_num_workers="4" \
|
||||
--push_to_hub \
|
||||
--report_to="wandb" \
|
||||
--save_steps="500" \
|
||||
--save_total_limit="3" \
|
||||
--text_column_name="sentence" \
|
||||
--use_auth_token \
|
||||
--warmup_steps="2000" \
|
||||
--do_train --do_eval
|
||||
734
run_speech_recognition_ctc.py
Normal file
734
run_speech_recognition_ctc.py
Normal file
@@ -0,0 +1,734 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
# Copyright 2021 The HuggingFace Inc. team. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
|
||||
""" Fine-tuning a 🤗 Transformers CTC model for automatic speech recognition"""
|
||||
|
||||
import functools
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import warnings
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Dict, List, Optional, Union
|
||||
|
||||
import datasets
|
||||
import numpy as np
|
||||
import torch
|
||||
from datasets import DatasetDict, load_dataset, load_metric
|
||||
|
||||
import transformers
|
||||
from transformers import (
|
||||
AutoConfig,
|
||||
AutoFeatureExtractor,
|
||||
AutoModelForCTC,
|
||||
AutoProcessor,
|
||||
AutoTokenizer,
|
||||
HfArgumentParser,
|
||||
Trainer,
|
||||
TrainingArguments,
|
||||
Wav2Vec2Processor,
|
||||
set_seed,
|
||||
)
|
||||
from transformers.trainer_utils import get_last_checkpoint, is_main_process
|
||||
from transformers.utils import check_min_version
|
||||
from transformers.utils.versions import require_version
|
||||
|
||||
|
||||
# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
|
||||
check_min_version("4.16.0.dev0")
|
||||
|
||||
require_version("datasets>=1.13.3", "To fix: pip install -r examples/pytorch/text-classification/requirements.txt")
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def list_field(default=None, metadata=None):
|
||||
return field(default_factory=lambda: default, metadata=metadata)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ModelArguments:
|
||||
"""
|
||||
Arguments pertaining to which model/config/tokenizer we are going to fine-tune from.
|
||||
"""
|
||||
|
||||
model_name_or_path: str = field(
|
||||
metadata={"help": "Path to pretrained model or model identifier from huggingface.co/models"}
|
||||
)
|
||||
tokenizer_name_or_path: Optional[str] = field(
|
||||
default=None,
|
||||
metadata={"help": "Path to pretrained tokenizer or tokenizer identifier from huggingface.co/models"},
|
||||
)
|
||||
cache_dir: Optional[str] = field(
|
||||
default=None,
|
||||
metadata={"help": "Where do you want to store the pretrained models downloaded from huggingface.co"},
|
||||
)
|
||||
freeze_feature_encoder: bool = field(
|
||||
default=True, metadata={"help": "Whether to freeze the feature encoder layers of the model."}
|
||||
)
|
||||
attention_dropout: float = field(
|
||||
default=0.0, metadata={"help": "The dropout ratio for the attention probabilities."}
|
||||
)
|
||||
activation_dropout: float = field(
|
||||
default=0.0, metadata={"help": "The dropout ratio for activations inside the fully connected layer."}
|
||||
)
|
||||
feat_proj_dropout: float = field(default=0.0, metadata={"help": "The dropout ratio for the projected features."})
|
||||
hidden_dropout: float = field(
|
||||
default=0.0,
|
||||
metadata={
|
||||
"help": "The dropout probability for all fully connected layers in the embeddings, encoder, and pooler."
|
||||
},
|
||||
)
|
||||
final_dropout: float = field(
|
||||
default=0.0,
|
||||
metadata={"help": "The dropout probability for the final projection layer."},
|
||||
)
|
||||
mask_time_prob: float = field(
|
||||
default=0.05,
|
||||
metadata={
|
||||
"help": "Probability of each feature vector along the time axis to be chosen as the start of the vector"
|
||||
"span to be masked. Approximately ``mask_time_prob * sequence_length // mask_time_length`` feature"
|
||||
"vectors will be masked along the time axis."
|
||||
},
|
||||
)
|
||||
mask_time_length: int = field(
|
||||
default=10,
|
||||
metadata={"help": "Length of vector span to mask along the time axis."},
|
||||
)
|
||||
mask_feature_prob: float = field(
|
||||
default=0.0,
|
||||
metadata={
|
||||
"help": "Probability of each feature vector along the feature axis to be chosen as the start of the vector"
|
||||
"span to be masked. Approximately ``mask_feature_prob * sequence_length // mask_feature_length`` feature bins will be masked along the time axis."
|
||||
},
|
||||
)
|
||||
mask_feature_length: int = field(
|
||||
default=10,
|
||||
metadata={"help": "Length of vector span to mask along the feature axis."},
|
||||
)
|
||||
layerdrop: float = field(default=0.0, metadata={"help": "The LayerDrop probability."})
|
||||
ctc_loss_reduction: Optional[str] = field(
|
||||
default="mean", metadata={"help": "The way the ctc loss should be reduced. Should be one of 'mean' or 'sum'."}
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class DataTrainingArguments:
|
||||
"""
|
||||
Arguments pertaining to what data we are going to input our model for training and eval.
|
||||
|
||||
Using `HfArgumentParser` we can turn this class
|
||||
into argparse arguments to be able to specify them on
|
||||
the command line.
|
||||
"""
|
||||
|
||||
dataset_name: str = field(
|
||||
metadata={"help": "The configuration name of the dataset to use (via the datasets library)."}
|
||||
)
|
||||
dataset_config_name: str = field(
|
||||
default=None, metadata={"help": "The configuration name of the dataset to use (via the datasets library)."}
|
||||
)
|
||||
train_split_name: str = field(
|
||||
default="train+validation",
|
||||
metadata={
|
||||
"help": "The name of the training data set split to use (via the datasets library). Defaults to 'train'"
|
||||
},
|
||||
)
|
||||
eval_split_name: str = field(
|
||||
default="test",
|
||||
metadata={
|
||||
"help": "The name of the training data set split to use (via the datasets library). Defaults to 'test'"
|
||||
},
|
||||
)
|
||||
audio_column_name: str = field(
|
||||
default="audio",
|
||||
metadata={"help": "The name of the dataset column containing the audio data. Defaults to 'audio'"},
|
||||
)
|
||||
text_column_name: str = field(
|
||||
default="text",
|
||||
metadata={"help": "The name of the dataset column containing the text data. Defaults to 'text'"},
|
||||
)
|
||||
overwrite_cache: bool = field(
|
||||
default=False, metadata={"help": "Overwrite the cached preprocessed datasets or not."}
|
||||
)
|
||||
preprocessing_num_workers: Optional[int] = field(
|
||||
default=None,
|
||||
metadata={"help": "The number of processes to use for the preprocessing."},
|
||||
)
|
||||
max_train_samples: Optional[int] = field(
|
||||
default=None,
|
||||
metadata={
|
||||
"help": "For debugging purposes or quicker training, truncate the number of training examples to this "
|
||||
"value if set."
|
||||
},
|
||||
)
|
||||
max_eval_samples: Optional[int] = field(
|
||||
default=None,
|
||||
metadata={
|
||||
"help": "For debugging purposes or quicker training, truncate the number of validation examples to this "
|
||||
"value if set."
|
||||
},
|
||||
)
|
||||
chars_to_ignore: Optional[List[str]] = list_field(
|
||||
default=None,
|
||||
metadata={"help": "A list of characters to remove from the transcripts."},
|
||||
)
|
||||
eval_metrics: List[str] = list_field(
|
||||
default=["wer"],
|
||||
metadata={"help": "A list of metrics the model should be evaluated on. E.g. `'wer cer'`"},
|
||||
)
|
||||
max_duration_in_seconds: float = field(
|
||||
default=20.0,
|
||||
metadata={
|
||||
"help": "Filter audio files that are longer than `max_duration_in_seconds` seconds to 'max_duration_in_seconds`"
|
||||
},
|
||||
)
|
||||
min_duration_in_seconds: float = field(
|
||||
default=0.0, metadata={"help": "Filter audio files that are shorter than `min_duration_in_seconds` seconds"}
|
||||
)
|
||||
preprocessing_only: bool = field(
|
||||
default=False,
|
||||
metadata={
|
||||
"help": "Whether to only do data preprocessing and skip training. "
|
||||
"This is especially useful when data preprocessing errors out in distributed training due to timeout. "
|
||||
"In this case, one should run the preprocessing in a non-distributed setup with `preprocessing_only=True` "
|
||||
"so that the cached datasets can consequently be loaded in distributed training"
|
||||
},
|
||||
)
|
||||
use_auth_token: bool = field(
|
||||
default=False,
|
||||
metadata={
|
||||
"help": "If :obj:`True`, will use the token generated when running"
|
||||
":obj:`transformers-cli login` as HTTP bearer authorization for remote files."
|
||||
},
|
||||
)
|
||||
unk_token: str = field(
|
||||
default="[UNK]",
|
||||
metadata={"help": "The unk token for the tokenizer"},
|
||||
)
|
||||
pad_token: str = field(
|
||||
default="[PAD]",
|
||||
metadata={"help": "The padding token for the tokenizer"},
|
||||
)
|
||||
word_delimiter_token: str = field(
|
||||
default="|",
|
||||
metadata={"help": "The word delimiter token for the tokenizer"},
|
||||
)
|
||||
phoneme_language: Optional[str] = field(
|
||||
default=None,
|
||||
metadata={
|
||||
"help": "The target language that should be used be"
|
||||
" passed to the tokenizer for tokenization. Note that"
|
||||
" this is only relevant if the model classifies the"
|
||||
" input audio to a sequence of phoneme sequences."
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class DataCollatorCTCWithPadding:
|
||||
"""
|
||||
Data collator that will dynamically pad the inputs received.
|
||||
Args:
|
||||
processor (:class:`~transformers.AutoProcessor`)
|
||||
The processor used for proccessing the data.
|
||||
padding (:obj:`bool`, :obj:`str` or :class:`~transformers.tokenization_utils_base.PaddingStrategy`, `optional`, defaults to :obj:`True`):
|
||||
Select a strategy to pad the returned sequences (according to the model's padding side and padding index)
|
||||
among:
|
||||
* :obj:`True` or :obj:`'longest'`: Pad to the longest sequence in the batch (or no padding if only a single
|
||||
sequence if provided).
|
||||
* :obj:`'max_length'`: Pad to a maximum length specified with the argument :obj:`max_length` or to the
|
||||
maximum acceptable input length for the model if that argument is not provided.
|
||||
* :obj:`False` or :obj:`'do_not_pad'` (default): No padding (i.e., can output a batch with sequences of
|
||||
different lengths).
|
||||
max_length (:obj:`int`, `optional`):
|
||||
Maximum length of the ``input_values`` of the returned list and optionally padding length (see above).
|
||||
max_length_labels (:obj:`int`, `optional`):
|
||||
Maximum length of the ``labels`` returned list and optionally padding length (see above).
|
||||
pad_to_multiple_of (:obj:`int`, `optional`):
|
||||
If set will pad the sequence to a multiple of the provided value.
|
||||
This is especially useful to enable the use of Tensor Cores on NVIDIA hardware with compute capability >=
|
||||
7.5 (Volta).
|
||||
"""
|
||||
|
||||
processor: AutoProcessor
|
||||
padding: Union[bool, str] = "longest"
|
||||
pad_to_multiple_of: Optional[int] = None
|
||||
pad_to_multiple_of_labels: Optional[int] = None
|
||||
|
||||
def __call__(self, features: List[Dict[str, Union[List[int], torch.Tensor]]]) -> Dict[str, torch.Tensor]:
|
||||
# split inputs and labels since they have to be of different lenghts and need
|
||||
# different padding methods
|
||||
input_features = [{"input_values": feature["input_values"]} for feature in features]
|
||||
label_features = [{"input_ids": feature["labels"]} for feature in features]
|
||||
|
||||
batch = self.processor.pad(
|
||||
input_features,
|
||||
padding=self.padding,
|
||||
pad_to_multiple_of=self.pad_to_multiple_of,
|
||||
return_tensors="pt",
|
||||
)
|
||||
|
||||
with self.processor.as_target_processor():
|
||||
labels_batch = self.processor.pad(
|
||||
label_features,
|
||||
padding=self.padding,
|
||||
pad_to_multiple_of=self.pad_to_multiple_of_labels,
|
||||
return_tensors="pt",
|
||||
)
|
||||
|
||||
# replace padding with -100 to ignore loss correctly
|
||||
labels = labels_batch["input_ids"].masked_fill(labels_batch.attention_mask.ne(1), -100)
|
||||
|
||||
batch["labels"] = labels
|
||||
|
||||
return batch
|
||||
|
||||
|
||||
def create_vocabulary_from_data(
|
||||
datasets: DatasetDict,
|
||||
word_delimiter_token: Optional[str] = None,
|
||||
unk_token: Optional[str] = None,
|
||||
pad_token: Optional[str] = None,
|
||||
):
|
||||
# Given training and test labels create vocabulary
|
||||
def extract_all_chars(batch):
|
||||
all_text = " ".join(batch["target_text"])
|
||||
vocab = list(set(all_text))
|
||||
return {"vocab": [vocab], "all_text": [all_text]}
|
||||
|
||||
vocabs = datasets.map(
|
||||
extract_all_chars,
|
||||
batched=True,
|
||||
batch_size=-1,
|
||||
keep_in_memory=True,
|
||||
remove_columns=datasets["train"].column_names,
|
||||
)
|
||||
|
||||
# take union of all unique characters in each dataset
|
||||
vocab_set = functools.reduce(
|
||||
lambda vocab_1, vocab_2: set(vocab_1["vocab"][0]) | set(vocab_2["vocab"][0]), vocabs.values()
|
||||
)
|
||||
|
||||
vocab_dict = {v: k for k, v in enumerate(sorted(list(vocab_set)))}
|
||||
|
||||
# replace white space with delimiter token
|
||||
if word_delimiter_token is not None:
|
||||
vocab_dict[word_delimiter_token] = vocab_dict[" "]
|
||||
del vocab_dict[" "]
|
||||
|
||||
# add unk and pad token
|
||||
if unk_token is not None:
|
||||
vocab_dict[unk_token] = len(vocab_dict)
|
||||
|
||||
if pad_token is not None:
|
||||
vocab_dict[pad_token] = len(vocab_dict)
|
||||
|
||||
return vocab_dict
|
||||
|
||||
|
||||
def main():
|
||||
# See all possible arguments in src/transformers/training_args.py
|
||||
# or by passing the --help flag to this script.
|
||||
# We now keep distinct sets of args, for a cleaner separation of concerns.
|
||||
|
||||
parser = HfArgumentParser((ModelArguments, DataTrainingArguments, TrainingArguments))
|
||||
if len(sys.argv) == 2 and sys.argv[1].endswith(".json"):
|
||||
# If we pass only one argument to the script and it's the path to a json file,
|
||||
# let's parse it to get our arguments.
|
||||
model_args, data_args, training_args = parser.parse_json_file(json_file=os.path.abspath(sys.argv[1]))
|
||||
else:
|
||||
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
||||
|
||||
# Detecting last checkpoint.
|
||||
last_checkpoint = None
|
||||
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
||||
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
||||
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
||||
raise ValueError(
|
||||
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
||||
"Use --overwrite_output_dir to overcome."
|
||||
)
|
||||
elif last_checkpoint is not None:
|
||||
logger.info(
|
||||
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
||||
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
||||
)
|
||||
|
||||
# Setup logging
|
||||
logging.basicConfig(
|
||||
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
||||
datefmt="%m/%d/%Y %H:%M:%S",
|
||||
handlers=[logging.StreamHandler(sys.stdout)],
|
||||
)
|
||||
logger.setLevel(logging.INFO if is_main_process(training_args.local_rank) else logging.WARN)
|
||||
|
||||
# Log on each process the small summary:
|
||||
logger.warning(
|
||||
f"Process rank: {training_args.local_rank}, device: {training_args.device}, n_gpu: {training_args.n_gpu}"
|
||||
f"distributed training: {bool(training_args.local_rank != -1)}, 16-bits training: {training_args.fp16}"
|
||||
)
|
||||
# Set the verbosity to info of the Transformers logger (on main process only):
|
||||
if is_main_process(training_args.local_rank):
|
||||
transformers.utils.logging.set_verbosity_info()
|
||||
logger.info("Training/evaluation parameters %s", training_args)
|
||||
|
||||
# Set seed before initializing model.
|
||||
set_seed(training_args.seed)
|
||||
|
||||
# 1. First, let's load the dataset
|
||||
raw_datasets = DatasetDict()
|
||||
|
||||
if training_args.do_train:
|
||||
raw_datasets["train"] = load_dataset(
|
||||
data_args.dataset_name,
|
||||
data_args.dataset_config_name,
|
||||
split=data_args.train_split_name,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
)
|
||||
|
||||
if data_args.audio_column_name not in raw_datasets["train"].column_names:
|
||||
raise ValueError(
|
||||
f"--audio_column_name '{data_args.audio_column_name}' not found in dataset '{data_args.dataset_name}'. "
|
||||
"Make sure to set `--audio_column_name` to the correct audio column - one of "
|
||||
f"{', '.join(raw_datasets['train'].column_names)}."
|
||||
)
|
||||
|
||||
if data_args.text_column_name not in raw_datasets["train"].column_names:
|
||||
raise ValueError(
|
||||
f"--text_column_name {data_args.text_column_name} not found in dataset '{data_args.dataset_name}'. "
|
||||
"Make sure to set `--text_column_name` to the correct text column - one of "
|
||||
f"{', '.join(raw_datasets['train'].column_names)}."
|
||||
)
|
||||
|
||||
if data_args.max_train_samples is not None:
|
||||
raw_datasets["train"] = raw_datasets["train"].select(range(data_args.max_train_samples))
|
||||
|
||||
if training_args.do_eval:
|
||||
raw_datasets["eval"] = load_dataset(
|
||||
data_args.dataset_name,
|
||||
data_args.dataset_config_name,
|
||||
split=data_args.eval_split_name,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
)
|
||||
|
||||
if data_args.max_eval_samples is not None:
|
||||
raw_datasets["eval"] = raw_datasets["eval"].select(range(data_args.max_eval_samples))
|
||||
|
||||
# 2. We remove some special characters from the datasets
|
||||
# that make training complicated and do not help in transcribing the speech
|
||||
# E.g. characters, such as `,` and `.` do not really have an acoustic characteristic
|
||||
# that could be easily picked up by the model
|
||||
chars_to_ignore_regex = '[^a-zàâäçéèêëîïôöùûüÿ\'’ ]'
|
||||
text_column_name = data_args.text_column_name
|
||||
|
||||
def remove_and_replace_special_characters(batch):
|
||||
batch["target_text"] = re.sub(chars_to_ignore_regex, "", batch[text_column_name].lower()).replace('’', "'") + " "
|
||||
return batch
|
||||
|
||||
with training_args.main_process_first(desc="dataset map special characters removal"):
|
||||
raw_datasets = raw_datasets.map(
|
||||
remove_and_replace_special_characters,
|
||||
remove_columns=[text_column_name],
|
||||
desc="remove special characters from datasets",
|
||||
)
|
||||
|
||||
# save special tokens for tokenizer
|
||||
word_delimiter_token = data_args.word_delimiter_token
|
||||
unk_token = data_args.unk_token
|
||||
pad_token = data_args.pad_token
|
||||
|
||||
# 3. Next, let's load the config as we might need it to create
|
||||
# the tokenizer
|
||||
# load config
|
||||
config = AutoConfig.from_pretrained(
|
||||
model_args.model_name_or_path, cache_dir=model_args.cache_dir, use_auth_token=data_args.use_auth_token
|
||||
)
|
||||
|
||||
# 4. Next, if no tokenizer file is defined,
|
||||
# we create the vocabulary of the model by extracting all unique characters from
|
||||
# the training and evaluation datasets
|
||||
# We need to make sure that only first rank saves vocabulary
|
||||
# make sure all processes wait until vocab is created
|
||||
tokenizer_name_or_path = model_args.tokenizer_name_or_path
|
||||
tokenizer_kwargs = {}
|
||||
if tokenizer_name_or_path is None:
|
||||
# save vocab in training output dir
|
||||
tokenizer_name_or_path = training_args.output_dir
|
||||
|
||||
vocab_file = os.path.join(tokenizer_name_or_path, "vocab.json")
|
||||
|
||||
with training_args.main_process_first():
|
||||
if training_args.overwrite_output_dir and os.path.isfile(vocab_file):
|
||||
os.remove(vocab_file)
|
||||
|
||||
with training_args.main_process_first(desc="dataset map vocabulary creation"):
|
||||
if not os.path.isfile(vocab_file):
|
||||
os.makedirs(tokenizer_name_or_path, exist_ok=True)
|
||||
vocab_dict = create_vocabulary_from_data(
|
||||
raw_datasets,
|
||||
word_delimiter_token=word_delimiter_token,
|
||||
unk_token=unk_token,
|
||||
pad_token=pad_token,
|
||||
)
|
||||
|
||||
# save vocab dict to be loaded into tokenizer
|
||||
with open(vocab_file, "w") as file:
|
||||
json.dump(vocab_dict, file)
|
||||
|
||||
# if tokenizer has just been created
|
||||
# it is defined by `tokenizer_class` if present in config else by `model_type`
|
||||
tokenizer_kwargs = {
|
||||
"config": config if config.tokenizer_class is not None else None,
|
||||
"tokenizer_type": config.model_type if config.tokenizer_class is None else None,
|
||||
"unk_token": unk_token,
|
||||
"pad_token": pad_token,
|
||||
"eos_token": None,
|
||||
"bos_token": None,
|
||||
"word_delimiter_token": word_delimiter_token,
|
||||
}
|
||||
|
||||
# 5. Now we can instantiate the feature extractor, tokenizer and model
|
||||
# Note for distributed training, the .from_pretrained methods guarantee that only
|
||||
# one local process can concurrently download model & vocab.
|
||||
|
||||
# load feature_extractor and tokenizer
|
||||
tokenizer = AutoTokenizer.from_pretrained(
|
||||
tokenizer_name_or_path,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
**tokenizer_kwargs,
|
||||
)
|
||||
feature_extractor = AutoFeatureExtractor.from_pretrained(
|
||||
model_args.model_name_or_path, cache_dir=model_args.cache_dir, use_auth_token=data_args.use_auth_token
|
||||
)
|
||||
|
||||
# adapt config
|
||||
config.update(
|
||||
{
|
||||
"feat_proj_dropout": model_args.feat_proj_dropout,
|
||||
"attention_dropout": model_args.attention_dropout,
|
||||
"hidden_dropout": model_args.hidden_dropout,
|
||||
"final_dropout": model_args.final_dropout,
|
||||
"mask_time_prob": model_args.mask_time_prob,
|
||||
"mask_time_length": model_args.mask_time_length,
|
||||
"mask_feature_prob": model_args.mask_feature_prob,
|
||||
"mask_feature_length": model_args.mask_feature_length,
|
||||
"gradient_checkpointing": training_args.gradient_checkpointing,
|
||||
"layerdrop": model_args.layerdrop,
|
||||
"ctc_loss_reduction": model_args.ctc_loss_reduction,
|
||||
"pad_token_id": tokenizer.pad_token_id,
|
||||
"vocab_size": len(tokenizer),
|
||||
"activation_dropout": model_args.activation_dropout,
|
||||
}
|
||||
)
|
||||
|
||||
# create model
|
||||
model = AutoModelForCTC.from_pretrained(
|
||||
model_args.model_name_or_path,
|
||||
cache_dir=model_args.cache_dir,
|
||||
config=config,
|
||||
use_auth_token=data_args.use_auth_token,
|
||||
)
|
||||
|
||||
# freeze encoder
|
||||
if model_args.freeze_feature_encoder:
|
||||
model.freeze_feature_encoder()
|
||||
|
||||
# 6. Now we preprocess the datasets including loading the audio, resampling and normalization
|
||||
# Thankfully, `datasets` takes care of automatically loading and resampling the audio,
|
||||
# so that we just need to set the correct target sampling rate and normalize the input
|
||||
# via the `feature_extractor`
|
||||
|
||||
# make sure that dataset decodes audio with correct sampling rate
|
||||
dataset_sampling_rate = next(iter(raw_datasets.values())).features[data_args.audio_column_name].sampling_rate
|
||||
if dataset_sampling_rate != feature_extractor.sampling_rate:
|
||||
raw_datasets = raw_datasets.cast_column(
|
||||
data_args.audio_column_name, datasets.features.Audio(sampling_rate=feature_extractor.sampling_rate)
|
||||
)
|
||||
|
||||
# derive max & min input length for sample rate & max duration
|
||||
max_input_length = data_args.max_duration_in_seconds * feature_extractor.sampling_rate
|
||||
min_input_length = data_args.min_duration_in_seconds * feature_extractor.sampling_rate
|
||||
audio_column_name = data_args.audio_column_name
|
||||
num_workers = data_args.preprocessing_num_workers
|
||||
|
||||
# `phoneme_language` is only relevant if the model is fine-tuned on phoneme classification
|
||||
phoneme_language = data_args.phoneme_language
|
||||
|
||||
# Preprocessing the datasets.
|
||||
# We need to read the audio files as arrays and tokenize the targets.
|
||||
def prepare_dataset(batch):
|
||||
# load audio
|
||||
sample = batch[audio_column_name]
|
||||
|
||||
inputs = feature_extractor(sample["array"], sampling_rate=sample["sampling_rate"])
|
||||
batch["input_values"] = inputs.input_values[0]
|
||||
batch["input_length"] = len(batch["input_values"])
|
||||
|
||||
# encode targets
|
||||
additional_kwargs = {}
|
||||
if phoneme_language is not None:
|
||||
additional_kwargs["phonemizer_lang"] = phoneme_language
|
||||
|
||||
batch["labels"] = tokenizer(batch["target_text"], **additional_kwargs).input_ids
|
||||
return batch
|
||||
|
||||
with training_args.main_process_first(desc="dataset map preprocessing"):
|
||||
vectorized_datasets = raw_datasets.map(
|
||||
prepare_dataset,
|
||||
remove_columns=next(iter(raw_datasets.values())).column_names,
|
||||
num_proc=num_workers,
|
||||
desc="preprocess datasets",
|
||||
)
|
||||
|
||||
def is_audio_in_length_range(length):
|
||||
return length > min_input_length and length < max_input_length
|
||||
|
||||
# filter data that is shorter than min_input_length
|
||||
vectorized_datasets = vectorized_datasets.filter(
|
||||
is_audio_in_length_range,
|
||||
num_proc=num_workers,
|
||||
input_columns=["input_length"],
|
||||
)
|
||||
|
||||
# 7. Next, we can prepare the training.
|
||||
# Let's use word error rate (WER) as our evaluation metric,
|
||||
# instantiate a data collator and the trainer
|
||||
|
||||
# Define evaluation metrics during training, *i.e.* word error rate, character error rate
|
||||
eval_metrics = {metric: load_metric(metric) for metric in data_args.eval_metrics}
|
||||
|
||||
# for large datasets it is advised to run the preprocessing on a
|
||||
# single machine first with ``args.preprocessing_only`` since there will mostly likely
|
||||
# be a timeout when running the script in distributed mode.
|
||||
# In a second step ``args.preprocessing_only`` can then be set to `False` to load the
|
||||
# cached dataset
|
||||
if data_args.preprocessing_only:
|
||||
logger.info(f"Data preprocessing finished. Files cached at {vectorized_datasets.cache_files}")
|
||||
return
|
||||
|
||||
def compute_metrics(pred):
|
||||
pred_logits = pred.predictions
|
||||
pred_ids = np.argmax(pred_logits, axis=-1)
|
||||
|
||||
pred.label_ids[pred.label_ids == -100] = tokenizer.pad_token_id
|
||||
|
||||
pred_str = tokenizer.batch_decode(pred_ids)
|
||||
# we do not want to group tokens when computing the metrics
|
||||
label_str = tokenizer.batch_decode(pred.label_ids, group_tokens=False)
|
||||
|
||||
metrics = {k: v.compute(predictions=pred_str, references=label_str) for k, v in eval_metrics.items()}
|
||||
|
||||
return metrics
|
||||
|
||||
# Now save everything to be able to create a single processor later
|
||||
if is_main_process(training_args.local_rank):
|
||||
# save feature extractor, tokenizer and config
|
||||
feature_extractor.save_pretrained(training_args.output_dir)
|
||||
tokenizer.save_pretrained(training_args.output_dir)
|
||||
config.save_pretrained(training_args.output_dir)
|
||||
|
||||
try:
|
||||
processor = AutoProcessor.from_pretrained(training_args.output_dir)
|
||||
except (OSError, KeyError):
|
||||
warnings.warn(
|
||||
"Loading a processor from a feature extractor config that does not"
|
||||
" include a `processor_class` attribute is deprecated and will be removed in v5. Please add the following "
|
||||
" attribute to your `preprocessor_config.json` file to suppress this warning: "
|
||||
" `'processor_class': 'Wav2Vec2Processor'`",
|
||||
FutureWarning,
|
||||
)
|
||||
processor = Wav2Vec2Processor.from_pretrained(training_args.output_dir)
|
||||
|
||||
# Instantiate custom data collator
|
||||
data_collator = DataCollatorCTCWithPadding(processor=processor)
|
||||
|
||||
# Initialize Trainer
|
||||
trainer = Trainer(
|
||||
model=model,
|
||||
data_collator=data_collator,
|
||||
args=training_args,
|
||||
compute_metrics=compute_metrics,
|
||||
train_dataset=vectorized_datasets["train"] if training_args.do_train else None,
|
||||
eval_dataset=vectorized_datasets["eval"] if training_args.do_eval else None,
|
||||
tokenizer=feature_extractor,
|
||||
)
|
||||
|
||||
# 8. Finally, we can start training
|
||||
|
||||
# Training
|
||||
if training_args.do_train:
|
||||
|
||||
# use last checkpoint if exist
|
||||
if last_checkpoint is not None:
|
||||
checkpoint = last_checkpoint
|
||||
elif os.path.isdir(model_args.model_name_or_path):
|
||||
checkpoint = model_args.model_name_or_path
|
||||
else:
|
||||
checkpoint = None
|
||||
|
||||
train_result = trainer.train(resume_from_checkpoint=checkpoint)
|
||||
trainer.save_model()
|
||||
|
||||
metrics = train_result.metrics
|
||||
max_train_samples = (
|
||||
data_args.max_train_samples
|
||||
if data_args.max_train_samples is not None
|
||||
else len(vectorized_datasets["train"])
|
||||
)
|
||||
metrics["train_samples"] = min(max_train_samples, len(vectorized_datasets["train"]))
|
||||
|
||||
trainer.log_metrics("train", metrics)
|
||||
trainer.save_metrics("train", metrics)
|
||||
trainer.save_state()
|
||||
|
||||
# Evaluation
|
||||
results = {}
|
||||
if training_args.do_eval:
|
||||
logger.info("*** Evaluate ***")
|
||||
metrics = trainer.evaluate()
|
||||
max_eval_samples = (
|
||||
data_args.max_eval_samples if data_args.max_eval_samples is not None else len(vectorized_datasets["eval"])
|
||||
)
|
||||
metrics["eval_samples"] = min(max_eval_samples, len(vectorized_datasets["eval"]))
|
||||
|
||||
trainer.log_metrics("eval", metrics)
|
||||
trainer.save_metrics("eval", metrics)
|
||||
|
||||
# Write model card and (optionally) push to hub
|
||||
config_name = data_args.dataset_config_name if data_args.dataset_config_name is not None else "na"
|
||||
kwargs = {
|
||||
"finetuned_from": model_args.model_name_or_path,
|
||||
"tasks": "speech-recognition",
|
||||
"tags": ["automatic-speech-recognition", data_args.dataset_name],
|
||||
"dataset_args": f"Config: {config_name}, Training split: {data_args.train_split_name}, Eval split: {data_args.eval_split_name}",
|
||||
"dataset": f"{data_args.dataset_name.upper()} - {config_name.upper()}",
|
||||
}
|
||||
if "common_voice" in data_args.dataset_name:
|
||||
kwargs["language"] = config_name
|
||||
|
||||
if training_args.push_to_hub:
|
||||
trainer.push_to_hub(**kwargs)
|
||||
else:
|
||||
trainer.create_model_card(**kwargs)
|
||||
|
||||
return results
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
1
special_tokens_map.json
Normal file
1
special_tokens_map.json
Normal file
@@ -0,0 +1 @@
|
||||
{"unk_token": "[UNK]", "pad_token": "[PAD]"}
|
||||
@@ -0,0 +1,2 @@
|
||||
WER: 0.6362465106291604
|
||||
CER: 0.17202817283379465
|
||||
1
tokenizer_config.json
Normal file
1
tokenizer_config.json
Normal file
@@ -0,0 +1 @@
|
||||
{"unk_token": "[UNK]", "bos_token": null, "eos_token": null, "pad_token": "[PAD]", "do_lower_case": false, "word_delimiter_token": "|", "special_tokens_map_file": null, "tokenizer_file": null, "name_or_path": "./", "tokenizer_class": "Wav2Vec2CTCTokenizer"}
|
||||
8
train_results.json
Normal file
8
train_results.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"epoch": 2.0,
|
||||
"train_loss": 1.788894365302016,
|
||||
"train_runtime": 52105.5599,
|
||||
"train_samples": 395042,
|
||||
"train_samples_per_second": 15.163,
|
||||
"train_steps_per_second": 0.118
|
||||
}
|
||||
499
trainer_state.json
Normal file
499
trainer_state.json
Normal file
@@ -0,0 +1,499 @@
|
||||
{
|
||||
"best_metric": 0.26187804341316223,
|
||||
"best_model_checkpoint": "./checkpoint-6000",
|
||||
"epoch": 1.9998784982382245,
|
||||
"global_step": 6172,
|
||||
"is_hyper_param_search": false,
|
||||
"is_local_process_zero": true,
|
||||
"is_world_process_zero": true,
|
||||
"log_history": [
|
||||
{
|
||||
"epoch": 0.03,
|
||||
"learning_rate": 3.7499999999999997e-06,
|
||||
"loss": 12.1043,
|
||||
"step": 100
|
||||
},
|
||||
{
|
||||
"epoch": 0.06,
|
||||
"learning_rate": 7.499999999999999e-06,
|
||||
"loss": 6.4771,
|
||||
"step": 200
|
||||
},
|
||||
{
|
||||
"epoch": 0.1,
|
||||
"learning_rate": 1.1249999999999999e-05,
|
||||
"loss": 4.4866,
|
||||
"step": 300
|
||||
},
|
||||
{
|
||||
"epoch": 0.13,
|
||||
"learning_rate": 1.4999999999999999e-05,
|
||||
"loss": 3.8842,
|
||||
"step": 400
|
||||
},
|
||||
{
|
||||
"epoch": 0.16,
|
||||
"learning_rate": 1.8712499999999997e-05,
|
||||
"loss": 3.495,
|
||||
"step": 500
|
||||
},
|
||||
{
|
||||
"epoch": 0.16,
|
||||
"eval_loss": 3.3882696628570557,
|
||||
"eval_runtime": 721.337,
|
||||
"eval_samples_per_second": 22.099,
|
||||
"eval_steps_per_second": 1.382,
|
||||
"eval_wer": 1.0,
|
||||
"step": 500
|
||||
},
|
||||
{
|
||||
"epoch": 0.19,
|
||||
"learning_rate": 2.2462499999999997e-05,
|
||||
"loss": 3.171,
|
||||
"step": 600
|
||||
},
|
||||
{
|
||||
"epoch": 0.23,
|
||||
"learning_rate": 2.6212499999999997e-05,
|
||||
"loss": 3.0275,
|
||||
"step": 700
|
||||
},
|
||||
{
|
||||
"epoch": 0.26,
|
||||
"learning_rate": 2.99625e-05,
|
||||
"loss": 2.9681,
|
||||
"step": 800
|
||||
},
|
||||
{
|
||||
"epoch": 0.29,
|
||||
"learning_rate": 3.37125e-05,
|
||||
"loss": 2.9347,
|
||||
"step": 900
|
||||
},
|
||||
{
|
||||
"epoch": 0.32,
|
||||
"learning_rate": 3.7462499999999996e-05,
|
||||
"loss": 2.9095,
|
||||
"step": 1000
|
||||
},
|
||||
{
|
||||
"epoch": 0.32,
|
||||
"eval_loss": 2.9152133464813232,
|
||||
"eval_runtime": 718.1623,
|
||||
"eval_samples_per_second": 22.197,
|
||||
"eval_steps_per_second": 1.388,
|
||||
"eval_wer": 0.9999871219487068,
|
||||
"step": 1000
|
||||
},
|
||||
{
|
||||
"epoch": 0.36,
|
||||
"learning_rate": 4.12125e-05,
|
||||
"loss": 2.8888,
|
||||
"step": 1100
|
||||
},
|
||||
{
|
||||
"epoch": 0.39,
|
||||
"learning_rate": 4.4962499999999995e-05,
|
||||
"loss": 2.8347,
|
||||
"step": 1200
|
||||
},
|
||||
{
|
||||
"epoch": 0.42,
|
||||
"learning_rate": 4.871249999999999e-05,
|
||||
"loss": 2.5318,
|
||||
"step": 1300
|
||||
},
|
||||
{
|
||||
"epoch": 0.45,
|
||||
"learning_rate": 5.2462499999999994e-05,
|
||||
"loss": 2.0502,
|
||||
"step": 1400
|
||||
},
|
||||
{
|
||||
"epoch": 0.49,
|
||||
"learning_rate": 5.62125e-05,
|
||||
"loss": 1.8434,
|
||||
"step": 1500
|
||||
},
|
||||
{
|
||||
"epoch": 0.49,
|
||||
"eval_loss": 1.0473320484161377,
|
||||
"eval_runtime": 720.1235,
|
||||
"eval_samples_per_second": 22.136,
|
||||
"eval_steps_per_second": 1.384,
|
||||
"eval_wer": 0.7446153648029981,
|
||||
"step": 1500
|
||||
},
|
||||
{
|
||||
"epoch": 0.52,
|
||||
"learning_rate": 5.9962499999999994e-05,
|
||||
"loss": 1.7339,
|
||||
"step": 1600
|
||||
},
|
||||
{
|
||||
"epoch": 0.55,
|
||||
"learning_rate": 6.367499999999999e-05,
|
||||
"loss": 1.6535,
|
||||
"step": 1700
|
||||
},
|
||||
{
|
||||
"epoch": 0.58,
|
||||
"learning_rate": 6.7425e-05,
|
||||
"loss": 1.5793,
|
||||
"step": 1800
|
||||
},
|
||||
{
|
||||
"epoch": 0.62,
|
||||
"learning_rate": 7.1175e-05,
|
||||
"loss": 1.5056,
|
||||
"step": 1900
|
||||
},
|
||||
{
|
||||
"epoch": 0.65,
|
||||
"learning_rate": 7.492499999999999e-05,
|
||||
"loss": 1.4298,
|
||||
"step": 2000
|
||||
},
|
||||
{
|
||||
"epoch": 0.65,
|
||||
"eval_loss": 0.5728740692138672,
|
||||
"eval_runtime": 712.5783,
|
||||
"eval_samples_per_second": 22.371,
|
||||
"eval_steps_per_second": 1.399,
|
||||
"eval_wer": 0.5129521000882147,
|
||||
"step": 2000
|
||||
},
|
||||
{
|
||||
"epoch": 0.68,
|
||||
"learning_rate": 7.325623202301054e-05,
|
||||
"loss": 1.3592,
|
||||
"step": 2100
|
||||
},
|
||||
{
|
||||
"epoch": 0.71,
|
||||
"learning_rate": 7.145853307766058e-05,
|
||||
"loss": 1.2917,
|
||||
"step": 2200
|
||||
},
|
||||
{
|
||||
"epoch": 0.75,
|
||||
"learning_rate": 6.966083413231063e-05,
|
||||
"loss": 1.2536,
|
||||
"step": 2300
|
||||
},
|
||||
{
|
||||
"epoch": 0.78,
|
||||
"learning_rate": 6.788111217641419e-05,
|
||||
"loss": 1.2345,
|
||||
"step": 2400
|
||||
},
|
||||
{
|
||||
"epoch": 0.81,
|
||||
"learning_rate": 6.608341323106423e-05,
|
||||
"loss": 1.1937,
|
||||
"step": 2500
|
||||
},
|
||||
{
|
||||
"epoch": 0.81,
|
||||
"eval_loss": 0.3795304000377655,
|
||||
"eval_runtime": 716.4435,
|
||||
"eval_samples_per_second": 22.25,
|
||||
"eval_steps_per_second": 1.392,
|
||||
"eval_wer": 0.34504806732645216,
|
||||
"step": 2500
|
||||
},
|
||||
{
|
||||
"epoch": 0.84,
|
||||
"learning_rate": 6.428571428571427e-05,
|
||||
"loss": 1.1806,
|
||||
"step": 2600
|
||||
},
|
||||
{
|
||||
"epoch": 0.87,
|
||||
"learning_rate": 6.248801534036433e-05,
|
||||
"loss": 1.1651,
|
||||
"step": 2700
|
||||
},
|
||||
{
|
||||
"epoch": 0.91,
|
||||
"learning_rate": 6.069031639501438e-05,
|
||||
"loss": 1.1455,
|
||||
"step": 2800
|
||||
},
|
||||
{
|
||||
"epoch": 0.94,
|
||||
"learning_rate": 5.889261744966442e-05,
|
||||
"loss": 1.1312,
|
||||
"step": 2900
|
||||
},
|
||||
{
|
||||
"epoch": 0.97,
|
||||
"learning_rate": 5.709491850431447e-05,
|
||||
"loss": 1.1248,
|
||||
"step": 3000
|
||||
},
|
||||
{
|
||||
"epoch": 0.97,
|
||||
"eval_loss": 0.3320523500442505,
|
||||
"eval_runtime": 716.2808,
|
||||
"eval_samples_per_second": 22.255,
|
||||
"eval_steps_per_second": 1.392,
|
||||
"eval_wer": 0.30515830344552264,
|
||||
"step": 3000
|
||||
},
|
||||
{
|
||||
"epoch": 1.0,
|
||||
"learning_rate": 5.5297219558964525e-05,
|
||||
"loss": 1.1017,
|
||||
"step": 3100
|
||||
},
|
||||
{
|
||||
"epoch": 1.04,
|
||||
"learning_rate": 5.3499520613614567e-05,
|
||||
"loss": 1.0978,
|
||||
"step": 3200
|
||||
},
|
||||
{
|
||||
"epoch": 1.07,
|
||||
"learning_rate": 5.1701821668264615e-05,
|
||||
"loss": 1.0954,
|
||||
"step": 3300
|
||||
},
|
||||
{
|
||||
"epoch": 1.1,
|
||||
"learning_rate": 4.990412272291467e-05,
|
||||
"loss": 1.0867,
|
||||
"step": 3400
|
||||
},
|
||||
{
|
||||
"epoch": 1.13,
|
||||
"learning_rate": 4.812440076701821e-05,
|
||||
"loss": 1.0835,
|
||||
"step": 3500
|
||||
},
|
||||
{
|
||||
"epoch": 1.13,
|
||||
"eval_loss": 0.3037940561771393,
|
||||
"eval_runtime": 714.1597,
|
||||
"eval_samples_per_second": 22.321,
|
||||
"eval_steps_per_second": 1.396,
|
||||
"eval_wer": 0.2805032742445413,
|
||||
"step": 3500
|
||||
},
|
||||
{
|
||||
"epoch": 1.17,
|
||||
"learning_rate": 4.632670182166826e-05,
|
||||
"loss": 1.0808,
|
||||
"step": 3600
|
||||
},
|
||||
{
|
||||
"epoch": 1.2,
|
||||
"learning_rate": 4.4529002876318304e-05,
|
||||
"loss": 1.0648,
|
||||
"step": 3700
|
||||
},
|
||||
{
|
||||
"epoch": 1.23,
|
||||
"learning_rate": 4.273130393096836e-05,
|
||||
"loss": 1.0541,
|
||||
"step": 3800
|
||||
},
|
||||
{
|
||||
"epoch": 1.26,
|
||||
"learning_rate": 4.093360498561841e-05,
|
||||
"loss": 1.0621,
|
||||
"step": 3900
|
||||
},
|
||||
{
|
||||
"epoch": 1.3,
|
||||
"learning_rate": 3.913590604026845e-05,
|
||||
"loss": 1.0479,
|
||||
"step": 4000
|
||||
},
|
||||
{
|
||||
"epoch": 1.3,
|
||||
"eval_loss": 0.2910499572753906,
|
||||
"eval_runtime": 718.1665,
|
||||
"eval_samples_per_second": 22.197,
|
||||
"eval_steps_per_second": 1.388,
|
||||
"eval_wer": 0.26888727197800427,
|
||||
"step": 4000
|
||||
},
|
||||
{
|
||||
"epoch": 1.33,
|
||||
"learning_rate": 3.7338207094918506e-05,
|
||||
"loss": 1.0428,
|
||||
"step": 4100
|
||||
},
|
||||
{
|
||||
"epoch": 1.36,
|
||||
"learning_rate": 3.555848513902205e-05,
|
||||
"loss": 1.047,
|
||||
"step": 4200
|
||||
},
|
||||
{
|
||||
"epoch": 1.39,
|
||||
"learning_rate": 3.37607861936721e-05,
|
||||
"loss": 1.0397,
|
||||
"step": 4300
|
||||
},
|
||||
{
|
||||
"epoch": 1.43,
|
||||
"learning_rate": 3.1963087248322145e-05,
|
||||
"loss": 1.0347,
|
||||
"step": 4400
|
||||
},
|
||||
{
|
||||
"epoch": 1.46,
|
||||
"learning_rate": 3.0165388302972194e-05,
|
||||
"loss": 1.0413,
|
||||
"step": 4500
|
||||
},
|
||||
{
|
||||
"epoch": 1.46,
|
||||
"eval_loss": 0.27976545691490173,
|
||||
"eval_runtime": 713.7382,
|
||||
"eval_samples_per_second": 22.335,
|
||||
"eval_steps_per_second": 1.397,
|
||||
"eval_wer": 0.2592995627901586,
|
||||
"step": 4500
|
||||
},
|
||||
{
|
||||
"epoch": 1.49,
|
||||
"learning_rate": 2.836768935762224e-05,
|
||||
"loss": 1.0238,
|
||||
"step": 4600
|
||||
},
|
||||
{
|
||||
"epoch": 1.52,
|
||||
"learning_rate": 2.656999041227229e-05,
|
||||
"loss": 1.0269,
|
||||
"step": 4700
|
||||
},
|
||||
{
|
||||
"epoch": 1.56,
|
||||
"learning_rate": 2.4772291466922337e-05,
|
||||
"loss": 1.021,
|
||||
"step": 4800
|
||||
},
|
||||
{
|
||||
"epoch": 1.59,
|
||||
"learning_rate": 2.2974592521572386e-05,
|
||||
"loss": 1.0186,
|
||||
"step": 4900
|
||||
},
|
||||
{
|
||||
"epoch": 1.62,
|
||||
"learning_rate": 2.1176893576222434e-05,
|
||||
"loss": 1.014,
|
||||
"step": 5000
|
||||
},
|
||||
{
|
||||
"epoch": 1.62,
|
||||
"eval_loss": 0.27265554666519165,
|
||||
"eval_runtime": 707.3075,
|
||||
"eval_samples_per_second": 22.538,
|
||||
"eval_steps_per_second": 1.41,
|
||||
"eval_wer": 0.25117351242409997,
|
||||
"step": 5000
|
||||
},
|
||||
{
|
||||
"epoch": 1.65,
|
||||
"learning_rate": 1.9379194630872483e-05,
|
||||
"loss": 1.0074,
|
||||
"step": 5100
|
||||
},
|
||||
{
|
||||
"epoch": 1.68,
|
||||
"learning_rate": 1.759947267497603e-05,
|
||||
"loss": 1.0193,
|
||||
"step": 5200
|
||||
},
|
||||
{
|
||||
"epoch": 1.72,
|
||||
"learning_rate": 1.5801773729626078e-05,
|
||||
"loss": 1.0044,
|
||||
"step": 5300
|
||||
},
|
||||
{
|
||||
"epoch": 1.75,
|
||||
"learning_rate": 1.4004074784276125e-05,
|
||||
"loss": 1.0005,
|
||||
"step": 5400
|
||||
},
|
||||
{
|
||||
"epoch": 1.78,
|
||||
"learning_rate": 1.2206375838926173e-05,
|
||||
"loss": 1.004,
|
||||
"step": 5500
|
||||
},
|
||||
{
|
||||
"epoch": 1.78,
|
||||
"eval_loss": 0.26460376381874084,
|
||||
"eval_runtime": 719.6956,
|
||||
"eval_samples_per_second": 22.15,
|
||||
"eval_steps_per_second": 1.385,
|
||||
"eval_wer": 0.2470782921128375,
|
||||
"step": 5500
|
||||
},
|
||||
{
|
||||
"epoch": 1.81,
|
||||
"learning_rate": 1.0408676893576222e-05,
|
||||
"loss": 1.0048,
|
||||
"step": 5600
|
||||
},
|
||||
{
|
||||
"epoch": 1.85,
|
||||
"learning_rate": 8.610977948226269e-06,
|
||||
"loss": 0.9988,
|
||||
"step": 5700
|
||||
},
|
||||
{
|
||||
"epoch": 1.88,
|
||||
"learning_rate": 6.813279002876318e-06,
|
||||
"loss": 0.9919,
|
||||
"step": 5800
|
||||
},
|
||||
{
|
||||
"epoch": 1.91,
|
||||
"learning_rate": 5.015580057526366e-06,
|
||||
"loss": 0.9886,
|
||||
"step": 5900
|
||||
},
|
||||
{
|
||||
"epoch": 1.94,
|
||||
"learning_rate": 3.217881112176414e-06,
|
||||
"loss": 0.9949,
|
||||
"step": 6000
|
||||
},
|
||||
{
|
||||
"epoch": 1.94,
|
||||
"eval_loss": 0.26187804341316223,
|
||||
"eval_runtime": 717.4473,
|
||||
"eval_samples_per_second": 22.219,
|
||||
"eval_steps_per_second": 1.39,
|
||||
"eval_wer": 0.24574541380398318,
|
||||
"step": 6000
|
||||
},
|
||||
{
|
||||
"epoch": 1.98,
|
||||
"learning_rate": 1.4201821668264622e-06,
|
||||
"loss": 0.9931,
|
||||
"step": 6100
|
||||
},
|
||||
{
|
||||
"epoch": 2.0,
|
||||
"step": 6172,
|
||||
"total_flos": 1.1573983785360925e+20,
|
||||
"train_loss": 1.788894365302016,
|
||||
"train_runtime": 52105.5599,
|
||||
"train_samples_per_second": 15.163,
|
||||
"train_steps_per_second": 0.118
|
||||
}
|
||||
],
|
||||
"max_steps": 6172,
|
||||
"num_train_epochs": 2,
|
||||
"total_flos": 1.1573983785360925e+20,
|
||||
"trial_name": null,
|
||||
"trial_params": null
|
||||
}
|
||||
3
training_args.bin
Normal file
3
training_args.bin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a08595bc646029dfd4b913401c9c8bbbebbda1fd5a0479444ebe9ba71638d4b1
|
||||
size 2991
|
||||
1
vocab.json
Normal file
1
vocab.json
Normal file
@@ -0,0 +1 @@
|
||||
{"'": 1, "a": 2, "b": 3, "c": 4, "d": 5, "e": 6, "f": 7, "g": 8, "h": 9, "i": 10, "j": 11, "k": 12, "l": 13, "m": 14, "n": 15, "o": 16, "p": 17, "q": 18, "r": 19, "s": 20, "t": 21, "u": 22, "v": 23, "w": 24, "x": 25, "y": 26, "z": 27, "à": 28, "â": 29, "ä": 30, "ç": 31, "è": 32, "é": 33, "ê": 34, "ë": 35, "î": 36, "ï": 37, "ô": 38, "ö": 39, "ù": 40, "û": 41, "ü": 42, "ÿ": 43, "|": 0, "[UNK]": 44, "[PAD]": 45}
|
||||
Reference in New Issue
Block a user