Download README.md from FlaneAI/Causal-Graph: direct link, hf CLI and curl.
- Browser
- Download file 9.2 kB
-
https://huggingface.co/datasets/FlaneAI/Causal-Graph/resolve/main/README.md
- Command line
-
hf download hf://datasets/FlaneAI/Causal-Graph/README.md
-
curl -L -o README.md https://huggingface.co/datasets/FlaneAI/Causal-Graph/resolve/main/README.md
language:
- en
license: other
license_name: undecided
license_link: LICENSE
pretty_name: Causal Graph
size_categories:
- 1K<n<10K
task_categories:
- question-answering
- text-retrieval
tags:
- knowledge-base
- knowledge-graph
- formulas
- symbolic-ai
- explainable-ai
- rule-based
- question-answering
- calculator
- physics
- chemistry
- finance
- statistics
- engineering
- ecology
- machine-learning
- reliability
- no-training
- json
- python
Causal Graph
This 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.
Nothing 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.
$ python3 -m symmix "What is the monthly payment on a 300000 loan at 5% over 20 years?"
Read from your question:
- Principal (loan or deposit amount) = 300,000.00 (from '300000')
- Annual interest or return rate = 5% (from '5%')
- Time in years = 20 years (from '20 years')
Fixed-rate loan payment (amortisation):
...
Result: Periodic payment (monthly by default) = 1,979.87, Total interest paid over the term = 175,168.13
Highlights
- Explainable by construction. Every number is traced to a named variable, every formula shows its steps, and every answer lists its assumptions.
- Fully inspectable. The knowledge base is plain JSON. The full graph is exported as one JSON file of typed nodes and edges.
- No training, no dependencies. The engine uses only the Python standard library. It runs offline and is deterministic.
- Abstains instead of guessing. Questions with no good match below a fixed threshold return no answer.
- Checked. The knowledge base is validated by
python3 -m symmix --check, and every formula carries worked examples that the test suite verifies.
Key numbers
| Component | Count |
|---|---|
| Formulas | 401 |
| Worked examples (checked by the tests) | 1,003 |
| Concepts | 377 |
| Variables | 1,285 |
| Processes | 23 |
| Rules | 56 |
| Lexicon feature atoms | 335 |
| Graph nodes | 2,616 |
| Graph edges | 4,831 |
| Vocabulary terms | 54,107 |
| Unit tests | 206 |
Coverage
Formulas by domain (largest 17 of 44 domains):
| Domain | Formulas | Domain | Formulas |
|---|---|---|---|
| finance | 34 | chemistry | 27 |
| mechanics | 30 | electrical | 22 |
| physics | 29 | geometry | 21 |
| statistics | 28 | software | 19 |
| optics | 14 | fluids | 14 |
| thermal | 13 | construction | 13 |
| everyday | 11 | math | 10 |
| transport | 9 | ml | 8 |
| energy | 8 |
Other domains include earth science, reliability, acoustics, project management, manufacturing, weather, ecology, queueing, inventory, genetics, logistics, growth, space and quality.
Quick start
Causal Graph needs Python 3 and nothing else. Clone or download this repository, then run from its root:
python3 -m symmix "How much will 2000 be worth after 8 years at 4%?"
python3 -m symmix --debug "..." # retrieval scores for the question
python3 -m symmix --check # validate the knowledge base
python3 -m symmix --export DIR # write the graph, vocabulary and vectors to DIR
python3 -m symmix --kb PATH "..." # use another knowledge-base folder
python3 -m symmix # interactive mode; a blank line quits
python3 -m unittest # run the test suite
From Python:
from symmix.model import Model
model = Model()
print(model.render(model.answer("How much will 2000 be worth after 8 years at 4%?")))
Output (abridged):
Future value with compound interest:
future_value = principal * (1 + annual_rate / periods_per_year) ^ (periods_per_year * years) -> 2000 * (1 + 0.04 / 1) ^ (1 * 8) = 2737.14
Result: Future value = 2,737.14, Interest earned = 737.14
Assumes: fixed rate; equal compounding periods; no deposits, withdrawals or fees.
How an answer is produced
- Extract. Numbers in the question are linked to named variables by nearby labels and compatible units. Links are one-to-one. Explicit
name=valuepairs always take precedence, so they are the most reliable way to state inputs. - 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. - 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.
- 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.
- 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.
- 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.
Knowledge base format
All knowledge is JSON under kb/, loaded strictly: unknown keys and duplicate IDs are errors.
| Folder | Item | Key fields |
|---|---|---|
kb/variables/ |
Quantity | id, name, kind, unit, base, aliases, weak, unit_only_ok, phrases |
kb/formulas/ |
Formula | id, name, domain, aliases, concepts, features, inputs, defaults, steps, outputs, guards, decisions, assumptions, examples |
kb/concepts/ |
Concept | id, name, domain, aliases, features, statements, pitfalls, actions, causes, uses, related, contrast |
kb/processes.json |
Process | id, name, domain, aliases, features, when, steps, checks |
kb/rules.json |
Rule | id, if_atoms, if_expr, then, text |
kb/lexicon.json |
Feature atoms | context, domain and intent cues used by retrieval |
kb/config.json |
Settings | retrieval weights, graph decay and hops, thresholds |
A formula example, from kb/formulas/ (abridged):
{
"id": "finance.future_value",
"inputs": ["principal", "annual_rate", "years", "periods_per_year"],
"steps": [["future_value", "principal * (1 + annual_rate / periods_per_year) ** (periods_per_year * years)"],
["interest_earned", "future_value - principal"]],
"outputs": ["future_value", "interest_earned"],
"examples": [{"inputs": {"principal": 1000, "annual_rate": 0.05, "periods_per_year": 12, "years": 10},
"expect": {"future_value": 1647.0095}}]
}
Graph export
python3 -m symmix --export DIR writes four files, computed from the knowledge base alone. A pre-built export is in export/.
| File | Contents |
|---|---|
graph.json |
The full typed graph: 2,616 nodes and 4,831 edges, pretty-printed JSON |
vocabulary.json |
54,107 n-gram terms (word, character and feature) |
vectors.json |
Sparse TF-IDF vectors for 2,477 items in word, character and feature spaces |
manifest.json |
Counts, retrieval settings and a statement of what the files are |
graph.json has the shape {"format": "symmix-export/1", "nodes": [...], "edges": [...]}.
Node types: variable (1,285), atom (474), formula (401), concept (377), rule (56), process (23).
A variable node and an edge:
{"id": "var:hourly_wage", "type": "variable", "name": "Hourly wage", "kind": "money", "unit": "currency per hour"}
{"source": "chem.titration_endpoint", "target": "var:analyte_concentration", "relation": "input"}
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.
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.
Adding knowledge
- Add or edit JSON in
kb/. Every new formula needs worked examples. - Run
python3 -m symmix --check. It checks references, cycles, lexicon coverage, weight sums and formula examples. - Run
python3 -m unittest. - Regenerate the export with
python3 -m symmix --export export.
Repository layout
symmix/ engine: model.py (pipeline), extract.py (number linking), index.py, graph.py,
formulas.py and safe_eval.py (formula engine), rules.py, units.py, kb.py, check.py, export.py, cli.py
kb/ the knowledge base (variables, formulas, concepts, processes, rules, lexicon, config)
export/ the pre-built graph, vocabulary, vectors and manifest
tests/ 206 tests in 14 modules
evaluation/ question-set scripts used during development
License
Apache 2.0