This repository contains the implementation used in our APCD experiments.
APCD is designed to improve faithfulness and reliability of LLM outputs. It has two stages:
- entropy warm-up to detect stable and informative branching points;
- dynamic multi-path contrastive decoding to increase trajectory diversity and adapt contrastive strength during generation.
Short-text QA benchmark entry for APCD + open-source baselines:
scripts/run_all_methods.sh: unified launcher for TruthfulQA / TriviaQA / Natural Questions / HotpotQA.method/: decoding and evaluation scripts used by the launcher.data/: local dataset files used by the short-text benchmark.
Notes:
- APCD-specific parameters are configured in the script and documented in this repository.
- Other methods (
DoLa,Activation Decoding,ITI,CAD,UCD, etc.) follow their corresponding open-source implementations and paper defaults, so we do not restate all method-specific parameters here. - For short-text experiments, we use the same environment as the official Activation Decoding repository to ensure complete parameter and runtime alignment.
Quick environment setup (short-text):
git clone https://github.com/hkust-nlp/Activation_Decoding.git
cd Activation_Decoding
conda create -n activation_decoding python=3.10 -y
conda activate activation_decoding
pip install -r requirements.txtMinimal pipeline for medical multiple-choice QA:
medical_inference/APCD.py: APCD (Adaptive Path-Contrastive Decoding) inference script.scripts/run_mode_commands.sh: shell launcher that calls APCD.eval_medical_qa.py: strict / GPT-assisted evaluator.medical_data/: sample datasets (NEJM, MedMCQA, MedQA, MedB-4).requirements.txt,gpt_config.jsonfor dependencies and optional GPT creds.- Setup
cd Medical_test conda create --name decode python=3.10 conda activate decode pip install -r requirements.txt
- Short-text QA: TruthfulQA, TriviaQA, HotpotQA, Natural Questions (under
Short_test/data/). - Medical QA: NEJM, MedMCQA, MedQA, MedB-4 (under
Medical_test/medical_data/).
- Dola : https://github.com/voidism/DoLa
- Activation Decoding: https://github.com/hkust-nlp/Activation_Decoding
- ITI : https://github.com/likenneth/honest_llama
- Context-Aware-Decoding : https://github.com/xhan77/context-aware-decoding/tree/main
Please cite our paper if it's helpful to your work!
[To be updated]
