This repository contains the implementation of Divergent Path Decoding (DPD), an inference-time approach that modifies the autoregressive token generation process to improve output reliability in large language models.
├── charts/ # Visualization tools for analysis plots
├── gsm8k/ # Output directory for GSM8K evaluation results
├── mmlu/ # Output directory for MMLU evaluation results
├── scripts/ # Utility scripts for experiments
├── utils/ # Common utility functions
├── custom_greedy_counterfactual.py
├── environment.yaml # Environment configuration
├── main.py # Main execution script
├── multi_causal_counterfactual_analysis.py
├── selective_distributed_multi_mmlu.py
├── selective_distributed_random_mmlu.py
├── selective_greedy_counterfactual.py
└── selective_greedy_counterfactual_analysis.py
This project implements a novel decoding method that:
- Modifies the autoregressive token generation process at inference time
- Explores alternative generation paths through controlled token interventions
- Requires no model fine-tuning or architectural changes
- Improves output reliability while maintaining model capabilities
The system was tested on a high-performance computing environment with:
- NVIDIA A100 GPUs (8 per node, 40GB VRAM each)
- Dual 64-core AMD EPYC processors
- 512GB system RAM
- SLURM workload manager
- PyTorch with DistributedDataParallel (DDP)
- Hugging Face Transformers library
# Clone the repository
git clone https://github.com/mmjerge/counterfactual_ensemble_decoding.git
# Create and configure environment from yaml
conda env create -f environment.yaml
conda activate divergent_decodingmain.py: Primary script for running experiments and generating resultscustom_greedy_counterfactual.py: Implementation of basic greedy counterfactual generationmulti_causal_counterfactual_analysis.py: Multi-causal analysis frameworkselective_distributed_multi_mmlu.py: Distributed MMLU evaluationselective_distributed_random_mmlu.py: Random sampling for distributed evaluationselective_greedy_counterfactual.py: Selective greedy counterfactual generationselective_greedy_counterfactual_analysis.py: Analysis tools for selective approaches
Run experiments using the main.py script:
# Run evaluation on GSM8K dataset with 150 samples
python3 main.py --dataset gsm8k --num_samples 150
# Run evaluation on MMLU dataset with 150 samples
python3 main.py --dataset mmlu --num_samples 150Results will be generated in the respective output directories:
mmlu/: Contains MMLU evaluation resultsgsm8k/: Contains GSM8K evaluation results
The implementation follows these key steps:
- Generates multiple decoding paths for each input prompt
- Introduces controlled deviations at specific token positions
- Explores alternative reasoning trajectories
- Aggregates results using majority voting
@article{jerge2024divergent,
title={Divergent Path Decoding},
author={Jerge, Michael},
institution={University of Virginia},
year={2024}
}See LICENSE file for details.
- Author: Michael Jerge
- Institution: University of Virginia
- Repository: https://github.com/mmjerge/divergent_path_decoding