-
Notifications
You must be signed in to change notification settings - Fork 2
/
treebank_data_gen.py
63 lines (58 loc) · 1.4 KB
/
treebank_data_gen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: -all
# custom_cell_magics: kql
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.11.2
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---
# %%
# !ls
# %%
# %cd eliciting-latent-sentiment
# %%
# !pip install circuitsvis
# %%
from enum import Enum
from typing import List
import pandas as pd
from datasets import Dataset, DatasetDict
import os
from transformer_lens import HookedTransformer
import torch
import plotly.express as px
from tqdm.auto import tqdm
from utils.treebank import get_merged_dataframe, convert_to_dataset_dict, create_datasets_for_model
# %%
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
sentence_phrase_df = get_merged_dataframe()
sentence_phrase_df.head()
# %%
sentence_phrase_df.split.value_counts()
# %%
convert_to_dataset_dict(sentence_phrase_df)
# %%
MODELS = [
'gpt2-small',
'gpt2-medium',
'gpt2-large',
'gpt2-xl',
'EleutherAI/pythia-160m',
'EleutherAI/pythia-410m',
'EleutherAI/pythia-1.4b',
'EleutherAI/pythia-2.8b',
]
for model in tqdm(MODELS):
model = HookedTransformer.from_pretrained(model, device=device)
create_datasets_for_model(
model, sentence_phrase_df, padding_side="left",
batch_size=16,
)
#%%