typevet 0.1.0.dev1__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 (134) hide show
  1. typevet-0.1.0.dev1/LICENSE +21 -0
  2. typevet-0.1.0.dev1/PKG-INFO +125 -0
  3. typevet-0.1.0.dev1/README.md +94 -0
  4. typevet-0.1.0.dev1/pyproject.toml +272 -0
  5. typevet-0.1.0.dev1/pyproject.toml.orig +238 -0
  6. typevet-0.1.0.dev1/src/typevet/__init__.py +67 -0
  7. typevet-0.1.0.dev1/src/typevet/_version.py +43 -0
  8. typevet-0.1.0.dev1/src/typevet/adapters/__init__.py +16 -0
  9. typevet-0.1.0.dev1/src/typevet/adapters/diagnostics/__init__.py +59 -0
  10. typevet-0.1.0.dev1/src/typevet/adapters/diagnostics/fields.py +108 -0
  11. typevet-0.1.0.dev1/src/typevet/adapters/diagnostics/generation_events.py +75 -0
  12. typevet-0.1.0.dev1/src/typevet/adapters/diagnostics/http_events.py +91 -0
  13. typevet-0.1.0.dev1/src/typevet/adapters/diagnostics/logs.py +116 -0
  14. typevet-0.1.0.dev1/src/typevet/adapters/diagnostics/redaction.py +94 -0
  15. typevet-0.1.0.dev1/src/typevet/adapters/diagnostics/settings.py +77 -0
  16. typevet-0.1.0.dev1/src/typevet/adapters/inbound/__init__.py +65 -0
  17. typevet-0.1.0.dev1/src/typevet/adapters/inbound/api.py +61 -0
  18. typevet-0.1.0.dev1/src/typevet/adapters/inbound/backend_settings.py +608 -0
  19. typevet-0.1.0.dev1/src/typevet/adapters/inbound/cord_semantic_acceptance_cli.py +135 -0
  20. typevet-0.1.0.dev1/src/typevet/adapters/inbound/helpers.py +67 -0
  21. typevet-0.1.0.dev1/src/typevet/adapters/inbound/settings.py +154 -0
  22. typevet-0.1.0.dev1/src/typevet/adapters/outbound/__init__.py +62 -0
  23. typevet-0.1.0.dev1/src/typevet/adapters/outbound/async_fake.py +123 -0
  24. typevet-0.1.0.dev1/src/typevet/adapters/outbound/async_llama_cpp.py +168 -0
  25. typevet-0.1.0.dev1/src/typevet/adapters/outbound/chat_completion.py +148 -0
  26. typevet-0.1.0.dev1/src/typevet/adapters/outbound/fake.py +119 -0
  27. typevet-0.1.0.dev1/src/typevet/adapters/outbound/gemma/__init__.py +84 -0
  28. typevet-0.1.0.dev1/src/typevet/adapters/outbound/gemma/answer_binding.py +290 -0
  29. typevet-0.1.0.dev1/src/typevet/adapters/outbound/gemma/scoring_prefix.py +102 -0
  30. typevet-0.1.0.dev1/src/typevet/adapters/outbound/gemma/served_template.py +131 -0
  31. typevet-0.1.0.dev1/src/typevet/adapters/outbound/gemma_native_vision_factory.py +286 -0
  32. typevet-0.1.0.dev1/src/typevet/adapters/outbound/generation_finite.py +50 -0
  33. typevet-0.1.0.dev1/src/typevet/adapters/outbound/http_errors.py +38 -0
  34. typevet-0.1.0.dev1/src/typevet/adapters/outbound/judgment_scoring.py +471 -0
  35. typevet-0.1.0.dev1/src/typevet/adapters/outbound/llama_cpp.py +187 -0
  36. typevet-0.1.0.dev1/src/typevet/adapters/outbound/llama_cpp_http.py +103 -0
  37. typevet-0.1.0.dev1/src/typevet/adapters/outbound/llama_cpp_multimodal.py +145 -0
  38. typevet-0.1.0.dev1/src/typevet/adapters/outbound/llama_cpp_scoring.py +333 -0
  39. typevet-0.1.0.dev1/src/typevet/adapters/outbound/vllm_content.py +63 -0
  40. typevet-0.1.0.dev1/src/typevet/adapters/outbound/vllm_generation.py +163 -0
  41. typevet-0.1.0.dev1/src/typevet/adapters/outbound/vllm_generation_async.py +257 -0
  42. typevet-0.1.0.dev1/src/typevet/adapters/outbound/vllm_http.py +121 -0
  43. typevet-0.1.0.dev1/src/typevet/adapters/outbound/vllm_judgment_factory.py +210 -0
  44. typevet-0.1.0.dev1/src/typevet/adapters/outbound/vllm_scoring.py +372 -0
  45. typevet-0.1.0.dev1/src/typevet/domain/__init__.py +193 -0
  46. typevet-0.1.0.dev1/src/typevet/domain/candidate_scoring_request.py +134 -0
  47. typevet-0.1.0.dev1/src/typevet/domain/candidate_scoring_response.py +96 -0
  48. typevet-0.1.0.dev1/src/typevet/domain/candidate_scoring_validate.py +197 -0
  49. typevet-0.1.0.dev1/src/typevet/domain/decision_compile.py +368 -0
  50. typevet-0.1.0.dev1/src/typevet/domain/decision_execute.py +229 -0
  51. typevet-0.1.0.dev1/src/typevet/domain/decisions.py +129 -0
  52. typevet-0.1.0.dev1/src/typevet/domain/errors.py +235 -0
  53. typevet-0.1.0.dev1/src/typevet/domain/field_instructions.py +134 -0
  54. typevet-0.1.0.dev1/src/typevet/domain/judgment_answers.py +198 -0
  55. typevet-0.1.0.dev1/src/typevet/domain/judgment_normalize.py +243 -0
  56. typevet-0.1.0.dev1/src/typevet/domain/judgment_questions.py +187 -0
  57. typevet-0.1.0.dev1/src/typevet/domain/judgment_response.py +102 -0
  58. typevet-0.1.0.dev1/src/typevet/domain/media.py +101 -0
  59. typevet-0.1.0.dev1/src/typevet/domain/models.py +115 -0
  60. typevet-0.1.0.dev1/src/typevet/domain/question_schema.py +254 -0
  61. typevet-0.1.0.dev1/src/typevet/domain/scoring_stage.py +34 -0
  62. typevet-0.1.0.dev1/src/typevet/evaluation/__init__.py +19 -0
  63. typevet-0.1.0.dev1/src/typevet/evaluation/consumer_http_accounting.py +135 -0
  64. typevet-0.1.0.dev1/src/typevet/evaluation/cord_expense_call_accounting.py +108 -0
  65. typevet-0.1.0.dev1/src/typevet/evaluation/cord_expense_live_harness.py +75 -0
  66. typevet-0.1.0.dev1/src/typevet/evaluation/cord_expense_receipt_requirement.py +212 -0
  67. typevet-0.1.0.dev1/src/typevet/evaluation/cord_expense_smoke.py +328 -0
  68. typevet-0.1.0.dev1/src/typevet/evaluation/cord_semantic_acceptance.py +463 -0
  69. typevet-0.1.0.dev1/src/typevet/evaluation/cord_semantic_acceptance_report.py +90 -0
  70. typevet-0.1.0.dev1/src/typevet/evaluation/cord_semantic_metrics.py +57 -0
  71. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/__init__.py +30 -0
  72. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/banking77.py +270 -0
  73. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/boolq.py +550 -0
  74. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/boolq_download.py +132 -0
  75. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/civil_comments.py +450 -0
  76. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/clinc.py +125 -0
  77. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/clinc_domains.json +172 -0
  78. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/clinc_download.py +103 -0
  79. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/clinc_plus_intent_names.json +153 -0
  80. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/clinc_rows.py +306 -0
  81. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/clinc_shard.py +156 -0
  82. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/cord_expense.py +381 -0
  83. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/difraud.py +256 -0
  84. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/go_emotions.py +368 -0
  85. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/go_emotions_download.py +154 -0
  86. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/hyperpartisan.py +562 -0
  87. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/partner_guard.py +170 -0
  88. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/psai.py +415 -0
  89. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/psai_download.py +167 -0
  90. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/psai_evidence_pilot.py +570 -0
  91. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/psai_schema.py +157 -0
  92. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/psai_stream.py +166 -0
  93. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/psai_vision.py +534 -0
  94. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/psai_vision_controls.py +502 -0
  95. typevet-0.1.0.dev1/src/typevet/evaluation/datasets/pubmedqa.py +420 -0
  96. typevet-0.1.0.dev1/src/typevet/evaluation/experiment_identity.py +677 -0
  97. typevet-0.1.0.dev1/src/typevet/evaluation/psai_vision_consumer_accounting.py +190 -0
  98. typevet-0.1.0.dev1/src/typevet/evaluation/psai_vision_consumer_dispatch.py +216 -0
  99. typevet-0.1.0.dev1/src/typevet/evaluation/psai_vision_consumer_harness.py +342 -0
  100. typevet-0.1.0.dev1/src/typevet/evaluation/psai_vision_consumer_live.py +332 -0
  101. typevet-0.1.0.dev1/src/typevet/evaluation/psai_vision_consumer_live_identity.py +156 -0
  102. typevet-0.1.0.dev1/src/typevet/evaluation/psai_vision_consumer_live_receipt.py +132 -0
  103. typevet-0.1.0.dev1/src/typevet/evaluation/psai_vision_consumer_live_router.py +162 -0
  104. typevet-0.1.0.dev1/src/typevet/evaluation/psai_vision_consumer_offline.py +418 -0
  105. typevet-0.1.0.dev1/src/typevet/evaluation/psai_vision_consumer_outcomes.py +224 -0
  106. typevet-0.1.0.dev1/src/typevet/evaluation/psai_vision_consumer_protocol.py +69 -0
  107. typevet-0.1.0.dev1/src/typevet/evaluation/psai_vision_consumer_receipt.py +161 -0
  108. typevet-0.1.0.dev1/src/typevet/evaluation/psai_vision_consumer_receipt_structure.py +263 -0
  109. typevet-0.1.0.dev1/src/typevet/evaluation/psai_vision_probability_evidence.py +336 -0
  110. typevet-0.1.0.dev1/src/typevet/evaluation/runner/__init__.py +56 -0
  111. typevet-0.1.0.dev1/src/typevet/evaluation/runner/core.py +104 -0
  112. typevet-0.1.0.dev1/src/typevet/evaluation/runner/datasets.py +186 -0
  113. typevet-0.1.0.dev1/src/typevet/evaluation/runner/live_gate.py +149 -0
  114. typevet-0.1.0.dev1/src/typevet/evaluation/runner/report.py +116 -0
  115. typevet-0.1.0.dev1/src/typevet/evaluation/tpjep/__init__.py +81 -0
  116. typevet-0.1.0.dev1/src/typevet/evaluation/tpjep/loader.py +237 -0
  117. typevet-0.1.0.dev1/src/typevet/evaluation/tpjep/outcome.py +101 -0
  118. typevet-0.1.0.dev1/src/typevet/evaluation/tpjep/records.py +428 -0
  119. typevet-0.1.0.dev1/src/typevet/evaluation/tpjep/runner.py +325 -0
  120. typevet-0.1.0.dev1/src/typevet/ports/__init__.py +39 -0
  121. typevet-0.1.0.dev1/src/typevet/ports/async_generation.py +57 -0
  122. typevet-0.1.0.dev1/src/typevet/ports/framing.py +59 -0
  123. typevet-0.1.0.dev1/src/typevet/ports/generation.py +58 -0
  124. typevet-0.1.0.dev1/src/typevet/ports/judgment.py +71 -0
  125. typevet-0.1.0.dev1/src/typevet/ports/scoring.py +64 -0
  126. typevet-0.1.0.dev1/src/typevet/py.typed +0 -0
  127. typevet-0.1.0.dev1/src/typevet/runtime/__init__.py +50 -0
  128. typevet-0.1.0.dev1/src/typevet/runtime/categorical.py +196 -0
  129. typevet-0.1.0.dev1/src/typevet/runtime/judgment.py +17 -0
  130. typevet-0.1.0.dev1/src/typevet/runtime/llama_cpp_gemma_vision.py +28 -0
  131. typevet-0.1.0.dev1/src/typevet/runtime/scoring_prefix.py +14 -0
  132. typevet-0.1.0.dev1/src/typevet/runtime/vllm_judgment.py +28 -0
  133. typevet-0.1.0.dev1/src/typevet/testing/__init__.py +22 -0
  134. typevet-0.1.0.dev1/src/typevet/testing/fakes.py +152 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alberto-Codes
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,125 @@
1
+ Metadata-Version: 2.4
2
+ Name: typevet
3
+ Version: 0.1.0.dev1
4
+ Summary: Type-safe structured generation under hexagonal architecture (llama.cpp first)
5
+ Keywords: evaluation,gemma,json-schema,llama-cpp,llm,structured-generation,structured-output,type-safe,vllm
6
+ Author: Alberto-Codes
7
+ Author-email: Alberto-Codes <alberto.codes.dev@gmail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Typing :: Typed
19
+ Requires-Dist: httpx>=0.28
20
+ Requires-Dist: jsonschema>=4.26.0
21
+ Requires-Dist: structlog>=24.1
22
+ Requires-Dist: typer>=0.12 ; extra == 'cli'
23
+ Requires-Python: >=3.12
24
+ Project-URL: Homepage, https://github.com/Alberto-Codes/typevet
25
+ Project-URL: Documentation, https://alberto-codes.github.io/typevet/
26
+ Project-URL: Repository, https://github.com/Alberto-Codes/typevet
27
+ Project-URL: Issues, https://github.com/Alberto-Codes/typevet/issues
28
+ Project-URL: Changelog, https://github.com/Alberto-Codes/typevet/blob/main/CHANGELOG.md
29
+ Provides-Extra: cli
30
+ Description-Content-Type: text/markdown
31
+
32
+ [![CI](https://img.shields.io/github/actions/workflow/status/Alberto-Codes/typevet/ci.yml?branch=main&label=CI)](https://github.com/Alberto-Codes/typevet/actions/workflows/ci.yml)
33
+ [![Docs](https://img.shields.io/github/actions/workflow/status/Alberto-Codes/typevet/docs.yml?branch=main&label=docs)](https://alberto-codes.github.io/typevet/)
34
+ [![Python](https://img.shields.io/badge/python-3.12-blue)](https://github.com/Alberto-Codes/typevet/blob/main/pyproject.toml)
35
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
36
+ [![docs vetted](https://img.shields.io/badge/docs%20vetted-docvet-purple)](https://github.com/Alberto-Codes/docvet)
37
+
38
+ # typevet
39
+
40
+ Kind: landing page (the project overview; the one page that mixes kinds).
41
+
42
+ typevet is a Python library that asks a model typed questions and returns typed answers.
43
+ The three question types are `Noul` (yes or no), `Choice` (one label) and `Score` (one rubric level).
44
+ typevet computes each answer from the model's next-token probabilities, read before sampling.
45
+ typevet also returns JSON objects that pass a JSON Schema you supply, or it raises an error.
46
+ The receipts cover Gemma 4 31B on llama.cpp for local work and on vLLM for hosting.
47
+
48
+ Read the documentation at <https://alberto-codes.github.io/typevet/>.
49
+
50
+ ## Status
51
+
52
+ - typevet is pre-1.0. The package version is `0.1.0`.
53
+ - typevet is not on PyPI yet.
54
+ Build a wheel from a checkout and install it: see
55
+ [Install typevet](https://github.com/Alberto-Codes/typevet/blob/main/docs/how-to/install.md).
56
+ - typevet requires Python 3.12 or later.
57
+ - Each backend has one tested model pin.
58
+ The receipts give the full pin and its limits.
59
+
60
+ | Backend | Tested pin | Receipt |
61
+ |---|---|---|
62
+ | vLLM | `vllm/vllm-openai:v0.30.0`, BF16 `google/gemma-4-31B-it`, one H100 80 GB | [#170](https://github.com/Alberto-Codes/typevet/issues/170#issuecomment-5884707915) |
63
+ | llama.cpp | Build `b11223-4da633776`, local alias `gemma-4-31b-kv9-q4km-mm` | [#203](https://github.com/Alberto-Codes/typevet/issues/203#issuecomment-5882379255) |
64
+ | llama.cpp grammar | Build `b11243-fc07d781e`, Gemma 4 31B QAT Q4_0 GGUF | [#129](https://github.com/Alberto-Codes/typevet/issues/129#issuecomment-5892208050) |
65
+
66
+ Performance: on one H100 at concurrency level 64, 480 Banking77 records took 12.1 s at 39.6 records/s.
67
+ That run had 0 errors. Banking77 calibration passed; DIFrauD SMS failed parity (ECE 0.158 against 0.10). One run, one pod, one pin.
68
+ See [Performance on one H100](https://alberto-codes.github.io/typevet/reference/performance/)
69
+ and [Serve Gemma 4 31B on a rented H100](https://alberto-codes.github.io/typevet/how-to/serve-gemma-4-31b-on-a-rented-h100/).
70
+ A valid structure does not prove accuracy or calibration.
71
+ The receipts are small samples.
72
+
73
+ ## Quickstart
74
+
75
+ Get one offline typed judgment from a scripted fake. This step needs no model.
76
+
77
+ ```bash
78
+ uv sync
79
+ uv run python -c "
80
+ from typevet.domain import Noul
81
+ from typevet.runtime import ScoringJudgmentAdapter
82
+ from typevet.testing import ScriptedScoringFake
83
+ fake = ScriptedScoringFake(logprobs={'True': -0.2, 'False': -1.0})
84
+ port = ScoringJudgmentAdapter(fake, tokenize_content=lambda t: (ord(t[0]),))
85
+ r = port.judge('text', {'q': Noul(instructions='Ok?', criteria={'true': 'Y', 'false': 'N'})}, 'fake')
86
+ print('noul', r.nouls['q'].noul)
87
+ "
88
+ ```
89
+
90
+ The command prints the probability of yes, near 0.69.
91
+ The [offline tutorial](https://github.com/Alberto-Codes/typevet/blob/main/docs/tutorials/first-typed-judgment-offline.md) explains each step.
92
+ Then connect a model server:
93
+
94
+ - To host typevet, follow [Serve typevet on vLLM](https://github.com/Alberto-Codes/typevet/blob/main/docs/how-to/serve-typevet-on-vllm.md).
95
+ - To run typevet locally, follow [Run Gemma 4 on llama.cpp](https://github.com/Alberto-Codes/typevet/blob/main/docs/how-to/run-gemma4-llamacpp.md).
96
+ - To call typevet from code, follow [Call typevet from Python](https://github.com/Alberto-Codes/typevet/blob/main/docs/how-to/call-typevet-from-python.md).
97
+
98
+ ## Learn more
99
+
100
+ - [How typevet works with Gemma 4](https://github.com/Alberto-Codes/typevet/blob/main/docs/explanation/how-typevet-works-with-gemma-4.md)
101
+ explains the scoring path, the two backends and the receipts.
102
+ - [Gemma 4 multimodal judgments](https://github.com/Alberto-Codes/typevet/blob/main/docs/explanation/gemma-4-multimodal-judgments.md)
103
+ explains how images reach each backend, and the limits.
104
+ - [Native typed judgments](https://github.com/Alberto-Codes/typevet/blob/main/docs/explanation/native-typed-judgments.md) states the scope and the limitations.
105
+ - [The documentation index](https://github.com/Alberto-Codes/typevet/blob/main/docs/README.md) lists every page and its kind.
106
+
107
+ [TypeLLM](https://github.com/TypeLLM/TypeLLM) is a research reference for the decision model.
108
+ It is not a runtime dependency.
109
+
110
+ ## For contributors
111
+
112
+ Read [CLAUDE.md](https://github.com/Alberto-Codes/typevet/blob/main/CLAUDE.md) first.
113
+ It states the gates, the issue workflow and the rules for agents and people.
114
+
115
+ ```bash
116
+ uv sync
117
+ uv run pre-commit install -t pre-commit -t pre-push -t commit-msg
118
+ uv run pytest -q
119
+ ```
120
+
121
+ The default test run skips live tests.
122
+ Pull requests and pushes to `main` run the hook stages in
123
+ [the CI workflow](https://github.com/Alberto-Codes/typevet/blob/main/.github/workflows/ci.yml).
124
+ [The writing system](https://github.com/Alberto-Codes/typevet/blob/main/docs/reference/writing-system.md) and
125
+ [the commit rules](https://github.com/Alberto-Codes/typevet/blob/main/docs/reference/commits.md) apply to every change.
@@ -0,0 +1,94 @@
1
+ [![CI](https://img.shields.io/github/actions/workflow/status/Alberto-Codes/typevet/ci.yml?branch=main&label=CI)](https://github.com/Alberto-Codes/typevet/actions/workflows/ci.yml)
2
+ [![Docs](https://img.shields.io/github/actions/workflow/status/Alberto-Codes/typevet/docs.yml?branch=main&label=docs)](https://alberto-codes.github.io/typevet/)
3
+ [![Python](https://img.shields.io/badge/python-3.12-blue)](https://github.com/Alberto-Codes/typevet/blob/main/pyproject.toml)
4
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
5
+ [![docs vetted](https://img.shields.io/badge/docs%20vetted-docvet-purple)](https://github.com/Alberto-Codes/docvet)
6
+
7
+ # typevet
8
+
9
+ Kind: landing page (the project overview; the one page that mixes kinds).
10
+
11
+ typevet is a Python library that asks a model typed questions and returns typed answers.
12
+ The three question types are `Noul` (yes or no), `Choice` (one label) and `Score` (one rubric level).
13
+ typevet computes each answer from the model's next-token probabilities, read before sampling.
14
+ typevet also returns JSON objects that pass a JSON Schema you supply, or it raises an error.
15
+ The receipts cover Gemma 4 31B on llama.cpp for local work and on vLLM for hosting.
16
+
17
+ Read the documentation at <https://alberto-codes.github.io/typevet/>.
18
+
19
+ ## Status
20
+
21
+ - typevet is pre-1.0. The package version is `0.1.0`.
22
+ - typevet is not on PyPI yet.
23
+ Build a wheel from a checkout and install it: see
24
+ [Install typevet](https://github.com/Alberto-Codes/typevet/blob/main/docs/how-to/install.md).
25
+ - typevet requires Python 3.12 or later.
26
+ - Each backend has one tested model pin.
27
+ The receipts give the full pin and its limits.
28
+
29
+ | Backend | Tested pin | Receipt |
30
+ |---|---|---|
31
+ | vLLM | `vllm/vllm-openai:v0.30.0`, BF16 `google/gemma-4-31B-it`, one H100 80 GB | [#170](https://github.com/Alberto-Codes/typevet/issues/170#issuecomment-5884707915) |
32
+ | llama.cpp | Build `b11223-4da633776`, local alias `gemma-4-31b-kv9-q4km-mm` | [#203](https://github.com/Alberto-Codes/typevet/issues/203#issuecomment-5882379255) |
33
+ | llama.cpp grammar | Build `b11243-fc07d781e`, Gemma 4 31B QAT Q4_0 GGUF | [#129](https://github.com/Alberto-Codes/typevet/issues/129#issuecomment-5892208050) |
34
+
35
+ Performance: on one H100 at concurrency level 64, 480 Banking77 records took 12.1 s at 39.6 records/s.
36
+ That run had 0 errors. Banking77 calibration passed; DIFrauD SMS failed parity (ECE 0.158 against 0.10). One run, one pod, one pin.
37
+ See [Performance on one H100](https://alberto-codes.github.io/typevet/reference/performance/)
38
+ and [Serve Gemma 4 31B on a rented H100](https://alberto-codes.github.io/typevet/how-to/serve-gemma-4-31b-on-a-rented-h100/).
39
+ A valid structure does not prove accuracy or calibration.
40
+ The receipts are small samples.
41
+
42
+ ## Quickstart
43
+
44
+ Get one offline typed judgment from a scripted fake. This step needs no model.
45
+
46
+ ```bash
47
+ uv sync
48
+ uv run python -c "
49
+ from typevet.domain import Noul
50
+ from typevet.runtime import ScoringJudgmentAdapter
51
+ from typevet.testing import ScriptedScoringFake
52
+ fake = ScriptedScoringFake(logprobs={'True': -0.2, 'False': -1.0})
53
+ port = ScoringJudgmentAdapter(fake, tokenize_content=lambda t: (ord(t[0]),))
54
+ r = port.judge('text', {'q': Noul(instructions='Ok?', criteria={'true': 'Y', 'false': 'N'})}, 'fake')
55
+ print('noul', r.nouls['q'].noul)
56
+ "
57
+ ```
58
+
59
+ The command prints the probability of yes, near 0.69.
60
+ The [offline tutorial](https://github.com/Alberto-Codes/typevet/blob/main/docs/tutorials/first-typed-judgment-offline.md) explains each step.
61
+ Then connect a model server:
62
+
63
+ - To host typevet, follow [Serve typevet on vLLM](https://github.com/Alberto-Codes/typevet/blob/main/docs/how-to/serve-typevet-on-vllm.md).
64
+ - To run typevet locally, follow [Run Gemma 4 on llama.cpp](https://github.com/Alberto-Codes/typevet/blob/main/docs/how-to/run-gemma4-llamacpp.md).
65
+ - To call typevet from code, follow [Call typevet from Python](https://github.com/Alberto-Codes/typevet/blob/main/docs/how-to/call-typevet-from-python.md).
66
+
67
+ ## Learn more
68
+
69
+ - [How typevet works with Gemma 4](https://github.com/Alberto-Codes/typevet/blob/main/docs/explanation/how-typevet-works-with-gemma-4.md)
70
+ explains the scoring path, the two backends and the receipts.
71
+ - [Gemma 4 multimodal judgments](https://github.com/Alberto-Codes/typevet/blob/main/docs/explanation/gemma-4-multimodal-judgments.md)
72
+ explains how images reach each backend, and the limits.
73
+ - [Native typed judgments](https://github.com/Alberto-Codes/typevet/blob/main/docs/explanation/native-typed-judgments.md) states the scope and the limitations.
74
+ - [The documentation index](https://github.com/Alberto-Codes/typevet/blob/main/docs/README.md) lists every page and its kind.
75
+
76
+ [TypeLLM](https://github.com/TypeLLM/TypeLLM) is a research reference for the decision model.
77
+ It is not a runtime dependency.
78
+
79
+ ## For contributors
80
+
81
+ Read [CLAUDE.md](https://github.com/Alberto-Codes/typevet/blob/main/CLAUDE.md) first.
82
+ It states the gates, the issue workflow and the rules for agents and people.
83
+
84
+ ```bash
85
+ uv sync
86
+ uv run pre-commit install -t pre-commit -t pre-push -t commit-msg
87
+ uv run pytest -q
88
+ ```
89
+
90
+ The default test run skips live tests.
91
+ Pull requests and pushes to `main` run the hook stages in
92
+ [the CI workflow](https://github.com/Alberto-Codes/typevet/blob/main/.github/workflows/ci.yml).
93
+ [The writing system](https://github.com/Alberto-Codes/typevet/blob/main/docs/reference/writing-system.md) and
94
+ [the commit rules](https://github.com/Alberto-Codes/typevet/blob/main/docs/reference/commits.md) apply to every change.
@@ -0,0 +1,272 @@
1
+ [project]
2
+ name = "typevet"
3
+ version = "0.1.0.dev1"
4
+ description = "Type-safe structured generation under hexagonal architecture (llama.cpp first)"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.12"
9
+ classifiers = [
10
+ "Development Status :: 3 - Alpha",
11
+ "Intended Audience :: Developers",
12
+ "Operating System :: OS Independent",
13
+ "Programming Language :: Python :: 3 :: Only",
14
+ "Programming Language :: Python :: 3.12",
15
+ "Programming Language :: Python :: 3.13",
16
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
17
+ "Topic :: Software Development :: Libraries :: Python Modules",
18
+ "Typing :: Typed",
19
+ ]
20
+ keywords = [
21
+ "evaluation",
22
+ "gemma",
23
+ "json-schema",
24
+ "llama-cpp",
25
+ "llm",
26
+ "structured-generation",
27
+ "structured-output",
28
+ "type-safe",
29
+ "vllm",
30
+ ]
31
+ dependencies = [
32
+ "httpx>=0.28",
33
+ "jsonschema>=4.26.0",
34
+ "structlog>=24.1",
35
+ ]
36
+
37
+ [[project.authors]]
38
+ name = "Alberto-Codes"
39
+ email = "alberto.codes.dev@gmail.com"
40
+
41
+ [project.optional-dependencies]
42
+ cli = ["typer>=0.12"]
43
+
44
+ [project.urls]
45
+ Homepage = "https://github.com/Alberto-Codes/typevet"
46
+ Documentation = "https://alberto-codes.github.io/typevet/"
47
+ Repository = "https://github.com/Alberto-Codes/typevet"
48
+ Issues = "https://github.com/Alberto-Codes/typevet/issues"
49
+ Changelog = "https://github.com/Alberto-Codes/typevet/blob/main/CHANGELOG.md"
50
+
51
+ [build-system]
52
+ requires = ["uv_build>=0.11.20,<0.13.0"]
53
+ build-backend = "uv_build"
54
+
55
+ [tool.uv_build]
56
+ include = ["src/typevet/py.typed"]
57
+
58
+ [tool.uv]
59
+ default-groups = [
60
+ "dev",
61
+ "docs",
62
+ ]
63
+
64
+ [tool.uv.workspace]
65
+ members = ["evals"]
66
+
67
+ [tool.uv.sources.typevet-evals]
68
+ workspace = true
69
+
70
+ [tool.ruff]
71
+ line-length = 88
72
+ target-version = "py312"
73
+ exclude = [
74
+ ".venv",
75
+ "__pycache__",
76
+ "*.egg-info",
77
+ ]
78
+
79
+ [tool.ruff.lint]
80
+ extend-select = [
81
+ "E402",
82
+ "E501",
83
+ "I",
84
+ "D",
85
+ "B",
86
+ "SIM",
87
+ "UP",
88
+ "RUF",
89
+ "PL",
90
+ "C901",
91
+ "TRY",
92
+ "PERF",
93
+ "S",
94
+ "G",
95
+ ]
96
+ ignore = ["TRY003"]
97
+
98
+ [tool.ruff.lint.mccabe]
99
+ max-complexity = 12
100
+
101
+ [tool.ruff.lint.pylint]
102
+ max-args = 7
103
+
104
+ [tool.ruff.lint.pycodestyle]
105
+ max-line-length = 100
106
+
107
+ [tool.ruff.lint.pydocstyle]
108
+ convention = "google"
109
+
110
+ [tool.ruff.lint.per-file-ignores]
111
+ "**/tests/**/*.py" = [
112
+ "S101",
113
+ "D100",
114
+ "D101",
115
+ "D102",
116
+ "D103",
117
+ "D104",
118
+ "PLR2004",
119
+ ]
120
+ "evals/src/typevet_evals/wheel_isolated.py" = ["S603"]
121
+ "scripts/check_commit_msg.py" = ["S603"]
122
+ "src/typevet/evaluation/datasets/partner_guard.py" = [
123
+ "S603",
124
+ "S607",
125
+ ]
126
+
127
+ [tool.ruff.lint.isort]
128
+ known-first-party = [
129
+ "typevet",
130
+ "typevet_evals",
131
+ ]
132
+
133
+ [tool.ruff.format]
134
+ quote-style = "double"
135
+ docstring-code-format = true
136
+
137
+ [tool.pytest.ini_options]
138
+ pythonpath = ["."]
139
+ testpaths = [
140
+ "tests",
141
+ "evals/tests",
142
+ ]
143
+ markers = [
144
+ "unit: fast, isolated",
145
+ "contract: adapter behaviour against fakes",
146
+ "live: touches local llama.cpp; never in default CI",
147
+ ]
148
+ addopts = [
149
+ "-ra",
150
+ "--strict-markers",
151
+ "--strict-config",
152
+ "--showlocals",
153
+ "-m",
154
+ "not live",
155
+ ]
156
+
157
+ [tool.coverage.run]
158
+ source = [
159
+ "typevet",
160
+ "typevet_evals",
161
+ ]
162
+
163
+ [tool.coverage.report]
164
+ fail_under = 90
165
+ show_missing = true
166
+
167
+ [tool.ty.src]
168
+ include = [
169
+ "src",
170
+ "tests",
171
+ "scripts",
172
+ "evals/src",
173
+ "evals/tests",
174
+ ]
175
+
176
+ [tool.importlinter]
177
+ root_packages = [
178
+ "typevet",
179
+ "typevet_evals",
180
+ ]
181
+ include_external_packages = true
182
+ exclude_type_checking_imports = true
183
+
184
+ [[tool.importlinter.contracts]]
185
+ name = "Hexagonal layers"
186
+ type = "layers"
187
+ layers = [
188
+ "typevet.runtime",
189
+ "typevet.evaluation : typevet.adapters.inbound",
190
+ "typevet.adapters.outbound",
191
+ "typevet.adapters.diagnostics",
192
+ "typevet.testing",
193
+ "typevet.ports",
194
+ "typevet.domain",
195
+ ]
196
+
197
+ [[tool.importlinter.contracts]]
198
+ name = "The library does not import the evals"
199
+ type = "forbidden"
200
+ source_modules = ["typevet"]
201
+ forbidden_modules = ["typevet_evals"]
202
+
203
+ [[tool.importlinter.contracts]]
204
+ name = "runtime_must_not_import_evaluation"
205
+ type = "forbidden"
206
+ source_modules = ["typevet.runtime"]
207
+ forbidden_modules = ["typevet.evaluation"]
208
+
209
+ [[tool.importlinter.contracts]]
210
+ name = "Fakes stay off the adapters"
211
+ type = "forbidden"
212
+ source_modules = ["typevet.testing"]
213
+ forbidden_modules = ["typevet.adapters"]
214
+
215
+ [[tool.importlinter.contracts]]
216
+ name = "Domain is IO-free"
217
+ type = "forbidden"
218
+ source_modules = ["typevet.domain"]
219
+ forbidden_modules = [
220
+ "json",
221
+ "pathlib",
222
+ "os",
223
+ "io",
224
+ "logging",
225
+ "httpx",
226
+ "typer",
227
+ "jsonschema",
228
+ "structlog",
229
+ ]
230
+
231
+ [tool.docvet]
232
+ fail-on = [
233
+ "enrichment",
234
+ "freshness",
235
+ "coverage",
236
+ "griffe",
237
+ "presence",
238
+ ]
239
+ exclude = [
240
+ "tests",
241
+ "scripts",
242
+ "evals/tests",
243
+ ]
244
+
245
+ [tool.docvet.presence]
246
+ min-coverage = 100.0
247
+
248
+ [tool.typevet.commit-msg]
249
+ allowed-authors = [
250
+ "alberto.nieto.80@gmail.com",
251
+ "alberto.codes.dev@gmail.com",
252
+ "github-actions[bot]@users.noreply.github.com",
253
+ ]
254
+ coauthor-grandfather-through = "1b1d9a3cfde019c5dbfe164c1660f1d3be28b5ba"
255
+
256
+ [dependency-groups]
257
+ dev = [
258
+ "docvet[griffe]>=1.16.0",
259
+ "import-linter>=2.15",
260
+ "pre-commit>=4.6.2",
261
+ "pytest>=9.1.1",
262
+ "pytest-cov>=7.1.0",
263
+ "ruff>=0.16.8",
264
+ "ty>=0.0.82",
265
+ "typevet-evals",
266
+ ]
267
+ docs = [
268
+ "mkdocs>=1.6.1,<2",
269
+ "mkdocs-material>=9.7.7",
270
+ "mkdocstrings[python]>=1.0.6",
271
+ "pymdown-extensions>=12.1",
272
+ ]