To install, clone this repo and its dependency into the same directory:
git clone https://github.com/patham9/PeTTa.git
git clone https://github.com/rTreutlein/PeTTaChainer.gitRun the NatDist vs ParticleDist benchmark:
python pettachainer/benchmarks/particle_vs_nat.py --sizes 100,500,1000 --particle-budgets 128,256,512 --repeats 2Run the simple forward vs backward chaining benchmark:
.venv/bin/python pettachainer/benchmarks/forward_vs_backward.py --depths 10,25,50 --noise-branching 8 --repeats 3Run the backward materialization benchmark:
.venv/bin/python pettachainer/benchmarks/backward_materialize.py --depths 5,10 --queries 200 --repeats 3Run the bounded priority queue benchmark:
.venv/bin/python pettachainer/benchmarks/bounded_queue.py --fanouts 2000,8000 --steps 100 --repeats 3Add --compare-pruning to compare pruning enabled and disabled within the same checkout.
Optional JSON export:
python pettachainer/benchmarks/particle_vs_nat.py --json-out /tmp/particle_bench.jsonProfile a .metta file through the underlying SWI-Prolog invocation that petta uses:
./profile_petta.sh tests/testmining.metta
./profile_petta.sh --mode time tests/testmining.metta
./profile_petta.sh --mode perf benchmarks/demo_benchgen_forward_backward_compare.mettaRelative paths are resolved from pettachainer/metta by default.
from pettachainer import get_language_spec
llm_spec = get_language_spec(llm_focused=True)
full_spec = get_language_spec(llm_focused=False)from pettachainer import PeTTaChainer, check_query, check_stmt
handler = PeTTaChainer()
stmt_eval = handler.evaluate_statement("(: s1 (Dog fido) (STV 1.0 1.0))")
check_stmt(stmt_eval)
query_eval = handler.evaluate_query("(: $prf (Dog fido) $tv)")
check_query(query_eval)from pettachainer import PeTTaChainer
handler = PeTTaChainer()
handler.add_atom("(: edge_ab (Edge A B) (STV 1.0 1.0))")
handler.add_atom("(: edge_bc (Edge B C) (STV 1.0 1.0))")
handler.add_atom("(: edge_to_path (Implication (Premises (Edge $x $y)) (Conclusions (Path $x $y))) (STV 1.0 1.0))")
handler.add_atom("(: path_step (Implication (Premises (Path $x $y) (Edge $y $z)) (Conclusions (Path $x $z))) (STV 1.0 1.0))")
handler.forward_chain(steps=50)
result = handler.query("(: $prf (Path A C) $tv)", timeout_sec=0)
handler.forward_chain(steps=1, term="(Edge A B)")