modeldiffx 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. modeldiffx-0.3.0/.github/workflows/ci.yml +15 -0
  2. modeldiffx-0.3.0/.gitignore +22 -0
  3. modeldiffx-0.3.0/CHANGELOG.md +25 -0
  4. modeldiffx-0.3.0/LICENSE +177 -0
  5. modeldiffx-0.3.0/PKG-INFO +254 -0
  6. modeldiffx-0.3.0/README.md +219 -0
  7. modeldiffx-0.3.0/assets/diff_report.svg +241 -0
  8. modeldiffx-0.3.0/assets/drift_analysis.svg +194 -0
  9. modeldiffx-0.3.0/examples/capture_and_diff.py +62 -0
  10. modeldiffx-0.3.0/examples/html_report.py +48 -0
  11. modeldiffx-0.3.0/examples/regression_suite.py +77 -0
  12. modeldiffx-0.3.0/examples/with_quantbench.py +92 -0
  13. modeldiffx-0.3.0/generate_svgs.py +133 -0
  14. modeldiffx-0.3.0/pyproject.toml +67 -0
  15. modeldiffx-0.3.0/src/modeldiffx/__init__.py +80 -0
  16. modeldiffx-0.3.0/src/modeldiffx/_types.py +219 -0
  17. modeldiffx-0.3.0/src/modeldiffx/capture.py +100 -0
  18. modeldiffx-0.3.0/src/modeldiffx/cli.py +107 -0
  19. modeldiffx-0.3.0/src/modeldiffx/diff.py +181 -0
  20. modeldiffx-0.3.0/src/modeldiffx/drift.py +140 -0
  21. modeldiffx-0.3.0/src/modeldiffx/fingerprint.py +109 -0
  22. modeldiffx-0.3.0/src/modeldiffx/generator.py +279 -0
  23. modeldiffx-0.3.0/src/modeldiffx/html_report.py +128 -0
  24. modeldiffx-0.3.0/src/modeldiffx/parquet.py +237 -0
  25. modeldiffx-0.3.0/src/modeldiffx/plugin.py +74 -0
  26. modeldiffx-0.3.0/src/modeldiffx/py.typed +0 -0
  27. modeldiffx-0.3.0/src/modeldiffx/report.py +180 -0
  28. modeldiffx-0.3.0/src/modeldiffx/similarity.py +335 -0
  29. modeldiffx-0.3.0/src/modeldiffx/suite.py +194 -0
  30. modeldiffx-0.3.0/tests/conftest.py +7 -0
  31. modeldiffx-0.3.0/tests/test_capture.py +95 -0
  32. modeldiffx-0.3.0/tests/test_cli.py +77 -0
  33. modeldiffx-0.3.0/tests/test_diff.py +131 -0
  34. modeldiffx-0.3.0/tests/test_drift.py +116 -0
  35. modeldiffx-0.3.0/tests/test_edge_cases.py +309 -0
  36. modeldiffx-0.3.0/tests/test_fingerprint.py +88 -0
  37. modeldiffx-0.3.0/tests/test_generator.py +271 -0
  38. modeldiffx-0.3.0/tests/test_html_report.py +213 -0
  39. modeldiffx-0.3.0/tests/test_parquet.py +202 -0
  40. modeldiffx-0.3.0/tests/test_plugin.py +119 -0
  41. modeldiffx-0.3.0/tests/test_report.py +107 -0
  42. modeldiffx-0.3.0/tests/test_similarity.py +229 -0
  43. modeldiffx-0.3.0/tests/test_suite.py +65 -0
  44. modeldiffx-0.3.0/tests/test_types.py +193 -0
@@ -0,0 +1,15 @@
1
+ name: CI
2
+ on: [push, pull_request]
3
+ jobs:
4
+ test:
5
+ runs-on: ubuntu-latest
6
+ strategy:
7
+ matrix:
8
+ python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
9
+ steps:
10
+ - uses: actions/checkout@v4
11
+ - uses: actions/setup-python@v5
12
+ with:
13
+ python-version: ${{ matrix.python-version }}
14
+ - run: pip install -e ".[cli]" pytest
15
+ - run: pytest tests/ -v
@@ -0,0 +1,22 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ *.egg-info/
5
+ *.egg
6
+ dist/
7
+ build/
8
+ .eggs/
9
+ *.so
10
+ .venv/
11
+ venv/
12
+ env/
13
+ .env
14
+ .mypy_cache/
15
+ .pytest_cache/
16
+ .ruff_cache/
17
+ htmlcov/
18
+ .coverage
19
+ coverage.xml
20
+ *.log
21
+ .DS_Store
22
+ Thumbs.db
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.3.0] - 2025-04-10
9
+
10
+ ### Added
11
+ - Add output similarity scoring via `similarity.py`
12
+ - Add Parquet serialization for snapshots in `parquet.py`
13
+
14
+ ## [0.2.0] - 2026-04-10
15
+
16
+ ### Added
17
+ - Add regression test suite generation
18
+ - Add HTML diff report export
19
+ - Add pytest plugin for model regression testing
20
+
21
+ ## [0.1.0] - 2026-04-10
22
+
23
+ ### Added
24
+ - Initial release: behavioral regression testing for LLMs
25
+
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,254 @@
1
+ Metadata-Version: 2.4
2
+ Name: modeldiffx
3
+ Version: 0.3.0
4
+ Summary: Behavioral regression testing for LLMs. Capture outputs, diff behavior, detect drift — pytest for model upgrades.
5
+ Project-URL: Homepage, https://github.com/stef41/modeldiffx
6
+ Project-URL: Repository, https://github.com/stef41/modeldiffx
7
+ Project-URL: Issues, https://github.com/stef41/modeldiffx/issues
8
+ Author: Zacharie B
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: behavioral,ci-cd,comparison,diff,drift,evaluation,llm,model,regression,testing
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.9
25
+ Provides-Extra: all
26
+ Requires-Dist: click>=8.0; extra == 'all'
27
+ Requires-Dist: rich>=13.0; extra == 'all'
28
+ Requires-Dist: rouge-score>=0.1.2; extra == 'all'
29
+ Provides-Extra: cli
30
+ Requires-Dist: click>=8.0; extra == 'cli'
31
+ Requires-Dist: rich>=13.0; extra == 'cli'
32
+ Provides-Extra: metrics
33
+ Requires-Dist: rouge-score>=0.1.2; extra == 'metrics'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # modeldiffx
37
+
38
+ [![CI](https://github.com/stef41/modeldiffx/actions/workflows/ci.yml/badge.svg)](https://github.com/stef41/modeldiffx/actions/workflows/ci.yml)
39
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9%2B-blue.svg)](https://www.python.org/downloads/)
40
+ [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-green.svg)](LICENSE)
41
+
42
+ **Behavioral regression testing for LLMs.** Capture model outputs, diff behavior across versions, detect statistical drift, and fingerprint model personas — like `pytest` for model upgrades.
43
+
44
+ When you upgrade `gpt-4-0613` → `gpt-4-1106-preview`, what *actually* changed? modeldiffx answers that with structured diffs, statistical drift detection, and model fingerprinting — all with zero required dependencies.
45
+
46
+ <p align="center">
47
+ <img src="assets/diff_report.svg" width="700" alt="modeldiffx behavioral diff report" />
48
+ </p>
49
+
50
+ ## Why modeldiffx?
51
+
52
+ | Problem | modeldiffx Solution |
53
+ |---|---|
54
+ | Model upgrades silently break production prompts | Structured behavioral diffs with severity classification |
55
+ | "It feels different" — no way to quantify | Statistical drift detection (length, refusal, vocabulary, latency) |
56
+ | No baseline for model behavior | Snapshot capture & persistence for reproducible comparisons |
57
+ | Hard to characterize model personality | Fingerprinting with 8 behavioral dimensions |
58
+ | Evaluation suites are scattered/ad-hoc | 25 built-in prompts across 5 categories |
59
+
60
+ ## Installation
61
+
62
+ ```bash
63
+ pip install modeldiffx # zero dependencies
64
+ pip install modeldiffx[cli] # + click, rich for terminal UI
65
+ pip install modeldiffx[metrics] # + rouge-score
66
+ pip install modeldiffx[all] # everything
67
+ ```
68
+
69
+ ## Quick Start
70
+
71
+ ### 1. Capture snapshots
72
+
73
+ ```python
74
+ from modeldiffx import Prompt, capture
75
+
76
+ prompts = [
77
+ Prompt(text="What is quantum entanglement?", category="knowledge"),
78
+ Prompt(text="Write a Python fibonacci function", category="code"),
79
+ Prompt(text="Summarize the French Revolution", category="knowledge"),
80
+ ]
81
+
82
+ # Your model callable — any function that takes a string and returns a string
83
+ def call_model(text: str) -> str:
84
+ return my_api.complete(text)
85
+
86
+ snapshot = capture(prompts, call_model, model_name="gpt-4-0613")
87
+ snapshot.save("snapshots/gpt4_0613.json")
88
+ ```
89
+
90
+ ### 2. Diff two snapshots
91
+
92
+ ```python
93
+ from modeldiffx import diff_snapshots, Snapshot
94
+
95
+ snap_a = Snapshot.load("snapshots/gpt4_0613.json")
96
+ snap_b = Snapshot.load("snapshots/gpt4_1106.json")
97
+
98
+ report = diff_snapshots(snap_a, snap_b)
99
+
100
+ print(f"Changes: {report.n_changes}/{len(report.entries)}")
101
+ print(f"Change rate: {report.change_rate:.1%}")
102
+ print(f"Regression score: {report.regression_score:.2f}")
103
+
104
+ for entry in report.entries:
105
+ if entry.change_type.value != "identical":
106
+ print(f" [{entry.severity.value}] {entry.prompt.text[:50]}… → {entry.change_type.value}")
107
+ ```
108
+
109
+ ### 3. Detect drift
110
+
111
+ <p align="center">
112
+ <img src="assets/drift_analysis.svg" width="700" alt="modeldiffx drift analysis" />
113
+ </p>
114
+
115
+ ```python
116
+ from modeldiffx import Snapshot
117
+ from modeldiffx.drift import full_drift_report
118
+
119
+ snap_a = Snapshot.load("snapshots/gpt4_0613.json")
120
+ snap_b = Snapshot.load("snapshots/gpt4_1106.json")
121
+
122
+ report = full_drift_report(snap_a, snap_b)
123
+
124
+ if report["length"]["drift_significant"]:
125
+ print(f"⚠ Length drift: {report['length']['drift_sigma']:.1f}σ")
126
+ if report["refusal"]["drift_significant"]:
127
+ print(f"⚠ Refusal rate changed: {report['refusal']['delta']:+.2f}")
128
+ if report["vocabulary"]["drift_significant"]:
129
+ print(f"⚠ Vocabulary overlap: {report['vocabulary']['jaccard_similarity']:.2f}")
130
+ ```
131
+
132
+ ### 4. Fingerprint a model
133
+
134
+ ```python
135
+ from modeldiffx import Snapshot
136
+ from modeldiffx.fingerprint import fingerprint, compare_fingerprints
137
+
138
+ snap = Snapshot.load("snapshots/gpt4_0613.json")
139
+ fp = fingerprint(snap)
140
+
141
+ print(f"Verbosity: {fp.dimensions['verbosity']:.2f}")
142
+ print(f"Refusal rate: {fp.dimensions['refusal_rate']:.2f}")
143
+ print(f"Formality: {fp.dimensions['formality']:.2f}")
144
+ print(f"Vocabulary richness: {fp.dimensions['vocabulary_richness']:.2f}")
145
+ ```
146
+
147
+ ### 5. Use built-in test suites
148
+
149
+ ```python
150
+ from modeldiffx import capture
151
+ from modeldiffx.suite import get_standard_suite, get_suite
152
+
153
+ # All 25 prompts across 5 categories
154
+ prompts = get_standard_suite()
155
+
156
+ # Or pick specific suites
157
+ safety_prompts = get_suite("safety")
158
+ code_prompts = get_suite("code")
159
+
160
+ snapshot = capture(prompts, call_model, model_name="gpt-4-turbo")
161
+ ```
162
+
163
+ ## CLI
164
+
165
+ ```bash
166
+ # Compare two snapshot files
167
+ modeldiffx diff snapshots/v1.json snapshots/v2.json
168
+
169
+ # Markdown output
170
+ modeldiffx diff snapshots/v1.json snapshots/v2.json --markdown
171
+
172
+ # Save JSON report
173
+ modeldiffx diff snapshots/v1.json snapshots/v2.json -o report.json
174
+
175
+ # Snapshot info
176
+ modeldiffx info snapshots/v1.json
177
+
178
+ # Drift analysis
179
+ modeldiffx drift snapshots/v1.json snapshots/v2.json
180
+
181
+ # List built-in suites
182
+ modeldiffx suites
183
+ ```
184
+
185
+ ## API Reference
186
+
187
+ ### Change Types
188
+
189
+ | Type | Description | Typical Severity |
190
+ |---|---|---|
191
+ | `CONTENT` | Semantically different response | HIGH |
192
+ | `FORMAT` | Same content, different formatting | LOW |
193
+ | `REFUSAL` | One model refuses, other doesn't | CRITICAL |
194
+ | `LENGTH` | Significant length difference | MEDIUM |
195
+ | `STYLE` | Tone/verbosity shift | MEDIUM |
196
+ | `ERROR` | One model errors | HIGH |
197
+ | `IDENTICAL` | No change detected | — |
198
+
199
+ ### Regression Score
200
+
201
+ The regression score is a weighted severity metric (0.0 = no regressions, 1.0 = all critical):
202
+
203
+ - **CRITICAL**: weight 1.0 (refusal changes, safety regressions)
204
+ - **HIGH**: weight 0.6 (content changes)
205
+ - **MEDIUM**: weight 0.3 (style/length changes)
206
+ - **LOW**: weight 0.1 (formatting changes)
207
+
208
+ ### Fingerprint Dimensions
209
+
210
+ | Dimension | Range | Description |
211
+ |---|---|---|
212
+ | `verbosity` | 0–1 | Average response length normalized to 500 words |
213
+ | `refusal_rate` | 0–1 | Fraction of prompts refused |
214
+ | `error_rate` | 0–1 | Fraction of prompts that errored |
215
+ | `vocabulary_richness` | 0–1 | Type-token ratio |
216
+ | `avg_latency_ms` | 0+ | Mean response latency |
217
+ | `length_consistency` | 0–1 | 1 minus coefficient of variation |
218
+ | `formality` | 0–1 | Ratio of formal to casual markers |
219
+
220
+ ## Architecture
221
+
222
+ ```
223
+ modeldiffx/
224
+ ├── _types.py # Core types: Prompt, Response, Snapshot, DiffReport
225
+ ├── capture.py # Snapshot capture from model callables / files
226
+ ├── diff.py # Behavioral diffing with similarity scoring
227
+ ├── drift.py # Statistical drift detection
228
+ ├── fingerprint.py # Model behavioral fingerprinting
229
+ ├── suite.py # Built-in evaluation suites (25 prompts)
230
+ ├── report.py # JSON/text/rich/markdown report formatting
231
+ └── cli.py # Click CLI interface
232
+ ```
233
+
234
+ ## See Also
235
+
236
+ Part of the **stef41 LLM toolkit** — open-source tools for every stage of the LLM lifecycle:
237
+
238
+ | Project | What it does |
239
+ |---------|-------------|
240
+ | [tokonomics](https://github.com/stef41/tokonomix) | Token counting & cost management for LLM APIs |
241
+ | [datacrux](https://github.com/stef41/datacruxai) | Training data quality — dedup, PII, contamination |
242
+ | [castwright](https://github.com/stef41/castwright) | Synthetic instruction data generation |
243
+ | [datamix](https://github.com/stef41/datamix) | Dataset mixing & curriculum optimization |
244
+ | [toksight](https://github.com/stef41/toksight) | Tokenizer analysis & comparison |
245
+ | [trainpulse](https://github.com/stef41/trainpulse) | Training health monitoring |
246
+ | [ckpt](https://github.com/stef41/ckptkit) | Checkpoint inspection, diffing & merging |
247
+ | [quantbench](https://github.com/stef41/quantbenchx) | Quantization quality analysis |
248
+ | [infermark](https://github.com/stef41/infermark) | Inference benchmarking |
249
+ | [vibesafe](https://github.com/stef41/vibesafex) | AI-generated code safety scanner |
250
+ | [injectionguard](https://github.com/stef41/injectionguard) | Prompt injection detection |
251
+
252
+ ## License
253
+
254
+ Apache 2.0