compute_wer_by_line raises OverflowError at 32,768 tokens with NumPy 2.3.5
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- numpy, python
- Lĩnh vực
- backend, performance
Hướng nghiên cứu
Đọc funasr/metrics/wer.py, đặc biệt là compute_wer_by_line và phần khởi tạo ma trận ở các dòng 137–144. Tái hiện trường hợp biên đã báo cáo với 32.768 token so với một token ở cả hai chiều đầu vào, sau đó kiểm tra kiểu biểu diễn số nguyên của ma trận và các kết quả đếm sai hiện có. Hoàn tất khi cả hai trường hợp trả về khoảng cách chỉnh sửa dự kiến cùng số lần chèn hoặc xóa mà không bị tràn số.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
🐛 Bug
compute_wer_by_line uses an np.int16 edit-distance matrix. When either input reaches 32,768 tokens, initializing the first row or column raises OverflowError: Python integer 32768 out of bounds for int16 under NumPy 2.3.5.
This can be reproduced with one input containing 32,768 tokens and the other containing only one token. The matrix has just 65,538 cells; the failure does not require two long inputs or a large quadratic allocation. All tokens can be identical, so the expected edit distance is 32,767, which itself fits in int16. The initialization still tries to store 32,768.
Environment
- Repository: modelscope/FunASR
- Commit:
879a219c717123fdec6024e8e56c734a7aace2ff - Source: funasr/metrics/wer.py
- Python 3.12.14
- NumPy 2.3.5
To Reproduce
Save the code sample below as repro_wer.py in the checkout root and run python repro_wer.py.
Code sample
From a checkout of the commit above with NumPy 2.3.5 installed, run the following. This loads the exact upstream function via Python's AST so the reproduction does not require unrelated ASR dependencies or importing the full FunASR package.
import ast
from pathlib import Path
import numpy as np
path = Path("funasr/metrics/wer.py")
tree = ast.parse(path.read_text())
function = next(
node for node in tree.body
if isinstance(node, ast.FunctionDef)
and node.name == "compute_wer_by_line"
)
namespace = {"np": np}
exec(compile(ast.Module(body=[function], type_ignores=[]), str(path), "exec"), namespace)
compute_wer_by_line = namespace["compute_wer_by_line"]
for n in (32766, 32767, 32768, 32769):
for hyp, ref in ((["a"] * n, ["a"]), (["a"], ["a"] * n)):
try:
result = compute_wer_by_line(hyp, ref)
print(len(hyp), len(ref), "wrong:", result["wrong"])
except OverflowError as exc:
print(len(hyp), len(ref), type(exc).__name__ + ":", exc)
Error logs
Observed output:
32766 1 wrong: 32765
1 32766 wrong: 32765
32767 1 wrong: 32766
1 32767 wrong: 32766
32768 1 OverflowError: Python integer 32768 out of bounds for int16
1 32768 OverflowError: Python integer 32768 out of bounds for int16
32769 1 OverflowError: Python integer 32768 out of bounds for int16
1 32769 OverflowError: Python integer 32768 out of bounds for int16
The exception occurs at cost_matrix[i][0] = i (line 142) when the hypothesis is long, or cost_matrix[0][j] = j (line 144) when the reference is long, before the main dynamic-programming loop.
Expected behavior
For the 32,768-vs-1 identical-token case, return an edit distance of 32,767 with one correct token and 32,767 insertions (long hypothesis) or deletions (long reference), instead of failing during initialization.
The cost matrix should use an integer representation that can safely hold the initialized lengths and edit costs for supported inputs.
Scope of verification
This report verifies the function from the pinned commit above on Python 3.12.14 / NumPy 2.3.5. Both input directions were tested at 32,766, 32,767, 32,768 and 32,769 tokens, with the other input fixed at one token. Passing controls were also checked for correct, insertion, deletion and substitution counts. Earlier NumPy versions, full ASR inference and the CLI were not tested. No claim is made here about behavior on other NumPy versions or later FunASR revisions.
Audio details
Not applicable: synthetic token lists only, no model, audio, GPU, PyTorch or torchaudio used. Source function loaded without importing the full package.
Would a focused change to the edit-distance matrix integer representation be welcome for this boundary? I am reporting the reproduction before making changes.
- Ngôn ngữ chính
- Python
- Star
- 20.8k
- Fork
- 2.1k
- Merge trung bình
- 23 giờ 48 phút
- Pull request đã merge (30 ngày)
- 38
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelscope/FunASR
-
`SentencepiecesTokenizer.ids2tokens` ignores `token_list` - root cause of the paraformer-en gibberish in #3040Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
modelscope/FunASR#3780 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
modelscope/FunASR#3762 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug: blank lines in wav.scp / jsonl file lists crash prepare_data_iterator (IndexError / JSONDecodeError)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởneeds feedback
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
modelscope/FunASR#3757 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
modelscope/FunASR#3730 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
modelscope/FunASR#3704 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelscope/FunASR
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
521xueweihan/HelloGitHub#4063 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Vanilla-OS/apx-gui#112 ·
-
Devstral and Voxtral: section 5 fails in us-east-1 with 400 "Model does not support audio modality"Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
aws-samples/sample-per-model-bedrock#409 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DuckDB 2.0 breaks to_pyarrow_batchesCó thể đã có người làm @DG47 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ibis-project/ibis#12196 ·
Maintainer thường phản hồi trong vòng 1 ngày