File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
users/zeyer/experiments/exp2024_04_23_baselines Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
from typing import Optional , Any , Tuple , Dict
6
6
import functools
7
+ import numpy as np
7
8
8
9
from returnn .tensor import Tensor , Dim
9
10
import returnn .frontend as rf
@@ -322,6 +323,33 @@ def py():
322
323
res .output ,
323
324
)
324
325
326
+ # Tune scales on N-best list with rescoring. (Efficient.)
327
+ beam_size = 128
328
+ for prior_scale in np .linspace (0.0 , 1.0 , 11 ):
329
+ for lm_scale in np .linspace (0.0 , 2.0 , 21 ):
330
+ res = recog_model (
331
+ task = task ,
332
+ model = ctc_model ,
333
+ recog_def = model_recog_ctc_only ,
334
+ config = {"beam_size" : beam_size },
335
+ recog_pre_post_proc_funcs_ext = [
336
+ functools .partial (
337
+ lm_framewise_prior_rescore ,
338
+ # framewise standard prior
339
+ prior = Prior (file = prior , type = "prob" , vocab = vocab_w_blank_file ),
340
+ prior_scale = prior_scale ,
341
+ lm = lm ,
342
+ lm_scale = lm_scale ,
343
+ vocab = vocab_file ,
344
+ vocab_opts_file = vocab_opts_file ,
345
+ )
346
+ ],
347
+ )
348
+ tk .register_output (
349
+ f"{ prefix } /rescore-beam{ beam_size } -lm_{ lm_out_name } -lmScale{ lm_scale } -priorScale{ prior_scale } " ,
350
+ res .output ,
351
+ )
352
+
325
353
326
354
_sis_prefix : Optional [str ] = None
327
355
You can’t perform that action at this time.
0 commit comments