英文

North-T5模型是一组挪威和斯堪的纳维亚序列到序列模型。它基于灵活的 T5 T5X ,并可用于从分类到翻译等各种NLP任务。

Small 60M Base 220M Large 770M XL 3B XXL 11B
North-T5‑NCC 1232321 1233321 1234321 1235321 1236321
North-T5‑NCC‑lm 1237321 1238321 1239321 12310321 12311321
North-T5‑NCC‑modern 12312321 12313321 12314321 12315321
North-T5‑NCC‑modern‑lm 12316321 12317321 12318321 12319321
North-T5‑NCC‑scand 12320321 12321321 12322321 12323321
North-T5‑scand 12324321 12325321 12326321
North-byT5‑NCC 12327321 12328321 12329321
North-T5‑scand3M 12330321 12331321

T5X检查点

该模型还提供了原始的T5X检查点,可在 Google Cloud Bucket 中找到。

性能

正在计划对North-T5模型进行全面评估,我强烈推荐外部研究人员进行自己的评估。 T5模型的主要优势是其灵活性。传统上,仅编码器模型(如BERT)在分类任务上表现出色,而序列到序列模型更易于用于翻译和问答等任务的训练。尽管如此,这里是使用North-T5进行政治分类任务的结果 here 的结果。

Model: F1
mT5-base 73.2
mBERT-base 78.4
NorBERT-base 78.2
North-T5-small 80.5
nb-bert-base 81.8
North-T5-base 85.3
North-T5-large 86.7
North-T5-xl 88.7
North-T5-xxl 91.8

这些是初步结果。BERT模型的 results 结果基于在提前停止和递减学习率的情况下进行10次运行后的测试结果。T5的结果是评估集上五次运行的平均值。小型模型训练了10,000步,其余模型训练了5,000步。使用固定的学习率(无衰减),没有提前停止。也没有使用推荐的等级分类。我们使用最大序列长度为512。此方法简化了测试设置并提供了易于解释的结果。然而,T5模型的结果实际上可能略有不佳。

North-T5的子版本

提供以下子版本。更多版本将尽快提供。

Model Description
North‑T5‑NCC This is the main version. It is trained an additonal 500.000 steps on from the mT5 checkpoint. The training corpus is based on 12335321 . In addition there are added data from MC4 and English Wikipedia.
North‑T5‑NCC‑lm The model is pretrained for an addtional 100k steps on the LM objective discussed in the 12336321 . In a way this turns a masked language model into an autoregressive model. It also prepares the model for some tasks. When for instance doing translation and NLI, it is well documented that there is a clear benefit to do a step of unsupervised LM-training before starting the finetuning.
North‑T5‑NCC‑modern The model is pretrained for an additional 200k steps on a blanaced Bokmål and Nynorsk corpus. While this was originally done for doing translation between Bokmål and Nynorsk, it might also give improved results on tasks where you know that the input/output is modern "standard" text. A significant part of the training corpus is newspapers and reports.
North‑T5‑NCC‑modern‑lm Trained as above but with an additional 100k "language model"-pretraining.
North‑T5‑NCC‑scand The model is pretrained for an additional 200k steps on a Scandinavian corpus (Bokmål, Nynorsk, Danish, Swedish and Icelandic (+ a tiny bit Faeroyish)). The model was trained for increasing the understanding of what effect such training has on various languages.
North‑T5‑scand Pretrained for 1,700,000 steps starting with the mT5 checkpoing. The purpose of the mode is studying the difference of different training regimes for Scandinavian language model.
North‑byT5‑base This is a vocabulary free version of T5. It is trained exactly like North-T5, but instead of the 250,112 vocabulary, this model operates directly on the raw text. The model architecture might be of particulary interest for tasks involving for instance spelling correction, OCR-cleaning, handwriting recognition etc. However, it will - by design - have amuch shorter maximum sequence length.

微调版本

如下所述,模型确实需要针对特定任务进行微调。这个过程相对简单,模型对所使用的超参数不太敏感。通常,通过使用固定的学习率1e-3可以获得不错的结果。较小的模型通常需要更长的训练时间。可以在Google Colab上轻松训练基础模型。

由于一些人确实想看到模型的能力,而不想经历训练过程,我提供了几个测试模型。这些模型绝对没有优化,只是展示了North-T5模型的用法。

  • 尼诺尔斯克翻译器。将任何来自挪威博克马尔语的文本翻译为挪威尼诺尔斯克语。请使用 Streamlit-demo HuggingFace repo 进行测试。
  • DeUnCaser。该模型将标点符号、空格和大写字母添加到文本中。输入需要是挪威语,但不必分成句子或正确使用大写字母。甚至可以从文本中删除空格,让模型重构它。可以使用 Streamlit-demo 测试,并可直接在 HuggingFace repo 上测试。

培训细节

所有模型都使用基于Flax的T5X代码库构建,并使用mT5预训练权重进行初始化。这些模型采用T5.1.1训练方案,仅在无监督的遮罩任务上进行训练。这也意味着模型(与原始T5相反)需要进行微调以解决特定任务。但是,这种微调通常计算成本不高,大多数情况下都可以在免费的在线训练资源上执行。

所有主要模型版本在mT5检查点(1,000,000步)之后训练了500,000步。它们主要在75GB的语料库上进行训练,包括NCC、Common Crawl和一些额外的高质量英文文本(维基百科)。该语料库大约有80%的挪威文本。添加其他语言以保留某种多语言能力,使模型对新单词/概念更加稳健,并且更适合作为翻译任务的基础。

尽管巨大的模型几乎总是提供最好的结果,但它们的微调也更加困难和昂贵。我强烈推荐从微调基础模型开始。基础模型可以在标准图形卡或通过Google Colab上的免费TPU上轻松进行微调。

所有模型都是在TPU上进行训练的。最大的XXL模型是在TPU v4-64上训练的,XL模型是在TPU v4-32上训练的,大模型是在TPU v4-16上训练的,其余模型是在TPU v4-8上训练的。由于在微调过程中可以减小批次大小,因此可以在稍小的硬件上进行微调。一般规则是在微调时可以“向下推进一步”。即使对于微调,大型模型仍需要访问大容量硬件。

格式

所有模型都使用基于Flax的T5X库进行训练。原始的检查点以T5X格式提供,并可用于微调或干预。除了XXL模型外,所有模型还转换为Transformers/HuggingFace格式。在这个框架中,模型可以在Flax、PyTorch和TensorFlow格式中加载,用于微调或推理。

未来

我将继续训练和发布此模型集的其他模型。添加哪些模型取决于用户的反馈。

感谢

感谢Google Research的 TPU Research Cloud 为这次发布提供了支持和硬件。 TPU Research Cloud团队和T5X团队在使其运行方面提供了非常有用的支持。

挪威国家图书馆的Freddy Wetjen在生成原始NCC语料库方面提供了巨大的帮助,还为此次训练生成的整理语料库做出了贡献。此外,他还是创建这些模型的讨论伙伴。

还要感谢Stefan Schweter编写的 script ,用于将这些模型从T5X转换为HuggingFace,以及Javier de la Rosa编写的数据加载器,用于从T5X中读取HuggingFace数据集。

保修

自担风险使用。这些模型尚未经过详细测试,可能包含错误和偏见。

联系/关于

这些模型是由Per E Kummervold培训的。请通过 per@capia.no 与我联系。