Skip to content

Source code for <Probability Consistency in Large Language Models: Theoretical Foundations Meet Empirical Discrepancies>

License

Notifications You must be signed in to change notification settings

braingpt-lovelab/backwards

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

203 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Probability Consistency in Large Language Models: Theoretical Foundations Meet Empirical Discrepancies

Work with this repo locally:

git clone https://github.com/braingpt-lovelab/backwards --recursive
  • Will recursively grab the asubmodule for human participant data from this repo.
  • Will recursively grab the submodule for BrainBench testcases from this repo.

Model weights

All model weights (including checkpoints) are hosted here.

Repo structure

  • model_training/: training scripts for forward, backward and permuted GPT-2 models.
  • analyses/: post-training analyses scripts for producing results in the paper.

Training

cd model_training

  • Entry-point is launch_training.sh which calls train_bayes.py given configurations.
  • Training configurations can be set in configs/ and accel_config.yaml.
  • Forward tokenizer can be trained from scratch by tokenizer.py.
  • Training data is hosted here.
  • Tokenize and cache training/validation data: caching_tokenized_dataset.py (for neuroscience), caching_tokenized_dataset_for_pile10k.py (for The Pile).

Reproduce analyses from scratch:

cd analyses

  • Fig. 1, S.1: plot_x_models_train_val_loss_diffs.py
  • Fig. 2, 3, S.6 - S.21: plot_attn_weights_by_distance.py
  • Fig. 4, S.22, S.23: get_hidden_states_for_rsa.py to save hidden states on disk and plot_hidden_states_rsa.py for plotting
  • Tab. 2, S.1, S.2: plot_x_models_x_seeds_x_directions_diffs_bayes.py
  • Fig. S.1: plot_x_models_train_val_losses.py
  • Fig. S.3, S.4, S.5: plot_attn_weights_by_distance_pretrained.py
  • Fig. S.24: run_choice_bayes.py to obtain model responses to BrainBench and plot_model_vs_human_x_seeds.py for plotting
  • Fig. S.25, S.26: plot_error_correlation_model_vs_human.py
  • Statistical analyses: anova_stats.R.

Relation to arXiv:2411.11061

This paper is a major follow-up to Beyond Human-Like Processing: Large Language Models Perform Equivalently on Forward and Backward Scientific Text. It corrects methodological issues from the earlier work and includes extensive additional training and analysis informed by newly established theoretical proofs.

For the latest developments, we recommend reading this paper. To access the code associated with the previous work, use:

git checkout arxiv.org/abs/2411.11061

Attribution

@misc{luo2025probabilityconsistencylargelanguage,
      title={Probability Consistency in Large Language Models: Theoretical Foundations Meet Empirical Discrepancies}, 
      author={Xiaoliang Luo and Xinyi Xu and Michael Ramscar and Bradley C. Love},
      year={2025},
      eprint={2505.08739},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2505.08739}, 
}

About

Source code for <Probability Consistency in Large Language Models: Theoretical Foundations Meet Empirical Discrepancies>

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages