Coder Social home page Coder Social logo

open-nllb's Introduction

Open No Language Left Behind

OPEN NLLB effort 🦜

Roadmap

After OpenAI's ChatGPT was released the whole world got caught up in the AI frenzy (and for a good reason). While systems such as Meta's Llama and OpenAI's GPT-4 are incredibly powerful - they only focus on English language.

Similarly, for machine translation systems, Meta released a powerful NLLB ("no language left behind") MT system that supports 202 languages! - but they didn't release open-source checkpoints (they were released under non-commercial CC-NC-BY 4.0 license).

The main goal of this effort is to release truly open-source NLLB checkpoints that can be freely used even for commercial purposes.

The extended goal of this project is to scale up beyond the original 3.3B parameters dense transformers (7B+) and also support non-English LLMs.

We strongly believe that focusing on multilingual AI models can help democratize this technology, and help businesses & researchers around the world.

Getting started 🚀

Check out our getting started guide if you wish to contribute! Or just play around!

Community

👨‍👩‍👧‍👦 Join Aleksa Gordić - The AI Epiphany Discord server and the #open-nllb channel if you want to engage with the rest of the community!

📺 Daily YouTube video streams here! 👀

Language champions

Here is a list of data contributors who are owners of their respective languages (they are all native speakers). 🙏

Below is the original fairseq README:

No Language Left Behind

No Language Left Behind (NLLB) is a first-of-its-kind, AI breakthrough project that open-sources models capable of delivering high-quality translations directly between any pair of 200+ languages — including low-resource languages like Asturian, Luganda, Urdu and more. It aims to help people communicate with anyone, anywhere, regardless of their language preferences.

To enable the community to leverage and build on top of NLLB, we open source all our evaluation benchmarks(FLORES-200, NLLB-MD, Toxicity-200), LID models and training code, LASER3 encoders, data mining code, MMT training and inference code and our final NLLB-200 models and their smaller distilled versions, for easier use and adoption by the research community.

This code repository contains instructions to get the datasets, optimized training and inference code for MMT models, training code for LASER3 encoders as well as instructions for downloading and using the final large NLLB-200 model and the smaller distilled models. In addition to supporting more than 200x200 translation directions, we also provide reliable evaluations of our model on all possible translation directions on the FLORES-200 benchmark. By open-sourcing our code, models and evaluations, we hope to foster even more research in low-resource languages leading to further improvements in the quality of low-resource translation through contributions from the research community.

Open Sourced Models and Community Integrations

Multilingual Translation Models

Model Name Model Type #params checkpoint metrics
NLLB-200 MoE 54.5B model metrics, translations
NLLB-200 Dense 3.3B model metrics
NLLB-200 Dense 1.3B model metrics
NLLB-200-Distilled Dense 1.3B model metrics
NLLB-200-Distilled Dense 600M model metrics

All models are licensed under CC-BY-NC 4.0 available in Model LICENSE file. We provide FLORES-200 evaluation results for all the models. For more details see the Modeling section README.

⭐ NEW ⭐ : We are releasing all the translations of NLLB-200 MoE model. Check Evaluation section README for more details.

Please use wget --trust-server-names <url> to download the provided links in proper file format.

LID Model

LID (Language IDentification) model to predict the language of the input text is available here under CC-BY-NC 4.0 license.

LASER3 Encoder Models

LASER3 models are available at LASER.

HuggingFace Integrations

Support for the dense models is available through the Hugging Face Hub under the NLLB tag. It is supported in the transformers library and the documentation for this model is available here.

Input and output languages are entirely customizable with BCP-47 codes used by the FLORES-200 dataset, here's an example usage with a translation from Romanian to German:

>>> from transformers import AutoModelForSeq2SeqLM, AutoTokenizer

>>> tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-200-distilled-600M", use_auth_token=True, src_lang="ron_Latn")
>>> model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-200-distilled-600M", use_auth_token=True)

>>> article = "Şeful ONU spune că nu există o soluţie militară în Siria"
>>> inputs = tokenizer(article, return_tensors="pt")

>>> translated_tokens = model.generate(
...     **inputs, forced_bos_token_id=tokenizer.lang_code_to_id["deu_Latn"], max_length=30
... )
>>> tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)[0]

Result:

UN-Chef sagt, es gibt keine militärische Lösung in Syrien

Installation

Follow installation instructions in INSTALL guide for running training/generation. For general instructions about fairseq and working with the codebase refer to fairseq README. For stopes and LASER follow their README files for installation.

Datasets

NLLB project uses data from three sources : public bitext, mined bitext and data generated using backtranslation. Details of different datasets used and open source links are provided in details here.

Primary Bitext

We provide a download script for public bitext data, and links to download NLLB-Seed data. For more details check here.

Mined Bitext

LASER3 teacher-student training code is open sourced here. LASER3 encoders and mined bitext metadata are open sourced in LASER repository. Global mining pipeline and monolingual data filtering pipelines are released and available in our stopes repository.

Backtranslated Bitext

Follow the instructions here to generate backtranslated data from a pretrained model.

Preparing Datasets for Training

We open source our dataset preparation pipeline for filtering/encoding/binarizing large scale datasets in stopes. Encoding the datasets are done using the new SPM-200 model which was trained on 200+ languages used in the NLLB project. For more details see link.

SPM-200 Artifacts download links
Model link
Dictionary link

Training NLLB Models

We open source all our model training and generation code in this repo. We also share code for finetuning our models on different domains like NLLB-MD. Additionally, we also share the code for online distillation that produced our 1.3B and 600M distilled models. For more details check the Modeling section Readme.

Evaluation and Generation

NLLB project includes release of evaluation datasets like Flores-200, NLLB-MD and Toxicity-200. For instructions to run evaluation see instructions here and for instructions to produce generations from the models follow instructions here.

Flores200 | NLLB-MD | Toxicity-200

Human Evaluations - (XSTS)

(Added Jan - 2023) We open-source additional guidelines and training materials for conducting the human evaluation protocol we utilized (XSTS), as well the calibration utilized and the entire human translation evaluation set for NLLB-200 and it's published baseline here.

Citation

If you use NLLB in your work or any models/datasets/artifacts published in NLLB, please cite :

@article{nllb2022,
  title={No Language Left Behind: Scaling Human-Centered Machine Translation},
  author={{NLLB Team} and Costa-jussà, Marta R. and Cross, James and Çelebi, Onur and Elbayad, Maha and Heafield, Kenneth and Heffernan, Kevin and Kalbassi, Elahe and Lam, Janice and Licht, Daniel and Maillard, Jean and Sun, Anna and Wang, Skyler and Wenzek, Guillaume and Youngblood, Al and Akula, Bapi and Barrault, Loic and Mejia-Gonzalez, Gabriel and Hansanti, Prangthip and Hoffman, John and Jarrett, Semarley and Sadagopan, Kaushik Ram and Rowe, Dirk and Spruit, Shannon and Tran, Chau and Andrews, Pierre and Ayan, Necip Fazil and Bhosale, Shruti and Edunov, Sergey and Fan, Angela and Gao, Cynthia and Goswami, Vedanuj and Guzmán, Francisco and Koehn, Philipp and Mourachko, Alexandre and Ropers, Christophe and Saleem, Safiyyah and Schwenk, Holger and Wang, Jeff},
  year={2022}
}

License

NLLB code and fairseq(-py) is MIT-licensed available in LICENSE file.

open-nllb's People

Contributors

alexeib avatar cndn avatar davidecaroselli avatar edunov avatar erip avatar freewym avatar gordicaleksa avatar huihuifan avatar jhcross avatar jingfeidu avatar jma127 avatar joshim5 avatar kahne avatar kartikayk avatar lematt1991 avatar liezl200 avatar liuchen9494 avatar louismartin avatar maigoakisame avatar mortimerp9 avatar multipath avatar myleott avatar pipibjc avatar skritika avatar sravyapopuri388 avatar sshleifer avatar tangyuq avatar theweiho avatar xu-song avatar xutaima avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

open-nllb's Issues

Native language visualizations

Go through the files for your native language and see whether there are any issues.

Check out the getting started document here for how to download public bi-text for your language.

Additionally feel free to do whatever type of analysis you see fit:

  • embedding the sentences
  • visualizing, counting the number of sentences/words for your native lang
  • ...

See if there anything wrong in the data.

Share for example a Weights & Biases report as the final result of your work. We'll keep track of these for all covered languages.

Provide context for input and output

🚀 Feature Request

Provide context to the input, but not actually include the context in the translation. Useful for real time translation applications. Also continue translations from context translation.

Example:

Context Input: I’m in a cave and see
Input to translate: a bat.
Context Output: Estoy en una cueva y veo
Translated Output: un murciélago.

Notice how bat (🦇) can also mean baseball bat unless you have the context.

Motivation

Real time translation.

Pitch

I can implement this if given some pointers as well. Thanks!

Get a compute grant

After we estimate the necessary compute requirements (see this) ask around for grants to support the project.

If you have experience writing grants - please reach out to me! (our Discord channel)

Standard Moroccan Tamazight is mislabeled

Standard Moroccan Tamazight (zgh) was mislabeld as Central Atlas Tamazight (tzm) in both FLORES and NLLB-SEED. This issue was fixed in the new FLORES+ and Seed datasets.
Which files should be changed to reflect this? can I just just find and replace (tzm -> zgh) on the entire repo or maybe follow this commit?

[Modeling] Release a 615M HBS (Croatian, Bosnian, Serbian) Open-NLLB checkpoint

Our goal is to release an open-source, 3.3B, dense checkpoint that does machine translation for 202 languages from the NLLB project.

To get to that point let's first start by releasing OSS checkpoints with smaller scale and smaller language scope.

The goal here will be to release a model with following properties:

  • (small scale) 615 M parameters
  • (smaller language scope) Support only Croatian, Bosnian, Serbian, Montenegrin languages + English.

[Modeling] Release a 615M English -> HBS Open-NLLB checkpoint

Our goal is to release an open-source, 3.3B, dense checkpoint that does machine translation for 202 languages from the NLLB project.

To get to that point let's first start by releasing OSS checkpoints with smaller scale and smaller language scope.

The goal here will be to release a model with following properties:

  • (small scale) 615 M parameters
  • (smaller language scope) Support only translation from English into HBS (Croatian, Bosnian, Serbian, Montenegrin).

Creation of a small model file for a few languages

Is it correct that there is currently no model file from the project even a small one for a few languages?

How long (how many GPU hours) would it take to generate a small model file (600M parameters) for a few languages? Is it possible to pause the generation and resume it after some time?

I can use a server with two NVIDIA A100 GPUs with 40 GB VRAM each and could possibly create a small model file for a few languages.

[Modeling] Release a 3.3B Open-NLLB checkpoint (~202 languages)

This the end goal for the current project scope.

Here the goal is to release a model with following properties:

  • Truly open-source
  • 3.3B dense
  • Supports all 202 NLLB languages in both direction

Note: it will be very hard to get a satisfactory level of quality for 202 languages with a dense checkpoint. The original work from Meta used a ~54B parameter MoE (mixture of experts) model to get decent results + a ton of compute (~52k hours on A100-SXM-80GB).

We do have plans to scale beyond 3.3B parameters scale.

[Modeling] Release a 1.3B Slavic languages Open-NLLB checkpoint

Our goal is to release an open-source, 3.3B, dense checkpoint that does machine translation for 202 languages from the NLLB project.

To get to that point let's first start by releasing OSS checkpoints with smaller scale and smaller language scope.

The goal here will be to release a model with following properties:

  • (small scale) 1.3B parameters
  • (smaller language scope) Supports only Slavic languages (~20 languages) and English.

Weird line length spikes in Serbian, Croatian, Bosnian (data analysis task)

We get weird regularly spaced out histogram spikes for HBS languages, see below:

image

On the x-axis is the line length (in chars) and on the y-axis is the number of lines with that line length in our corpus.

Understand why this is happening and write a short report.

Instructions:

  • Download the OPUS data using the download_opus.py script + some manual download see which datasets in the script (all those that are in the ignore list, see the OPUS website: https://opus.nlpl.eu/
  • Use the parse_macocu.py to parse the MaCoCu data that has to be manually downloaded (for now, feel free to add functions to support the download through Python) from https://macocu.eu/ (only a couple of datasets so doesn't take too much time to do it manually).
  • After that you can use the analyse_data.py script to replicate the graph above and then do your own analysis.

[Future - outside current project scope] non-English LLMs (Serbian LLM, etc.)

The AI world is obsessed with LLMs but most of the models you can get your hands on atm support only (or mostly) English:
ChatGPT, GPT-4, Falcon, Llama 1/2 & derivatives, etc.

Let's train high-quality language specific LLMs and open-source them! ❤️

This will help spread this technology outside of the western-centric world and help preserve diversity and richness of culture around the world.

Hydra pickle issue in generate_multi.py

Figure out the pickle issue mentioned here:
facebookresearch/fairseq#5315

Conf file

conf.zip

Current workaround:

@hydra.main(config_path="conf", config_name="generate_multi_full")
def main(config: DictConfig) -> None:
    launcher = hydra.utils.instantiate(config.launcher)
    module = GenerateMultiModule(config)
    asyncio.run(module.run())
    # asyncio.run(tabulate(config))

and modify the run method of GenerateMultiModule class by prepending it with the following:

jobs = self.array()
        for iteration_value in jobs:

Understand how to do 4-stage curriculum learning from the paper

It's not quite clear how do we setup a 4-stage curriculum learning training going through the codebase & existing documentation.

Understanding this will be super important once we start running on a bigger number of languages.

There is some mention of it in this README.

Write a report and share the learnings on how do do this.

Note: we could always do this manually by stopping and restarting 4 different jobs, but that's error-prone and I suspect Meta had a more streamlined approach. :)

sub-batches creation

Understand which optimizations are done in fairseq under the hood (sub-batches creation wrt. src/target len)
Explore fairseq codebase in this matter

Question to answer

How are sub-batches generated wrt. src/target len in fairseq?

[Future - outside current project scope] 7B lang-family-specific Open-NLLB checkpoint

Our current project scope's goal is to release an open-source, 3.3B, dense checkpoint that does machine translation for 202 languages from the NLLB project.

Going past that I would love to scale up to 7B parameters dense transformers and train a set of such models for different language families:

  • 7B Open-NLLB model for Slavic languages
  • 7B Open-NLLB model for African languages
  • 7B Open-NLLB model for Germanic languages
  • ...

(I'm not a linguist so excuse me if any mistakes in the preliminary list above :) ).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.