From 2b9707cf4246648eb936ead27dfa844f1150d59a Mon Sep 17 00:00:00 2001 From: nckcard Date: Thu, 3 Jul 2025 14:05:04 -0700 Subject: [PATCH] lm redis bool fix --- language_model/language-model-standalone.py | 58 ++++++++++----------- model_training/evaluate_model.py | 4 ++ 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/language_model/language-model-standalone.py b/language_model/language-model-standalone.py index 173e322..5d10769 100644 --- a/language_model/language-model-standalone.py +++ b/language_model/language-model-standalone.py @@ -450,20 +450,20 @@ def main(args): # create a nice dict of params to put into redis lm_args = { 'lm_path': lm_path, - 'max_active': max_active, - 'min_active': min_active, - 'beam': beam, - 'lattice_beam': lattice_beam, - 'acoustic_scale': acoustic_scale, - 'ctc_blank_skip_threshold': ctc_blank_skip_threshold, - 'length_penalty': length_penalty, - 'nbest': nbest, - 'blank_penalty': blank_penalty, - 'alpha': alpha, - 'do_opt': do_opt, - 'rescore': rescore, - 'top_candidates_to_augment': top_candidates_to_augment, - 'score_penalty_percent': score_penalty_percent, + 'max_active': int(max_active), + 'min_active': int(min_active), + 'beam': float(beam), + 'lattice_beam': float(lattice_beam), + 'acoustic_scale': float(acoustic_scale), + 'ctc_blank_skip_threshold': float(ctc_blank_skip_threshold), + 'length_penalty': float(length_penalty), + 'nbest': int(nbest), + 'blank_penalty': float(blank_penalty), + 'alpha': float(alpha), + 'do_opt': int(do_opt), + 'rescore': int(rescore), + 'top_candidates_to_augment': int(top_candidates_to_augment), + 'score_penalty_percent': float(score_penalty_percent), } # pick GPU @@ -671,7 +671,6 @@ def main(args): blank_penalty = float(entry_data.get(b'blank_penalty', blank_penalty)) alpha = float(entry_data.get(b'alpha', alpha)) do_opt = int(entry_data.get(b'do_opt', do_opt)) - # opt_cache_dir = entry_data.get(b'opt_cache_dir', opt_cache_dir).decode() rescore = int(entry_data.get(b'rescore', rescore)) top_candidates_to_augment = int(entry_data.get(b'top_candidates_to_augment', top_candidates_to_augment)) score_penalty_percent = float(entry_data.get(b'score_penalty_percent', score_penalty_percent)) @@ -679,21 +678,20 @@ def main(args): # make sure that the update remote lm args are put into redis nicely lm_args = { 'lm_path': lm_path, - 'max_active': max_active, - 'min_active': min_active, - 'beam': beam, - 'lattice_beam': lattice_beam, - 'acoustic_scale': acoustic_scale, - 'ctc_blank_skip_threshold': ctc_blank_skip_threshold, - 'length_penalty': length_penalty, - 'nbest': nbest, - 'blank_penalty': blank_penalty, - 'alpha': alpha, - 'do_opt': do_opt, - # 'opt_cache_dir': opt_cache_dir, - 'rescore': rescore, - 'top_candidates_to_augment': top_candidates_to_augment, - 'score_penalty_percent': score_penalty_percent, + 'max_active': int(max_active), + 'min_active': int(min_active), + 'beam': float(beam), + 'lattice_beam': float(lattice_beam), + 'acoustic_scale': float(acoustic_scale), + 'ctc_blank_skip_threshold': float(ctc_blank_skip_threshold), + 'length_penalty': float(length_penalty), + 'nbest': int(nbest), + 'blank_penalty': float(blank_penalty), + 'alpha': float(alpha), + 'do_opt': int(do_opt), + 'rescore': int(rescore), + 'top_candidates_to_augment': int(top_candidates_to_augment), + 'score_penalty_percent': float(score_penalty_percent), } r.xadd('remote_lm_args', lm_args) diff --git a/model_training/evaluate_model.py b/model_training/evaluate_model.py index 65c8fe5..306641c 100644 --- a/model_training/evaluate_model.py +++ b/model_training/evaluate_model.py @@ -154,10 +154,14 @@ for session, data in test_data.items(): # make sure that the standalone language model is running on the localhost redis ip # see README.md for instructions on how to run the language model r = redis.Redis(host='localhost', port=6379, db=0) +r.flushall() # clear all streams in redis + +# define redis streams for the remote language model remote_lm_input_stream = 'remote_lm_input' remote_lm_output_partial_stream = 'remote_lm_output_partial' remote_lm_output_final_stream = 'remote_lm_output_final' +# set timestamps for last entries seen in the redis streams remote_lm_output_partial_lastEntrySeen = get_current_redis_time_ms(r) remote_lm_output_final_lastEntrySeen = get_current_redis_time_ms(r) remote_lm_done_resetting_lastEntrySeen = get_current_redis_time_ms(r)