Skip to content

zty-king/APCD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

APCD

Adaptive Path-Contrastive Decoding (APCD)

APCD Overview

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:

  1. entropy warm-up to detect stable and informative branching points;
  2. dynamic multi-path contrastive decoding to increase trajectory diversity and adapt contrastive strength during generation.

Repository Structure

Short_test/

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.txt

Medical_test/

Minimal 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.json for dependencies and optional GPT creds.
  • Setup
    cd Medical_test
    conda create --name decode python=3.10
    conda activate decode
    pip install -r requirements.txt

Datasets

  • Short-text QA: TruthfulQA, TriviaQA, HotpotQA, Natural Questions (under Short_test/data/).
  • Medical QA: NEJM, MedMCQA, MedQA, MedB-4 (under Medical_test/medical_data/).

Reference Repositories

Citation

Please cite our paper if it's helpful to your work!

[To be updated]

About

APCD method and test code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors