Giter Club home page Giter Club logo

pythia's Introduction

Pythia: Interpreting Transformers Across Time and Scale

This repository is for EleutherAI's project Pythia which combines interpretability analysis and scaling laws to understand how knowledge develops and evolves during training in autoregressive transformers. For detailed info on the models, their training, and their properties, please see our paper Pythia: A Suite for Analyzing Large Language Models Across Training and Scaling.

The Pythia suite was developed with the explicit purpose of enabling research in interpretability, learning dynamics, and ethics and transparency for which existing model suites were inadequate. The key features of the Pythia suite are:

  1. All models, data, and code used in the paper are publicly released, enabling full reproducibility of results. All results in our paper have been independently verified by at least one other lab.
  2. All models feature 154 checkpoints saved throughout training, enabling the study of learning dynamics of LLMs.
  3. All models were trained on the same data in the same order, enabling researchers to explore causal interventions on the training process.

Aside from the Pythia suite itself, this repository also acts as a hub containing information, code, and reproducibility instructions for the following papers:

  • Emergent and Predictable Memorization in Large Language Models code paper

Contents

Models

Params n_layers d_model n_heads d_head Batch Size Learning Rate Hugging Face Checkpoints
14M 6 128 4 32 2M 1.0e-3 Standard
31M 6 256 8 32 2M 1.0e-3 Standard
70M 6 512 8 64 2M 1.0e-3 Standard, Deduped
160M 12 768 12 64 2M 6.0e-4 Standard, Deduped
410M 24 1024 16 64 2M 3.0e-4 Standard, Deduped
1B 16 2048 8 256 2M 3.0e-4 Standard, Deduped
1.4B 24 2048 16 128 2M 2.0e-4 Standard, Deduped
2.8B 32 2560 32 80 2M 1.6e-4 Standard, Deduped
6.9B 32 4096 32 128 2M 1.2e-4 Standard, Deduped
12B 36 5120 40 128 2M 1.2e-4 Standard, Deduped

We train and release a suite of 8 model sizes on the Pile (paper, datasheet) as well as the Pile with deduplication applied. All 8 model sizes are trained on the exact same data, in the exact same order. Each model saw 299,892,736,000 ~= 299.9B tokens during training. This corresponds to just under 1 epoch on the Pile for non-"deduped" models, and ~= 1.5 epochs on the deduped Pile (which contains 207B tokens in 1 epoch). All models are trained with mixed precision, using fp16 for all models except EleutherAI/pythia-1b which trained with bf16, because in fp16 the model experienced an irreconcilable loss spike late in training.

To promote research on the learning dynamics of LLMs we make 154 checkpoints available for each model, representing steps 0 (initialization), 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1000, and then every 1,000 subsequent steps.

Config files used to train these models with the GPT-NeoX library can be found at the models/ directory within this repository, as well as in the GPT-NeoX library itself.

We also upload the pre-tokenized data files and a script to reconstruct the dataloader as seen during training for all models. See Reproducing Training section for more details.

Changelog

[November 2, 2023] We have added 14M and 31M models at the request of some researchers. We plan on training deduped versions of these models in the future.

[April 3, 2023] We have released a new version of all Pythia models, fixing various inconsistencies in the original suite. Please see our [paper]((https://arxiv.org/abs/2304.01373) appendix B for details on the changes. The old models ("v0") remain available here and may be useful for ablation studies.

[January 20, 2023] On January 20, 2023, we chose to rename the Pythia model suite to include both embedding layer and unembedding layer parameters in our total parameter counts, in line with many other model suites and because we believe this convention better reflects the on-device memory usage of these models. We also discovered that due to a typo one of our models was smaller than we thought, and replaced it with a model of the intended size. See here for more details.

Using Pythia

Quickstart

All Pythia models are hosted on the Huggingface hub. They can be loaded and used via the following code (shown for the 3000-step pythia-70M-deduped model checkpoint):

from transformers import GPTNeoXForCausalLM, AutoTokenizer

model = GPTNeoXForCausalLM.from_pretrained(
  "EleutherAI/pythia-70m-deduped",
  revision="step3000",
  cache_dir="./pythia-70m-deduped/step3000",
)

tokenizer = AutoTokenizer.from_pretrained(
  "EleutherAI/pythia-70m-deduped",
  revision="step3000",
  cache_dir="./pythia-70m-deduped/step3000",
)

inputs = tokenizer("Hello, I am", return_tensors="pt")
tokens = model.generate(**inputs)
tokenizer.decode(tokens[0])

All models were trained for the equivalent of 143000 steps at a batch size of 2,097,152 tokens. Revision/branch step143000 corresponds exactly to the model checkpoint on the main branch of each model.

We additionally have all model checkpoints in the format accepted by the GPT-NeoX library, with final-step checkpoints+optimizer states downloadable from the Hugging Face Hub at EleutherAI/neox-ckpt-pythia-xxx-deduped-v1 but do not serve them for all steps at scale due to size of optimizer states and anticipated lower demand. If you would like to perform analysis using the intermediate models within the GPT-NeoX codebase, or would like the optimizer states for other steps, please email [email protected] and [email protected].

pythia-{size}-v0 models on Huggingface of sizes 160m, 410m, 1.4b were trained with a batch size of 4M tokens across 71500 steps and checkpointed every 500 steps. The step names on Huggingface for these v0 models are renamed for consistency with all 2M batch models so the model checkpointed labeled step1000 of pythia-1.4b-v0 was actually step 500, but has seen the same number of tokens as the other step1000 checkpoints.

Reproducing Training

(Expanded reproduction instructions provided by @BaruchG ).

We provide the training data for replication of our training runs. The GPT-NeoX library requires the pre-tokenized training data in the form of 2 memory-mapped numpy arrays: a .bin and .idx file. We provide these files via the Hugging Face hub. To download and use the deduplicated Pile training data:

git lfs clone https://huggingface.co/datasets/EleutherAI/pythia_deduped_pile_idxmaps

# Optionally, to ensure against corrupt files
python utils/checksum_shards.py

python utils/unshard_memmap.py --input_file ./pythia_deduped_pile_idxmaps/pile_0.87_deduped_text_document-00000-of-00082.bin --num_shards 83 --output_dir ./pythia_pile_idxmaps/

# The correct sha256 for the full file is 0cd548efd15974d5cca78f9baddbd59220ca675535dcfc0c350087c79f504693
# This can be checked with sha256sum ./pythia_pile_idxmaps/*

This will take over a day to run, though it should not require more than 5 GB of RAM. We recommend downloading this rather than retokenizing the Pile from scratch in order to guarantee preservation of the data order seen by the Pythia models. In addition to the training data, you will need to make a local copy of the tokenizer we used to train our models. You can find it here.

Next you will need to set up the training environment:

git clone https://github.com/EleutherAI/gpt-neox.git
cd gpt-neox
git checkout v1.0
pip install -r requirements/requirements-flashattention.txt
wget https://github.com/EleutherAI/pythia/blob/main/models/160M/pythia-160m-deduped.yml
docker build -t pythia:latest .

After the container finishes building, run the container using the following command (from the root of the GPT-NeoX repo with your pythia yaml accessible from within that folder):

docker run --runtime=nvidia --rm -it -e NVIDIA_VISIBLE_DEVICES=0,1,2,3 --shm-size=1g --ulimit memlock=-1 --mount type=bind,src=$PWD,dst=/gpt-neox -v $(pwd):/workspace/ pythia:latest bash

You can use the -v argument to add more connected volumes for the dataset and the Yaml file if is not accessible from within the docker container.

Change the lines of the data paths and tokenizer paths as follows:

  "train-data-paths": ["/fsx/pile/pile_20B_tokenizer_text_document"], #point this to your folder which was generated in step 1 containing the .bin and .idx file
  "valid-data-paths": ["/fsx/pile/pile_20B_tokenizer_text_document"], #point this to your folder which was generated in step 1 containing the .bin and .idx file
  "test-data-paths": ["/fsx/pile/pile_20B_tokenizer_text_document"], #point this to your folder which was generated in step 1 containing the .bin and .idx file

  "tokenizer-type": "HFTokenizer",
  "vocab-file": "/fsx/pile/20B_tokenizer.json", # point this to the tokenizer retrieved in step 2

Depending on how much VRAM you have available you may need to adjust the batch sizes. The total batch size is calculated via Total GPUs * train_micro_batch_size_per_gpu * gradient_accumulation_steps / (pipe-parallel-size * model-parallel-size) and needs to be kept at 1024 to match the Pythia training batch size. You

   "train_micro_batch_size_per_gpu": XXX, # make this a value that will fit within your GPU memory
   "gradient_accumulation_steps": 1, # make this a value to compensate to make the total batch size 1024.

If you would like your weights to be saved add that information to the yaml file as well. For example, to save in the checkpoints folder, at the bottom you can add:

  "launcher": "slurm",
  "deepspeed_slurm": false,

  "save": "checkpoints",
  "load": "checkpoints",
  "checkpoint_validation_with_forward_pass": False,
}

Make sure the paths are the paths from inside your docker container and if you want the weights to have persistence, make sure that they are accessible from outside the container, for example in /workspace/ .

You should now be able to start training your model by running:

python deepy.py train.py pythia-160m-deduped.yml  2>&1 | tee output.txt

the output will be saved to output.txt, if you don’t want that just delete the end.

In order to convert your model to the Hugging Face transformers format, you can use the script tools/convert_to_hf.py from within the GPT-NeoX library. You may have to add from typing import List to the type of the file and change the line here from list[torch.Tensor] to List[torch.Tensor]. You can then run the script like this to convert the weights at step 143000:

python tools/convert_to_hf.py --input_dir checkpoints/global_step143000/ --config_file checkpoints2/global_step 143000/configs/pythia-70m.yml --output_dir ./output/ 

This should output a file structure similar to the one found at https://huggingface.co/EleutherAI/pythia-70m-deduped/tree/main.

❗ Sometimes people find that they don't end up with the right tokenizer for reasons we have been unable to debug. If your tokenizer_config.json looks different than the one here and special_tokens_map.json look different than here you may need to replace them with the ones on Huggingface.

To run evaluations using our evaluation library, install the containers here (tested with the 4.28 and 4.29 versions). After setting up that docker container run:

git clone https://github.com/EleutherAI/lm-evaluation-harness
cd lm-evaluation-harness
pip install -e .

as outlined in the Harness repository. You should then be able to run the benchmark by pointing it at your weights (which should be in your container) by running a command similar to this:

python3 main.py --model hf-causal-experimental  --model_args pretrained=../gpt-neox/output/ --tasks lambada_openai,piqa,winogrande,arc_easy,sciq,wikitext --device cuda:0

Exploring the Dataset

We provide a tool to view particular portions of the training dataloader used by all models during training, at utils/batch_viewer.py.

First, we need to clone the Pythia repository:

git clone https://github.com/EleutherAI/pythia

Next, we must install dependencies:

pip install torch==1.13.0+cu117 -f https://download.pytorch.org/whl/torch/
pip install numpy tqdm huggingface_hub

Next, we must download the appropriate dataset. We provide preshuffled versions of the duped and deduped pile. Download the appropriate one using Huggingface's utilities as follows:

Tip: Make sure to replace path/to/* to appropriate paths where you intend to save datasets downloaded from Huggingface.

  • To download standard version, use
    from huggingface_hub import hf_hub_download
    hf_hub_download(repo_id="EleutherAI/pile-standard-pythia-preshuffled", repo_type="dataset", cache_dir="path/to/local/folder")
  • To download the deduped version, use
    from huggingface_hub import hf_hub_download
    hf_hub_download(repo_id="EleutherAI/pile-deduped-pythia-preshuffled", repo_type="dataset", cache_dir="path/to/local/folder")

You can now merge the files by using the script utils/unshard_mmap.py :

python3 utils/unshard_mmap.py --input_file "path/to/local/folder/document-00000-of-00020.bin" --num_shards 21 --output_dir "path/to/merged/folder/"

Make sure to also copy index file to the merged folder, using the command

cp path/to/local/folder/document.idx path/to/merged/folder/document.idx

Now, we're all set up to run utils/batch_viewer.py !

python3 utils/batch_viewer.py \
  --start_iteration 0 \
  --end_iteration 1000 \
  --load_path path/to/merged/folder/document \
  --save_path path/to/save/folder/ \
  --conf_dir utils/dummy_config.yml 

This will save a separate file containing all the indicies as a numpy array.

You can now load this using numpy as

import numpy as np

indicies = np.load("path/to/save/folder/indicies.npy")

These indicies contain tokenized sequences of integers of size (None, 2049), where an integer corresponds to a unique token index. Note that documents are concatenated and saperated by an EOD token. Thus, each sample or batch may not start with an EOD token. During training, target tokens are left shifted by 1. Thus, a model of sequence length 2048 requires 2049 length sequences for training (For more info, refer to this comment)

Pythia Paper Replication

We provide further information for those interested in replicating our case studies performed in the Pythia suite paper in the case-studies/ folder of this repository, being

  • Memorization density over training
  • Intervention on pronoun frequencies in pretraining
  • Term frequency effects over training

Benchmark Scores

We also provide benchmark 0-shot and 5-shot results on a variety of NLP datasets:

  • Lambada (lambada_openai)
  • Wikitext (wikitext)
  • PiQA (piqa)
  • SciQ (sciq)
  • WSC (wsc)
  • Winogrande (winogrande)
  • ARC-challenge (arc_challenge)
  • ARC-easy (arc_easy)
  • LogiQA (logiqa)
  • BLiMP (blimp_*)
  • MMLU (hendrycksTest*)

Evaluations were performed in GPT-NeoX using the LM Evaluation Harness, and are viewable by model and step at evals/pythia-v1/*/* in this repository.

Research Building on Pythia

Our primary goal with the Pythia project is to enable research on interpretability and learning dynamics at EleutherAI and in the community writ large. Here we document select papers using our models, focusing on work that is uniquely empowered by the Pythia suite and would be less feasible or infeasible with models released by other organizations. For a larger list of papers citing Pythia, see here.

Language Model Internals

Learning Dynamics

Ethics, Security, and Transparency Research

Other Notable Research

Citation Details

If you use the Pythia models in your research, please cite our paper via:

@inproceedings{biderman2023pythia,
  title={Pythia: A suite for analyzing large language models across training and scaling},
  author={Biderman, Stella and Schoelkopf, Hailey and Anthony, Quentin Gregory and Bradley, Herbie and O’Brien, Kyle and Hallahan, Eric and Khan, Mohammad Aflah and Purohit, Shivanshu and Prashanth, USVSN Sai and Raff, Edward and others},
  booktitle={International Conference on Machine Learning},
  pages={2397--2430},
  year={2023},
  organization={PMLR}
}

If you use data or results from other papers found in this repository, please cite the corresponding papers. Citation information can be found in the respective README and are also reproduced below for convenience:

@inproceedings{biderman2023emergent,
      title={Emergent and Predictable Memorization in Large Language Models}, 
      author={Biderman, Stella and Prashanth, USVSN Sai and Sutawika, Lintang and Schoelkopf, Hailey and Anthony, Quentin and Purohit, Shivanshu and Raff, Edward},
      journal={Advances in Neural Information Processing Systems},
      year={2023}
}

If you are interested in citing our training data, training library, or evaluation library you can do so with the following:

@article{gao2020pile,
  title={The pile: An 800gb dataset of diverse text for language modeling},
  author={Gao, Leo and Biderman, Stella and Black, Sid and Golding, Laurence and Hoppe, Travis and Foster, Charles and Phang, Jason and He, Horace and Thite, Anish and Nabeshima, Noa and others},
  journal={arXiv preprint arXiv:2101.00027},
  year={2020}
}

@article{biderman2022datasheet,
  title={Datasheet for the pile},
  author={Biderman, Stella and Bicheno, Kieran and Gao, Leo},
  journal={arXiv preprint arXiv:2201.07311},
  year={2022}
}

@software{gpt-neox-library,
  title = {{GPT-NeoX: Large Scale Autoregressive Language Modeling in PyTorch}},
  author = {Andonian, Alex and Anthony, Quentin and Biderman, Stella and Black, Sid and Gali, Preetham and Gao, Leo and Hallahan, Eric and Levy-Kramer, Josh and Leahy, Connor and Nestler, Lucas and Parker, Kip and Pieler, Michael and Phang, Jason and Purohit, Shivanshu and Schoelkopf, Hailey and Stander, Dashiell and Songz, Tri and Tigges, Curt and Thérien, Benjamin and Wang, Phil and Weinbach, Samuel},
  url = {https://www.github.com/eleutherai/gpt-neox},
  doi = {10.5281/zenodo.5879544},
  month = {9},
  year = {2023},
  version = {2.0.0},
}

@misc{eval-harness,
  author       = {Gao, Leo and Tow, Jonathan and Abbasi, Baber and Biderman, Stella and Black, Sid and DiPofi, Anthony and Foster, Charles and Golding, Laurence and Hsu, Jeffrey and Le Noac'h, Alain and Li, Haonan and McDonell, Kyle and Muennighoff, Niklas and Ociepa, Chris and Phang, Jason and Reynolds, Laria and Schoelkopf, Hailey and Skowron, Aviya and Sutawika, Lintang and Tang, Eric and Thite, Anish and Wang, Ben and Wang, Kevin and Zou, Andy},
  title        = {A framework for few-shot language model evaluation},
  month        = sep,
  year         = 2021,
  publisher    = {Zenodo},
  version      = {v0.0.1},
  doi          = {10.5281/zenodo.5371628},
  url          = {https://doi.org/10.5281/zenodo.5371628}
}

License

The following license applies to all code in this GitHub repo, as well as the Pythia models and any other copyrightable artifacts contained in this repository.

   Copyright 2023 EleutherAI

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

pythia's People

Contributors

aflah02 avatar aviskowron avatar baruchg avatar borgr avatar erichallahan avatar haileyschoelkopf avatar herbiebradley avatar igor0 avatar kyle1668 avatar l-ma avatar lintangsutawika avatar osanseviero avatar quentin-anthony avatar rdiehlmartinez avatar segyges avatar stellaathena avatar usaiprashanth 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pythia's Issues

Pythia few shot capabilities

Hi, thanks for the amazing work!

I tried to use the Pythia model on a simple few-shot task. I gave it a few examples of sentiment analysis tasks (as shown in this example on GPT-J: https://github.com/NielsRogge/Transformers-Tutorials/blob/master/GPT-J-6B/Inference_with_GPT_J_6B.ipynb which successfully solves this), and it seems like it even did not understand the job (generates unrelated tokens).
Is there a reason for Pythia's failure on this simple task, compared to GPT-J's success (although having twice the number of parameters)?

Does early memorization predict late memorization?

We currently have the following correlation heat-map which indicates that the answer is "yes." We should probably also make confusion matrices for the classifier that takes a model and predicts memorization by the fully trained model by assuming it is the same as the 23M sequence checkpoint.

Image

pythia ckpts in hf config vocab_size(50304, 70m ckpt) and tokenizer.json(50257) are mismatch

I modified the https://github.com/EleutherAI/lm-evaluation-harness/blob/f9eca2c8160be8c20ecc956b7ff545f880160d0e/lm_eval/models/gpt2.py#L50
add transformers.GPTNeoXTokenizerFast,

command is:
python main.py --model gpt2 --model_args pretrained=/work/lm-evaluation-harness/ckpts/pythia-70m/step143000/models--EleutherAI--pythia-70m/snapshots/1c607732430c35e6387a86528d857887e87cae1f --tasks lambada_openai,hellaswag --device 1

traceback is:

Running loglikelihood requests
0%| | 8/45296 [00:01<1:46:22, 7.10it/s]
Traceback (most recent call last):
File "/work/lm-evaluation-harness/main.py", line 108, in
main()
File "/work/lm-evaluation-harness/main.py", line 79, in main
results = evaluator.simple_evaluate(
File "/work/lm-evaluation-harness/lm_eval/utils.py", line 161, in _wrapper
return fn(*args, **kwargs)
File "/work/lm-evaluation-harness/lm_eval/evaluator.py", line 86, in simple_evaluate
results = evaluate(
File "/work/lm-evaluation-harness/lm_eval/utils.py", line 161, in _wrapper
return fn(*args, **kwargs)
File "/work/lm-evaluation-harness/lm_eval/evaluator.py", line 247, in evaluate
resps = getattr(lm, reqtype)([req.args for req in reqs])
File "/work/lm-evaluation-harness/lm_eval/base.py", line 820, in fn
rem_res = getattr(self.lm, attr)(remaining_reqs)
File "/work/lm-evaluation-harness/lm_eval/base.py", line 185, in loglikelihood
return self._loglikelihood_tokens(new_reqs)
File "/work/lm-evaluation-harness/lm_eval/base.py", line 317, in _loglikelihood_tokens
logits = torch.gather(logits, 2, cont_toks.unsqueeze(-1)).squeeze(
RuntimeError: index 50276 is out of bounds for dimension 2 with size 50257

Data viewing / Batch Reconstruction utility

I need to upload a utility / sample guide on how to inspect the data ordering / extract a batch at a given timestep. This'll essentially be a cleaned up version of the memorized seq util I'm working on.

Features we want:

  • Verified correct dataloader construction (verify w/ memorization)
  • Tool to extract + save a single timestep's batch to a numpy file
  • Take as argument a YML file from this repo
  • Detach from GPT-NeoX repo fully (or preserve this utility in a separate branch of NeoX)
  • Argparse to select: model, mode, some default statistics?
  • Support stepping through data over all timesteps + recording a statistic

Mistake in readme

In the readme it says

To download and use the deduplicated Pile training data, run:

git lfs clone https://huggingface.co/datasets/EleutherAI/pythia_pile_idxmaps

python utils/unshard_memmap.py --input_file ./pythia_pile_idxmaps/pile_0.87_deduped_text_document-00000-of-00082.bin --num_shards 83 --output_dir ./pythia_pile_idxmaps/```

But it should actually point to EleutherAI/pythia_deduped_pile_idxmaps.

Inconsistent batch sizes reported in readme

Thanks for the amazing work!

In the readme, the table reports some models as being trained with a batch size of 4M, but later on you say

All models were trained for the equivalent of 143000 steps at a batch size of 2,097,152 tokens

which of these is correct?

(Also, you say that checkpoints are created every 2B tokens - if batch sizes differ between models, does that mean that some models have only 500 training steps between checkpoints?)

Question about naming convention for models

Hi there! Thank you so much for releasing these models! They've already been really valuable for my research. One small question: how were the model names chosen, specifically the parameter number part of the names? By my calculation here are the number of parameters for each of the models, excluding the embed and unembed matrices:

 'pythia-19m': 18915328,
 'pythia-125m': 85056000,
 'pythia-350m': 302311424,
 'pythia-800m': 805736448,
 'pythia-1.3b': 1208602624,
 'pythia-2.7b': 2517652480,
 'pythia-6.7b': 6444163072,
 'pythia-13b': 11327027200

And here are the number of parameters if I include one, but not both, of the embed/unembed matrices in the calculation:

 'pythia-19m': 44670976,
 'pythia-125m': 123689472,
 'pythia-350m': 353822720,
 'pythia-800m': 908759040,
 'pythia-1.3b': 1311625216,
 'pythia-2.7b': 2646430720,
 'pythia-6.7b': 6650732544,
 'pythia-13b': 11586549760

I guess for some of the models, one embed matrix was included in the parameter count, but others exclude both the embed and unembed matrix from the count? The 13b model seems like an overestimate whichever way you count it.

Improve Pythia repository documentation

Todo items include:

  • upload all NeoX final configs to repository
  • Update table
  • Expand readme documentation with description of model suite
  • Add instructions for downloading model ckpts from HF hub, and from the eye

Are pythia_v0 and the new pythia_v1 models using the same input embedding matrix?

I've noticed something really odd while messing around with the pythia models for the tuned_lens project.

It seems like the input embeddings where not reset from the v0 to current models. Was that intentional?

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer


device = torch.device('cpu')
model_a = AutoModelForCausalLM.from_pretrained('EleutherAI/pythia-410m-deduped-v0')
model_a = model_a.to(device)
model_b = AutoModelForCausalLM.from_pretrained('EleutherAI/pythia-410m-deduped')
model_b = model_b.to(device)
tokenizer = AutoTokenizer.from_pretrained('EleutherAI/pythia-410m-deduped')

input_ids = tokenizer.encode("it was the best of times, it was the worst of times", return_tensors="pt")
model_b.set_input_embeddings(model_a.get_input_embeddings())
with torch.no_grad():
    print("Outputs with the input embeddings swapped")
    print(tokenizer.decode(model_b(input_ids).logits.argmax(dim=-1)[0].tolist()))

model_a.get_input_embeddings().reset_parameters()
model_b.set_input_embeddings(model_a.get_input_embeddings())
with torch.no_grad():
    print("Sanity check: outputs with the input embeddings reset")
    print(tokenizer.decode(model_b(input_ids).logits.argmax(dim=-1)[0].tolist()))

Output:

Outputs with the input embeddings swapped
, a first of the to and was the best of times,
Sanity check: outputs with the input embeddings reset

se-. for-..of-- for.

FYI this does not seem to happen with the output embeddings.

Bias metrics on selected Pythia models

We want metrics on the following models and checkpoints:

pythia-19m-deduped

  • Checkpoints at s3://s-eai-neox/pythia/19M_deduped/global_step{3000, 13000, 23000, ...., 133000, 143000}

pythia-350m-deduped

  • Checkpoints at s3://s-eai-neox/pythia/350M_dedup/global_step{1500, 6500, 11500, ...., 66500, 71500}
  • Or at HuggingFace, EleutherAI/pythia-350m-deduped, revision={3000, 13000, 23000, ..., 133000, 143000}

pythia-1.3b-deduped

  • Checkpoints at s3://s-eai-neox/pythia/1.3B_dedup/global_step{1500, 6500, 11500, ...., 66500, 71500}
  • Or at HuggingFace, EleutherAI/pythia-1.3b-deduped, revision={3000, 13000, 23000, ..., 133000, 143000}

pythia-6.7b-deduped

  • Checkpoints at s3://s-eai-neox/pythia/6.7B_deduped_new/global_step{3000, 13000, 23000, ...., 133000, 143000}
  • Or at HuggingFace, EleutherAI/pythia-19m-deduped, revision={3000, 13000, 23000, ..., 133000, 143000}

We want to use the following tasks:

  • wino_bias all 4 subsets, templates "What does p stand for" and "refers_to"
  • Other selected bias evaluation datasets???

Host Pile pretokenized .bin and .idx megatron files?

It might be worth also hosting the Pile .bin and .idx files, for people to more easily reproduce our training runs on the same data if they desire. I don't think the deduplicated Pile has been hosted anywhere before.

Generation issues when using KoboldAI

Hi there, I only used Pythia with KoboldAI, particularly 13B and 13B deduped (or maybe 12B due to the rename) and I'm having generation issues. Since I already have a thread on this on KoboldAI, and my post there is already substantial I think, I'm just gonna link it here. ebolam/KoboldAI#312. I'm also gonna attach a pic with one of the issues, particularly spacing issue.
209335571-43c5da4a-b695-47d7-a2f2-470aba0c8334

Host pythia suite

We need to upload all model checkpoints to be hosted somewhere for researchers to access them.

Final checkpoints should go on the HF hub. Intermediate ckpts pending

Survival model analysis

Survival analysis is a potential model for understanding whether the fact that a model has memorized a string at time t is likely to continue to have that string memorized or not.

Host Deduped Pile raw jsonls

I don't think that the deduped Pile raw text data is hosted anywhere--I couldn't find it on the eye. Even if we don't host the deduped Pile .bin and .idx files somewhere, we definitely need to host the raw deduped Pile data to make these experiments replicable.

pythia-13b size mismatch

When I run the following code to load up pythia-13b, I get a bunch of size mismatch errors.

model = GPTNeoXForCausalLM.from_pretrained(
        f"EleutherAI/pythia-13b",
        revision=f"step143000",
        cache_dir=f"./"
)

Errors:

Traceback (most recent call last):
  File "download_pythia_models.py", line 34, in <module>
    model = GPTNeoXForCausalLM.from_pretrained(
  File "/om2/user/ericjm/miniconda3/envs/phase-changes/lib/python3.8/site-packages/transformers/modeling_utils.py", line 2379, in from_pretrained
    ) = cls._load_pretrained_model(
  File "/om2/user/ericjm/miniconda3/envs/phase-changes/lib/python3.8/site-packages/transformers/modeling_utils.py", line 2695, in _load_pretrained_model
    raise RuntimeError(f"Error(s) in loading state_dict for {model.__class__.__name__}:\n\t{error_msg}")
RuntimeError: Error(s) in loading state_dict for GPTNeoXForCausalLM:
        size mismatch for gpt_neox.embed_in.weight: copying a param with shape torch.Size([50688, 5120]) from checkpoint, the shape in current model is torch.Size([50432, 4096]).
        size mismatch for gpt_neox.layers.0.input_layernorm.weight: copying a param with shape torch.Size([5120]) from checkpoint, the shape in current model is torch.Size([4096]).
        size mismatch for gpt_neox.layers.0.input_layernorm.bias: copying a param with shape torch.Size([5120]) from checkpoint, the shape in current model is torch.Size([4096]).
        size mismatch for gpt_neox.layers.0.post_attention_layernorm.weight: copying a param with shape torch.Size([5120]) from checkpoint, the shape in current model is torch.Size([4096]).
        size mismatch for gpt_neox.layers.0.post_attention_layernorm.bias: copying a param with shape torch.Size([5120]) from checkpoint, the shape in current model is torch.Size([4096]).
...

These continue for every layer of the model. When I use ignore_mismatched_sizes=True in GPTNeoXForCausalLM.from_pretrained, I get this error instead:

Traceback (most recent call last):
  File "/om2/user/ericjm/the-everything-machine/experiments/pythia-0/eval.py", line 52, in <module>
    model = GPTNeoXForCausalLM.from_pretrained(
  File "/om2/user/ericjm/miniconda3/envs/phase-changes/lib/python3.8/site-packages/transformers/modeling_utils.py", line 2379, in from_pretrained
    ) = cls._load_pretrained_model(
  File "/om2/user/ericjm/miniconda3/envs/phase-changes/lib/python3.8/site-packages/transformers/modeling_utils.py", line 2636, in _load_pretrained_model
    mismatched_keys += _find_mismatched_keys(
  File "/om2/user/ericjm/miniconda3/envs/phase-changes/lib/python3.8/site-packages/transformers/modeling_utils.py", line 2564, in _find_mismatched_keys
    and state_dict[checkpoint_key].shape != model_state_dict[model_key].shape
KeyError: 'embed_out.weight'

I imagine that some config just needs to be updated to reflect the actual model sizes? I do not get this error with any of the smaller models.

Weights of "step0" and "step1" checkpoints are identical for all pythia models

Dear EleutherAI team,

I've noticed that the weights associated with the recently added "step0" and "step1" checkpoints are identical for all pythia models:

def main():
    print(f"========== {sys.argv[1]} ==========")
    model_step0 = GPTNeoXForCausalLM.from_pretrained(sys.argv[1], revision="step0", cache_dir=f"./test")
    model_step1 = GPTNeoXForCausalLM.from_pretrained(sys.argv[1], revision="step1", cache_dir=f"./test")

    for (name0, param0), (name1, param1) in zip(model_step0.named_parameters(), model_step1.named_parameters()):
        print(name0, name1, name0 == name1, torch.all(param0==param1))

This yields something like the following for all eight pythia models:

========== EleutherAI/pythia-70m ==========
gpt_neox.embed_in.weight gpt_neox.embed_in.weight True tensor(True)
gpt_neox.layers.0.input_layernorm.weight gpt_neox.layers.0.input_layernorm.weight True tensor(True)
...
gpt_neox.final_layer_norm.weight gpt_neox.final_layer_norm.weight True tensor(True)
gpt_neox.final_layer_norm.bias gpt_neox.final_layer_norm.bias True tensor(True)
embed_out.weight embed_out.weight True tensor(True)

Would it be possible for you to clarify whether these identical weights correspond to those from "step0" or "step1?" I've noticed that the conditional probabilities calculated using these weights aren't perfectly uniform, which leads me to believe these are actually weights from "step1."

Thanks!
Byung-Doh

Pythia Experiment 3: Gender bias

  • Collect cooccurrence statistics on deduped and non-deduped Pile
  • Cast WinoBias as a multiple choice classification task
  • Convert corpus stats into Pandas dataset + visualize distribution
  • Run WinoBias on all models
  • Collect correlations between WinoBias scores and data statistics
  • Create fine-tuning data points for insertion into last 3 ckpt retraining

General zero and few-shot evaluations on model suite

Collect zero-shot and 5-shot performance on the Pythia model suite across a selected subset of checkpoints over time.

Tasks:

  • MMLU (57 tasks)
  • BLiMP
  • PiQA
  • SciQ
  • Lambada
  • Wikitext
  • Winogrande
  • WSC
  • Arc-challenge and ARC-easy
  • Logiqa

How was deduplication done?

Specifically what method or library does the deduplication of the Pile carried out?

I have search previous issues and this repo and see no other mention of the methodology for deduplication.

Train M -> F pronoun interventions on selected Pythia models

(Re)train pythia models with the last 7% of training data adjusted to have all female pronouns.

  • s3://s-eai-neox/pythia/1.3B_dedup/global_step66500 trained for last 5k steps with intervened data
  • s3://s-eai-neox/pythia/19M_deduped/global_step133000 trained for last 10k steps with intervened data
  • s3://s-eai-neox/pythia/350M_dedup/global_step66500 trained for last 5k steps with intervened data
  • s3://s-eai-neox/pythia/6.7B_deduped_new/global_step133000 trained for last 10k steps with intervened data

All intervened models should be evaluated on the same benchmarks as #16 for all the saved checkpoints post-intervention. All saved intervened checkpoints should also be evaluated on the same benchmarks as chosen in #51 .

If get meaningful numbers from the above and have evaluated all the above models:

  • s3://s-eai-neox/pythia/1.3B_dedup/global_step66500 trained for last 10k steps with intervened data

Add more details for reproducing training runs

In the readme you have a note

TODO: forthcoming: more information on how to replicate + relaunch the Pythia training runs, once the data is actually downloaded.

We are trying to reproduce your results and it would be awesome to get some more details here. One particular thing that would be helpful would be to point us to a version/commit of gpt-neox that is similar to the one you used for these training runs, unless you're confident that the newest version of that library will still closely reproduce these results.

Inconsistency in vocab sizes

Thank you EleutherAI team for this valuable resource!

I noticed that the vocab_size changes between different pythia models. Based on the config.json files from the models hosted on HuggingFace, the models have the following vocab sizes:

pythia-70m: 50304
pythia-160m: 50304
pythia-410m: 50304
pythia-1b: 50304
pythia-1.4b: 50304
pythia-2.8b: 50304
pythia-6.9b: 50432
pythia-12b: 50688

Strangely, these sizes also don't match the vocab size of the tokenizers for each model. Based on tokenizer.get_vocab(), the tokenizer for each model size has a vocab size of 50277. Does anyone know the reason for this vocab size mismatch?

Social bias and knowledge of social bias

Pretty straight forward… need to implement the following in the eval harness:

  1. WinoGender Schemas (also called AX-g under SuperGLUE)
  2. CrowS-Pairs
  3. WinoBias

For a discussion of “recognizing bias” vs “reproducing bias” check out here. The primary goal is to look at how the development of understanding of bias correlates with the development of tendency to produce biased content.

It would also be interesting to look at correlations across categories of bias, e.g., does the model learn to reproduce and/or identify all types of bias at an equal rate? And if not, can we identify specific subsets of the Pile that are “biased in how they are biased” so to speak.

Validation Perplexities

Thanks for sharing this amazing work. This will hopefully help in developing a better understanding of how LLMs work.

I had one question. Are the validation perplexities for each of the models available (ideally with every model snapshot) so that we can compare models on equal footing?

Pythia v.s. GPT-neox

Hi, thanks for the awesome work.

I notice there are Pythia models and GPT-neox models on Eleuther's HF hub, both seem to be very recent. Wonder what are the the main differences between them, and if there is any preference on one of them.

Thank you.

training logs

Hi,

first of all, thanks for your great contributions to open research!

is there any plan to make the training logs accessible?

Training time or approximation of TFLOPs?

Hi, there seems no training time or GPU utilzation report in your paper. Can you offer us some details like approximation of TFLOPs per GPU when training the 12B model? It'll be useful to approximate training time with a similar model scale.

Thanks a lot!

What tool do you use for your data preprocessing/binarization?

Hi, I am trying to train a GPT model from scratch using your training script. However, you have only provided your preprocessed data without the preprocessing script. Would it be possible to share the preprocessing scripts to generate the .bin and .idx files?

EleutherAI/pythia-800m tokenizer adds unusual kwargs, causes a ValueError when evaluating model

It seems like the EleutherAI/pythia-800m tokenizer includes 'token_type_ids' values, but these lead to a ValueError when evaluating the following code:

from transformers import GPTNeoXForCausalLM, AutoTokenizer

model = GPTNeoXForCausalLM.from_pretrained(
  "EleutherAI/pythia-800m",
  revision="step143000",
  cache_dir=".pythia-800m/step143000",
)

tokenizer = AutoTokenizer.from_pretrained(
  "EleutherAI/pythia-800m",
  revision="step143000",
  cache_dir="./pythia-800m/step143000",
)

inputs = tokenizer("Hello, I am", return_tensors="pt")
model.generate(**inputs)

Here is the stack trace:

Traceback (most recent call last):
  File "eval.py", line 76, in <module>
    outputs = model.generate(**inputs, temperature=0.0, max_new_tokens=40)
  File "/om2/user/ericjm/miniconda3/envs/phase-changes/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/om2/user/ericjm/miniconda3/envs/phase-changes/lib/python3.8/site-packages/transformers/generation/utils.py", line 1296, in generate
    self._validate_model_kwargs(model_kwargs.copy())
  File "/om2/user/ericjm/miniconda3/envs/phase-changes/lib/python3.8/site-packages/transformers/generation/utils.py", line 993, in _validate_model_kwargs
    raise ValueError(
ValueError: The following `model_kwargs` are not used by the model: ['token_type_ids'] (note: typos in the generate arguments will also show up in this list)

I can get around this error by simply using a tokenizer from another one of the models. This tokenizer, for instance, works:

tokenizer = AutoTokenizer.from_pretrained(
  "EleutherAI/pythia-19m",
  revision="step143000",
  cache_dir="./pythia-19m/step143000",
)

It seems like the tokenizers are the same for all the models, so this issue is pretty easy to get around, but I just thought I'd report it.

Ordering of deduplicated datasets?

I just wanted to confirm that the 3 versions you have of the deduplicated data have the same data ordering?

I was hoping to use the jsonl one but wanted to ensure it will accurately replicate the data ordering in your tokenized dataset that you used for training.

Complete outstanding evals

Hailey:
0-shot:

  • EleutherAI/pythia-v1.1-70m
  • EleutherAI/pythia-v1.1-70m-deduped
  • EleutherAI/pythia-v1.1-160m
  • EleutherAI/pythia-v1.1-160m-deduped
  • EleutherAI/pythia-v1.1-410m
  • EleutherAI/pythia-v1.1-410m-deduped
  • EleutherAI/pythia-v1.1-1b
  • EleutherAI/pythia-v1.1-1b-deduped
  • EleutherAI/pythia-v1.1-1.4b
  • EleutherAI/pythia-v1.1-1.4b-deduped
  • EleutherAI/pythia-v1.1-2.8b
  • EleutherAI/pythia-v1.1-2.8b-deduped
  • EleutherAI/pythia-v1.1-6.9b
  • EleutherAI/pythia-v1.1-6.9b-deduped
  • EleutherAI/pythia-v1.1-12b (missing 43000, 123000, 133000, 143000)
  • EleutherAI/pythia-v1.1-12b-deduped (missing 33000, 43000, 53000, 63000, 73000, 83000, 93000)
  • interventions

Sai:
steps equivalent to [3000,13000,....,123000,133000,143000]

  • EleutherAI/pythia-v1.1-70m-0.25MtokBS (model total steps: 1144000)
  • EleutherAI/pythia-v1.1-160m-0.5MtokBS (model total steps: 572000)
  • EleutherAI/pythia-v1.1-410m-0.5MtokBS (model total steps: 572000)
  • EleutherAI/pythia-v1.1-1b-0.5MtokBS (model total steps: 572000)
  • EleutherAI/pythia-v1.1-1.4b-1MtokBS (model total steps: 286000)

Aviya:
5-shot, steps [3000,13000,....,123000,133000,143000]:

  • EleutherAI/pythia-v1.1-70m
  • EleutherAI/pythia-v1.1-70m-deduped
  • EleutherAI/pythia-v1.1-160m
  • EleutherAI/pythia-v1.1-160m-deduped
  • EleutherAI/pythia-v1.1-410m
  • EleutherAI/pythia-v1.1-410m-deduped
  • EleutherAI/pythia-v1.1-1b
  • EleutherAI/pythia-v1.1-1b-deduped
  • EleutherAI/pythia-v1.1-1.4b
  • EleutherAI/pythia-v1.1-1.4b-deduped
  • EleutherAI/pythia-v1.1-2.8b
  • EleutherAI/pythia-v1.1-2.8b-deduped
  • EleutherAI/pythia-v1.1-6.9b
  • EleutherAI/pythia-v1.1-6.9b-deduped
  • EleutherAI/pythia-v1.1-12b
  • EleutherAI/pythia-v1.1-12b-deduped

Herbie?

  • Winobias on interventions + baseline

Task list:

  • hendrycksTest*
  • piqa
  • sciq
  • lambada_openai
  • winogrande
  • wsc
  • arc_challenge
  • arc_easy
  • logiqa
  • crows_pairs_*

Models missing still:

  • EleutherAI/intervention-pythia-v1.1-1.4b (MISSING)
  • EleutherAI/intervention-pythia-v1.1-1.4b-long (MISSING)
  • EleutherAI/pythia-v1.1-12b (steps after 123000 are missing)
  • EleutherAI/pythia-v1.1-1b (MISSING)
  • EleutherAI/pythia-v1.1-410m-0.5MtokBS
  • EleutherAI/pythia-v1.1-1b-0.5MtokBS
  • EleutherAI/pythia-v1.1-1.4b-1MtokBS

Fit the exponential decay curve to accuracy distribution

We hypothesize that the Scatter SDE summary plot of the accuracy distribution is an exponential decay with a bump at acc = 1 corresponding to the sum of the tail probabilities (since the memorization score can't go above 1). Specifically, let p(x) = [the number of sequences in the training data that have accuracy x]. We want to do the following:

  1. Fit an exponential decay curve to p(x) looking only at x in [0, k] for k in [0.25, 0.5, 0.75, 0.9, 0.99]
  2. Check how well the curves agree on [k, infinity)
  3. Check whether the sum from i = 1 to infinity of p(i) according to the fit model equals the observed p(1) value.

Fix currently uploaded eval-harness numbers for 1.3B ; 6.7B

Currently some of the 0 and 5 shot evals I ran appear to be wrong. (the 6.7B and 1.3B evals, for sure.) Not sure what went wrong but rerunning is quick.

I'll pull the ones that may be bad from the repo asap! We'll need to rerun these.

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.