transformers - 💡(How to fix) Fix MoonshineStreaming: sliding_window_mask_function off-by-one — right_window_size=4 attends to 3 future frames instead of 4 [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fixed

RAW_BUFFERClick to expand / collapse

System Info

  • transformers version: 5.9.0
  • Platform: Linux-6.8.0-100-generic-x86_64-with-glibc2.39
  • Python version: 3.12.3
  • PyTorch version: 2.12.0

Who can help?

@eustlb

Information

sliding_window_mask_function in modeling_moonshine_streaming.py (line 349) uses strict less-than (< right_window_size) for the right context, which means right_window_size=4 only attends to 3 future frames instead of 4.

The Moonshine v2 paper (arXiv:2602.12241) explicitly states:

"a right window of w_right=4 implies an algorithmic lookahead of 4×20 ms = 80 ms"

At 50 Hz, 4 future frames = 80 ms. But the current code gives 3 future frames = 60 ms.

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

from transformers.models.moonshine_streaming.modeling_moonshine_streaming import sliding_window_mask_function

fn = sliding_window_mask_function((16, 4))

q = 10 future = [kv for kv in range(q + 1, 20) if fn(0, 0, q, kv)] print(f"Future frames attended: {future}") Actual: [11, 12, 13] — 3 frames, 60ms Expected: [11, 12, 13, 14] — 4 frames, 80ms (per paper)

Expected behavior

With sliding_window_mask_function((16, 4)), a query at position 10 should attend to future positions {11, 12, 13, 14} — 4 future frames, matching the paper's definition of w_right=4

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

With sliding_window_mask_function((16, 4)), a query at position 10 should attend to future positions {11, 12, 13, 14} — 4 future frames, matching the paper's definition of w_right=4

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING