Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binarized meta-templates; some extraction refactoring #218

Closed
wants to merge 24 commits into from
Closed
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bbee489
Initial support for FEVER
norabelrose Apr 22, 2023
5ba1ddd
Start saving and fitting a reporter to the input embeddings
norabelrose Apr 22, 2023
3b1f74d
Merge branch 'input-embeddings' into template-filtering
norabelrose Apr 22, 2023
51ba54f
Rename layer 0 to 'input' to make it more clear
norabelrose Apr 22, 2023
544b485
Actually rename layer 0 correctly
norabelrose Apr 22, 2023
43da44e
Handle layer_stride correctly
norabelrose Apr 22, 2023
9056e00
Merge branch 'input-embeddings' into template-filtering
norabelrose Apr 22, 2023
756fa53
label_choices
norabelrose Apr 22, 2023
93b7ae0
Clean up train and eval commands; do transfer in sweep
norabelrose Apr 22, 2023
57d0b8b
Support INLP and split eval output into multiple CSVs
norabelrose Apr 22, 2023
228a6a0
Merge branch 'inlp' into template-filtering
norabelrose Apr 22, 2023
b086f0b
Merge branch 'inlp' into template-filtering
norabelrose Apr 25, 2023
934cd54
Log ensembled metrics
norabelrose Apr 26, 2023
dff69bf
Fixing pyright version
norabelrose Apr 26, 2023
b181d3e
Merge remote-tracking branch 'origin/main' into ensembling
norabelrose Apr 26, 2023
15254bf
Merge main
norabelrose Apr 26, 2023
69c2d55
Tons of stuff, preparing for sciq_binary experiment
norabelrose Apr 27, 2023
960ff01
Support --binarize again
norabelrose Apr 27, 2023
c9e62ea
Partial support for truthful_qa
norabelrose Apr 27, 2023
eb71a6c
Merge branch 'main' into template-filtering
norabelrose Apr 29, 2023
88bb15e
Merge remote-tracking branch 'origin/main' into template-filtering
norabelrose Apr 29, 2023
c648ff0
Remove crap
norabelrose Apr 29, 2023
ef12130
EleutherAI/truthful_qa_mc
norabelrose Apr 29, 2023
5d60ebd
Update templates
norabelrose Apr 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions elk/extraction/extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ def __post_init__(self, layer_stride: int):
config = assert_type(
PretrainedConfig, AutoConfig.from_pretrained(self.model)
)
self.layers = tuple(range(0, config.num_hidden_layers, layer_stride))
# Note that we always include 0 which is the embedding layer
layer_range = range(0, config.num_hidden_layers, layer_stride)
self.layers = (0,) + tuple(layer_range)

def explode(self) -> list["Extract"]:
"""Explode this config into a list of configs, one for each layer."""
Expand Down Expand Up @@ -132,8 +134,8 @@ def extract_hiddens(
world_size=world_size,
)

# Iterating over questions
layer_indices = cfg.layers or tuple(range(model.config.num_hidden_layers))
# Add one to the number of layers to account for the embedding layer
layer_indices = cfg.layers or tuple(range(model.config.num_hidden_layers + 1))

global_max_examples = p_cfg.max_examples[0 if split_type == "train" else 1]
# break `max_examples` among the processes roughly equally
Expand Down Expand Up @@ -225,9 +227,6 @@ def extract_hiddens(
hiddens = (
outputs.get("decoder_hidden_states") or outputs["hidden_states"]
)
# First element of list is the input embeddings
hiddens = hiddens[1:]

# Throw out layers we don't care about
hiddens = [hiddens[i] for i in layer_indices]

Expand Down Expand Up @@ -316,7 +315,8 @@ def get_splits() -> SplitDict:
dtype="int16",
shape=(num_variants, num_classes, model_cfg.hidden_size),
)
for layer in cfg.layers or range(model_cfg.num_hidden_layers)
# Add 1 to include the embedding layer
for layer in cfg.layers or range(model_cfg.num_hidden_layers + 1)
}
other_cols = {
"variant_ids": Sequence(
Expand Down