Framework for comparing language model configurations
Project description
lmdiff
Compare language model configurations — not just weights, but weights + context + decoding + adapter + agent — via behavioral distance and multi-level diagnostics.
Status
Phase 1 complete. Working: BehavioralDistance, TokenEntropy, TokenKL, CapabilityRadar, CLI, JSON reports, Python API. Not yet: representation/trajectory/causal metrics, HTML/LaTeX reports, viz. See CLAUDE.md for the full roadmap.
Install
mamba create -n lmdiff python=3.12
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu130
pip install -e .
cu130 is for RTX 5090 / Blackwell. Pick the CUDA version that matches your GPU.
Command line
# Metric-level comparison (BD, token entropy, token KL)
lmdiff compare gpt2 distilgpt2 --probes v01
# Same, but JSON output to file
lmdiff compare gpt2 distilgpt2 --probes v01 --json --output result.json
# Per-domain capability radar (accuracy + BD per domain)
lmdiff radar gpt2 distilgpt2 --probes v01
# Single-model task evaluation
lmdiff run-task gpt2 --probes v01 --evaluator contains_answer
# List available metrics
lmdiff list-metrics
Python API
from lmdiff import Config, ModelDiff, ProbeSet
from lmdiff.report.terminal import print_report, print_radar
probes = ProbeSet.from_json("lmdiff/probes/v01.json")
md = ModelDiff(
Config(model="gpt2"),
Config(model="distilgpt2"),
probes,
)
# Metric-level comparison
report = md.run(level="output", max_new_tokens=16)
print_report(report)
# Per-domain capability radar
radar_result = md.run_radar(probes=probes, max_new_tokens=16)
print_radar(radar_result)
What gets measured
Three output-level metrics:
- BehavioralDistance — symmetric, self-entropy-baseline-subtracted cross-entropy distance. BPB-normalized when tokenizers differ.
- TokenEntropy — mean per-token next-token entropy delta, A vs B.
- TokenKL — symmetric KL divergence over full vocab.
CapabilityRadar adds per-domain accuracy + BD breakdown across math/knowledge/code (or any multi-domain probe set).
All return structured results with per-probe breakdowns in .details.
Configuration abstraction
A Config is more than a model name:
Config(
model="gpt2",
system_prompt="You are concise.",
context=[{"role": "user", "content": "..."}],
decode={"strategy": "sample", "temperature": 0.7},
name="gpt2-concise",
)
Same weights + different context/decoding = different config = measurable behavioral difference.
JSON output
All results serialize to deterministic JSON with schema_version for forward compatibility:
from lmdiff.report.json_report import to_json, write_json
write_json(report, "output.json")
Development
pytest # fast tests (mocks only)
pytest -m slow -o "addopts=" # includes gpt2/distilgpt2 E2E
Architecture rules, implementation order, and coding conventions live in CLAUDE.md.
License
TBD
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lmdiff_kit-0.1.0.tar.gz.
File metadata
- Download URL: lmdiff_kit-0.1.0.tar.gz
- Upload date:
- Size: 43.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db050786fb34486d6a3883087efe0338edc46bbaa54c2c90afc3f75bec37c7c3
|
|
| MD5 |
bb2adab33aa088ed8063fa4d21864e6b
|
|
| BLAKE2b-256 |
155c377cd0950a0287ae6c639405032720dc0b5eddcb343845cc43f1abc49563
|
Provenance
The following attestation bundles were made for lmdiff_kit-0.1.0.tar.gz:
Publisher:
publish.yml on MaiqiVerse/lmdiff
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lmdiff_kit-0.1.0.tar.gz -
Subject digest:
db050786fb34486d6a3883087efe0338edc46bbaa54c2c90afc3f75bec37c7c3 - Sigstore transparency entry: 1321561650
- Sigstore integration time:
-
Permalink:
MaiqiVerse/lmdiff@6bfa26ecfbb38cb21d8196db32bd6becb870d3f9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/MaiqiVerse
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6bfa26ecfbb38cb21d8196db32bd6becb870d3f9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file lmdiff_kit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lmdiff_kit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
570c9aa04dec90e771fa6258ed5fcf134c98031c81a472b0894987c548dfca91
|
|
| MD5 |
29a87f01d12e16331a65fd067015361e
|
|
| BLAKE2b-256 |
6a00e2f2b62863608cc74c6e6f85e33abd3995f878ad05d289b3273152d9907a
|
Provenance
The following attestation bundles were made for lmdiff_kit-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on MaiqiVerse/lmdiff
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lmdiff_kit-0.1.0-py3-none-any.whl -
Subject digest:
570c9aa04dec90e771fa6258ed5fcf134c98031c81a472b0894987c548dfca91 - Sigstore transparency entry: 1321561723
- Sigstore integration time:
-
Permalink:
MaiqiVerse/lmdiff@6bfa26ecfbb38cb21d8196db32bd6becb870d3f9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/MaiqiVerse
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6bfa26ecfbb38cb21d8196db32bd6becb870d3f9 -
Trigger Event:
release
-
Statement type: