From 0e9f02d4d6818639a9d9559a9df8e0944fbdc384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=2EL=2E=20=CE=9B?= Date: Thu, 9 Jan 2025 18:11:52 +0800 Subject: [PATCH] fixed max_hit compute bug in jacobi_greedy_search_multilevel. --- lade/decoding.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lade/decoding.py b/lade/decoding.py index c08ee69..1d4d396 100644 --- a/lade/decoding.py +++ b/lade/decoding.py @@ -1031,7 +1031,7 @@ def copy_from_last(): first_guess = next_tokens.item() max_hit = 0 - hits = [first_guess] + [0] * (GUESS_SIZE - 1) + hits = [first_guess] + [0] * GUESS_SIZE new_results = [] @@ -1075,8 +1075,9 @@ def copy_from_last(): correct = [first_guess] + guess_results[egx:egx + GUESS_SIZE] myguess = guess_tokens[egx:egx + GUESS_SIZE] gg = 0 - for gg in range(len(myguess)): - if myguess[gg] != correct[gg]: + # if all tokens in myguess equal to correct, gg should be len(myguess) + for gg in range(len(myguess) + 1): + if gg >= len(myguess) or myguess[gg] != correct[gg]: break if gg > max_hit: max_hit = gg