modelswapbench 0.1.0a1__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 (119) hide show
  1. modelswapbench-0.1.0a1/.gitignore +39 -0
  2. modelswapbench-0.1.0a1/ARCHITECTURE.md +66 -0
  3. modelswapbench-0.1.0a1/CHANGELOG.md +27 -0
  4. modelswapbench-0.1.0a1/CODEOWNERS +2 -0
  5. modelswapbench-0.1.0a1/CODE_OF_CONDUCT.md +29 -0
  6. modelswapbench-0.1.0a1/CONTRIBUTING.md +34 -0
  7. modelswapbench-0.1.0a1/LICENSE +21 -0
  8. modelswapbench-0.1.0a1/Makefile +48 -0
  9. modelswapbench-0.1.0a1/NOTICE.md +22 -0
  10. modelswapbench-0.1.0a1/PKG-INFO +255 -0
  11. modelswapbench-0.1.0a1/README.md +189 -0
  12. modelswapbench-0.1.0a1/SECURITY.md +31 -0
  13. modelswapbench-0.1.0a1/THREAT_MODEL.md +40 -0
  14. modelswapbench-0.1.0a1/docs/adding-a-provider.md +36 -0
  15. modelswapbench-0.1.0a1/docs/adding-an-evaluator.md +35 -0
  16. modelswapbench-0.1.0a1/docs/benchmark-format.md +76 -0
  17. modelswapbench-0.1.0a1/docs/cascade-routing.md +33 -0
  18. modelswapbench-0.1.0a1/docs/ci-integration.md +45 -0
  19. modelswapbench-0.1.0a1/docs/contributor-handoff.md +43 -0
  20. modelswapbench-0.1.0a1/docs/cost-per-success.md +45 -0
  21. modelswapbench-0.1.0a1/docs/dependency-licenses.md +24 -0
  22. modelswapbench-0.1.0a1/docs/evaluators.md +34 -0
  23. modelswapbench-0.1.0a1/docs/getting-started.md +41 -0
  24. modelswapbench-0.1.0a1/docs/privacy.md +32 -0
  25. modelswapbench-0.1.0a1/docs/provider-trust.md +30 -0
  26. modelswapbench-0.1.0a1/docs/providers.md +50 -0
  27. modelswapbench-0.1.0a1/docs/replacement-decisions.md +39 -0
  28. modelswapbench-0.1.0a1/docs/reproducibility.md +28 -0
  29. modelswapbench-0.1.0a1/docs/scoring.md +21 -0
  30. modelswapbench-0.1.0a1/examples/cascade-routing/benchmark.yaml +52 -0
  31. modelswapbench-0.1.0a1/examples/cascade-routing/fixtures/first_stage.yaml +16 -0
  32. modelswapbench-0.1.0a1/examples/code-review-summary/benchmark.yaml +50 -0
  33. modelswapbench-0.1.0a1/examples/code-review-summary/fixtures/baseline.yaml +12 -0
  34. modelswapbench-0.1.0a1/examples/code-review-summary/fixtures/candidate.yaml +13 -0
  35. modelswapbench-0.1.0a1/examples/local-rag-citations/benchmark.yaml +56 -0
  36. modelswapbench-0.1.0a1/examples/local-rag-citations/fixtures/baseline.yaml +12 -0
  37. modelswapbench-0.1.0a1/examples/local-rag-citations/fixtures/candidate.yaml +13 -0
  38. modelswapbench-0.1.0a1/examples/support-ticket-triage/benchmark.yaml +82 -0
  39. modelswapbench-0.1.0a1/examples/support-ticket-triage/fixtures/baseline.yaml +24 -0
  40. modelswapbench-0.1.0a1/examples/support-ticket-triage/fixtures/candidate.yaml +24 -0
  41. modelswapbench-0.1.0a1/model_swap_bench/__init__.py +28 -0
  42. modelswapbench-0.1.0a1/model_swap_bench/_version.py +3 -0
  43. modelswapbench-0.1.0a1/model_swap_bench/cli/__init__.py +3 -0
  44. modelswapbench-0.1.0a1/model_swap_bench/cli/app.py +305 -0
  45. modelswapbench-0.1.0a1/model_swap_bench/cli/commands.py +310 -0
  46. modelswapbench-0.1.0a1/model_swap_bench/cli/doctor.py +124 -0
  47. modelswapbench-0.1.0a1/model_swap_bench/cli/output.py +47 -0
  48. modelswapbench-0.1.0a1/model_swap_bench/config/__init__.py +50 -0
  49. modelswapbench-0.1.0a1/model_swap_bench/config/loader.py +59 -0
  50. modelswapbench-0.1.0a1/model_swap_bench/config/models.py +269 -0
  51. modelswapbench-0.1.0a1/model_swap_bench/config/schema.py +35 -0
  52. modelswapbench-0.1.0a1/model_swap_bench/config/validation.py +79 -0
  53. modelswapbench-0.1.0a1/model_swap_bench/errors.py +70 -0
  54. modelswapbench-0.1.0a1/model_swap_bench/evaluators/__init__.py +34 -0
  55. modelswapbench-0.1.0a1/model_swap_bench/evaluators/base.py +133 -0
  56. modelswapbench-0.1.0a1/model_swap_bench/evaluators/citation.py +41 -0
  57. modelswapbench-0.1.0a1/model_swap_bench/evaluators/contains.py +36 -0
  58. modelswapbench-0.1.0a1/model_swap_bench/evaluators/cost.py +25 -0
  59. modelswapbench-0.1.0a1/model_swap_bench/evaluators/exact_match.py +29 -0
  60. modelswapbench-0.1.0a1/model_swap_bench/evaluators/field_match.py +55 -0
  61. modelswapbench-0.1.0a1/model_swap_bench/evaluators/json_parse.py +22 -0
  62. modelswapbench-0.1.0a1/model_swap_bench/evaluators/json_schema.py +53 -0
  63. modelswapbench-0.1.0a1/model_swap_bench/evaluators/latency.py +27 -0
  64. modelswapbench-0.1.0a1/model_swap_bench/evaluators/policy.py +54 -0
  65. modelswapbench-0.1.0a1/model_swap_bench/evaluators/regex.py +39 -0
  66. modelswapbench-0.1.0a1/model_swap_bench/evaluators/rubric.py +40 -0
  67. modelswapbench-0.1.0a1/model_swap_bench/evaluators/tool_selection.py +38 -0
  68. modelswapbench-0.1.0a1/model_swap_bench/execution/__init__.py +8 -0
  69. modelswapbench-0.1.0a1/model_swap_bench/execution/cascade.py +109 -0
  70. modelswapbench-0.1.0a1/model_swap_bench/execution/context.py +78 -0
  71. modelswapbench-0.1.0a1/model_swap_bench/execution/retry.py +50 -0
  72. modelswapbench-0.1.0a1/model_swap_bench/execution/runner.py +220 -0
  73. modelswapbench-0.1.0a1/model_swap_bench/execution/scheduler.py +28 -0
  74. modelswapbench-0.1.0a1/model_swap_bench/pricing/__init__.py +7 -0
  75. modelswapbench-0.1.0a1/model_swap_bench/pricing/default_pricing.yaml +41 -0
  76. modelswapbench-0.1.0a1/model_swap_bench/pricing/registry.py +86 -0
  77. modelswapbench-0.1.0a1/model_swap_bench/providers/__init__.py +27 -0
  78. modelswapbench-0.1.0a1/model_swap_bench/providers/base.py +121 -0
  79. modelswapbench-0.1.0a1/model_swap_bench/providers/deterministic.py +138 -0
  80. modelswapbench-0.1.0a1/model_swap_bench/providers/forge.py +110 -0
  81. modelswapbench-0.1.0a1/model_swap_bench/providers/ollama.py +93 -0
  82. modelswapbench-0.1.0a1/model_swap_bench/providers/openai_compatible.py +133 -0
  83. modelswapbench-0.1.0a1/model_swap_bench/py.typed +0 -0
  84. modelswapbench-0.1.0a1/model_swap_bench/reports/__init__.py +21 -0
  85. modelswapbench-0.1.0a1/model_swap_bench/reports/csv_report.py +38 -0
  86. modelswapbench-0.1.0a1/model_swap_bench/reports/html.py +30 -0
  87. modelswapbench-0.1.0a1/model_swap_bench/reports/json_report.py +12 -0
  88. modelswapbench-0.1.0a1/model_swap_bench/reports/markdown.py +189 -0
  89. modelswapbench-0.1.0a1/model_swap_bench/resources/benchmark.schema.json +851 -0
  90. modelswapbench-0.1.0a1/model_swap_bench/results.py +227 -0
  91. modelswapbench-0.1.0a1/model_swap_bench/scoring/__init__.py +15 -0
  92. modelswapbench-0.1.0a1/model_swap_bench/scoring/aggregation.py +99 -0
  93. modelswapbench-0.1.0a1/model_swap_bench/scoring/economics.py +58 -0
  94. modelswapbench-0.1.0a1/model_swap_bench/scoring/metrics.py +39 -0
  95. modelswapbench-0.1.0a1/model_swap_bench/scoring/replacement.py +145 -0
  96. modelswapbench-0.1.0a1/model_swap_bench/security/__init__.py +8 -0
  97. modelswapbench-0.1.0a1/model_swap_bench/security/paths.py +29 -0
  98. modelswapbench-0.1.0a1/model_swap_bench/security/redaction.py +41 -0
  99. modelswapbench-0.1.0a1/model_swap_bench/storage/__init__.py +8 -0
  100. modelswapbench-0.1.0a1/model_swap_bench/storage/files.py +52 -0
  101. modelswapbench-0.1.0a1/model_swap_bench/storage/manifests.py +84 -0
  102. modelswapbench-0.1.0a1/model_swap_bench/storage/repository.py +92 -0
  103. modelswapbench-0.1.0a1/model_swap_bench/storage/sqlite.py +76 -0
  104. modelswapbench-0.1.0a1/pyproject.toml +165 -0
  105. modelswapbench-0.1.0a1/tests/__init__.py +0 -0
  106. modelswapbench-0.1.0a1/tests/conftest.py +47 -0
  107. modelswapbench-0.1.0a1/tests/integration/__init__.py +0 -0
  108. modelswapbench-0.1.0a1/tests/integration/test_ollama_integration.py +66 -0
  109. modelswapbench-0.1.0a1/tests/security/__init__.py +0 -0
  110. modelswapbench-0.1.0a1/tests/security/test_security.py +48 -0
  111. modelswapbench-0.1.0a1/tests/unit/__init__.py +0 -0
  112. modelswapbench-0.1.0a1/tests/unit/test_cli.py +67 -0
  113. modelswapbench-0.1.0a1/tests/unit/test_config.py +80 -0
  114. modelswapbench-0.1.0a1/tests/unit/test_evaluators.py +90 -0
  115. modelswapbench-0.1.0a1/tests/unit/test_execution.py +74 -0
  116. modelswapbench-0.1.0a1/tests/unit/test_pricing.py +31 -0
  117. modelswapbench-0.1.0a1/tests/unit/test_providers.py +75 -0
  118. modelswapbench-0.1.0a1/tests/unit/test_scoring.py +80 -0
  119. modelswapbench-0.1.0a1/tests/unit/test_storage_reports.py +55 -0
@@ -0,0 +1,39 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ build/
7
+ dist/
8
+ *.so
9
+
10
+ # Virtual environments
11
+ .venv/
12
+ venv/
13
+ .env
14
+ .env.*
15
+ !.env.example
16
+
17
+ # Test / coverage
18
+ .pytest_cache/
19
+ .mypy_cache/
20
+ .ruff_cache/
21
+ htmlcov/
22
+ .coverage
23
+ coverage.xml
24
+
25
+ # ModelSwapBench run storage & generated artifacts
26
+ .modelswapbench/
27
+ reports/*/
28
+ !reports/.gitkeep
29
+
30
+ # Databases
31
+ *.db
32
+ *.sqlite
33
+ *.sqlite3
34
+
35
+ # OS / editor
36
+ .DS_Store
37
+ *.swp
38
+ .idea/
39
+ .vscode/
@@ -0,0 +1,66 @@
1
+ # Architecture
2
+
3
+ ModelSwapBench is a layered, provider-neutral pipeline. Each layer has a single
4
+ responsibility and a typed boundary, so components (providers, evaluators,
5
+ pricing, storage) can be replaced without touching the rest.
6
+
7
+ ## Layers
8
+
9
+ | Layer | Package | Responsibility |
10
+ |---|---|---|
11
+ | Config | `config/` | Typed Pydantic models, safe YAML loading, semantic validation, JSON Schema |
12
+ | Providers | `providers/` | Provider-neutral model calls: deterministic, Ollama, Forge, OpenAI-compatible |
13
+ | Execution | `execution/` | Runner, bounded concurrency, retries, timeouts, cascade, raw capture |
14
+ | Evaluators | `evaluators/` | Deterministic, pluggable, evidence-producing checks |
15
+ | Scoring | `scoring/` | Metrics, economics (cost/success), aggregation, replacement decisions |
16
+ | Storage | `storage/` | SQLite index + filesystem artifacts + reproducibility manifests |
17
+ | Reports | `reports/` | Markdown, JSON, CSV, HTML renderers |
18
+ | Pricing | `pricing/` | Editable, versioned, offline pricing registry |
19
+ | Security | `security/` | Path-safety and secret redaction |
20
+ | CLI | `cli/` | Typer app, doctor, commands, output |
21
+
22
+ ## Data flow
23
+
24
+ ```
25
+ benchmark.yaml
26
+ │ load + validate (config)
27
+ ▼
28
+ BenchmarkSuite ──► BenchmarkRunner (execution)
29
+ │ build_provider() per model
30
+ ▼
31
+ Provider.complete() ──► ProviderResponse
32
+ │
33
+ ▼
34
+ Evaluators ──► EvaluationResult (evidence)
35
+ │
36
+ ▼
37
+ CaseResult ──► aggregation ──► ModelSummary
38
+ │ │
39
+ │ ▼
40
+ │ replacement decision engine
41
+ ▼ │
42
+ BenchmarkRun ◄───────────────────┘
43
+ │ save (storage: sqlite + files + manifest)
44
+ ▼
45
+ reports (md / json / csv / html)
46
+ ```
47
+
48
+ ## Trust boundaries
49
+
50
+ - **Benchmark files** are untrusted data: loaded with `yaml.safe_load`, never
51
+ executed. No custom Python evaluators in v0.1.
52
+ - **Model output** is untrusted: bounded in size, HTML-escaped in reports, and
53
+ parsed defensively.
54
+ - **Providers**: hosted providers are refused unless explicitly permitted. API
55
+ keys come from the environment and never enter results.
56
+ - **Filesystem**: all writes are confined to the storage directory via
57
+ `security.paths` (traversal + symlink guards).
58
+
59
+ ## Key design decisions
60
+
61
+ - **Deterministic provider** makes the whole pipeline testable and demoable fully
62
+ offline, and can simulate failures for cascade/escalation.
63
+ - **Cost per success** is the primary economic metric; zero-success is `None`, not
64
+ a crash.
65
+ - **Replacement decisions** are rules-based and carry evidence — no black-box score.
66
+ - **SQLite + files** over a server database keeps everything local and portable.
@@ -0,0 +1,27 @@
1
+ # Changelog
2
+
3
+ All notable changes to ModelSwapBench are documented here.
4
+ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
5
+ Versioning follows [Semantic Versioning](https://semver.org/).
6
+
7
+ ---
8
+
9
+ ## [Unreleased]
10
+
11
+ ## [0.1.0a1] — 2026-07-05
12
+
13
+ ### Added
14
+ - First alpha of ModelSwapBench — model portability and replacement benchmark.
15
+ - Providers: deterministic (offline), Ollama, Forge adapter (agentforge-oss), OpenAI-compatible (self-hosted).
16
+ - Deterministic evaluators: exact_match, contains/forbidden_content, regex, json_parse, json_schema,
17
+ field_match, tool_selection, policy_compliance, citation, latency, cost, and an optional keyword rubric.
18
+ - Execution modes: single, comparison, baseline-vs-candidate, and cascade (escalate-on-failure).
19
+ - Scoring: success rate, quality, valid-JSON rate, policy pass rate, tool accuracy, latency percentiles,
20
+ and the primary economic metric — cost per successful outcome.
21
+ - Transparent, evidence-backed replacement decision engine.
22
+ - Local, portable storage (SQLite index + filesystem artifacts) with reproducibility manifests.
23
+ - Reports: Markdown, JSON, CSV, and self-contained HTML.
24
+ - Editable, versioned pricing registry (offline; estimates only).
25
+ - Typer CLI: doctor, init, validate, schema, models, providers, run, compare, report, runs, reproduce,
26
+ clean, pricing, examples.
27
+ - Four offline examples: support-ticket-triage, local-rag-citations, code-review-summary, cascade-routing.
@@ -0,0 +1,2 @@
1
+ # Default owner for everything in this repository.
2
+ * @sekacorn
@@ -0,0 +1,29 @@
1
+ # Code of Conduct
2
+
3
+ ## Our pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in the
6
+ ModelSwapBench community a harassment-free experience for everyone, regardless of
7
+ age, body size, visible or invisible disability, ethnicity, sex characteristics,
8
+ gender identity and expression, level of experience, education, socio-economic
9
+ status, nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our standards
13
+
14
+ Examples of behavior that contributes to a positive environment: demonstrating
15
+ empathy and kindness, being respectful of differing opinions, giving and
16
+ gracefully accepting constructive feedback, and focusing on what is best for the
17
+ community.
18
+
19
+ Unacceptable behavior includes harassment, trolling, insulting or derogatory
20
+ comments, personal or political attacks, and publishing others' private
21
+ information without permission.
22
+
23
+ ## Enforcement
24
+
25
+ Instances of abusive or unacceptable behavior may be reported to the project
26
+ maintainer. All complaints will be reviewed and investigated promptly and fairly.
27
+
28
+ This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
29
+ version 2.1.
@@ -0,0 +1,34 @@
1
+ # Contributing to ModelSwapBench
2
+
3
+ Thanks for your interest! ModelSwapBench is MIT-licensed and provider-neutral by
4
+ design — contributions should preserve both.
5
+
6
+ ## Getting started
7
+
8
+ ```bash
9
+ python -m venv .venv
10
+ .venv/bin/python -m pip install -e ".[dev,security,quality]" # Windows: .venv\Scripts\python
11
+ make quality # lint + typecheck + test + security
12
+ ```
13
+
14
+ ## Ground rules
15
+
16
+ - **Tests must pass offline** — no paid APIs, internet, Ollama, Docker, or GPU
17
+ required for the default suite. Use the deterministic provider.
18
+ - **Typed and linted**: `ruff` clean, `mypy --strict` clean.
19
+ - **≥ 80% meaningful coverage** — no superficial tests to pad the number.
20
+ - **No incompatible source code** may be copied in. All original code is MIT.
21
+ - **Provider neutrality**: don't hard-code a single vendor into core logic.
22
+ - **Honesty**: never fabricate results, prices, or benchmark scores.
23
+
24
+ ## Extending
25
+
26
+ - Add a provider: implement `providers.base.Provider`; see
27
+ [docs/adding-a-provider.md](docs/adding-a-provider.md).
28
+ - Add an evaluator: subclass `evaluators.base.Evaluator` and `@register`; see
29
+ [docs/adding-an-evaluator.md](docs/adding-an-evaluator.md).
30
+
31
+ ## Pull requests
32
+
33
+ Keep PRs focused. Update docs and `CHANGELOG.md`. Ensure `make quality` and
34
+ `make build` pass. Good first issues are listed in `reports/v0.1-verification.md`.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 sekacorn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,48 @@
1
+ # ModelSwapBench developer tasks. `make quality` must not hide failures.
2
+ .DEFAULT_GOAL := help
3
+ PY ?= python
4
+ EXAMPLES := examples
5
+
6
+ .PHONY: help setup test test-integration lint format typecheck security quality build example-offline example-ollama clean
7
+
8
+ help:
9
+ @echo "Targets: setup test test-integration lint format typecheck security quality build example-offline example-ollama clean"
10
+
11
+ setup:
12
+ $(PY) -m pip install -e ".[dev,security,quality]"
13
+
14
+ test:
15
+ $(PY) -m pytest -m "not integration"
16
+
17
+ test-integration:
18
+ $(PY) -m pytest -m integration
19
+
20
+ lint:
21
+ $(PY) -m ruff check .
22
+
23
+ format:
24
+ $(PY) -m ruff format . && $(PY) -m ruff check --fix .
25
+
26
+ typecheck:
27
+ $(PY) -m mypy model_swap_bench
28
+
29
+ security:
30
+ $(PY) -m bandit -c pyproject.toml -r model_swap_bench -q
31
+ $(PY) -m pip_audit || true
32
+
33
+ quality: lint typecheck test security
34
+
35
+ build:
36
+ rm -rf dist && $(PY) -m build && $(PY) -m twine check dist/*
37
+
38
+ example-offline:
39
+ modelswapbench run $(EXAMPLES)/support-ticket-triage/benchmark.yaml
40
+ modelswapbench report latest --format markdown
41
+
42
+ example-ollama:
43
+ @echo "Requires: ollama pull qwen2.5:3b, then edit a suite to use provider: ollama"
44
+ modelswapbench doctor
45
+
46
+ clean:
47
+ rm -rf dist build .pytest_cache .mypy_cache .ruff_cache htmlcov .coverage coverage.xml
48
+ find . -type d -name __pycache__ -prune -exec rm -rf {} + 2>/dev/null || true
@@ -0,0 +1,22 @@
1
+ # NOTICE
2
+
3
+ ModelSwapBench
4
+ Copyright (c) 2026 sekacorn
5
+
6
+ This product is licensed under the MIT License (see LICENSE).
7
+
8
+ ## Dependencies
9
+
10
+ ModelSwapBench depends on the following open-source packages, each under its own
11
+ license (see docs/dependency-licenses.md for details):
12
+
13
+ - pydantic (MIT)
14
+ - pyyaml (MIT)
15
+ - jsonschema (MIT)
16
+ - httpx (BSD-3-Clause)
17
+ - typer (MIT)
18
+ - rich (MIT)
19
+ - agentforge-oss (MIT)
20
+
21
+ All original ModelSwapBench source code is MIT licensed. No incompatible source
22
+ code has been copied into this repository.
@@ -0,0 +1,255 @@
1
+ Metadata-Version: 2.4
2
+ Name: modelswapbench
3
+ Version: 0.1.0a1
4
+ Summary: Open-source model portability and replacement benchmark: measure which model delivers an acceptable outcome at the lowest cost, latency, and operational risk.
5
+ Project-URL: Homepage, https://github.com/sekacorn/ModelSwapBench
6
+ Project-URL: Repository, https://github.com/sekacorn/ModelSwapBench.git
7
+ Project-URL: Issues, https://github.com/sekacorn/ModelSwapBench/issues
8
+ Project-URL: Changelog, https://github.com/sekacorn/ModelSwapBench/blob/main/CHANGELOG.md
9
+ Project-URL: Documentation, https://github.com/sekacorn/ModelSwapBench/tree/main/docs
10
+ Author: sekacorn
11
+ Maintainer: sekacorn
12
+ License-Expression: MIT
13
+ License-File: LICENSE
14
+ License-File: NOTICE.md
15
+ Keywords: ai,benchmark,cost,devsecops,llm,local-first,model-evaluation,ollama,portability,provider-neutral,replacement
16
+ Classifier: Development Status :: 3 - Alpha
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Intended Audience :: Information Technology
19
+ Classifier: Intended Audience :: System Administrators
20
+ Classifier: License :: OSI Approved :: MIT License
21
+ Classifier: Operating System :: OS Independent
22
+ Classifier: Programming Language :: Python :: 3
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
27
+ Classifier: Topic :: Software Development :: Quality Assurance
28
+ Classifier: Topic :: Software Development :: Testing
29
+ Classifier: Topic :: System :: Benchmark
30
+ Classifier: Typing :: Typed
31
+ Requires-Python: >=3.11
32
+ Requires-Dist: agentforge-oss<0.6.0,>=0.5.1
33
+ Requires-Dist: httpx>=0.27
34
+ Requires-Dist: jsonschema>=4.21
35
+ Requires-Dist: pydantic>=2.9
36
+ Requires-Dist: pyyaml>=6.0
37
+ Requires-Dist: rich>=13.7
38
+ Requires-Dist: typer>=0.12
39
+ Provides-Extra: all
40
+ Requires-Dist: anthropic>=0.34; extra == 'all'
41
+ Requires-Dist: boto3>=1.34; extra == 'all'
42
+ Requires-Dist: openai>=1.40; extra == 'all'
43
+ Provides-Extra: anthropic
44
+ Requires-Dist: anthropic>=0.34; extra == 'anthropic'
45
+ Provides-Extra: bedrock
46
+ Requires-Dist: boto3>=1.34; extra == 'bedrock'
47
+ Provides-Extra: dev
48
+ Requires-Dist: build>=1.2; extra == 'dev'
49
+ Requires-Dist: mypy>=1.10; extra == 'dev'
50
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
51
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
52
+ Requires-Dist: pytest>=8.0; extra == 'dev'
53
+ Requires-Dist: ruff>=0.6; extra == 'dev'
54
+ Requires-Dist: twine>=5.1; extra == 'dev'
55
+ Requires-Dist: types-jsonschema>=4.21; extra == 'dev'
56
+ Requires-Dist: types-pyyaml>=6.0; extra == 'dev'
57
+ Provides-Extra: openai
58
+ Requires-Dist: openai>=1.40; extra == 'openai'
59
+ Provides-Extra: quality
60
+ Requires-Dist: yamllint>=1.35; extra == 'quality'
61
+ Provides-Extra: security
62
+ Requires-Dist: bandit>=1.7; extra == 'security'
63
+ Requires-Dist: detect-secrets>=1.5; extra == 'security'
64
+ Requires-Dist: pip-audit>=2.7; extra == 'security'
65
+ Description-Content-Type: text/markdown
66
+
67
+ # ModelSwapBench
68
+
69
+ **Open-source model portability testing for real AI workflows.**
70
+
71
+ Run the same workflow across local, open-weight, self-hosted, and hosted models.
72
+ Measure quality, latency, policy compliance, and **cost per successful outcome**
73
+ before you commit to a vendor.
74
+
75
+ > Status: **v0.1.0-alpha** — usable and fully offline-capable. APIs may change before 1.0.
76
+
77
+ ---
78
+
79
+ ## Why it exists
80
+
81
+ Teams are told a cheaper or local model "can't replace" their expensive hosted
82
+ model — but rarely with evidence tied to the actual workflow. ModelSwapBench
83
+ answers the real question:
84
+
85
+ > Can a cheaper, local, open-weight, or alternative-provider model replace my
86
+ > current model **without breaking my workflow** — and what does it cost per
87
+ > successful outcome?
88
+
89
+ It is a **decision-support tool for model replacement**, not a leaderboard, not a
90
+ foundation-model laboratory, and not proof that one model is universally better.
91
+
92
+ ## Anti-lock-in by design
93
+
94
+ - Provider-neutral benchmark definitions in plain **YAML/JSON** you own and edit.
95
+ - Portable **JSON, CSV, Markdown, and HTML** reports; raw results always exportable.
96
+ - Standard HTTP provider interfaces; **OpenAI-compatible** local endpoints; **Ollama**; **Forge**.
97
+ - **No** mandatory hosted service, account, cloud database, or telemetry.
98
+ - Replaceable model adapters, evaluators, and pricing registries.
99
+ - Everything runs **local-first**; hosted providers are opt-in per suite.
100
+
101
+ ## Architecture
102
+
103
+ ```
104
+ benchmark.yaml ─► config (typed, validated) ─► runner ─► providers ─► models
105
+ │
106
+ evaluators ◄─┘ (deterministic, evidence-based)
107
+ │
108
+ scoring / economics / replacement ◄──┘
109
+ │
110
+ storage (SQLite index + files) ◄──────────┤──► reports (md/json/csv/html)
111
+ │
112
+ reproducibility manifest
113
+ ```
114
+
115
+ ## Five-minute offline example (no downloads, no credentials)
116
+
117
+ ```bash
118
+ git clone https://github.com/sekacorn/ModelSwapBench.git
119
+ cd ModelSwapBench
120
+ python -m venv .venv
121
+ # Windows:
122
+ .venv\Scripts\python -m pip install -e ".[dev]"
123
+ # Linux/macOS:
124
+ .venv/bin/python -m pip install -e ".[dev]"
125
+
126
+ modelswapbench doctor
127
+ modelswapbench validate examples/support-ticket-triage/benchmark.yaml
128
+ modelswapbench run examples/support-ticket-triage/benchmark.yaml
129
+ modelswapbench report latest --format markdown
130
+ modelswapbench compare latest
131
+ ```
132
+
133
+ The first example runs entirely with the **deterministic provider** — no paid
134
+ model credentials and no model downloads required.
135
+
136
+ ## Run against a real local model (Ollama)
137
+
138
+ ```bash
139
+ ollama pull qwen2.5:3b
140
+ # Edit a suite so a model uses: provider: ollama, model: qwen2.5:3b, deployment: local
141
+ modelswapbench run examples/support-ticket-triage/benchmark.yaml
142
+ ```
143
+
144
+ No model is ever pulled automatically, and there is no silent hosted fallback.
145
+
146
+ ## Benchmark YAML
147
+
148
+ ```yaml
149
+ name: support-ticket-triage
150
+ version: "1.0"
151
+ baseline_model: hosted-baseline
152
+ models:
153
+ - {alias: local-candidate, provider: ollama, model: qwen2.5:3b, deployment: local}
154
+ - {alias: hosted-baseline, provider: deterministic, model: baseline-fixture, deployment: test}
155
+ cases:
156
+ - id: duplicate-billing
157
+ input: {message: "I was charged twice and need help."}
158
+ expected: {category: billing, escalation_required: true}
159
+ evaluators: [json_parse, json_schema, field_match, forbidden_content]
160
+ constraints: {minimum_success_rate: 0.80, maximum_cost_per_success_usd: 0.05}
161
+ replacement: {baseline: hosted-baseline, candidates: [local-candidate], maximum_quality_drop: 0.05}
162
+ ```
163
+
164
+ Print the full JSON Schema any time: `modelswapbench schema`.
165
+
166
+ ## Cost per successful outcome
167
+
168
+ The primary economic metric is:
169
+
170
+ ```
171
+ cost_per_success = total_cost / successful_cases
172
+ ```
173
+
174
+ Zero successful cases is handled safely (reported as "n/a", never a divide error).
175
+ Cost can be computed as **zero-marginal** (token/API pricing) or **estimated
176
+ compute** (electricity, GPU amortization, cloud-GPU-equivalent) from an
177
+ operator-supplied profile. Estimates are always clearly labeled as estimates.
178
+
179
+ ## Replacement recommendations
180
+
181
+ A candidate is recommended only when every required gate passes. The decision is
182
+ transparent and always carries its evidence — failures are never hidden behind an
183
+ aggregate score. Possible outcomes: recommended replacement · recommended with
184
+ conditions · suitable as first-stage model with escalation · not recommended ·
185
+ insufficient evidence.
186
+
187
+ ## Cascade strategy
188
+
189
+ Run a cheap/local model first and escalate only failing or low-confidence cases to
190
+ a stronger model. Reports escalation rate, combined success, and combined cost per
191
+ success — see `examples/cascade-routing`.
192
+
193
+ ## Privacy
194
+
195
+ - Local providers allowed by default; **hosted providers denied by default**.
196
+ - Benchmark data never leaves the machine unless you pass `--allow-hosted` **and**
197
+ set `privacy.allow_hosted_providers: true`, after an explicit warning.
198
+ - No telemetry, no uploads; raw outputs stored locally; secrets redacted from logs
199
+ and reports; API keys are read from environment variables and never written out.
200
+
201
+ ## Evaluators
202
+
203
+ `exact_match` · `contains` / `forbidden_content` · `regex` · `json_parse` ·
204
+ `json_schema` · `field_match` · `tool_selection` · `policy_compliance` ·
205
+ `citation` · `latency` · `cost` · optional `rubric` (keyword heuristic; never the
206
+ sole evaluator; judge-model mode on the roadmap).
207
+
208
+ ## CLI
209
+
210
+ `doctor` · `init` · `validate` · `schema` · `models` · `providers` · `run` ·
211
+ `compare` · `report` · `runs list|show` · `reproduce` · `clean` ·
212
+ `pricing show|validate|set` · `examples list`.
213
+
214
+ Exit codes: `0` success · `1` constraints failed · `2` invalid input ·
215
+ `3` provider unavailable · `4` partial run · `5` internal error.
216
+
217
+ ## Output formats
218
+
219
+ Markdown (human report), JSON (full machine record), CSV (per-model summary), and
220
+ self-contained HTML. Raw model outputs and evaluator evidence are stored per run.
221
+
222
+ ## Reproducibility
223
+
224
+ Every run writes a manifest (suite hash, package/Forge/Python versions, platform,
225
+ models, execution params, seed, git commit). `modelswapbench reproduce RUN_ID`
226
+ re-runs the recorded suite and warns on version drift rather than pretending the
227
+ run is identical.
228
+
229
+ ## Known limitations
230
+
231
+ - Results are evidence for a replacement decision, not proof one model is best.
232
+ - Cost figures are estimates, not measured billing.
233
+ - Deterministic providers simulate behavior; only Ollama / OpenAI-compatible runs
234
+ reflect real models.
235
+ - Small case counts yield low-confidence decisions.
236
+ - The Forge adapter exercises the provider layer, not full agent orchestration (roadmap).
237
+
238
+ ## Roadmap
239
+
240
+ **v0.1** deterministic + Ollama + Forge + OpenAI-compatible providers, YAML suites,
241
+ deterministic evaluators, cost/latency/reliability metrics, replacement decisions,
242
+ cascade analysis, JSON/CSV/Markdown reports, offline tests. **v0.2** richer hosted
243
+ adapters, compute-cost profiler, statistical confidence, variance analysis, CI
244
+ regression gates, HTML dashboards. **v0.3** benchmark registries, signed manifests,
245
+ distributed execution, richer tool-use evaluation.
246
+
247
+ ## Contributing
248
+
249
+ See [CONTRIBUTING.md](CONTRIBUTING.md), [ARCHITECTURE.md](ARCHITECTURE.md), and
250
+ `docs/`. Issues and PRs welcome.
251
+
252
+ ## License
253
+
254
+ MIT — Copyright (c) 2026 sekacorn. See [LICENSE](LICENSE). Dependency
255
+ licenses are listed in [docs/dependency-licenses.md](docs/dependency-licenses.md).