This guide will help you set up the environment to run experiments and generate plots.
git clone https://github.com/yourusername/probabilistic-reasoning-clean.git
cd probabilistic-reasoning-cleanpython -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtCreate a .env file in the project root with your API keys:
# OpenAI
export OPENAI_API_KEY="your-openai-api-key"
# Anthropic
export ANTHROPIC_API_KEY="your-anthropic-api-key"
# Google
export GOOGLE_API_KEY="your-google-api-key"
# Together AI
export TOGETHER_API_KEY="your-together-api-key"
# OpenRouter (for Grok and other models)
export OPENROUTER_API_KEY="your-openrouter-api-key"Then source the file:
source .envSee scripts/README.md for detailed examples. Basic usage:
python scripts/get_probcopa_results.py \
--dataset-path ./datasets/probcopa_items.jsonl \
--provider openai \
--model gpt-5 \
--n-responses 30 \
--results-tag probcopa_gpt-5 \
--output-dir ./results/Before running the analysis notebooks, remove canary strings from the data files:
python scripts/remove_canary_strings.py \
--input-path datasets/probcopa_CANARY.jsonl \
--output-path datasets/probcopa.jsonl
python scripts/remove_canary_strings.py \
--input-path results/probcopa_human_results_annotated_CANARY.jsonl \
--output-path results/probcopa_human_results_annotated.jsonl
python scripts/remove_canary_strings.py \
--input-path results/probcopa_random_sample_validation_round_human_results_CANARY.jsonl \
--output-path results/probcopa_random_sample_validation_round_human_results_cleaned.jsonl
python scripts/remove_canary_strings.py \
--input-path results/probcopa_random_sample_prompt_validation_round_human_results_CANARY.jsonl \
--output-path results/probcopa_random_sample_prompt_validation_round_human_results_cleaned.jsonlThen open and run the analysis notebooks:
jupyter notebook scripts/analyze_and_plot_results_models.ipynb
jupyter notebook scripts/analyze_and_plot_results_human.ipynbprobabilistic-reasoning-clean/
├── README.md # Main documentation
├── SETUP.md # This file
├── LICENSE # MIT License
├── requirements.txt # Python dependencies
├── .gitignore # Git ignore rules
├── ProbabilisticInferences.pdf # Paper manuscript
├── datasets/ # Data files
│ ├── probcopa_items.jsonl # ProbCOPA items (210 items)
│ ├── probcopa_CANARY.jsonl # Full dataset with human annotations (canary-protected)
│ ├── probcopa_30_samples.jsonl # Random sample for validation
│ └── pavlick_kwiatkowski_2019_sentencepair_data.jsonl # NLI comparison dataset
├── results/ # Experiment results
│ ├── probcopa_human_results_annotated_CANARY.jsonl # Human annotations (canary-protected)
│ ├── probcopa_{model}.jsonl # Model results (8 models)
│ ├── temperature_experiments/ # Temperature ablations
│ ├── reasoning_effort_experiments/ # Reasoning effort & thinking budget ablations
│ └── persona_prompt_experiments/ # Persona prompting experiments
├── plots/ # Generated figures (31 PDFs)
├── scripts/ # Code
│ ├── README.md # Script documentation
│ ├── analyze_and_plot_results_models.ipynb # Model analysis & plots
│ ├── analyze_and_plot_results_human.ipynb # Human analysis & plots
│ ├── probcopa_inference_batch_api.py # Batch API inference (primary)
│ ├── probcopa_inference_openrouter_async.py # OpenRouter async inference
│ ├── get_probcopa_results.py # Synchronous inference (testing)
│ ├── fetch_batch_api_results.py # Fetch batch results
│ ├── process_batch_api_results.py # Process batch results
│ ├── process_openrouter_results.py # Process OpenRouter results
│ ├── create_probcopa_samples.py # Dataset sampling
│ ├── add_canary_strings.py # Add canary strings to data files
│ ├── remove_canary_strings.py # Remove canary strings from data files
│ └── silverman_test.R # Silverman's test of multimodality
└── assets/ # Configuration files
├── model_argument_limits.json
├── structured_personas_demographic.jsonl
└── structured_personas_psychological.jsonl
If you encounter rate limits, you can:
- Reduce
--n-responsesto generate fewer samples per item - Add delays between API calls (modify the script)
- Use batch processing for supported providers
If you run out of memory when generating plots:
- Process models one at a time instead of loading all at once
- Reduce the number of items processed simultaneously
- Close other applications
Some result files may not be included in the repository due to size constraints. You can:
- Generate them yourself using the inference scripts
- Contact the authors for access to the full dataset
If the analysis notebooks fail because data files are missing, you likely need to run remove_canary_strings.py first (see Generate Plots above). The cleaned files are not tracked by git.
If you use this code or data, please cite:
For questions or issues, please open an issue on GitHub.