自然言語処理周りの処理を担うNatural Languageフレームワークのアップデートについて解説してくれているWWDC23の「Explore Natural Language multilingual models」というセッションを見たメモ。
Natural Language関連のセッションとしてはWWDC20以来の実に3年ぶり。
概要をざっくりいうと「多言語の BERT embedding をサポートしました」という話。
(以下、引用表記と画像は基本的に "Explore Natural Language multilingual models" セッションより引用)
埋め込み(embedding)とは何か
LLMの隆盛もあり、自然言語処理を専門としていない人でも "embedding" という単語は耳にしたことがあるかもしれない。セッションではまずはここの解説があった。
Contextual embedding
続いて、今回新たにサポートされた contextual embedding について解説があった。
Static embeddings と Contextual embeddings の違い
Contextual embeddingを入力層に持つ意味
これも重要なので引用:
Create MLにおけるELMoモデルのサポート
なお、Create MLの新しいバージョンでは、ELMoモデルによる Contextual Embedding の生成をサポートしているとのこと。
Multilingual embeddings
ここからがBERTを用いたMultilingualなembeddingの話。
今回から Transformerベースの文脈埋め込み、BERT embeddings を提供するようになったとのこと。(BERTは "Bidirectional Encoder Representations from Transformers" の略)
「多言語」であることのポイント
Transformerのアテンションメカニズム(具体的にはmulti-headed self-attentionと呼ばれるもの)により、モデルは、一度に複数の異なる方法で、異なる重みでテキストの異なる部分を考慮することができる。
これにより、一度の複数の言語で学習することができる。
で、そのミソは「多言語対応」というところではなくて、言語間の類似性から、ある言語のデータが他の言語のデータに役立つという相乗効果にあるらしい。
日本語を含む27言語をサポート
以下の27言語をサポートしているとのこと。
これらを3つの言語グループに分けて、3つの別々のモデルで実現しているとのこと。
Create MLにおけるサポート
このBert Embeddings は Create ML の新バージョンで入力エンコーディング層として利用可能。
学習データは、すべて単一の言語である必要はない。
NLContextualEmbedding APIs
Natural Languageフレームワークにも、同埋め込みモデルを利用するAPIが追加されている。
もちろんiOSでも利用可能で、何ならwatchOSでも利用可能。iOS 17.0, macOS 14.0, watchOS 10.0, tvOS 17.0以降。