iwiwi 備忘録

学んだことを殴り書きます。自分向けのメモです。

Pythonで間違えて全体にインストールしちゃったパッケージを消す

仮想環境をactivateするのを忘れてpip installしたりする。その後の色々な環境に影響したりして最悪。依存でいっぱいインストールされてたりして消すの結構面倒。

import pkg_resources
import os

directory = os.path.expanduser("~/.local/lib/python3.8/site-packages")

distributions = pkg_resources.find_distributions(directory)

for dist in distributions:
    print(str(dist).split()[0])

pip install -y -r user_installed.txt

GPT-NeoXをとりあえず動かす

環境

基本requirementsをインストールしていくんだけど、問題がいくつか

  • best_downloadというライブラリがrequests経由でurllib3を使っているが、 method_whitelist という古い引数名を使っており、そこで落ちる。ダウングレードする手もありそうだが、一旦 allowed_methods に直接書き換えた。
  • tensorboardの指定バージョンが古く、numpyの新し目のバージョンとぶつかる。普通に最新のtensorboardでも動いている気がするので一旦それで。

データ準備

python prepare_data.py -d ./data

実行

  vocab_file: "data/gpt2-vocab.json",
  merge_file: "data/gpt2-merges.txt",
  data_path: "data/enwik8/enwik8_text_document",
  save: "./out_19M/checkpoints/",
  tensorboard_dir: "./out_19M/tensorboard/"

これを付け加えて実行

python ./deepy.py train.py 設定ファイルのパス

一旦19M.yamlを実行中。GPUメモリは6GBしか使ってない。

lm-eval-harnessでよく使われている評価タスク (LAMBADA, HellaSwag, WinoGrande, PIQA, CoQA)

https://docs.google.com/spreadsheets/d/1kT4or6b0Fedd-W_jMwYpb63e1ZR3aePczz3zlbJW-Y4/edit#gid=0

とりあえずこのシートで使われてるタスクを理解する。

The LAMBADA dataset: Word prediction requiring a broad discourse context

https://github.com/EleutherAI/lm-evaluation-harness/blob/fdd3dbc3b2871d6a0a5433bfa42f56490ee058ab/lm_eval/tasks/lambada.py https://arxiv.org/pdf/1606.06031.pdf

LAnguage Modeling Broadened to Account for Discourse AspectsでLAMBADA。

(1) Context: “Yes, I thought I was going to lose the baby.” “I was scared too,” he stated, sincerity flooding his eyes. “You were ?” “Yes, of course. Why do you even ask?” “This baby wasn’t exactly planned for.”
Target sentence: “Do you honestly think that I would want you to have a ?”
Target word: miscarriage

回答は1単語で、accuracyやperplexityを評価指標として計算する。

HellaSwag: Can a Machine Really Finish Your Sentence?

常識を必要とする問題。人間には>95%の精度が出せる。"Adversarial Filtering"により、人間には簡単だが機械には間違えやすい選択肢を生成しているらしい。

SWAGというデータセットがすでに存在していて、こちらも常識を必要とするものだったが、BERTが人間並の性能になっちゃったからもっと難しいの作ったらしい。

HuggingFace Dataset

https://huggingface.co/datasets/hellaswag

{'activity_label': 'Removing ice from car',
 'ctx': 'Then, the man writes over the snow covering the window of a car, and '
        'a woman wearing winter clothes smiles. then',
 'ctx_a': 'Then, the man writes over the snow covering the window of a car, '
          'and a woman wearing winter clothes smiles.',
 'ctx_b': 'then',
 'endings': [', the man adds wax to the windshield and cuts it.',
             ', a person board a ski lift, while two men supporting the head '
             'of the person wearing winter clothes snow as the we girls sled.',
             ', the man puts on a christmas coat, knitted with netting.',
             ', the man continues removing the snow on his car.'],
 'ind': 4,
 'label': '3',
 'source_id': 'activitynet~v_-1IBHYS3L-Y',
 'split': 'train',
 'split_type': 'indomain'}

lm-eval-harness

https://github.com/EleutherAI/lm-evaluation-harness/blob/fdd3dbc3b2871d6a0a5433bfa42f56490ee058ab/lm_eval/tasks/hellaswag.py

    def _process_doc(self, doc):
        ctx = doc["ctx_a"] + " " + doc["ctx_b"].capitalize()
        out_doc = {
            "query": self.preprocess(doc["activity_label"] + ": " + ctx),
            "choices": [self.preprocess(ending) for ending in doc["endings"]],
            "gold": int(doc["label"]),
        }
        return out_doc

この前処理をすると、以下のようになる。

{'choices': [', the man adds wax to the windshield and cuts it.',
             ', a person board a ski lift, while two men supporting the head '
             'of the person wearing winter clothes snow as the we girls sled.',
             ', the man puts on a christmas coat, knitted with netting.',
             ', the man continues removing the snow on his car.'],
 'gold': 3,
 'query': 'Removing ice from car: Then, the man writes over the snow covering '
          'the window of a car, and a woman wearing winter clothes smiles. '
          'Then'}

この query を与え、続きを生成させる。評価部分は継承元の MultipleChoiceTask のものがそのまま利用されている。choices のそれぞれに対するlog likelihoodを計算する。

    def process_results(self, doc, results):
        gold = doc["gold"]

        acc = 1.0 if np.argmax(results) == gold else 0.0
        completion_len = np.array([float(len(i)) for i in doc["choices"]])
        acc_norm = 1.0 if np.argmax(results / completion_len) == gold else 0.0

        return {
            "acc": acc,
            "acc_norm": acc_norm,
        }

一般的には acc_norm が利用されている。 acc_norm は回答の長さに応じた有利不利が出ないように、長さで正規化したもののようだ。

WinoGrande: An Adversarial Winograd Schema Challenge at Scale

https://arxiv.org/abs/1907.10641

2011年に作られたThe Winograd Schema Challenge (WSC)というデータセットの新しい版みたいなもの。 WSCは273問しかなかったが、これは44k問ある。WSCは、常識に基づく推論に関するデータセットである。

文中の代名詞が指すものは何かを当てる。基本二択になるような感じで文章が作られており、細かい違いでその両方が答えになり得るようになっており、その両方が実際にexampleとして含まれている。その組をtwinと呼ぶ。

HuggingFace Dataset

https://huggingface.co/datasets/winogrande

このうち winogrande_xl が44kデータを含むもの。

{'answer': '2',
 'option1': 'Ian',
 'option2': 'Dennis',
 'sentence': "Ian volunteered to eat Dennis's menudo after already having a "
             'bowl because _ despised eating intestine.'}
{'answer': '1',
 'option1': 'Ian',
 'option2': 'Dennis',
 'sentence': "Ian volunteered to eat Dennis's menudo after already having a "
             'bowl because _ enjoyed eating intestine.'}

このようにtwinのexampleが別々に連続して入ってる。

lm-eval-harness

https://github.com/EleutherAI/lm-evaluation-harness/blob/master/lm_eval/tasks/winogrande.py

    def construct_requests(self, doc, ctx):
        target = self.partial_target(doc)
        lls = []
        for option in [doc["option1"], doc["option2"]]:
            partial_ctx = self.partial_context(doc, option)
            full_ctx = self.append_context(ctx, partial_ctx)
            lls.append(rf.loglikelihood(full_ctx, target)[0])
        return lls

partial_context_ までの文字列 + 選択肢。partial_target_ 以降の文字列。 つまり、以下のようになる。

  • _ までの文字列 + 各選択肢、をcontextとして与える
  • _ 以降を生成させ _ 以降に対するlog likelihoodを計算
  • 大きいのが正解の選択肢の方かどうか見る

PIQA: Reasoning about Physical Commonsense in Natural Language

https://arxiv.org/abs/1911.11641

Physicalとある通り、物理世界の理解を問うような質問になっているらしい。例えば何かするときの道具とか手順とかについて聞いてくる。問題は2択。

HuggingFace Dataset

https://huggingface.co/datasets/piqa

{'goal': "When boiling butter, when it's ready, you can",
 'label': 1,
 'sol1': 'Pour it onto a plate',
 'sol2': 'Pour it into a jar'}

lm-eval-harness

MultipleChoiceTask で実装されている。

        out_doc = {
            "goal": doc["goal"],
            "choices": [doc["sol1"], doc["sol2"]],
            "gold": doc["label"],
        }

hellaswagも MultipleChoiceTask だが、こっちは acc_norm ではなく acc が使われるっぽい。上の例のように、各選択肢が類似した文章になっておりほぼ同じ長さだからかな。

CoQA: A Conversational Question Answering Challenge

https://arxiv.org/abs/1808.07042

ストーリーがあり、それに関するQAを会話形式で行う。

HugingFace Dataset

lm-eval-harnessで使われているのは、HF Datasetそのものではない。

https://github.com/EleutherAI/lm-evaluation-harness/blob/d145167959c2b1826d900524912cb99c44d5fb30/lm_eval/datasets/coqa/coqa.py

{'additional_answers': {'0': {'input_text': [''],
                              'span_end': [-1],
                              'span_start': [-1],
                              'span_text': [''],
                              'turn_id': [-1]},
                        '1': {'input_text': [''],
                              'span_end': [-1],
                              'span_start': [-1],
                              'span_text': [''],
                              'turn_id': [-1]},
                        '2': {'input_text': [''],
                              'span_end': [-1],
                              'span_start': [-1],
                              'span_text': [''],
                              'turn_id': [-1]}},
 'answers': {'input_text': ['It was formally established in 1475',
                            'research',
                            'history, and law',
                            'philosophy, science and theology',
                            'a  project',
                            'into periods',
                            'five',
                            'The Vatican Apostolic Library',
                            'in Vatican City',
                            '1.1 million',
                            'at the beginning of the 17th century;',
                            '150,000',
                            'anyone who can document their qualifications and '
                            'research needs.',
                            'unknown',
                            'Photocopies',
                            'only books published between 1801 and 1990',
                            'the Holy See',
                            'a handful of volumes',
                            'digitising manuscripts',
                            'them to be viewed online.'],
             'span_end': [179,
                          494,
                          511,
                          545,
                          879,
                          1127,
                          1128,
                          94,
                          150,
                          412,
                          1009,
                          1046,
                          643,
                          -1,
                          764,
                          724,
                          125,
                          1384,
                          881,
                          910],
             'span_start': [151,
                            454,
                            457,
                            457,
                            769,
                            1048,
                            1048,
                            4,
                            94,
                            328,
                            917,
                            915,
                            546,
                            -1,
                            643,
                            644,
                            78,
                            1192,
                            785,
                            868],
             'span_text': ['Formally established in 1475',
                           'he Vatican Library is a research library',
                           'Vatican Library is a research library for history, '
                           'law',
                           'Vatican Library is a research library for history, '
                           'law, philosophy, science and theology',
                           'March 2014, the Vatican Library began an initial '
                           'four-year project of digitising its collection of '
                           'manuscripts',
                           'Scholars have traditionally divided the history of '
                           'the library into five period',
                           'Scholars have traditionally divided the history of '
                           'the library into five periods',
                           'Vatican Apostolic Library (), more commonly called '
                           'the Vatican Library or simply the Vat, ',
                           'is the library of the Holy See, located in Vatican '
                           'City.',
                           ' It has 75,000 codices from throughout history, as '
                           'well as 1.1 million printed books',
                           'atican Secret Archives were separated from the '
                           'library at the beginning of the 17th century;',
                           ' Vatican Secret Archives were separated from the '
                           'library at the beginning of the 17th century; they '
                           'contain another 150,000 items. ',
                           ' The Vatican Library is open to anyone who can '
                           'document their qualifications and research needs. ',
                           'unknown',
                           'Photocopies for private study of pages from books '
                           'published between 1801 and 1990 can be requested '
                           'in person or by mail. ',
                           'hotocopies for private study of pages from books '
                           'published between 1801 and 1990',
                           'simply the Vat, is the library of the Holy See,',
                           'Pre-Lateran period, comprising the initial days of '
                           'the library, dated from the earliest days of the '
                           'Church. Only a handful of volumes survive from '
                           'this period, though some are very significant',
                           'Vatican Library began an initial four-year project '
                           'of digitising its collection of manuscripts, ',
                           'manuscripts, to be made available online. '],
             'turn_id': [1,
                         2,
                         3,
                         4,
                         5,
                         6,
                         7,
                         8,
                         9,
                         10,
                         11,
                         12,
                         13,
                         14,
                         15,
                         16,
                         17,
                         18,
                         19,
                         20]},
 'id': '3zotghdk5ibi9cex97fepx7jetpso7',
 'questions': {'input_text': ['When was the Vat formally opened?',
                              'what is the library for?',
                              'for what subjects?',
                              'and?',
                              'what was started in 2014?',
                              'how do scholars divide the library?',
                              'how many?',
                              'what is the official name of the Vat?',
                              'where is it?',
                              'how many printed books does it contain?',
                              'when were the Secret Archives moved from the '
                              'rest of the library?',
                              'how many items are in this secret collection?',
                              'Can anyone use this library?',
                              'what must be requested to view?',
                              'what must be requested in person or by mail?',
                              'of what books?',
                              'What is the Vat the library of?',
                              'How many books survived the Pre Lateran period?',
                              'what is the point of the project started in '
                              '2014?',
                              'what will this allow?'],
               'turn_id': [1,
                           2,
                           3,
                           4,
                           5,
                           6,
                           7,
                           8,
                           9,
                           10,
                           11,
                           12,
                           13,
                           14,
                           15,
                           16,
                           17,
                           18,
                           19,
                           20]},
 'source': 'wikipedia',
 'story': 'The Vatican Apostolic Library (), more commonly called the Vatican '
          'Library or simply the Vat, is the library of the Holy See, located '
          'in Vatican City. Formally established in 1475, although it is much '
          'older, it is one of the oldest libraries in the world and contains '
          'one of the most significant collections of historical texts. It has '
          '75,000 codices from throughout history, as well as 1.1 million '
          'printed books, which include some 8,500 incunabula. \n'
          '\n'
          'The Vatican Library is a research library for history, law, '
          'philosophy, science and theology. The Vatican Library is open to '
          'anyone who can document their qualifications and research needs. '
          'Photocopies for private study of pages from books published between '
          '1801 and 1990 can be requested in person or by mail. \n'
          '\n'
          'In March 2014, the Vatican Library began an initial four-year '
          'project of digitising its collection of manuscripts, to be made '
          'available online. \n'
          '\n'
          'The Vatican Secret Archives were separated from the library at the '
          'beginning of the 17th century; they contain another 150,000 '
          'items. \n'
          '\n'
          'Scholars have traditionally divided the history of the library into '
          'five periods, Pre-Lateran, Lateran, Avignon, Pre-Vatican and '
          'Vatican. \n'
          '\n'
          'The Pre-Lateran period, comprising the initial days of the library, '
          'dated from the earliest days of the Church. Only a handful of '
          'volumes survive from this period, though some are very significant.'}

lm-eval-harness

ストーリーと何組かのQAを受け取った後、最後のQに回答する。contextは A: まで。モデルは "\nQ:" と出力するまで文字列を生成する。その後、生成した回答について評価される。

評価指標は2つ。

  • exact:正規化した後で文章が完全一致するかを見る
  • F1: tokenize後に単語の集合に関するprecision, recallに基づくF1 scoreを計算する

1つのQに対し複数の正答例がある場合があり、その場合は平均する……んだと思うんだけど compute_scores の実装はどういうことなんだろう?

VSCodeでPythonをデバッグ

code.visualstudio.com

  • 左の▷を押す、"create a launch.json file" を押してテンプレを作る。
  • "args"っていうのを追加する(上のサイト参照)。
  • break pointをエディタ上で設定しとく
  • ▷のとこから実行する
  • break pointに到達したら下の"DEBUG CONSOLE"ってとこ行くとinteractiveに色々できて便利

Corsair HS80 Wireless

選定理由

  • マイク音質を向上したかった
  • マイクを買う事も考えたが、色々面倒そう&邪魔に感じそうだったので、無線ヘッドセットを更新することにした
  • Ubuntuでも利用したいが、Ubuntuでのbluetoothが不安定な印象がある(思い込みかもしれないが)のでUSBドングルで接続可のものがよい

iCUEにHS80が出てこない問題

有線で1回接続したら無線でも出てくるようになった。有線で接続したとき、最初は出てくるまでかなり時間がかかった。

ボリューム問題

HS80 microphone volume is low - Gaming Peripherals & Audio Troubleshooting - Corsair Community

HS80は、返品レベルでマイク音量がめちゃくちゃ小さいと言われまくっている。なお自分は解決できるだろうと知ってて購入した。

ファームウェアの更新

製品ページにある公式のFAQは、「ファームウェアを最新にしてください」である。自分は最近買ったので最初から新しく、ファームウェア起因の問題には直面してなさそうだが、一応更新しておいた。

なお、それでも音量はかなり小さい気がする。

Windows

更に音量を上げる必要を感じた。以下の動画が参考になった。

www.youtube.com

iCue上でマイクの音量を+10DBまで上げる。なお、この設定はiCueが実行中のときのみ有効なことに注意。iCueを終了すると、その瞬間に音量は元に戻る。

Mac

Macに繋いでみても、やはり小さい。iCueにはMac版もある。本当は入れたくないが、渋々インストール。同じ設定があり、同じような挙動。自分はスタートアップ時にウィンドウを出してくるアプリケーションをCmd+Qで終了しまくる癖があるが、iCueは終了しないように注意する必要がある。

注意すべき点として、なぜかHS80が出力デバイスに出てこないことがある。入力デバイスには出てくるのに。こういう時は、レシーバを抜き差しするのが良さそうだった。ヘッドセットの電源on/offでは駄目そうだった。

Ubuntu

askubuntu.com

上で紹介されている pavcontrolpactl が使えそうだった。

pavcontrolGUIだが、スライドバーの限界まで上げても150%ちょい(+10db)。これでもまだちょっと小さいぐらいな気がする……?このぐらいかなぁ?

pactl を使うと、更に上げられるが、気をつけたほうが良さそう。一応この200%でもかなり大きめに声を出してみても割れることはなかった。

pactl set-source-volume alsa_input.usb-Corsair_CORSAIR_HS80_RGB_Wireless_Gaming_Receiver_16ce14a400020215-00.mono-fallback 200%

なお、この数値は通常の設定画面のものとも共通しており、そっちのスライドバーとか触ると100%まで戻っちゃうから気をつけること。

GPTs are GPTs: An Early Look at the Labor Market Impact Potential of Large Language Models

arxiv.org

openai.com

generative pretrained transformersがgeneral-purpose technologiesだよ、って言いたい論文。様々な職種における作業へのインパクトを見積もる。

結論

  • 80%の職種で、作業の10%がLLMにより効率化される
  • 20%の職種で、作業の50%がLLMにより効率化される

Figure 3などがこの結論に相当。

方法

O*NETという職業DBに、各職種で行うことになる作業内容が掲載されている。職種と作業は一対多。

各作業が、LLMで効率化できるかどうか、アノテートしていく。

  • E0は無関係のもの
  • E1はLLMそのままで効率化できるもの
  • E2は追加の開発を行うことで効率化できるもの

アノテートは、以下の2通り作成した。

  • LLMを理解している人間によるもの。
  • LLMにより自動的に行わせたもの。

感想

実際に仕事に使ったり計測したりしたわけではないことには気をつけたほうが良さそう。

Emergent Abilities of Large Language Models

arxiv.org

基本的には、既存の文献から"Emergent"な現象をまとめる、という感じの論文だった。現象自体は面白いと思うので、有用な文献だと思う。ただし、本文は、あんま面白くない議論が長々と続いており、「JMLRに通すためのレビュワー対策で色々入れたんだろうなぁ」と邪推してしまう。

本文に掲載されている物理学者Philip Andersonの"Emergence"の定義:

Emergence is when quantitative changes in a system result in qualitative changes in behavior.

それに基づくこの論文の"Emergent"の定義:

An ability is emergent if it is not present in smaller models but is present in larger models.

これを満たすタスクと具体的な実験結果がいっぱい載ってる。

実験結果は全て、x軸がmodel scale、縦軸がscore。model scaleはtraining FLOPsとしている。他にも、パラメタ数や、データセットのサイズなどが要素としては有るが、パラメタ数が上がればFLOPsは上がるし、みたいな考えでFLOPsに統一している。

Scaling Vision Transformers to 22 Billion Parameters

arxiv.org

Google Research

Introduction

  • LLMは10B〜540Bって感じだけど、Vision Transformerは4Bとかしか見たことないから頑張るわ
  • ちょっと発散しないためとか工夫必要だったわ
  • 性能良かったわ

Model Architecture

  • GPT-J風のparallel layer
  • QK normalization: Q, Kにlayer normかける。attentionがめっちゃhard気味になって発散してたからこれで解決。
  • biasがあったりなかったり
  • 224x224 image, 解像度14x14のパッチを16x16=256個

Training Infrastructure and Efficiency

  • JAX, FLAX, Scenicというライブラリを使ったよ
  • 他の論文で言ういわゆるtensor parallelismについて深堀りしている。例えばmegatronとかでは「bcastとかall-reduceしてから、計算」ってしてる。でも、よく考えると、行列積の計算とring reduce-scatterを重ね合わせることができる。確かに。
  • MFU (model flops utilization) が54.9%だって。TPUよくわからんが。

Experiments

Training Details

  • label hierarchyを潰してsigmoid cross entropy
  • reciprocal squared root learning rate(てなに?)
  • few-shot adaptationの性能を良くするためにheadに高いweight decayをかけるらしい、知らんかったけどまぁ確かにという感じがするね

RoFormer: Enhanced Transformer with Rotary Position Embedding

arxiv.org

GPT-NeoX等で使われているposition embedding。

そもそも三角関数足す元祖のposition embeddingしか知らなかったので、relative position embeddingがどういうものかも知れてよかった。この手法自体は足す(additive)んじゃなくて回転させる(multicative)で、一見かなりアグレッシブな気もしたけど、足すのもまぁまぁやべーし良いかという気持ちになった。内積の大きさを制御したいと思えば全然普通かもしれない。

An Empirical Model of Large-Batch Training

arxiv.org

OpenAIのLLMの論文がbatchsize関連の議論で頻繁に引用している論文なので見てみた。

理解が正しいかあんま自信ない。

実験的な話

critical batch sizeとは、「そのバッチサイズまでなら上げても効率的」というバッチサイズである。

「効率的」というのは、「バッチサイズを上げた分だけステップ数を減らしてもいい」という意味。合計の計算量が変わらないままバッチサイズを上げて計算効率(並列性)を上げることができる範囲ということ。

実験での主張

  • 境界(超えたら性能が大きく劣化するところ)が割とはっきりしてる
  • critical batch sizeとgradient noise scale(後述)は相関する

理論的な話

critical batch sizeはgradient noise scaleで予測可能だということを説明している。簡単に説明すると:

  • batch sizeを上げることで、samplingによるgraidentの近似がtrue gradientに近づく
  • その近づき具合がサチるのが、critical batch size
  • 従って、gradient noise scaleがそれを決める

引用元でよく見る式のメモ

様々なバッチサイズでの学習を考える。

学習を行いある性能に至るためには、「ステップ数が $S\text{min}$ 以上」かつ「example数が $E\text{min}$ 以上」という条件がある(らしい)。

そして、別のステップ数 $S$ 及び example数 $E$ で同じ性能に至ろうと思うと、$S$ と $E$ 間は以下のような関係になる(らしい)。 $$ (S / S\text{min} - 1) = (E / E\text{min} - 1) ^{-1} $$

この、双曲線にフィットさせるた $B\text{crit} = E\text{min} / S_\text{min}$ がcritical batch sizeらしい。

感想

$B\text{crit} = E\text{min} / S_\text{min}$は結論だけ見るとあまりに当たり前の式すぎて草。

train lossしか登場せず、汎化誤差の話が一切考えられていないというのは重要な留意すべき点だと思った。ただ、確かにLLMの文脈だとあまり重要ではないのかもしれない。この論文自体はLMだけの論文じゃないんだけどね。

Scaling Laws for Neural Language Models

arxiv.org

transformerのLMがいわゆるscaling lawに従うという話。

一番大事で有名な結論は、モデルサイズと学習ステップ数を両方増やしていくのが一番効率的だよ、ということだろうか。なるべく定量的に関係を推定しており、具体的な指針となるようになってる。

他にもかなり色々な実験や主張があり、とりあえず図をどんどん見ていくのが楽しいと思う。学習のハイパラに迷ったら開くと良さそう。

具体的な指針にする際には、後続論文で反論もあることに注意(例:chinchilla scaling)。

Self-attention Does Not Need O(n2) Memory

arxiv.org

xformers.ops.memory_efficient_attentionはこれを実装してると引用してる。

K*Q全部一旦計算する必要なくてある場所のattention計算するためにはその行列のその行だけでいいから各場所について1つずつ計算すれば必要メモリはO(n)って話。

√nってなんだろうと思ったが、並列計算のためにchunkに分ける話だった。

Deduplicating Training Data Makes Language Models Better

arxiv.org

Google Research、ACL2022

学習データのdeduplicationを頑張る方法とその結果について

モチベ・利点

  • umpromptedで出す文字列、データセットで繰り返されまくってた文字列を記憶してるらしく、それを減らせる。
  • train test overlapによる評価の誤りを直せる。
  • データを減らすことで学習時間が減らせる。20%データが減ったらしい。
  • その割にモデルは悪くならない、なんならたまに性能よくなる。

手法

  • exact: データセット全体で、2回以上現れる50 PBE tokens以上の部分文字列を削除して1回にする。suffix arrayを使えば線形時間。
  • approx: 文章ごとで、5-gramがの一致率(Jaccard similarity)が高い文章対を検出し削除する。MinHashを使う。

Pythia: A Suite for Analyzing Large Language Models Across Training and Scaling

arxiv.org

EleutherAIの人たちが、学習完了したLLMだけでなく、学習過程の分析をしたい人のために、スナップショットを一杯公開したよ、という話だと理解した。

コードとかも色々あるので参考になるかも。