|
Algorithm 1 AST Fine-Tuning with Selective Layer Unfreezing and Early Stopping |
Require: Pre-trained AST weights , Fine-tuning dataset , Validation dataset , Evaluation set , Patience , Max Epochs
-
Ensure: Optimal Model (Early-stopped), Final Epoch Model
-
1:
1. Model Initialization & Freezing Mechanism:
-
2:
Set for all parameters in ▹ Freeze all layers
-
3:
Unfreeze classification head and final 5 Transformer layers ()
-
4:
Initialize ,
-
5:
2. Fine-Tuning and Early Stopping Loop:
-
6:
for each do
-
7:
▹ Update only 5 layers + classification head
-
8:
-
9:
if then ▹ New global minimum found
-
10:
-
11:
▹ Save early-stopped model checkpoint
-
12:
▹ Reset patience tracker
-
13:
else
-
14:
-
15:
if then ▹ Patience limit reached
-
16:
▹ Save state at fine-tuning termination
-
17:
break ▹ Early stopping triggered
-
18:
end if
-
19:
end if
-
20:
end for
-
21:
3. Model Evaluation:
-
22:
▹ Evaluate Early-stopped Model
-
23:
▹ Evaluate Final Epoch Model
-
24:
return, , and Metrics
|