File size: 4,128 Bytes
6a125ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Sequential Fine-Tuning of Whisper for Persian ASR

## 1. Overview

This document describes a **sequential fine-tuning strategy** for adapting the OpenAI Whisper model to large-scale **Persian (Farsi) Automatic Speech Recognition (ASR)** datasets. The approach is designed for scenarios where multiple very large datasets (β‰ˆ244 GB each) are available and training must be done in stages rather than as a single joint run.

The goal is to incrementally improve ASR performance while maintaining stability, avoiding catastrophic forgetting, and ensuring reproducibility.

---

## 2. Problem Statement

* Number of datasets: 7
* Language: Persian (Farsi)
* Sampling rate: 16 kHz (native Whisper format)
* Task: Speech-to-text (transcription only)
* Dataset size: ~244 - ~300 GB per dataset

Due to data volume and compute constraints, training on all datasets simultaneously is impractical. Therefore, **sequential fine-tuning** is used.

---

## 3. Proposed Training Strategy

### 3.1 Sequential Fine-Tuning

The model is trained iteratively:

1. Start from the base Whisper model
2. Fine-tune on Dataset 1 β†’ save best checkpoint
3. Load best checkpoint from Dataset 1
4. Fine-tune on Dataset 2 β†’ save best checkpoint
5. Repeat until Dataset 7

The final model is the **best checkpoint obtained from the last dataset**.

This strategy allows gradual adaptation while preserving previously learned knowledge.

---

## 4. Risk Analysis

### 4.1 Catastrophic Forgetting

Catastrophic forgetting occurs when a model loses performance on earlier datasets after training on new data.

**Risk level in this project: LOW**, because:

* All datasets are Persian
* Same task (ASR)
* Same sampling rate (16 kHz)
* Same tokenizer and vocabulary

However, mitigation strategies are still applied as best practice.

---

## 5. Learning Rate Policy

### 5.1 Motivation

Later datasets should refine the model rather than overwrite earlier representations. Therefore, learning rate must decrease over time.

### 5.2 Recommended Learning Rate Schedule

| Dataset | Learning Rate |
| ------- | ------------- |
| DS1     | 1e-5          |
| DS2     | 5e-6          |
| DS3     | 5e-6          |
| DS4     | 2e-6          |
| DS5     | 2e-6          |
| DS6     | 1e-6          |
| DS7     | 1e-6          |

This gradual decay ensures stable convergence and reduces forgetting.


## 6. Checkpointing Strategy

### 6.1 Intra-Dataset Checkpointing

During training on each dataset:

* Save checkpoints every 1000 steps
* Evaluate every 1000 steps
* Track Word Error Rate (WER)
* Load best checkpoint at end of training

### 6.2 Inter-Dataset Checkpointing

Each dataset has its own output directory:

```
Checkpoints/
 β”œβ”€β”€ ds1/
 β”‚    └── best/
 β”œβ”€β”€ ds2/
 β”‚    └── best/
 β”œβ”€β”€ ds3/
 β”‚    └── best/
 β”œβ”€β”€ ds4/
 β”‚    └── best/
 β”œβ”€β”€ ds5/
 β”‚    └── best/
 β”œβ”€β”€ ds6/
 β”‚    └── best/
 └── ds7/
      └── best/   ← Final Model
```

This structure allows rollback, debugging, and domain-specific model reuse.

---

## 7. Evaluation Protocol

### 7.1 Metrics

* Primary metric: Word Error Rate (WER)
* Evaluation performed at fixed step intervals

### 7.2 Validation Sets

* Maintain a small validation split per dataset
* Optionally evaluate previous datasets to detect regression

---

## 8. Logging and Monitoring

### 8.1 TensorBoard

Training and evaluation metrics are logged using TensorBoard:

* Training loss
* Evaluation loss
* Evaluation WER
* Learning rate

TensorBoard enables comparison across datasets and early detection of instability.

---

## 9. Whisper-Specific Configuration

* Language token forced to Persian (`<|fa|>`)
* Task set to transcription only
* No translation mixing
* Consistent text normalization (digits, punctuation)

---

## 10. Trainer Configuration Example

Key parameters:

* Gradient accumulation for large effective batch size
* BF16 precision for performance
* Checkpoint saving every 1000 steps
* Best model selection based on WER

This configuration balances performance, stability, and resource efficiency.

---