• Stars
    star
    171
  • Rank 215,488 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created over 1 year ago
  • Updated 20 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Keeping language models honest by directly eliciting knowledge encoded in their activations.

Introduction

WIP: This codebase is under active development

Because language models are trained to predict the next token in naturally occurring text, they often reproduce common human errors and misconceptions, even when they "know better" in some sense. More worryingly, when models are trained to generate text that's rated highly by humans, they may learn to output false statements that human evaluators can't detect. We aim to circumvent this issue by directly **eliciting latent knowledge ** (ELK) inside the activations of a language model.

Specifically, we're building on the Contrastive Representation Clustering (CRC) method described in the paper Discovering Latent Knowledge in Language Models Without Supervision by Burns et al. (2022). In CRC, we search for features in the hidden states of a language model which satisfy certain logical consistency requirements. It turns out that these features are often useful for question-answering and text classification tasks, even though the features are trained without labels.

Quick Start

Our code is based on PyTorch and Huggingface Transformers. We test the code on Python 3.10 and 3.11.

First install the package with pip install -e . in the root directory, or pip install -e .[dev] if you'd like to contribute to the project (see Development section below). This should install all the necessary dependencies.

To fit reporters for the HuggingFace model model and dataset dataset, just run:

elk elicit microsoft/deberta-v2-xxlarge-mnli imdb

This will automatically download the model and dataset, run the model and extract the relevant representations if they aren't cached on disk, fit reporters on them, and save the reporter checkpoints to the elk-reporters folder in your home directory. It will also evaluate the reporter classification performance on a held out test set and save it to a CSV file in the same folder.

The following will generate a CCS (Contrast Consistent Search) reporter instead of the CRC-based reporter, which is the default.

elk elicit microsoft/deberta-v2-xxlarge-mnli imdb --net ccs

The following command will evaluate the probe from the run naughty-northcutt on the hidden states extracted from the model deberta-v2-xxlarge-mnli for the imdb dataset. It will result in an eval.csv and cfg.yaml file, which are stored under a subfolder in elk-reporters/naughty-northcutt/transfer_eval.

elk eval naughty-northcutt microsoft/deberta-v2-xxlarge-mnli imdb

The following runs elicit on the Cartesian product of the listed models and datasets, storing it in a special folder ELK_DIR/sweeps/<memorable_name>. Moreover, --add_pooled adds an additional dataset that pools all of the datasets together. You can also add a --visualize flag to visualize the results of the sweep.

elk sweep --models gpt2-{medium,large,xl} --datasets imdb amazon_polarity --add_pooled

If you just do elk plot, it will plot the results from the most recent sweep. If you want to plot a specific sweep, you can do so with:

elk plot {sweep_name}

Caching

The hidden states resulting from elk elicit are cached as a HuggingFace dataset to avoid having to recompute them every time we want to train a probe. The cache is stored in the same place as all other HuggingFace datasets, which is usually ~/.cache/huggingface/datasets.

Development

Use pip install pre-commit && pre-commit install in the root folder before your first commit.

Devcontainer

Open in Remote - Containers

Run tests

pytest

Run type checking

We use pyright, which is built into the VSCode editor. If you'd like to run it as a standalone tool, it requires a nodejs installation.

pyright

Run the linter

We use ruff. It is installed as a pre-commit hook, so you don't have to run it manually. If you want to run it manually, you can do so with:

ruff . --fix

Contributing to this repository

If you work on a new feature / fix or some other code task, make sure to create an issue and assign it to yourself ( Maybe, even share it in the elk channel of Eleuther's Discord with a small note). In this way, others know you are working on the issue and people won't do the same thing twice 👍 Also others can contact you easily.

More Repositories

1

gpt-neo

An implementation of model parallel GPT-2 and GPT-3-style models using the mesh-tensorflow library.
Python
8,150
star
2

gpt-neox

An implementation of model parallel autoregressive transformers on GPUs, based on the DeepSpeed library.
Python
6,467
star
3

lm-evaluation-harness

A framework for few-shot evaluation of language models.
Python
5,205
star
4

pythia

The hub for EleutherAI's work on interpretability and learning dynamics
Jupyter Notebook
1,935
star
5

the-pile

Python
1,375
star
6

math-lm

Python
989
star
7

polyglot

Polyglot: Large Language Models of Well-balanced Competence in Multi-languages
460
star
8

DALLE-mtf

Open-AI's DALL-E for large scale training in mesh-tensorflow.
Python
436
star
9

vqgan-clip

Jupyter Notebook
339
star
10

concept-erasure

Erasing concepts from neural representations with provable guarantees
Python
186
star
11

oslo

OSLO: Open Source for Large-scale Optimization
Python
170
star
12

lm_perplexity

Python
137
star
13

knowledge-neurons

A library for finding knowledge neurons in pretrained transformer models.
Python
130
star
14

cookbook

Deep learning for dummies. All the practical details and useful utilities that go into working with real models.
Python
123
star
15

pyfra

Python Research Framework
Python
107
star
16

dps

Data processing system for polyglot
Python
83
star
17

openwebtext2

Python
81
star
18

info

(Deprecated) A hub for onboarding & other information.
78
star
19

project-menu

See the issue board for the current status of active and prospective projects!
65
star
20

stackexchange-dataset

Python tools for processing the stackexchange data dumps into a text dataset for Language Models
Python
64
star
21

magiCARP

One stop shop for all things carp
Python
58
star
22

tqdm-multiprocess

Using queues, tqdm-multiprocess supports multiple worker processes, each with multiple tqdm progress bars, displaying them cleanly through the main process. It offers similar functionality for python logging.
Python
41
star
23

aria

Python
36
star
24

semantic-memorization

Jupyter Notebook
34
star
25

rnngineering

Engineering the state of RNN language models (Mamba, RWKV, etc.)
Jupyter Notebook
31
star
26

hae-rae

30
star
27

improved-t5

Experiments for efforts to train a new and improved t5
Python
26
star
28

mp_nerf

Massively-Parallel Natural Extension of Reference Frame
Jupyter Notebook
26
star
29

features-across-time

Understanding how features learned by neural networks evolve throughout training
Python
25
star
30

pile-pubmedcentral

A script for collecting the PubMed Central dataset in a language modelling friendly format.
Python
20
star
31

best-download

URL downloader supporting checkpointing and continuous checksumming.
Python
19
star
32

polyglot-data

data related codebase for polyglot project
Python
19
star
33

elk-generalization

Investigating the generalization behavior of LM probes trained to predict truth labels: (1) from one annotator to another, and (2) from easy questions to hard
Jupyter Notebook
19
star
34

text-generation-testing-ui

Web app for demoing the EAI models
JavaScript
16
star
35

exploring-contrastive-topology

Jupyter Notebook
16
star
36

mdl

Minimum Description Length probing for neural network representations
Python
14
star
37

pile_dedupe

Pile Deduplication Code
Python
14
star
38

pilev2

Python
13
star
39

distilling

Experiments with distilling large language models.
Python
13
star
40

lm-eval2

Python
11
star
41

equivariance

A framework for implementing equivariant DL
Jupyter Notebook
10
star
42

radioactive-lab

Adapting the "Radioactive Data" paper to work for text models
Python
9
star
43

tagged-pile

Part-of-Speech Tagging for the Pile and RedPajama
Python
9
star
44

pile-literotica

Download, parse, and filter data from Literotica. Data-ready for The-Pile.
Python
8
star
45

hn-scraper

Python
8
star
46

multimodal-fid

Python
7
star
47

pile-cc-filtering

The code used to filter CC data for The Pile
Python
6
star
48

minetest-baselines

Baseline agents for Minetest tasks.
Python
6
star
49

CodeCARP

Data collection pipeline for CodeCARP. Includes PyCharm plugins.
6
star
50

LLM-Markov-Chains

Project github for LLM Markov Chains Project
6
star
51

pile-uspto

A script for collecting the USPTO Backgrounds dataset in a language modelling friendly format.
Python
6
star
52

thonkenizers

yes
5
star
53

minetest-interpretabilty-notebook

Jupyter notebook for the interpretablity section of the minetester blog post
Jupyter Notebook
5
star
54

visual-grounding

Visually ground GPT-Neo 1.3b and 2.7b
Python
5
star
55

Unpaired-Image-Generation

Project Repo for Unpaired Image Generation project
5
star
56

pile-enron-emails

A script for collecting the Enron Emails dataset in a language modelling friendly format.
Python
5
star
57

architecture-experiments

Repository to host architecture experiments and development using Paxml and Praxis
Python
5
star
58

llemma-sample-explorer

Sample explorer tool for the Llemma models.
HTML
5
star
59

pile-explorer

For exploring the data and documenting its limitations
Python
4
star
60

lm-scope

Jupyter Notebook
4
star
61

megatron-3d

Python
4
star
62

tokengrams

Efficiently computing & storing token n-grams from large corpora
Rust
4
star
63

ccs

Python
4
star
64

latent-video-diffusion

Latent video diffusion
Python
3
star
65

eleutherai-instruct-dataset

A large instruct dataset for open-source models (WIP).
3
star
66

isaac-mchorse

EleutherAI's discord bot
Python
3
star
67

pile-allpoetry

Scraper to gather poems from allpoetry.com
Python
3
star
68

eai-prompt-gallery

Library of interesting prompt generations
JavaScript
3
star
69

eleutherai.github.io

This is the Hugo generated website for eleuther.ai. The source of this build is new-website repo.
HTML
3
star
70

website

New website for EleutherAI based on Hugo static site generator
HTML
3
star
71

variance-across-time

Studying the variance in neural net predictions across training time
Python
3
star
72

pile-ubuntu-irc

A script for collecting the Ubuntu IRC dataset in a language modelling friendly format.
Python
3
star
73

aria-amt

MIDI conditioned automatic music transcription
Jupyter Notebook
3
star
74

reddit-comment-processing

Python
2
star
75

language-adaptation

2
star
76

EvilModel

A replication of "EvilModel 2.0: Bringing Neural Network Models into Malware Attacks"
2
star
77

bucket-cleaner

A small utility to clear out old model checkpoints in Google Cloud Buckets whilst keeping tensorboard event files
Python
2
star
78

groupoid-rl

Jupyter Notebook
2
star
79

lang-filter

Filter text files or archives by language
Python
1
star
80

eleuther-blog

here is the generated content for the EleutherAI blog. Source is from new-website repo
HTML
1
star
81

prefix-free-tokenizer

A prefix free tokenizer
Python
1
star
82

alignment-reader

Search and filter through alignment literature
JavaScript
1
star
83

grouch

HTML
1
star
84

perceptors

central location for access to pretrained models for CLIP and variants, with common API and out-of-the-box differentiable weighted multi-perceptor
1
star
85

classifier-latent-diffusion

Python
1
star
86

common-llm-settings

Common LLM Settings App
JavaScript
1
star
87

bayesian-adam

Exactly what it says on the tin
Python
1
star
88

pile-cord19

A script for collecting the CORD-19 dataset in a language modelling friendly format.
Python
1
star
89

conceptual-constraints

Applying LEACE to models during training
Jupyter Notebook
1
star
90

truncated-gaussian

Method-of-moments estimation and sampling for truncated multivariate Gaussian distributions
Python
1
star