Skip to content

Commit

Permalink
Add links to existing colab notebook and more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
egorkrash committed Feb 20, 2024
1 parent 56759a0 commit fd69e6d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ class GradientVarianceCallback(EvaluationCallbackBase):
"""Calculates gradient variance and distance between definitions and corresponding questions.
Requires a tokenized eval dataset with keys: [<d1 definitions dataset>, '<d2 definitions dataset>', '<d1 questions>', '<d2 questions>'].
Example: ['train_defs_d1consis', 'train_defs_d2consis', 'd1consis', 'd2consis']
You can play with existing tensor logs in this colab notebook:
https://colab.research.google.com/drive/1K-bWitUMffNlB1cIl8ELq6jtnyG6_J5b?usp=sharing
"""
def __init__(self, eval_dataset_tokenized,
keys,
Expand Down
1 change: 1 addition & 0 deletions src/lm_training_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def create_tokenizer(add_tokens_for_var_names=True, num_letters_per_var=3, max_x
return tokenizer


# !!! THIS FUNCTION IS NOT USED FOR THE EXPERIMENTS IN THE PAPER !!!
def linear_probe(hugginface_model, eval_dataset_d1, eval_dataset_d2, save_path='logit_results.txt', device='cuda'):
try:
import statsmodels.api as sm
Expand Down
2 changes: 1 addition & 1 deletion src/train_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def compute_objective(metrics: Dict[str, float]) -> float:
trainer.log_metrics(f"eval_{k}", metrics)
trainer.save_metrics(f"eval_{k}", metrics)

# linear probes
# !!! THIS BLOCK WITH LINEAR PROBES IS NOT USED FOR THE EXPERIMENTS IN THE PAPER !!!
if training_args.do_lin_probe:
from src.lm_training_utils import linear_probe
logger.info('Starting linear probe')
Expand Down

0 comments on commit fd69e6d

Please sign in to comment.