hvme 0.1.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 (123) hide show
  1. hvme-0.1.0/LICENSE +202 -0
  2. hvme-0.1.0/PKG-INFO +190 -0
  3. hvme-0.1.0/README.md +144 -0
  4. hvme-0.1.0/hvme/__init__.py +2 -0
  5. hvme-0.1.0/hvme/api.py +243 -0
  6. hvme-0.1.0/hvme/bench/__init__.py +4 -0
  7. hvme-0.1.0/hvme/bench/calm.py +48 -0
  8. hvme-0.1.0/hvme/bench/datasets.py +83 -0
  9. hvme-0.1.0/hvme/bench/general.py +53 -0
  10. hvme-0.1.0/hvme/bench/metrics.py +66 -0
  11. hvme-0.1.0/hvme/bench/prompts.py +35 -0
  12. hvme-0.1.0/hvme/bench/runner.py +55 -0
  13. hvme-0.1.0/hvme/engine/__init__.py +10 -0
  14. hvme-0.1.0/hvme/engine/discovery.py +57 -0
  15. hvme-0.1.0/hvme/engine/dsep.py +36 -0
  16. hvme-0.1.0/hvme/engine/estimate.py +93 -0
  17. hvme-0.1.0/hvme/engine/identify.py +172 -0
  18. hvme-0.1.0/hvme/engine/refute.py +32 -0
  19. hvme-0.1.0/hvme/engine/scm.py +161 -0
  20. hvme-0.1.0/hvme/fast/__init__.py +6 -0
  21. hvme-0.1.0/hvme/fast/calibrate.py +59 -0
  22. hvme-0.1.0/hvme/fast/data.py +59 -0
  23. hvme-0.1.0/hvme/fast/distill.py +109 -0
  24. hvme-0.1.0/hvme/fast/judge.py +121 -0
  25. hvme-0.1.0/hvme/fast/lora.py +49 -0
  26. hvme-0.1.0/hvme/fast/router.py +41 -0
  27. hvme-0.1.0/hvme/fast/seed_worker.py +63 -0
  28. hvme-0.1.0/hvme/fast/train.py +106 -0
  29. hvme-0.1.0/hvme/graph/__init__.py +5 -0
  30. hvme-0.1.0/hvme/graph/schema.py +172 -0
  31. hvme-0.1.0/hvme/graph/serialize.py +29 -0
  32. hvme-0.1.0/hvme/graph/tabular/__init__.py +10 -0
  33. hvme-0.1.0/hvme/graph/tabular/networks.py +24 -0
  34. hvme-0.1.0/hvme/graph/tabular/oracle.py +38 -0
  35. hvme-0.1.0/hvme/graph/tabular/pc.py +172 -0
  36. hvme-0.1.0/hvme/graph/tabular/pipeline.py +106 -0
  37. hvme-0.1.0/hvme/graph/tabular/prior.py +106 -0
  38. hvme-0.1.0/hvme/graph/tabular/profile.py +18 -0
  39. hvme-0.1.0/hvme/graph/text/__init__.py +13 -0
  40. hvme-0.1.0/hvme/graph/text/aggregate.py +31 -0
  41. hvme-0.1.0/hvme/graph/text/canonical.py +45 -0
  42. hvme-0.1.0/hvme/graph/text/evaluate.py +35 -0
  43. hvme-0.1.0/hvme/graph/text/extract.py +68 -0
  44. hvme-0.1.0/hvme/graph/text/merge.py +63 -0
  45. hvme-0.1.0/hvme/graph/text/oracle.py +58 -0
  46. hvme-0.1.0/hvme/graph/text/pipeline.py +54 -0
  47. hvme-0.1.0/hvme/graph/text/synth.py +147 -0
  48. hvme-0.1.0/hvme/graph/text/verify.py +21 -0
  49. hvme-0.1.0/hvme/gym/__init__.py +9 -0
  50. hvme-0.1.0/hvme/gym/ancestry.py +80 -0
  51. hvme-0.1.0/hvme/gym/check.py +80 -0
  52. hvme-0.1.0/hvme/gym/dataset.py +89 -0
  53. hvme-0.1.0/hvme/gym/evaluate.py +36 -0
  54. hvme-0.1.0/hvme/gym/formats.py +91 -0
  55. hvme-0.1.0/hvme/gym/graphid.py +162 -0
  56. hvme-0.1.0/hvme/gym/graphs.py +63 -0
  57. hvme-0.1.0/hvme/gym/kosurf.py +209 -0
  58. hvme-0.1.0/hvme/gym/prob.py +166 -0
  59. hvme-0.1.0/hvme/gym/queries.py +363 -0
  60. hvme-0.1.0/hvme/gym/v3.py +517 -0
  61. hvme-0.1.0/hvme/gym/verbalize.py +85 -0
  62. hvme-0.1.0/hvme/gym/vocab.py +83 -0
  63. hvme-0.1.0/hvme/lm/__init__.py +7 -0
  64. hvme-0.1.0/hvme/lm/data.py +65 -0
  65. hvme-0.1.0/hvme/lm/grpo.py +244 -0
  66. hvme-0.1.0/hvme/lm/jobs.py +168 -0
  67. hvme-0.1.0/hvme/lm/sample.py +100 -0
  68. hvme-0.1.0/hvme/lm/sft.py +107 -0
  69. hvme-0.1.0/hvme/lm/solutions.py +469 -0
  70. hvme-0.1.0/hvme/lm/tools.py +674 -0
  71. hvme-0.1.0/hvme/lm/trajectories.py +554 -0
  72. hvme-0.1.0/hvme/mcp/__init__.py +1 -0
  73. hvme-0.1.0/hvme/mcp/__main__.py +3 -0
  74. hvme-0.1.0/hvme/mcp/server.py +128 -0
  75. hvme-0.1.0/hvme/orchestrator/__init__.py +6 -0
  76. hvme-0.1.0/hvme/orchestrator/analysis.py +193 -0
  77. hvme-0.1.0/hvme/orchestrator/core.py +85 -0
  78. hvme-0.1.0/hvme/orchestrator/demo.py +162 -0
  79. hvme-0.1.0/hvme/orchestrator/explain.py +160 -0
  80. hvme-0.1.0/hvme/orchestrator/query.py +88 -0
  81. hvme-0.1.0/hvme/orchestrator/route.py +104 -0
  82. hvme-0.1.0/hvme/paths.py +15 -0
  83. hvme-0.1.0/hvme/providers/__init__.py +4 -0
  84. hvme-0.1.0/hvme/providers/anthropic_api.py +25 -0
  85. hvme-0.1.0/hvme/providers/base.py +15 -0
  86. hvme-0.1.0/hvme/providers/cache.py +50 -0
  87. hvme-0.1.0/hvme/providers/hf.py +43 -0
  88. hvme-0.1.0/hvme/providers/remote.py +40 -0
  89. hvme-0.1.0/hvme/providers/spec.py +39 -0
  90. hvme-0.1.0/hvme/validate/__init__.py +10 -0
  91. hvme-0.1.0/hvme/validate/benchmark.py +28 -0
  92. hvme-0.1.0/hvme/validate/ci.py +58 -0
  93. hvme-0.1.0/hvme/validate/experiment.py +29 -0
  94. hvme-0.1.0/hvme/validate/falsify.py +59 -0
  95. hvme-0.1.0/hvme/validate/report.py +141 -0
  96. hvme-0.1.0/hvme/validate/structure.py +14 -0
  97. hvme-0.1.0/hvme.egg-info/PKG-INFO +190 -0
  98. hvme-0.1.0/hvme.egg-info/SOURCES.txt +121 -0
  99. hvme-0.1.0/hvme.egg-info/dependency_links.txt +1 -0
  100. hvme-0.1.0/hvme.egg-info/entry_points.txt +2 -0
  101. hvme-0.1.0/hvme.egg-info/requires.txt +32 -0
  102. hvme-0.1.0/hvme.egg-info/top_level.txt +1 -0
  103. hvme-0.1.0/pyproject.toml +52 -0
  104. hvme-0.1.0/setup.cfg +4 -0
  105. hvme-0.1.0/tests/test_api.py +45 -0
  106. hvme-0.1.0/tests/test_cache.py +23 -0
  107. hvme-0.1.0/tests/test_engine.py +125 -0
  108. hvme-0.1.0/tests/test_fast.py +46 -0
  109. hvme-0.1.0/tests/test_fast_distill.py +59 -0
  110. hvme-0.1.0/tests/test_fast_torch.py +134 -0
  111. hvme-0.1.0/tests/test_gym.py +66 -0
  112. hvme-0.1.0/tests/test_gym_kosurf.py +13 -0
  113. hvme-0.1.0/tests/test_gym_repro.py +25 -0
  114. hvme-0.1.0/tests/test_lm.py +36 -0
  115. hvme-0.1.0/tests/test_lm_tools.py +489 -0
  116. hvme-0.1.0/tests/test_metrics.py +50 -0
  117. hvme-0.1.0/tests/test_orchestrator.py +94 -0
  118. hvme-0.1.0/tests/test_orchestrator_v1.py +85 -0
  119. hvme-0.1.0/tests/test_runner.py +47 -0
  120. hvme-0.1.0/tests/test_schema.py +54 -0
  121. hvme-0.1.0/tests/test_tabular.py +110 -0
  122. hvme-0.1.0/tests/test_text.py +87 -0
  123. hvme-0.1.0/tests/test_validate.py +73 -0
hvme-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
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 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 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 those 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
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
hvme-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,190 @@
1
+ Metadata-Version: 2.4
2
+ Name: hvme
3
+ Version: 0.1.0
4
+ Summary: Verifiable causal graphs, a tool-using causal reasoning LLM and a symbolic causal engine, tied together by an orchestrator and an MCP server
5
+ Author-email: josh <ai@namuax.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/namuax/hvme
8
+ Project-URL: Repository, https://github.com/namuax/hvme
9
+ Project-URL: Issues, https://github.com/namuax/hvme/issues
10
+ Project-URL: Changelog, https://github.com/namuax/hvme/blob/main/CHANGELOG.md
11
+ Project-URL: Models, https://huggingface.co/namuax
12
+ Keywords: causal inference,causal discovery,llm,mcp,do-calculus
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Classifier: Operating System :: OS Independent
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: networkx>=3.3
21
+ Requires-Dist: pydantic>=2.6
22
+ Requires-Dist: numpy
23
+ Requires-Dist: pandas
24
+ Requires-Dist: scipy
25
+ Provides-Extra: bench
26
+ Requires-Dist: pgmpy>=1.0; extra == "bench"
27
+ Provides-Extra: hf
28
+ Requires-Dist: torch>=2.7; extra == "hf"
29
+ Requires-Dist: transformers>=5.2; extra == "hf"
30
+ Requires-Dist: accelerate; extra == "hf"
31
+ Provides-Extra: vllm
32
+ Requires-Dist: transformers>=5.2; extra == "vllm"
33
+ Provides-Extra: api
34
+ Requires-Dist: anthropic; extra == "api"
35
+ Provides-Extra: mcp
36
+ Requires-Dist: mcp<2,>=1.2; extra == "mcp"
37
+ Provides-Extra: causal
38
+ Requires-Dist: dowhy; extra == "causal"
39
+ Requires-Dist: causal-learn; extra == "causal"
40
+ Requires-Dist: econml; extra == "causal"
41
+ Provides-Extra: dev
42
+ Requires-Dist: pytest; extra == "dev"
43
+ Requires-Dist: nbformat; extra == "dev"
44
+ Requires-Dist: jupyter; extra == "dev"
45
+ Dynamic: license-file
46
+
47
+ # hvme
48
+
49
+ **Verifiable causal graphs + a tool-using causal reasoning LLM + a symbolic causal engine, behind one orchestrator and an MCP server.**
50
+
51
+ [English](https://github.com/namuax/hvme/blob/main/README.md) · [한국어](https://github.com/namuax/hvme/blob/main/README.ko.md)
52
+
53
+ > Status: v0.1.0, first public release. Model weights are on Hugging Face (see [Models](https://github.com/namuax/hvme#models)).
54
+
55
+ hvme turns tables and documents into a causal DAG (HCG, *Hvme Causal Graph*), checks the DAG against the data, and answers causal questions with numbers that come from a symbolic engine rather than from the language model's guess. A small LLM is trained to translate a question into engine calls and to read the result back; a single-pass judge routes easy questions and calibrates confidence.
56
+
57
+ ## What is different
58
+
59
+ Ask a plain LLM "If we raise the ad budget, do sales go up?" and you get a fluent answer with no number and no check. hvme answers the same question like this:
60
+
61
+ 1. builds a graph from the data and the documents (every edge carries its evidence: data test, text, LLM prior),
62
+ 2. tests the graph against the data (local Markov conditions, permutation test, edge tests),
63
+ 3. identifies the effect (backdoor / front-door / IV / ID algorithm) and estimates it with a bootstrap interval,
64
+ 4. runs refutation tests and, if an experiment exists, checks the estimate against it,
65
+ 5. explains the answer with the causal paths and the assumptions it relied on.
66
+
67
+ ```
68
+ strategy: backdoor
69
+ answer: 광고비를 1로 바꾸면 매출=1일 확률이 +0.211 (95% 구간 +0.185 ~ +0.241)만큼 달라진다. 즉 광고비는 매출을 높인다.
70
+ ```
71
+ (output of `examples/01_quickstart.py`; the demo scenario is in Korean, English questions work the same way)
72
+
73
+ ## Install
74
+
75
+ ```bash
76
+ pip install hvme # core: graph, engine, validation, Gym (CPU only)
77
+ pip install "hvme[mcp]" # MCP server (hvme-mcp)
78
+ pip install "hvme[hf]" # local Hugging Face models (torch, transformers)
79
+ pip install "hvme[vllm]" # client for an OpenAI-compatible server such as vLLM
80
+ pip install "hvme[bench]" # benchmark extras (pgmpy)
81
+ ```
82
+
83
+ From source:
84
+
85
+ ```bash
86
+ git clone https://github.com/namuax/hvme && cd hvme
87
+ pip install -e ".[dev,mcp,bench]"
88
+ pytest -q --ignore=tests/test_fast_torch.py
89
+ ```
90
+
91
+ Data, models and results live under `HVME_HOME` (default: the repository root).
92
+
93
+ ## Quick start
94
+
95
+ No GPU and no LLM needed. The example generates a synthetic marketing scenario (observational data, an experiment and twelve documents from a known DAG) and uses a text oracle in place of the LLM:
96
+
97
+ ```bash
98
+ HVME_HOME=./hvme_work python examples/01_quickstart.py
99
+ ```
100
+
101
+ ```python
102
+ from hvme import api
103
+
104
+ api.validate_run("marketing", "data.csv") # does the graph survive the data?
105
+ api.engine_identify("marketing", "ad_spend", "sales", "data.csv") # -> backdoor
106
+ api.engine_estimate("marketing", "data.csv", "ad_spend", "sales") # ATE with a bootstrap CI
107
+ api.engine_counterfactual("marketing", "data.csv", "ad_spend", "sales", "nie", ["web_traffic"])
108
+ api.ask("광고비를 늘리면 매출이 오르는가?", "marketing", "data.csv")
109
+ ```
110
+
111
+ Examples: [`01_quickstart.py`](https://github.com/namuax/hvme/blob/main/examples/01_quickstart.py) (full chain, no GPU) · [`02_graph_from_table.py`](https://github.com/namuax/hvme/blob/main/examples/02_graph_from_table.py) · [`03_gym_generate.py`](https://github.com/namuax/hvme/blob/main/examples/03_gym_generate.py) · [MCP setup](https://github.com/namuax/hvme/blob/main/examples/04_mcp_server.md) · [vLLM serving](https://github.com/namuax/hvme/blob/main/examples/05_serve_vllm.md)
112
+
113
+ MCP server (17 tools: `graph_*`, `validate_run`, `engine_*`, `ask`, `fast_*`, `classify_question`, `lm_verify`, `ask_v1`):
114
+
115
+ ```bash
116
+ hvme-mcp
117
+ ```
118
+
119
+ Serving the LLM with vLLM and pointing hvme at it:
120
+
121
+ ```bash
122
+ vllm serve <model> --served-model-name hvme-lm --port 8011
123
+ HVME_LM_URL=http://127.0.0.1:8011/v1 HVME_LM=<model> python -c "from hvme import api; print(api.ask_v1('...', 'marketing', 'data.csv'))"
124
+ ```
125
+
126
+ ## Results
127
+
128
+ Measured on our own runs; the raw numbers are in [`bench/`](https://github.com/namuax/hvme/tree/main/bench/). The 9B model is Qwen3.5-9B fine-tuned with LoRA on engine-verified tool trajectories (tool mode: the model calls the engine). The base model answers without tools.
129
+
130
+ | Benchmark | Base Qwen3.5-9B (no tools) | hvme 9B |
131
+ |---|---|---|
132
+ | CaLM-lite (45 English tasks × 30) | 51.0 | **91.5** |
133
+ | CauGym (6 sets × 7 types × 15) | 31.3 | **75.6** |
134
+ | Target metric (mean of the two above) | 41.1 | **83.6** |
135
+ | CLadder 150 (base: CausalCoT 8k, hvme: tool mode) | 86.7 | **90.7** |
136
+ | Corr2Cause (300, F1) | — | **0.923** |
137
+ | KoCLadder (528, Korean, machine-translated) | — | 0.758 (English same items 0.907) |
138
+ | KoCorr2Cause (1,157, Korean, machine-translated) | — | 0.963 |
139
+
140
+ Single-pass judge (Qwen3.5-4B, one forward pass, calibrated): CLadder 600 0.843, CauGym yes/no 2,500 0.751. Rung router: CLadder Rung 0.992, KoCLadder Rung 0.983.
141
+
142
+ General ability is kept: MATH-500 and KMMLU stay within about 1 point of the base model.
143
+
144
+ Caveats: the Korean sets are machine translations that passed automatic checks (numbers, back-translation polarity, comparison order) and have not been reviewed by people yet. Single training runs differ by up to about 8 items on CLadder 150 and 2 points on KMMLU; smaller gaps are noise.
145
+
146
+ ## How it works
147
+
148
+ ![How hvme answers a causal question](https://raw.githubusercontent.com/namuax/hvme/main/assets/architecture.svg)
149
+
150
+ More: [architecture](https://github.com/namuax/hvme/blob/main/docs/architecture.md) · [HCG format](https://github.com/namuax/hvme/blob/main/docs/hcg.md) · [engine](https://github.com/namuax/hvme/blob/main/docs/engine.md) · [LM tools](https://github.com/namuax/hvme/blob/main/docs/tools.md) · [training](https://github.com/namuax/hvme/blob/main/docs/training.md) · [evaluation](https://github.com/namuax/hvme/blob/main/docs/evaluation.md)
151
+
152
+ | Package | Role |
153
+ |---|---|
154
+ | `hvme.graph` | HCG schema; table → HCG (PC with background knowledge, LLM pairwise direction, bootstrap); text → HCG (extraction, normalisation, cross-document aggregation) |
155
+ | `hvme.validate` | DAG checks: cycles and time order, conditional-independence tests, permutation test, edge tests, experiment comparison |
156
+ | `hvme.engine` | d-separation, identification (backdoor, O-set, front-door, IV, ID), binary and linear SCMs, estimation, refutation, causal discovery over Markov equivalence classes |
157
+ | `hvme.gym` | Question generator whose answers are computed by the engine (associational, interventional, counterfactual, structural), English and Korean |
158
+ | `hvme.lm` | Tool definitions, trajectories, SFT/GRPO training, sampling with engine calls |
159
+ | `hvme.fast` | Single-pass judge (yes/no, choice, score), temperature calibration, routing to a larger model when unsure |
160
+ | `hvme.orchestrator` | Question analysis → graph → validation → identification → estimation → refutation → explanation |
161
+ | `hvme.mcp`, `hvme.api` | MCP server and the path-based API it wraps |
162
+ | `skills/` | Nine agent skills built on the MCP tools |
163
+
164
+ ## Models
165
+
166
+ | Model | Base | Use | Hugging Face |
167
+ |---|---|---|---|
168
+ | hvme LM 9B | Qwen3.5-9B | main reasoning model (tool mode) | [`namuax/hvme-lm-9b`](https://huggingface.co/namuax/hvme-lm-9b) |
169
+ | hvme LM 4B | Qwen3.5-4B | light model | [`namuax/hvme-lm-4b`](https://huggingface.co/namuax/hvme-lm-4b) |
170
+ | hvme Fast 4B | Qwen3.5-4B | single-pass judge | [`namuax/hvme-fast-4b`](https://huggingface.co/namuax/hvme-fast-4b) |
171
+ | hvme Router 4B | Qwen3.5-4B | Rung classifier (English and Korean) | [`namuax/hvme-router-4b`](https://huggingface.co/namuax/hvme-router-4b) |
172
+
173
+ Everything except `api.ask_v1`, `fast_*`, `classify_question` and `lm_verify` runs without the weights.
174
+
175
+ ## Reproducing
176
+
177
+ - Benchmarks are not redistributed. `hvme.bench.datasets` downloads CLadder, Corr2Cause, CauGym, MATH-500 and KMMLU from their original sources.
178
+ - Training questions come from the Gym generators (`hvme.gym`), so every label is computed by the engine. Benchmark items are never used for training.
179
+ - Notebooks `notebooks/01–09` walk through the schema, engine, Gym, validation, graph construction and the single-pass judge. They are stored without outputs.
180
+
181
+ ## Limitations
182
+
183
+ - The engine works on binary and linear SCMs. Other mechanisms need a different estimator.
184
+ - The LM still fails to translate some free-form passages into engine arguments (most remaining CLadder and CauGym errors are "no answer").
185
+ - Korean performance trails English by about 15 points on KoCLadder.
186
+ - Graphs from text depend on the extraction LLM. Edges that only an LLM prior supports are marked as such and should be checked.
187
+
188
+ ## License
189
+
190
+ Code is released under the [Apache License 2.0](https://github.com/namuax/hvme/blob/main/LICENSE). Model weights also follow the license of their Qwen3.5 base models.
hvme-0.1.0/README.md ADDED
@@ -0,0 +1,144 @@
1
+ # hvme
2
+
3
+ **Verifiable causal graphs + a tool-using causal reasoning LLM + a symbolic causal engine, behind one orchestrator and an MCP server.**
4
+
5
+ [English](https://github.com/namuax/hvme/blob/main/README.md) · [한국어](https://github.com/namuax/hvme/blob/main/README.ko.md)
6
+
7
+ > Status: v0.1.0, first public release. Model weights are on Hugging Face (see [Models](https://github.com/namuax/hvme#models)).
8
+
9
+ hvme turns tables and documents into a causal DAG (HCG, *Hvme Causal Graph*), checks the DAG against the data, and answers causal questions with numbers that come from a symbolic engine rather than from the language model's guess. A small LLM is trained to translate a question into engine calls and to read the result back; a single-pass judge routes easy questions and calibrates confidence.
10
+
11
+ ## What is different
12
+
13
+ Ask a plain LLM "If we raise the ad budget, do sales go up?" and you get a fluent answer with no number and no check. hvme answers the same question like this:
14
+
15
+ 1. builds a graph from the data and the documents (every edge carries its evidence: data test, text, LLM prior),
16
+ 2. tests the graph against the data (local Markov conditions, permutation test, edge tests),
17
+ 3. identifies the effect (backdoor / front-door / IV / ID algorithm) and estimates it with a bootstrap interval,
18
+ 4. runs refutation tests and, if an experiment exists, checks the estimate against it,
19
+ 5. explains the answer with the causal paths and the assumptions it relied on.
20
+
21
+ ```
22
+ strategy: backdoor
23
+ answer: 광고비를 1로 바꾸면 매출=1일 확률이 +0.211 (95% 구간 +0.185 ~ +0.241)만큼 달라진다. 즉 광고비는 매출을 높인다.
24
+ ```
25
+ (output of `examples/01_quickstart.py`; the demo scenario is in Korean, English questions work the same way)
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ pip install hvme # core: graph, engine, validation, Gym (CPU only)
31
+ pip install "hvme[mcp]" # MCP server (hvme-mcp)
32
+ pip install "hvme[hf]" # local Hugging Face models (torch, transformers)
33
+ pip install "hvme[vllm]" # client for an OpenAI-compatible server such as vLLM
34
+ pip install "hvme[bench]" # benchmark extras (pgmpy)
35
+ ```
36
+
37
+ From source:
38
+
39
+ ```bash
40
+ git clone https://github.com/namuax/hvme && cd hvme
41
+ pip install -e ".[dev,mcp,bench]"
42
+ pytest -q --ignore=tests/test_fast_torch.py
43
+ ```
44
+
45
+ Data, models and results live under `HVME_HOME` (default: the repository root).
46
+
47
+ ## Quick start
48
+
49
+ No GPU and no LLM needed. The example generates a synthetic marketing scenario (observational data, an experiment and twelve documents from a known DAG) and uses a text oracle in place of the LLM:
50
+
51
+ ```bash
52
+ HVME_HOME=./hvme_work python examples/01_quickstart.py
53
+ ```
54
+
55
+ ```python
56
+ from hvme import api
57
+
58
+ api.validate_run("marketing", "data.csv") # does the graph survive the data?
59
+ api.engine_identify("marketing", "ad_spend", "sales", "data.csv") # -> backdoor
60
+ api.engine_estimate("marketing", "data.csv", "ad_spend", "sales") # ATE with a bootstrap CI
61
+ api.engine_counterfactual("marketing", "data.csv", "ad_spend", "sales", "nie", ["web_traffic"])
62
+ api.ask("광고비를 늘리면 매출이 오르는가?", "marketing", "data.csv")
63
+ ```
64
+
65
+ Examples: [`01_quickstart.py`](https://github.com/namuax/hvme/blob/main/examples/01_quickstart.py) (full chain, no GPU) · [`02_graph_from_table.py`](https://github.com/namuax/hvme/blob/main/examples/02_graph_from_table.py) · [`03_gym_generate.py`](https://github.com/namuax/hvme/blob/main/examples/03_gym_generate.py) · [MCP setup](https://github.com/namuax/hvme/blob/main/examples/04_mcp_server.md) · [vLLM serving](https://github.com/namuax/hvme/blob/main/examples/05_serve_vllm.md)
66
+
67
+ MCP server (17 tools: `graph_*`, `validate_run`, `engine_*`, `ask`, `fast_*`, `classify_question`, `lm_verify`, `ask_v1`):
68
+
69
+ ```bash
70
+ hvme-mcp
71
+ ```
72
+
73
+ Serving the LLM with vLLM and pointing hvme at it:
74
+
75
+ ```bash
76
+ vllm serve <model> --served-model-name hvme-lm --port 8011
77
+ HVME_LM_URL=http://127.0.0.1:8011/v1 HVME_LM=<model> python -c "from hvme import api; print(api.ask_v1('...', 'marketing', 'data.csv'))"
78
+ ```
79
+
80
+ ## Results
81
+
82
+ Measured on our own runs; the raw numbers are in [`bench/`](https://github.com/namuax/hvme/tree/main/bench/). The 9B model is Qwen3.5-9B fine-tuned with LoRA on engine-verified tool trajectories (tool mode: the model calls the engine). The base model answers without tools.
83
+
84
+ | Benchmark | Base Qwen3.5-9B (no tools) | hvme 9B |
85
+ |---|---|---|
86
+ | CaLM-lite (45 English tasks × 30) | 51.0 | **91.5** |
87
+ | CauGym (6 sets × 7 types × 15) | 31.3 | **75.6** |
88
+ | Target metric (mean of the two above) | 41.1 | **83.6** |
89
+ | CLadder 150 (base: CausalCoT 8k, hvme: tool mode) | 86.7 | **90.7** |
90
+ | Corr2Cause (300, F1) | — | **0.923** |
91
+ | KoCLadder (528, Korean, machine-translated) | — | 0.758 (English same items 0.907) |
92
+ | KoCorr2Cause (1,157, Korean, machine-translated) | — | 0.963 |
93
+
94
+ Single-pass judge (Qwen3.5-4B, one forward pass, calibrated): CLadder 600 0.843, CauGym yes/no 2,500 0.751. Rung router: CLadder Rung 0.992, KoCLadder Rung 0.983.
95
+
96
+ General ability is kept: MATH-500 and KMMLU stay within about 1 point of the base model.
97
+
98
+ Caveats: the Korean sets are machine translations that passed automatic checks (numbers, back-translation polarity, comparison order) and have not been reviewed by people yet. Single training runs differ by up to about 8 items on CLadder 150 and 2 points on KMMLU; smaller gaps are noise.
99
+
100
+ ## How it works
101
+
102
+ ![How hvme answers a causal question](https://raw.githubusercontent.com/namuax/hvme/main/assets/architecture.svg)
103
+
104
+ More: [architecture](https://github.com/namuax/hvme/blob/main/docs/architecture.md) · [HCG format](https://github.com/namuax/hvme/blob/main/docs/hcg.md) · [engine](https://github.com/namuax/hvme/blob/main/docs/engine.md) · [LM tools](https://github.com/namuax/hvme/blob/main/docs/tools.md) · [training](https://github.com/namuax/hvme/blob/main/docs/training.md) · [evaluation](https://github.com/namuax/hvme/blob/main/docs/evaluation.md)
105
+
106
+ | Package | Role |
107
+ |---|---|
108
+ | `hvme.graph` | HCG schema; table → HCG (PC with background knowledge, LLM pairwise direction, bootstrap); text → HCG (extraction, normalisation, cross-document aggregation) |
109
+ | `hvme.validate` | DAG checks: cycles and time order, conditional-independence tests, permutation test, edge tests, experiment comparison |
110
+ | `hvme.engine` | d-separation, identification (backdoor, O-set, front-door, IV, ID), binary and linear SCMs, estimation, refutation, causal discovery over Markov equivalence classes |
111
+ | `hvme.gym` | Question generator whose answers are computed by the engine (associational, interventional, counterfactual, structural), English and Korean |
112
+ | `hvme.lm` | Tool definitions, trajectories, SFT/GRPO training, sampling with engine calls |
113
+ | `hvme.fast` | Single-pass judge (yes/no, choice, score), temperature calibration, routing to a larger model when unsure |
114
+ | `hvme.orchestrator` | Question analysis → graph → validation → identification → estimation → refutation → explanation |
115
+ | `hvme.mcp`, `hvme.api` | MCP server and the path-based API it wraps |
116
+ | `skills/` | Nine agent skills built on the MCP tools |
117
+
118
+ ## Models
119
+
120
+ | Model | Base | Use | Hugging Face |
121
+ |---|---|---|---|
122
+ | hvme LM 9B | Qwen3.5-9B | main reasoning model (tool mode) | [`namuax/hvme-lm-9b`](https://huggingface.co/namuax/hvme-lm-9b) |
123
+ | hvme LM 4B | Qwen3.5-4B | light model | [`namuax/hvme-lm-4b`](https://huggingface.co/namuax/hvme-lm-4b) |
124
+ | hvme Fast 4B | Qwen3.5-4B | single-pass judge | [`namuax/hvme-fast-4b`](https://huggingface.co/namuax/hvme-fast-4b) |
125
+ | hvme Router 4B | Qwen3.5-4B | Rung classifier (English and Korean) | [`namuax/hvme-router-4b`](https://huggingface.co/namuax/hvme-router-4b) |
126
+
127
+ Everything except `api.ask_v1`, `fast_*`, `classify_question` and `lm_verify` runs without the weights.
128
+
129
+ ## Reproducing
130
+
131
+ - Benchmarks are not redistributed. `hvme.bench.datasets` downloads CLadder, Corr2Cause, CauGym, MATH-500 and KMMLU from their original sources.
132
+ - Training questions come from the Gym generators (`hvme.gym`), so every label is computed by the engine. Benchmark items are never used for training.
133
+ - Notebooks `notebooks/01–09` walk through the schema, engine, Gym, validation, graph construction and the single-pass judge. They are stored without outputs.
134
+
135
+ ## Limitations
136
+
137
+ - The engine works on binary and linear SCMs. Other mechanisms need a different estimator.
138
+ - The LM still fails to translate some free-form passages into engine arguments (most remaining CLadder and CauGym errors are "no answer").
139
+ - Korean performance trails English by about 15 points on KoCLadder.
140
+ - Graphs from text depend on the extraction LLM. Edges that only an LLM prior supports are marked as such and should be checked.
141
+
142
+ ## License
143
+
144
+ Code is released under the [Apache License 2.0](https://github.com/namuax/hvme/blob/main/LICENSE). Model weights also follow the license of their Qwen3.5 base models.
@@ -0,0 +1,2 @@
1
+ """Hvme: causal graph framework, causal reasoning LLM and orchestrator."""
2
+ __version__ = "0.0.1"