Skip to content

Fix order of bos_idx and eos_idx assignment#65

Open
lsrami wants to merge 1 commit into
facebookresearch:mainfrom
lsrami:main
Open

Fix order of bos_idx and eos_idx assignment#65
lsrami wants to merge 1 commit into
facebookresearch:mainfrom
lsrami:main

Conversation

@lsrami

@lsrami lsrami commented Jan 15, 2026

Copy link
Copy Markdown

Why?

Fixed incorrect variable assignment order for BOS/EOS token indices in the create_zero_shot_syntax method. The original code assigned eos_idx to the BOS token and bos_idx to the EOS token, causing the model to use incorrect special tokens during sequence construction. This bug would lead to malformed input sequences and potentially incorrect model predictions in zero-shot learning scenarios.

How?

Technical Decision:

  • Swapped the variable assignment order from eos_idx, bos_idx = self._get_bos_eos() to bos_idx, eos_idx = self._get_bos_eos()
  • This ensures bos_idx receives the beginning-of-sequence token index and eos_idx receives the end-of-sequence token index
  • The fix aligns with the subsequent usage where bos_idx is used to create bos_input (line 843) and eos_idx is used to create eos_input (line 844)

Location:

  • File: src/omnilingual_asr/models/wav2vec2_llama/model.py
  • Line: 842

Test Plan

Testing Approach:

  1. Verified that _get_bos_eos() returns tokens in the order (bos_token, eos_token)
  2. Traced through the zero-shot syntax creation to confirm BOS tokens are correctly placed at sequence beginnings
  3. Validated that EOS tokens are correctly placed at sequence endings
  4. Ran existing unit tests for the create_zero_shot_syntax method to ensure no regressions

Reproduction:

  • Before fix: BOS and EOS tokens would be swapped in generated sequences
  • After fix: Tokens are correctly positioned according to their semantic meaning

@lsrami lsrami requested a review from artemru as a code owner January 15, 2026 07:08
@meta-cla

meta-cla Bot commented Jan 15, 2026

Copy link
Copy Markdown

Hi @lsrami!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jan 15, 2026
@meta-cla

meta-cla Bot commented Jan 15, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant