fix(nllb): refactor NLLB translator for correctness and performance#1158
Open
zachelnet wants to merge 1 commit into
Open
fix(nllb): refactor NLLB translator for correctness and performance#1158zachelnet wants to merge 1 commit into
zachelnet wants to merge 1 commit into
Conversation
- Use tokenizer+model directly instead of recreating pipeline() per sentence - Move model to device via .to(device) (was missing, broke ROCm/CUDA usage) - Fix device normalization: skip ':0' suffix for 'cpu' - Fix language code bugs: POL -> PLK, UKR: 'Ukrainian' -> 'ukr_Cyrl' - Fix _check_downloaded: also check model.safetensors (newer HF format) - Remove *.safetensors from download ignore_patterns (prevented model download) - Return '' on unrecoverable failure instead of per-sentence retry loop - Fix logger.warn -> logger.warning (deprecated)
b56b1e5 to
13ba227
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes several correctness and performance bugs in
nllb.pyandNLLBBigTranslator.Issues fixed
pipeline()recreated per sentencefrom_pretrained()→ CPU, device ignored.to(device)after loading'cpu'gets:0appendedcpu:0(invalid)cpustays as-isUKR'Ukrainian'(string, not a FLORES-200 code)'ukr_Cyrl'POL'POL''PLK'(consistent with rest of project)*.safetensorsexcluded from downloadignore_patterns_check_downloadedmisses safetensorspytorch_model.binlogger.warn(deprecated)logger.warningImpact
Co-authored-by: GitHub Copilot <github-copilot[bot]@users.noreply.github.com>