Codync
免费开源的 1:1 Grok Bot 与 Muse 替代方案。可在 iPhone、Mac 或 Linux 桌面上将 Claude 代码、Codex、Cursor 以及 40 多个编码代理作为持久机器人使用。支持群组聊天、线程、应用。
AI 翻译
尚未检测到更新。GitHub 发布版本后会显示在这里。
个人 GitHub 账号下公开仓库的所有者可以登录并验证所有权,自行管理介绍,无需管理员批准。
登录并生成验证文件,在 30 分钟内将其提交到此仓库的默认分支。其他分支或分叉仓库中的文件无效。然后在下方检查文件,即可无需管理员批准直接管理项目。请保留文件以维持管理权限。
如需登录,将前往登录页面。登录后请回到此处,再次点击所选的验证按钮。
在项目文件夹中运行 /nomorevibe verify,即可验证所有权并自行管理介绍。
一分钟完成验证Exact probabilistic inference by compilation into tree decision diagrams
翻译准备中
取自仓库 README
正在加载完整 README。
查看完整 README ↗Exact probabilistic inference by compilation into tree decision diagrams.
tddlog answers probabilistic Datalog programs exactly: probabilistic facts, annotated disjunctions, and recursive rules with negation, comparisons and arithmetic. Front ends reduce ProbLog programs with function symbols and lists, Bayesian and Markov networks, Dice programs and LPADs to it. tddlog grounds the program, simplifies it, compiles it bottom up into tree decision diagrams (TDDs) with the tididi library, and reads every query's probability off the diagrams. It is a Rust library and command-line tool with Python, C and WebAssembly bindings, and it runs in the browser.
On every type of program, tddlog answers more instances than each exact inference system native to it, in less total time (Performance).
cargo install --locked --git https://github.com/Tractables/tddlog tddlog.tddlog = { git = "https://github.com/Tractables/tddlog" } under
[dependencies]. See the Rust API.A build from source needs Rust 1.88 or newer and a C++ compiler (gcc 12 or newer, or a recent clang) for the tree-decomposition solver that goatd vendors.
A program states probabilistic facts, rules, evidence and queries.
This is examples/alarm.pl:
0.1::burglary.
0.2::earthquake.
0.7::hears_alarm(john).
0.4::hears_alarm(mary).
alarm :- burglary.
alarm :- earthquake.
calls(X) :- alarm, hears_alarm(X).
evidence(calls(john), true).
query(burglary).
query(earthquake).
query(calls(mary)).
tddlog prints the probability of each query given the evidence:
$ tddlog examples/alarm.pl
burglary: 0.357143
earthquake: 0.714286
calls(mary): 0.400000
Each probabilistic fact p::f holds with probability p, independently
of the others, and the rules derive the other atoms. The alarm goes off
with probability 1 − 0.9 × 0.8 = 0.28, so John calls with probability
0.28 × 0.7 = 0.196, and P(burglary | John calls) = 0.1 × 0.7 / 0.196 =
0.357143.
A program can take values from the command line: the arguments after its
file take its places $1, $2, ... (outside comments and quoted
atoms), each read as a term, so that one program serves every size,
probability, query and observation. In
examples/chain.pl they are the length of a chain,
the probability of each link and the node queried, and --program
prints the program with them in place:
$ tddlog examples/chain.pl 10 0.9 4
reach(4): 0.656100
$ tddlog --program examples/chain.pl 20 0.9 7 > chain_20.pl
The guide describes the language and the command line, with worked examples that open in the playground. examples/ lists every example program by what it shows.
Every input is reduced to a probabilistic Datalog program before inference:
| Input | Read by | Reduced to probabilistic Datalog as |
|---|---|---|
| ProbLog programs | tddlog | function symbols and lists ground to constants, with ProbLog's list predicates, call/N, findall/3, all/3 and forall/2 over probabilistic goals, and library(aggregate)'s aggregates |
Bayesian networks in BIF, Hugin, GeNIe or UAI, with evidence in Ace's .inst or UAI's .evid | tddlog, by the file's extension | one annotated disjunction per row of each table |
| Markov networks in UAI | tddlog | one observed atom per factor; --evidence-probability prints the partition function |
| Dice programs | tddlog, by the extension .dice | each integer as its bits, each operation as rules over them, a loop as recursion over a step index |
Alea.jl programs (model() and QUERY) | scripts/alea2problog.jl, in Julia with Alea.jl | the Boolean circuit Alea.jl builds: each flip a probabilistic fact, each gate a rule, each observation evidence |
Roulette programs (#lang roulette/example/disrupt) | scripts/roulette2problog.rkt, in Racket with Roulette; with --tddlog, the program runs with tddlog answering its queries | the Boolean circuit Roulette builds: each flip a probabilistic fact, each gate a rule, each observation evidence |
| LPADs written for cplint and PITA | tddlog, where the file holds :- begin_lpad. | the same clauses in ProbLog's syntax, with the database clauses they call and the file's example queries; under PITA's depth bound, each predicate with the depth as an argument; PRISM's switches as annotated disjunctions of msw/2 |
$ tddlog examples/asia.net --query leaves
$ tddlog tests/dice/arith.dice
$ tddlog --program tests/lpad/coin.cplint.pl
--program prints the program an input is read as, and --ground the
ground program after it, which ProbLog also reads, so each reduction can
be checked on its own. As a library, tddlog::read reads an input in
any of these formats as a program and tddlog::solve answers it; the
Python (tddlog.solve(text, format="dice")),
C and WebAssembly
bindings take the text with its format's name. A front end of one's own
writes the program's text, as examples/sprinkler.rs
does from Rust data.
Not yet read: cut, if-then-else, assert, strings and a findall in a
cycle of calls in ProbLog; /, % and sample in Dice.
docs/design.md describes each stage and the cases measured behind it.
Grounding and simplification
Compilation
Vtrees
Queries and evidence
tddlog was compared with every exact inference system we could find, on six types of program, each against the systems that natively handle it, and on all programs together, against every system. Every answer is checked against an exact reference. Each table gives a system's answers, its total time and tddlog's over the instances it is given and either answers, and how many times faster tddlog is. The results page has every instance, time and program, and a page for each system.
baselines branch
has the code that runs each system,
how each was given each suite,
and the machines, versions and tables.tddlog answers 342 of 365 ProbLog programs, of 25 families: paths in random graphs and grids, Biomine's paths, smokers, UW-CSE, Cora's citation matching, blood types and pedigrees, sickness, Mastermind, MNIST addition and handwritten formulas, Prob-EC's event calculus, taint analyses of Android apps, probabilistic grammars, hidden Markov models, and the programs of the ProbLog tutorial and of ProbLog's and cplint's examples.
| System | Answers | Its total time | tddlog's total time | tddlog faster |
|---|---|---|---|---|
| ProbLog | 260 | 15 h | 40 min | 48× |
| PITA | 221 | 22 h | 30 min | 174× |
| aspmc | 219 | 22 h | 30 min | 96× |
| Scallop | 156 | 32 h | 30 min | too few in common |
| PSouffle | 108 | 42 h | 30 min | 667× |
subquery/3.tddlog answers 308 of 320 Boolean queries over tuple-independent databases: 16 TPC-H queries, the queries h0 and h1, the safe queries QW and Q9, and paths of two edges in random graphs.
| System | Answers | Its total time | tddlog's total time | tddlog faster |
|---|---|---|---|---|
| ProvSQL | 268 | 16 h | 45 min | 20× |
| ProbLog | 204 | 39 h | 45 min | 72× |
| PSouffle | 189 | 41 h | 45 min | 94× |
| PITA | 123 | 62 h | 45 min | 223× |
| Scallop | 30 | 90 h | 45 min | too few in common |
| aspmc | 16 | 97 h | 45 min | too few in common |
tddlog answers 609 of 636 networks: bnlearn's, the large ones and the Roulette and noDice papers' versions among them, Ace's, the noisy-or networks, and the networks of the UAI 2022 competition and of Ihler's collection whose factors are conditional probability tables (diagnosis, pedigree, BN, blockmap, Mastermind and fs networks, and the classic networks).
| System | Answers | Its total time | tddlog's total time | tddlog faster |
|---|---|---|---|---|
| Ace | 416 | 34 h | 1.3 h | 23× |
| TensorInference.jl | 323 | 56 h | 1.5 h | 34× |
| Merlin | 293 | 57 h | 1.5 h | 34× |
| libDAI | 291 | 58 h | 1.5 h | 33× |
| pyAgrum | 263 | 63 h | 1.5 h | 37× |
| 14 others: PITA, pgmpy, aspmc, Alea.jl, Roulette, Pluck, ProbLog, Dice, Genfer, SPPL, noDice, Scallop, Psi, Geni | 43 to 238 | over 19 h each | 2 min to 1.5 h | at least 42× |
PSouffle was given 11 of the networks and answers 6.
tddlog answers 243 of 290 networks, those of the UAI 2022 competition and of Ihler's collection whose factors are not conditional probability tables over an acyclic graph: object detection, segmentation, grid, DBN, CSP and Alchemy networks, protein side chains, the rus networks, weighted CSPs, and pedigree and diagnosis networks.
| System | Answers | Its total time | tddlog's total time | tddlog faster |
|---|---|---|---|---|
| TensorInference.jl | 198 | 9.3 h | 2.6 h | 2.5× |
| libDAI | 180 | 13 h | 1.4 h | 16× |
| Merlin | 171 | 13 h | 1.6 h | 11× |
| pyAgrum | 170 | 13 h | 1.4 h | 13× |
| pgmpy | 117 | 22 h | 1.4 h | 28× |
tddlog answers 279 of 315 programs over discrete values with conditionals and loops, of 17 families: the Caesar cipher, diamond and ladder networks, Geni's router grids with failing links or routers and its weather factory, hidden Markov models and Pluck's sequence models, a Markov chain, a lossy network, contract signing, a perturbed-memory interpreter, Cao et al.'s integer programs, the coupon collector, 3-SAT, the bounded retransmission protocol and the Dice paper's small programs.
| System | Answers | Its total time | tddlog's total time | tddlog faster |
|---|---|---|---|---|
| Alea.jl | 209 | 25 h | 1.2 h | 12× |
| Roulette | 171 | 37 h | 1.2 h | 18× |
| Dice | 171 | 38 h | 1.2 h | 36× |
| Pluck | 123 | 53 h | 1.2 h | 39× |
| Geni | 91 | 63 h | 1.2 h | 70× |
| 4 others: Genfer, noDice, SPPL, Psi | 8 to 83 | over 65 h each | 1.2 h | at least 408× |
tddlog answers 224 of 257 programs over integers written in Alea.jl, which compiles each to a Boolean circuit. Alea.jl runs its own program; every other system is given the circuit.
| System | Answers | Its total time | tddlog's total time | tddlog faster |
|---|---|---|---|---|
| Alea.jl | 139 | 32 h | 3.7 h | 6.6× |
| Roulette | 98 | 43 h | 2.1 h | 20× |
| Pluck | 54 | 58 h | 2.1 h | 31× |
| Dice | 19 | 69 h | 2.1 h | too few in common |
| Genfer | 12 | 71 h | 2.1 h | too few in common |
| 4 others: noDice, Psi, SPPL, Geni | 0 to 7 | over 72 h each | 2.1 h to 2.7 h | too few in common |
tddlog answers 2005 of 2183: the six types together, every system on every program it is given, natively or through a translation.
| System | Answers | Its total time | tddlog's total time | tddlog faster |
|---|---|---|---|---|
| Ace | 1070 | 179 h | 7.1 h | 28× |
| libDAI | 913 | 227 h | 7.4 h | 36× |
| TensorInference.jl | 890 | 243 h | 8.4 h | 30× |
| pyAgrum | 866 | 233 h | 7.4 h | 35× |
| Merlin | 862 | 238 h | 7.6 h | 30× |
| 18 others: ProbLog, PITA, pgmpy, Alea.jl, aspmc, Roulette, Storm, Pluck, Dice, PRISM, PSouffle, ProvSQL, Scallop, noDice, Genfer, Geni, SPPL, Psi | 88 to 761 | over 16 h each | 45 min to 7.6 h | at least 20× |
From a checkout, cargo build --release builds target/release/tddlog,
and cargo test checks it against ProbLog's answers on the examples and
on ProbLog's own system tests. CONTRIBUTING.md lists
the checks a change runs.
tddlog has no paper yet: cite the software, as CITATION.cff describes it (GitHub's "Cite this repository"). TDDs were introduced in A Canonical Generalization of OBDD.
This material is based upon work supported by the Defense Advanced Research Projects Agency (DARPA) under Agreement No. HR0011269E224.
Apache-2.0 (LICENSE). The copies of third-party programs in
tests/problog and tests/dice keep their own licenses
(NOTICE); THIRD-PARTY.md lists the components
compiled into the binaries.