A research toolkit for investigating Chain of Thought (CoT) reasoning, faithfulness, and mechanistic interpretability in Large Language Models.
git clone https://github.com/huseyincavusbi/CoTLab.git
cd CoTLab
uv venv cotlab --python 3.11
source cotlab/bin/activate
uv pip install -e ".[dev]"
# GPU Setup:
# NVIDIA: uv pip install vllm
# AMD ROCm: ./scripts/cotlab-rocm.sh (uses Docker)
# AMD ROCm (Transformers backend): install ROCm PyTorch wheels
# uv pip install --reinstall --index-url https://download.pytorch.org/whl/rocm6.4 torch torchvision torchaudio
# Apple Silicon: requires Python 3.12 and vllm-metal plugin
# See docs/getting-started/installation.md for Metal setup instructions
See Installation Docs for detailed GPU setup.
CoTLab supports two inference backends with different strengths:
Best for large-scale generation experiments.
cot_faithfulness, radiologygemma_270m, medgemma_27b_text_it)medgemma_4b_it) are currently incompatible with vLLM 0.12.0 due to architecture detection issues. Use transformers backend for these.Best for mechanistic interpretability and activation patching.
To switch backends:
# Use vLLM (fast generation)
python -m cotlab.main backend=vllm ...
# Use Transformers (activation access)
python -m cotlab.main backend=transformers ...
# Run logit lens on MedGemma
python -m cotlab.main experiment=logit_lens model=medgemma_4b
# Find sycophancy heads
python -m cotlab.main experiment=sycophancy_heads model=medgemma_4b
# Test CoT ablation on pediatrics dataset
python -m cotlab.main experiment=cot_ablation dataset=pediatrics
# Compare prompt strategies
python -m cotlab.main -m prompt=chain_of_thought,direct_answer,sycophantic
CoTLab ships config files for some models, but in principle it supports any model that the selected backend can load. Mechanistic experiments can still fail for models with unusual architectures.
You can add a model config file for more control over hyperparameters, but you can also run any experiment by passing a Hugging Face model name directly.
# Use a built-in model config
python -m cotlab.main model=medgemma_4b
# Or pass any HF model name directly
python -m cotlab.main model.name=google/gemma-3-270m
If you prefer, you can pre-create model configs with cotlab-template, but
this is optional because CoTLab can auto-generate model configs when running
with model=org/repo-id.
All configs auto-detect layers/heads at runtime. Override via CLI:
python -m cotlab.main \
model=medgemma_4b \
dataset=pediatrics \
prompt=chain_of_thought \
experiment.top_k=10
This research is conducted in collaboration with the Great Ormond Street Hospital DRIVE Unit.
MIT
525 commits
22 commits
Python
98.8%
A research toolkit for investigating Chain of Thought (CoT) reasoning, faithfulness, and mechanistic interpretability in Large Language Models.
git clone https://github.com/huseyincavusbi/CoTLab.git
cd CoTLab
uv venv cotlab --python 3.11
source cotlab/bin/activate
uv pip install -e ".[dev]"
# GPU Setup:
# NVIDIA: uv pip install vllm
# AMD ROCm: ./scripts/cotlab-rocm.sh (uses Docker)
# AMD ROCm (Transformers backend): install ROCm PyTorch wheels
# uv pip install --reinstall --index-url https://download.pytorch.org/whl/rocm6.4 torch torchvision torchaudio
# Apple Silicon: requires Python 3.12 and vllm-metal plugin
# See docs/getting-started/installation.md for Metal setup instructions
See Installation Docs for detailed GPU setup.
CoTLab supports two inference backends with different strengths:
Best for large-scale generation experiments.
cot_faithfulness, radiologygemma_270m, medgemma_27b_text_it)medgemma_4b_it) are currently incompatible with vLLM 0.12.0 due to architecture detection issues. Use transformers backend for these.Best for mechanistic interpretability and activation patching.
To switch backends:
# Use vLLM (fast generation)
python -m cotlab.main backend=vllm ...
# Use Transformers (activation access)
python -m cotlab.main backend=transformers ...
# Run logit lens on MedGemma
python -m cotlab.main experiment=logit_lens model=medgemma_4b
# Find sycophancy heads
python -m cotlab.main experiment=sycophancy_heads model=medgemma_4b
# Test CoT ablation on pediatrics dataset
python -m cotlab.main experiment=cot_ablation dataset=pediatrics
# Compare prompt strategies
python -m cotlab.main -m prompt=chain_of_thought,direct_answer,sycophantic
CoTLab ships config files for some models, but in principle it supports any model that the selected backend can load. Mechanistic experiments can still fail for models with unusual architectures.
You can add a model config file for more control over hyperparameters, but you can also run any experiment by passing a Hugging Face model name directly.
# Use a built-in model config
python -m cotlab.main model=medgemma_4b
# Or pass any HF model name directly
python -m cotlab.main model.name=google/gemma-3-270m
If you prefer, you can pre-create model configs with cotlab-template, but
this is optional because CoTLab can auto-generate model configs when running
with model=org/repo-id.
All configs auto-detect layers/heads at runtime. Override via CLI:
python -m cotlab.main \
model=medgemma_4b \
dataset=pediatrics \
prompt=chain_of_thought \
experiment.top_k=10
This research is conducted in collaboration with the Great Ormond Street Hospital DRIVE Unit.
MIT
525 commits
22 commits
Python
98.8%