{"id":23701,"library":"fairseq","title":"fairseq","description":"fairseq is a sequence-to-sequence toolkit by Facebook AI Research, written in PyTorch. It provides reference implementations of various models for machine translation, language modeling, and other sequence generation tasks. Current version: 0.12.2. Release cadence is irregular, with the last significant release in 2021.","status":"maintenance","version":"0.12.2","language":"python","source_language":"en","source_url":"https://github.com/pytorch/fairseq","tags":["sequence-to-sequence","machine-translation","nlp","facebook","pytorch"],"install":[{"cmd":"pip install fairseq","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for tensor operations and neural network modules","package":"torch","optional":false},{"reason":"Used for numerical operations","package":"numpy","optional":false}],"imports":[{"note":"","wrong":null,"symbol":"fairseq","correct":"import fairseq"},{"note":"","wrong":null,"symbol":"fairseq.models","correct":"from fairseq.models import transformer"}],"quickstart":{"code":"import torch\nimport fairseq\n\n# Load a pretrained model from torch.hub\nmodel = torch.hub.load('pytorch/fairseq', 'transformer.wmt14.en-fr', tokenizer='moses', bpe='subword_nmt')\n\n# Prepare input\ninput_text = 'Hello world!'\n\n# Translate\nprint(model.translate(input_text))","lang":"python","description":"Quickstart: load a pretrained translation model and translate a sentence."},"warnings":[{"fix":"Update model checkpoints or adjust code to match new parameter structure.","message":"Between v0.9.0 and v0.10.0, the MultiheadAttention module changed from a single 'in_proj_weight' to separate k, v, q projections. Models saved with older versions will not load directly.","severity":"breaking","affected_versions":"0.9.0 and earlier vs 0.10.0+"},{"fix":"Replace .generate() with .translate() in your code.","message":"In v0.8.0, the torch.hub interface changed: 'generate' was renamed to 'translate'. Code using 'generate' will break.","severity":"breaking","affected_versions":"0.7.x vs 0.8.0+"},{"fix":"Refer to the latest documentation and avoid using deprecated APIs.","message":"Many components (e.g., older masked LM modules, dataset formats) have been deprecated or replaced. The project is in maintenance mode with few updates.","severity":"deprecated","affected_versions":"all"},{"fix":"For new projects, consider using fairseq2 or other actively maintained toolkits.","message":"fairseq is no longer actively maintained; new projects should consider alternatives like fairseq2 or direct PyTorch implementations.","severity":"gotcha","affected_versions":"all"},{"fix":"Use pip install fairseq to get prebuilt wheels or carefully match PyTorch version when building from source.","message":"Installing from source may require specific PyTorch versions (e.g., PyTorch 1.8 or older). Check the setup.py for exact dependencies.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from fairseq.models.transformer import TransformerModel","cause":"Incorrect or incomplete import path. The models are submodules that must be imported after fairseq is installed.","error":"ImportError: cannot import name 'transformer' from 'fairseq.models'"},{"fix":"Convert the checkpoint using a migration script or use the version of fairseq that matches the checkpoint.","cause":"Loading a checkpoint from an older version of fairseq that used separate k, v, q projections in MultiheadAttention, but the current version expects a single weight.","error":"KeyError: 'in_proj_weight'"},{"fix":"Replace .generate() with .translate() in your code.","cause":"Using fairseq versions 0.8.0+ where the method was renamed from 'generate' to 'translate'.","error":"'generator' object has no attribute 'generate'"},{"fix":"Run: pip install fairseq","cause":"fairseq is not installed or the environment is incorrect.","error":"ModuleNotFoundError: No module named 'fairseq'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}