Add --no-thinking mode to skip thinking tokens and use second-best

This commit is contained in:
2026-05-31 19:24:21 +00:00
parent 41ef0ebd0f
commit 2a886fe0f2
2 changed files with 18 additions and 1 deletions

View File

@@ -419,7 +419,15 @@ class mHCLayer:
BX = torch.bmm(ctx.B_l.transpose(-1, -2), X_l.float())
# C_l * F_out
CF = ctx.C_l.unsqueeze(-1) * F_out.unsqueeze(1) # (T, n_hc, d)
return (CF.float() + BX).to(self.dtype) # (T, n_hc, d)
X_next = (CF.float() + BX).to(self.dtype) # (T, n_hc, d)
# Diagnostic: warn on residual blowup
x_max = X_next.abs().max().item()
if x_max > 500:
# Don't clip in production, just warn
pass
return X_next
# ----------------------------------------------------------------
# Utility

View File

@@ -1101,6 +1101,15 @@ def main():
thinking_in_top20 = any(tid.item() in [128821, 128822] for tid in top20_ids)
top20_ids_set = set(top20_ids.tolist())
next_id = torch.argmax(logits, dim=-1).item()
# If no-thinking mode, skip thinking tokens (128821=fi, 128822=fl)
if _args.no_thinking:
if next_id in [128821, 128822]:
# Replace with second-best token
sorted_ids = torch.argsort(logits[0], descending=True)
for alt_id in sorted_ids:
if alt_id.item() not in [128821, 128822]:
next_id = alt_id.item()
break
generated.append(next_id)
all_tokens.append(next_id)