Skip to content
Open
Changes from 3 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
620a042
feat: Add option to generate LM image and GC via two separate jobs
NeoLegends Aug 21, 2023
a68265c
chore: Document parameter
NeoLegends Aug 21, 2023
b74c654
fix: Always assign the (possibly to None) lm_gc property
NeoLegends Aug 21, 2023
79cbd2a
fix bug, assign jobs to class if possible
NeoLegends Aug 22, 2023
78f6bed
refactor find_arpa_lms into standalone function
NeoLegends Aug 29, 2023
291b734
Merge branch 'main' into feat/separate-lmi-gc-generation
NeoLegends Aug 29, 2023
d209e8f
fix bugs from trial runs
NeoLegends Aug 29, 2023
02d7088
Re-enable lm-util
NeoLegends Aug 29, 2023
6a236c8
more mem for LM + GC jobs
NeoLegends Aug 29, 2023
a61b03f
make mem configurable
NeoLegends Aug 29, 2023
008c9dc
even more mem
NeoLegends Aug 29, 2023
07e1136
enable split behavior by default, document hash implications
NeoLegends Aug 29, 2023
cdc791a
disable flag by default
NeoLegends Aug 30, 2023
ab010c5
Rename flag to be more clear
NeoLegends Sep 11, 2023
5a8ec3d
rename local function
NeoLegends Sep 11, 2023
ed001c4
fix wording
NeoLegends Nov 6, 2023
115b160
Merge branch 'main' into feat/separate-lmi-gc-generation
NeoLegends Nov 9, 2023
49315ea
Merge branch 'main' into feat/separate-lmi-gc-generation
Jul 15, 2025
0182ad6
introduce enum
Jul 30, 2025
f3199fb
Apply suggestions from code review
DanEnergetics Jul 30, 2025
f784e87
Merge branch 'feat/separate-lmi-gc-generation' of github.com:rwth-i6/…
Jul 30, 2025
f02c2c9
change util function signature
Jul 30, 2025
9b61538
more reviewer comments
Jul 30, 2025
d2507d0
ruff formatting
Jul 30, 2025
a5a6af9
adjust rescoring job
Jul 30, 2025
f74c52f
fix parameter name typo
Jul 30, 2025
0f82f3f
fix empty post config
Jul 30, 2025
ffe3681
postpone arpa discovery -> should fix hash test
Aug 6, 2025
ef5e8ce
ruff
Aug 6, 2025
a2292d0
reviewer comments
Aug 15, 2025
7d1bcc9
more reviewer comments
Aug 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions recognition/advanced_tree_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

Path = setup_path(__package__)

import copy
import math
import os
import shutil
Expand Down Expand Up @@ -167,6 +168,7 @@ def __init__(
lmgc_mem: float = 12.0,
lmgc_alias: Optional[str] = None,
lmgc_scorer: Optional[rasr.FeatureScorer] = None,
separate_lmi_gc_generation: bool = False,
model_combination_config: Optional[rasr.RasrConfig] = None,
model_combination_post_config: Optional[rasr.RasrConfig] = None,
extra_config: Optional[rasr.RasrConfig] = None,
Expand All @@ -190,6 +192,7 @@ def __init__(
:param lmgc_mem: Memory requirement for the AdvancedTreeSearchLmImageAndGlobalCacheJob
:param lmgc_alias: Alias for the AdvancedTreeSearchLmImageAndGlobalCacheJob
:param lmgc_scorer: Dummy scorer for the AdvancedTreeSearchLmImageAndGlobalCacheJob which is required but unused
:param separate_lmi_gc_generation: Whether to generate the LM image and the global cache via two separate jobs for a more stable hash
:param model_combination_config: Configuration for model combination
:param model_combination_post_config: Post config for model combination
:param extra_config: Additional Config for recognition
Expand Down Expand Up @@ -286,18 +289,41 @@ def create_config(
lmgc_mem: float,
lmgc_alias: Optional[str],
lmgc_scorer: Optional[rasr.FeatureScorer],
separate_lmi_gc_generation: bool,
model_combination_config: Optional[rasr.RasrConfig],
model_combination_post_config: Optional[rasr.RasrConfig],
extra_config: Optional[rasr.RasrConfig],
extra_post_config: Optional[rasr.RasrConfig],
**kwargs,
):
lm_gc = AdvancedTreeSearchLmImageAndGlobalCacheJob(
crp, lmgc_scorer if lmgc_scorer is not None else feature_scorer, extra_config, extra_post_config
)
if lmgc_alias is not None:
lm_gc.add_alias(lmgc_alias)
lm_gc.rqmt["mem"] = lmgc_mem
def specialize_lm_config(crp, lm_config):
crp = copy.deepcopy(crp)
crp.language_model = lm_config
return crp

if separate_lmi_gc_generation:
gc = BuildGlobalCacheJob(crp, extra_config, extra_post_config).out_global_cache

arpa_lms = AdvancedTreeSearchLmImageAndGlobalCacheJob.find_arpa_lms(
crp.language_model, post_config.lm if post_config is not None else None
)
lm_images = {
(i + 1): lm.CreateLmImageJob(
specialize_lm_config(crp, lm), extra_config=extra_config, extra_post_config=extra_post_config
).out_lm
for i, lm in enumerate(arpa_lms)
}
lm_gc = None
else:
lm_gc = AdvancedTreeSearchLmImageAndGlobalCacheJob(
crp, lmgc_scorer if lmgc_scorer is not None else feature_scorer, extra_config, extra_post_config
)
if lmgc_alias is not None:
lm_gc.add_alias(lmgc_alias)
lm_gc.rqmt["mem"] = lmgc_mem

gc = lm_gc.out_global_cache
lm_images = lm_gc.out_lm_images

search_parameters = cls.update_search_parameters(search_parameters)

Expand Down Expand Up @@ -397,14 +423,14 @@ def create_config(
]

post_config.flf_lattice_tool.global_cache.read_only = True
post_config.flf_lattice_tool.global_cache.file = lm_gc.out_global_cache
post_config.flf_lattice_tool.global_cache.file = gc

arpa_lms = AdvancedTreeSearchLmImageAndGlobalCacheJob.find_arpa_lms(
config.flf_lattice_tool.network.recognizer.lm,
post_config.flf_lattice_tool.network.recognizer.lm,
)
for i, lm_config in enumerate(arpa_lms):
lm_config[1].image = lm_gc.out_lm_images[i + 1]
lm_config[1].image = lm_images[i + 1]

# Remaining Flf-network

Expand Down