FlaneAI commited on
Commit
e2c3c1c
·
verified ·
1 Parent(s): 6f74f8b

Upload 2 files

Browse files
Files changed (2) hide show
  1. Causal-Graph.json +0 -0
  2. README.md +227 -1
Causal-Graph.json ADDED
The diff for this file is too large to render. See raw diff
 
README.md CHANGED
@@ -1,3 +1,229 @@
1
  ---
2
- license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ license: other
5
+ license_name: undecided
6
+ license_link: LICENSE
7
+ pretty_name: symmix Knowledge Base
8
+ size_categories:
9
+ - 1K<n<10K
10
+ task_categories:
11
+ - question-answering
12
+ - text-retrieval
13
+ tags:
14
+ - knowledge-base
15
+ - knowledge-graph
16
+ - formulas
17
+ - symbolic-ai
18
+ - explainable-ai
19
+ - rule-based
20
+ - question-answering
21
+ - calculator
22
+ - physics
23
+ - chemistry
24
+ - finance
25
+ - statistics
26
+ - engineering
27
+ - ecology
28
+ - machine-learning
29
+ - reliability
30
+ - no-training
31
+ - json
32
+ - python
33
  ---
34
+
35
+ # symmix
36
+
37
+ **symmix** is a hand-written knowledge base of quantitative formulas, concepts, processes and rules, together with a small, dependency-free Python engine that answers practical numerical questions from it.
38
+
39
+ Nothing in symmix is trained. Every formula, concept, variable, rule and worked example was written by hand. Each answer shows the numbers it read from the question, the formulas it ran, the assumptions it made and the reasoning it used, so every result can be checked.
40
+
41
+ ```text
42
+ $ python3 -m symmix "What is the monthly payment on a 300000 loan at 5% over 20 years?"
43
+ Read from your question:
44
+ - Principal (loan or deposit amount) = 300,000.00 (from '300000')
45
+ - Annual interest or return rate = 5% (from '5%')
46
+ - Time in years = 20 years (from '20 years')
47
+
48
+ Fixed-rate loan payment (amortisation):
49
+ ...
50
+ Result: Periodic payment (monthly by default) = 1,979.87, Total interest paid over the term = 175,168.13
51
+ ```
52
+
53
+ ## Highlights
54
+
55
+ - **Explainable by construction.** Every number is traced to a named variable, every formula shows its steps, and every answer lists its assumptions.
56
+ - **Fully inspectable.** The knowledge base is plain JSON. The full graph is exported as one JSON file of typed nodes and edges.
57
+ - **No training, no dependencies.** The engine uses only the Python standard library. It runs offline and is deterministic.
58
+ - **Abstains instead of guessing.** Questions with no good match below a fixed threshold return no answer.
59
+ - **Checked.** The knowledge base is validated by `python3 -m symmix --check`, and every formula carries worked examples that the test suite verifies.
60
+
61
+ ## Key numbers
62
+
63
+ | Component | Count |
64
+ |---|---:|
65
+ | Formulas | 401 |
66
+ | Worked examples (checked by the tests) | 1,003 |
67
+ | Concepts | 377 |
68
+ | Variables | 1,285 |
69
+ | Processes | 23 |
70
+ | Rules | 56 |
71
+ | Lexicon feature atoms | 335 |
72
+ | Graph nodes | 2,616 |
73
+ | Graph edges | 4,831 |
74
+ | Vocabulary terms | 54,107 |
75
+ | Unit tests | 206 |
76
+
77
+ ## Coverage
78
+
79
+ Formulas by domain (largest 17 of 44 domains):
80
+
81
+ | Domain | Formulas | Domain | Formulas |
82
+ |---|---:|---|---:|
83
+ | finance | 34 | chemistry | 27 |
84
+ | mechanics | 30 | electrical | 22 |
85
+ | physics | 29 | geometry | 21 |
86
+ | statistics | 28 | software | 19 |
87
+ | optics | 14 | fluids | 14 |
88
+ | thermal | 13 | construction | 13 |
89
+ | everyday | 11 | math | 10 |
90
+ | transport | 9 | ml | 8 |
91
+ | energy | 8 | | |
92
+
93
+ Other domains include earth science, reliability, acoustics, project management, manufacturing, weather, ecology, queueing, inventory, genetics, logistics, growth, space and quality.
94
+
95
+ ## Quick start
96
+
97
+ symmix needs Python 3 and nothing else. Clone or download this repository, then run from its root:
98
+
99
+ ```bash
100
+ python3 -m symmix "How much will 2000 be worth after 8 years at 4%?"
101
+ python3 -m symmix --debug "..." # retrieval scores for the question
102
+ python3 -m symmix --check # validate the knowledge base
103
+ python3 -m symmix --export DIR # write the graph, vocabulary and vectors to DIR
104
+ python3 -m symmix --kb PATH "..." # use another knowledge-base folder
105
+ python3 -m symmix # interactive mode; a blank line quits
106
+ python3 -m unittest # run the test suite
107
+ ```
108
+
109
+ From Python:
110
+
111
+ ```python
112
+ from symmix.model import Model
113
+
114
+ model = Model()
115
+ print(model.render(model.answer("How much will 2000 be worth after 8 years at 4%?")))
116
+ ```
117
+
118
+ Output (abridged):
119
+
120
+ ```text
121
+ Future value with compound interest:
122
+ future_value = principal * (1 + annual_rate / periods_per_year) ^ (periods_per_year * years) -> 2000 * (1 + 0.04 / 1) ^ (1 * 8) = 2737.14
123
+ Result: Future value = 2,737.14, Interest earned = 737.14
124
+ Assumes: fixed rate; equal compounding periods; no deposits, withdrawals or fees.
125
+ ```
126
+
127
+ ## How an answer is produced
128
+
129
+ 1. **Extract.** Numbers in the question are linked to named variables by nearby labels and compatible units. Links are one-to-one. Explicit `name=value` pairs always take precedence, so they are the most reliable way to state inputs.
130
+ 2. **Retrieve.** Formulas, concepts and processes are scored on alias phrases, word and character n-grams, lexicon features, a two-hop graph spread and input availability. Weights live in `kb/config.json`.
131
+ 3. **Choose.** A formula is used only if it scores at least 0.8 of the best match. Anything below an absolute threshold of 0.12 is not shown, and the engine abstains.
132
+ 4. **Re-read.** Inputs are extracted again with the chosen formula in view. If an output is given and one input is missing, the formula is solved for that input and the answer says so.
133
+ 5. **Compute.** Formulas run through a whitelisted evaluator with guards. Producers run before consumers. Values that disagree by more than 1% with stated figures are flagged.
134
+ 6. **Report.** The answer lists what was read, each formula's steps and assumptions, plans for formulas that cannot run ("To use X, I still need ..."), applicable rules, and the matching concept with a pitfall.
135
+
136
+ ## Knowledge base format
137
+
138
+ All knowledge is JSON under `kb/`, loaded strictly: unknown keys and duplicate IDs are errors.
139
+
140
+ | Folder | Item | Key fields |
141
+ |---|---|---|
142
+ | `kb/variables/` | Quantity | `id`, `name`, `kind`, `unit`, `base`, `aliases`, `weak`, `unit_only_ok`, `phrases` |
143
+ | `kb/formulas/` | Formula | `id`, `name`, `domain`, `aliases`, `concepts`, `features`, `inputs`, `defaults`, `steps`, `outputs`, `guards`, `decisions`, `assumptions`, `examples` |
144
+ | `kb/concepts/` | Concept | `id`, `name`, `domain`, `aliases`, `features`, `statements`, `pitfalls`, `actions`, `causes`, `uses`, `related`, `contrast` |
145
+ | `kb/processes.json` | Process | `id`, `name`, `domain`, `aliases`, `features`, `when`, `steps`, `checks` |
146
+ | `kb/rules.json` | Rule | `id`, `if_atoms`, `if_expr`, `then`, `text` |
147
+ | `kb/lexicon.json` | Feature atoms | context, domain and intent cues used by retrieval |
148
+ | `kb/config.json` | Settings | retrieval weights, graph decay and hops, thresholds |
149
+
150
+ A formula example, from `kb/formulas/` (abridged):
151
+
152
+ ```json
153
+ {
154
+ "id": "finance.future_value",
155
+ "inputs": ["principal", "annual_rate", "years", "periods_per_year"],
156
+ "steps": [["future_value", "principal * (1 + annual_rate / periods_per_year) ** (periods_per_year * years)"],
157
+ ["interest_earned", "future_value - principal"]],
158
+ "outputs": ["future_value", "interest_earned"],
159
+ "examples": [{"inputs": {"principal": 1000, "annual_rate": 0.05, "periods_per_year": 12, "years": 10},
160
+ "expect": {"future_value": 1647.0095}}]
161
+ }
162
+ ```
163
+
164
+ ## Graph export
165
+
166
+ `python3 -m symmix --export DIR` writes four files, computed from the knowledge base alone. A pre-built export is in `export/`.
167
+
168
+ | File | Contents |
169
+ |---|---|
170
+ | `graph.json` | The full typed graph: 2,616 nodes and 4,831 edges, pretty-printed JSON |
171
+ | `vocabulary.json` | 54,107 n-gram terms (word, character and feature) |
172
+ | `vectors.json` | Sparse TF-IDF vectors for 2,477 items in word, character and feature spaces |
173
+ | `manifest.json` | Counts, retrieval settings and a statement of what the files are |
174
+
175
+ `graph.json` has the shape `{"format": "symmix-export/1", "nodes": [...], "edges": [...]}`.
176
+
177
+ Node types: `variable` (1,285), `atom` (474), `formula` (401), `concept` (377), `rule` (56), `process` (23).
178
+
179
+ A variable node and an edge:
180
+
181
+ ```json
182
+ {"id": "var:hourly_wage", "type": "variable", "name": "Hourly wage", "kind": "money", "unit": "currency per hour"}
183
+ {"source": "chem.titration_endpoint", "target": "var:analyte_concentration", "relation": "input"}
184
+ ```
185
+
186
+ Edge relations and counts: `feature` 2,001, `input` 1,084, `output` 523, `explains` 403, `asserts` 143, `related` 272, `uses` 122, `requires` 60, `feeds` 59, `contrast` 49, `cites` 47, `suggests` 35, `causes` 33.
187
+
188
+ The vectors are sparse lexical weights over written terms. They are not learned embeddings, and two items are similar only when they share words, character sequences or features. The graph is hand-built and has not been checked against an independent reference.
189
+
190
+ ## Evaluation and limitations
191
+
192
+ symmix is a sample of quantitative knowledge, not a large corpus, and it is not a general language model.
193
+
194
+ - **Scope.** It answers questions that match its formulas. It does not do open-ended language tasks, reasoning beyond its knowledge base, or explanation beyond the written concept texts.
195
+ - **Unrelated questions.** On a probe of 89 questions outside the knowledge base, symmix answered 27. Retrieval can clear the threshold on a single shared word, so the abstain threshold is a trade-off, not a guarantee.
196
+ - **Wrong links.** A number can link to the wrong variable and still produce an answer. Check the "Read from your question" list before relying on a result.
197
+ - **Approximations.** Formulas are approximations under the assumptions they list.
198
+ - **Label phrasing.** A number links only to a label beside it, within a few words. Write `name=value` when in doubt.
199
+ - **Units.** Some unit forms are not converted, for example kelvin after a number (`400 K` is read as 400,000) and scientific notation written as `2e-7` (only the mantissa links). Write temperatures in degrees Celsius and expand scientific notation to a decimal.
200
+ - **Shared aliases.** Some alias phrases belong to more than one item. Other signals then decide between them.
201
+ - **Not benchmarked.** No comparison against a language model or an independent benchmark has been run, and none is claimed.
202
+
203
+ The `evaluation/` folder contains question-set scripts used during development. Their results are not reported in this card.
204
+
205
+ ## Adding knowledge
206
+
207
+ 1. Add or edit JSON in `kb/`. Every new formula needs worked examples.
208
+ 2. Run `python3 -m symmix --check`. It checks references, cycles, lexicon coverage, weight sums and formula examples.
209
+ 3. Run `python3 -m unittest`.
210
+ 4. Regenerate the export with `python3 -m symmix --export export`.
211
+
212
+ ## Repository layout
213
+
214
+ ```text
215
+ symmix/ engine: model.py (pipeline), extract.py (number linking), index.py, graph.py,
216
+ formulas.py and safe_eval.py (formula engine), rules.py, units.py, kb.py, check.py, export.py, cli.py
217
+ kb/ the knowledge base (variables, formulas, concepts, processes, rules, lexicon, config)
218
+ export/ the pre-built graph, vocabulary, vectors and manifest
219
+ tests/ 206 tests in 14 modules
220
+ evaluation/ question-set scripts used during development
221
+ ```
222
+
223
+ ## Citation
224
+
225
+ If you use symmix in research or teaching, please cite the repository and state the version (knowledge base: 401 formulas, 377 concepts).
226
+
227
+ ## License
228
+
229
+ License not yet chosen. See `LICENSE` once it is added.