Skip to content

All-zero Paraformer token lengths collapse a batch to one unkeyed result #3782

Open

Description

@hulkbig

Source-level report; runtime reproduction is still pending.

🐛 Bug

In the ordinary non-VAD, single-best Paraformer inference path, a batch whose rounded predicted token lengths are all zero returns a bare empty list. AutoModel then substitutes one empty-text result without a key for the whole batch.

I checked current main 879a219c717123fdec6024e8e56c734a7aace2ff. The same early return is present in ContextualParaformer.

To Reproduce

This is a conditional source trace, not an executed audio/model reproduction. No inference command has been run for this report.

  1. Consider two inputs with keys ["a", "b"], processed together with batch_size=2, without VAD and with single-best decoding.
  2. If their predicted token lengths round to [0, 0], Paraformer lines 618–620 return []. ContextualParaformer lines 458–460 do the same.
  3. AutoModel lines 958–963 treat that empty return as [{"text": ""}] and extend the public result list with this single unkeyed row.

Code sample

Relevant current source:

pre_token_length = pre_token_length.round().long()
if torch.max(pre_token_length) < 1:
    return []

The wrapper then uses:

res = model.inference(**batch, **kwargs)
if isinstance(res, (list, tuple)):
    results = res[0] if len(res) > 0 else [{"text": ""}]
    meta_data = res[1] if len(res) > 1 else {}
asr_result_list.extend(results)

Thus, conditional on the all-zero branch, the two-input batch contributes [{"text": ""}], rather than two keyed rows. Processing all-zero items in separate batches would instead contribute one unkeyed row per batch.

Expected behavior

Preserve the two input keys and order, for example [{"key": "a", "text": ""}, {"key": "b", "text": ""}].

The model registration contract specifies a (results, meta_data) model return and retaining ASR input order/keys. The existing batch key test also expects two results with distinct keys for two inputs at batch sizes 1 and 2; that is a routing control, not a reproduction of this predictor branch.

Could you confirm the intended empty-result behavior and model return shape before I work on a focused runtime reproduction and fix?

Error logs

None: source inspection only. I have not demonstrated a real audio input that reaches this branch, and do not claim that silence necessarily triggers it.

Environment

  • Source: main commit 879a219c717123fdec6024e8e56c734a7aace2ff
  • Python / PyTorch / torchaudio / ModelScope / device: not exercised for this report.
  • No model weights, audio, GPU, CLI, or end-to-end inference validation was performed.

Audio details

No audio reproduction yet. This report is limited to the ordinary non-VAD model-return and batching path; other integrations have not been tested.

Activity

  1. added
    bugSomething isn't working
    needs triageNeeds maintainer triage and routing
    on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triageNeeds maintainer triage and routing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions