hufu 0.5.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.
- hufu-0.5.0/.gitattributes +5 -0
- hufu-0.5.0/.github/workflows/ci.yml +72 -0
- hufu-0.5.0/.github/workflows/publish.yml +47 -0
- hufu-0.5.0/.gitignore +76 -0
- hufu-0.5.0/CITATION.cff +11 -0
- hufu-0.5.0/LICENSE +201 -0
- hufu-0.5.0/NOTICE +51 -0
- hufu-0.5.0/PKG-INFO +203 -0
- hufu-0.5.0/README.md +160 -0
- hufu-0.5.0/README_zh.md +85 -0
- hufu-0.5.0/TEST_REPORT.md +100 -0
- hufu-0.5.0/benchmarks/README.md +51 -0
- hufu-0.5.0/benchmarks/calibrate_doc_threshold.py +141 -0
- hufu-0.5.0/benchmarks/data/ContraDoc.json +8784 -0
- hufu-0.5.0/benchmarks/data/cache/contradoc_doc_eval_20.json +296 -0
- hufu-0.5.0/benchmarks/data/cache/contradoc_doc_eval_3.json +58 -0
- hufu-0.5.0/benchmarks/data/cache/contradoc_eval_reference_10_identity.json +178 -0
- hufu-0.5.0/benchmarks/data/cache/contradoc_eval_reference_50_identity.json +818 -0
- hufu-0.5.0/benchmarks/data/cache/contradoc_eval_reference_6.json +112 -0
- hufu-0.5.0/benchmarks/data/cache/contradoc_eval_reference_6_identity.json +114 -0
- hufu-0.5.0/benchmarks/data/cache/doc_threshold_calibration_20.json +254 -0
- hufu-0.5.0/benchmarks/data/cache/doc_threshold_calibration_20_base.json +254 -0
- hufu-0.5.0/benchmarks/data/cache/doc_threshold_calibration_v25.json +13349 -0
- hufu-0.5.0/benchmarks/data/cache/doc_threshold_calibration_v26.json +21778 -0
- hufu-0.5.0/benchmarks/data/cache/prompt_tune_results.json +35 -0
- hufu-0.5.0/benchmarks/nli_loaders.py +219 -0
- hufu-0.5.0/benchmarks/profile_pair.py +113 -0
- hufu-0.5.0/benchmarks/run_contradoc_doc_eval.py +251 -0
- hufu-0.5.0/benchmarks/run_contradoc_eval.py +248 -0
- hufu-0.5.0/examples/quickstart_core.py +102 -0
- hufu-0.5.0/examples/quickstart_text.py +28 -0
- hufu-0.5.0/pyproject.toml +85 -0
- hufu-0.5.0/rust/graph-simulation/Cargo.lock +955 -0
- hufu-0.5.0/rust/graph-simulation/Cargo.toml +23 -0
- hufu-0.5.0/rust/graph-simulation/README.md +1 -0
- hufu-0.5.0/rust/graph-simulation/benches/simulation.rs +132 -0
- hufu-0.5.0/rust/graph-simulation/src/algorithm/bounded.rs +256 -0
- hufu-0.5.0/rust/graph-simulation/src/algorithm/hyper_simulation.rs +1160 -0
- hufu-0.5.0/rust/graph-simulation/src/algorithm/mod.rs +6 -0
- hufu-0.5.0/rust/graph-simulation/src/algorithm/simulation.rs +258 -0
- hufu-0.5.0/rust/graph-simulation/src/lib.rs +25 -0
- hufu-0.5.0/rust/graph-simulation/src/utils/logger.rs +83 -0
- hufu-0.5.0/rust/graph-simulation/src/utils/mod.rs +5 -0
- hufu-0.5.0/rust/graph-simulation/src/utils/predicate.rs +124 -0
- hufu-0.5.0/rust/graph-simulation/src/utils/validation.rs +198 -0
- hufu-0.5.0/rust/graph-simulation/tests/inter.rs +63 -0
- hufu-0.5.0/rust/graph-simulation/tests/native.rs +63 -0
- hufu-0.5.0/rust/graph-simulation/tests/simulation_test.rs +183 -0
- hufu-0.5.0/rust/simulation/Cargo.lock +696 -0
- hufu-0.5.0/rust/simulation/Cargo.toml +22 -0
- hufu-0.5.0/rust/simulation/pyproject.toml +13 -0
- hufu-0.5.0/rust/simulation/python/__init__.py +1 -0
- hufu-0.5.0/rust/simulation/simulation.pyi +162 -0
- hufu-0.5.0/rust/simulation/src/graph/hypergraph.rs +679 -0
- hufu-0.5.0/rust/simulation/src/graph/mod.rs +17 -0
- hufu-0.5.0/rust/simulation/src/graph/networkx_graph.rs +744 -0
- hufu-0.5.0/rust/simulation/src/lib.rs +31 -0
- hufu-0.5.0/rust/simulation/src/utils.rs +3 -0
- hufu-0.5.0/rust/simulation/tests/test_hyper_simulation.py +116 -0
- hufu-0.5.0/rust/simulation/tests/test_simulation.py +55 -0
- hufu-0.5.0/src/hufu/__init__.py +78 -0
- hufu-0.5.0/src/hufu/api.py +184 -0
- hufu-0.5.0/src/hufu/backends.py +77 -0
- hufu-0.5.0/src/hufu/core/__init__.py +5 -0
- hufu-0.5.0/src/hufu/core/log.py +80 -0
- hufu-0.5.0/src/hufu/core/query_instance.py +189 -0
- hufu-0.5.0/src/hufu/core/text.py +15 -0
- hufu-0.5.0/src/hufu/engine/__init__.py +1 -0
- hufu-0.5.0/src/hufu/engine/alignment.py +433 -0
- hufu-0.5.0/src/hufu/engine/bridge.py +390 -0
- hufu-0.5.0/src/hufu/engine/build_hypergraph.py +342 -0
- hufu-0.5.0/src/hufu/engine/config.py +233 -0
- hufu-0.5.0/src/hufu/engine/consistent.py +529 -0
- hufu-0.5.0/src/hufu/engine/contracts.py +546 -0
- hufu-0.5.0/src/hufu/engine/d_match.py +417 -0
- hufu-0.5.0/src/hufu/engine/decision.py +69 -0
- hufu-0.5.0/src/hufu/engine/denial.py +415 -0
- hufu-0.5.0/src/hufu/engine/embedding.py +151 -0
- hufu-0.5.0/src/hufu/engine/fixed_point.py +172 -0
- hufu-0.5.0/src/hufu/engine/hyper_simulation.py +2867 -0
- hufu-0.5.0/src/hufu/engine/nli.py +136 -0
- hufu-0.5.0/src/hufu/engine/postprocess.py +717 -0
- hufu-0.5.0/src/hufu/engine/reference_check.py +303 -0
- hufu-0.5.0/src/hufu/engine/registration.py +191 -0
- hufu-0.5.0/src/hufu/engine/scoring.py +302 -0
- hufu-0.5.0/src/hufu/engine/semantic_cluster.py +535 -0
- hufu-0.5.0/src/hufu/engine/star_graph.py +1080 -0
- hufu-0.5.0/src/hufu/graphgen/__init__.py +1 -0
- hufu-0.5.0/src/hufu/graphgen/build.py +271 -0
- hufu-0.5.0/src/hufu/graphgen/ontology.py +23 -0
- hufu-0.5.0/src/hufu/hypergraph/__init__.py +1 -0
- hufu-0.5.0/src/hufu/hypergraph/abstraction.py +218 -0
- hufu-0.5.0/src/hufu/hypergraph/combine.py +402 -0
- hufu-0.5.0/src/hufu/hypergraph/corref.py +438 -0
- hufu-0.5.0/src/hufu/hypergraph/dependency.py +683 -0
- hufu-0.5.0/src/hufu/hypergraph/display.py +55 -0
- hufu-0.5.0/src/hufu/hypergraph/entity.py +114 -0
- hufu-0.5.0/src/hufu/hypergraph/formal.py +1 -0
- hufu-0.5.0/src/hufu/hypergraph/graph.py +36 -0
- hufu-0.5.0/src/hufu/hypergraph/hypergraph.py +654 -0
- hufu-0.5.0/src/hufu/hypergraph/linguistic.py +154 -0
- hufu-0.5.0/src/hufu/hypergraph/linking.py +329 -0
- hufu-0.5.0/src/hufu/hypergraph/ontology_mapping_seed.json +51 -0
- hufu-0.5.0/src/hufu/hypergraph/path.py +244 -0
- hufu-0.5.0/src/hufu/hypergraph/union.py +422 -0
- hufu-0.5.0/src/hufu/llm/__init__.py +5 -0
- hufu-0.5.0/src/hufu/llm/chat.py +33 -0
- hufu-0.5.0/src/hufu/llm/client.py +75 -0
- hufu-0.5.0/src/hufu/llm/prompt_graph.py +460 -0
- hufu-0.5.0/src/hufu/rules/__init__.py +48 -0
- hufu-0.5.0/src/hufu/rules/calibrate.py +65 -0
- hufu-0.5.0/src/hufu/rules/discovery.py +180 -0
- hufu-0.5.0/src/hufu/rules/engine.py +148 -0
- hufu-0.5.0/src/hufu/rules/model.py +146 -0
- hufu-0.5.0/src/hufu/rules/predicates.py +220 -0
- hufu-0.5.0/src/hufu/rules/registry.py +109 -0
- hufu-0.5.0/src/hufu/scenarios/__init__.py +69 -0
- hufu-0.5.0/src/hufu/scenarios/detectors.py +154 -0
- hufu-0.5.0/src/hufu/scenarios/documents.py +130 -0
- hufu-0.5.0/src/hufu/scenarios/memory.py +127 -0
- hufu-0.5.0/src/hufu/scenarios/outlier_discovery.py +113 -0
- hufu-0.5.0/src/hufu/scenarios/outliers.py +437 -0
- hufu-0.5.0/src/hufu/scenarios/rulesets/doc_contradictions.json +49 -0
- hufu-0.5.0/src/hufu/scenarios/rulesets/memory_conflicts.json +218 -0
- hufu-0.5.0/src/hufu/scenarios/trim.py +200 -0
- hufu-0.5.0/tests/e2e/golden100.py +151 -0
- hufu-0.5.0/tests/e2e/golden250.py +197 -0
- hufu-0.5.0/tests/e2e/golden_doc300.py +253 -0
- hufu-0.5.0/tests/e2e/golden_doc300_report_rules_strict.json +3800 -0
- hufu-0.5.0/tests/e2e/golden_doc300_report_rules_strict_trf.json +3760 -0
- hufu-0.5.0/tests/e2e/golden_doc_corpus.py +124 -0
- hufu-0.5.0/tests/e2e/golden_mem300.py +281 -0
- hufu-0.5.0/tests/e2e/golden_mem300_report.json +2584 -0
- hufu-0.5.0/tests/e2e/golden_mem_corpus.py +405 -0
- hufu-0.5.0/tests/e2e/golden_mem_report.json +550 -0
- hufu-0.5.0/tests/e2e/golden_rag200.py +152 -0
- hufu-0.5.0/tests/e2e/golden_rag200_report.json +3604 -0
- hufu-0.5.0/tests/e2e/golden_struct200.py +238 -0
- hufu-0.5.0/tests/e2e/golden_struct200_report.json +2175 -0
- hufu-0.5.0/tests/e2e/mem_pair_scores.json +1 -0
- hufu-0.5.0/tests/e2e/run_doc300.py +110 -0
- hufu-0.5.0/tests/e2e/test_benchmark_contradoc.py +92 -0
- hufu-0.5.0/tests/e2e/test_benchmark_l4.py +84 -0
- hufu-0.5.0/tests/e2e/test_bridge.py +151 -0
- hufu-0.5.0/tests/e2e/test_build_golden.py +170 -0
- hufu-0.5.0/tests/e2e/test_cdrs_fixture.py +60 -0
- hufu-0.5.0/tests/e2e/test_dual_track_l3.py +148 -0
- hufu-0.5.0/tests/e2e/test_golden100.py +105 -0
- hufu-0.5.0/tests/e2e/test_golden250.py +98 -0
- hufu-0.5.0/tests/e2e/test_golden_doc300.py +124 -0
- hufu-0.5.0/tests/e2e/test_golden_mem.py +93 -0
- hufu-0.5.0/tests/e2e/test_golden_mem300.py +109 -0
- hufu-0.5.0/tests/e2e/test_golden_rag200.py +119 -0
- hufu-0.5.0/tests/e2e/test_golden_struct200.py +107 -0
- hufu-0.5.0/tests/e2e/test_reference_l2.py +92 -0
- hufu-0.5.0/tests/e2e/test_snli_real.py +114 -0
- hufu-0.5.0/tests/e2e/test_strategy_convergence.py +113 -0
- hufu-0.5.0/tests/test_boundary.py +126 -0
- hufu-0.5.0/tests/test_cdrs_port.py +62 -0
- hufu-0.5.0/tests/test_engine_core.py +688 -0
- hufu-0.5.0/tests/test_ohunt_port.py +218 -0
- hufu-0.5.0/tests/test_ohunt_sweep.py +167 -0
- hufu-0.5.0/tests/test_real_outliers.py +137 -0
- hufu-0.5.0/tests/test_rules.py +171 -0
- hufu-0.5.0/tests/test_scenarios_v04.py +143 -0
- hufu-0.5.0/tests/test_text_level_integration.py +39 -0
- hufu-0.5.0/tests/test_trim_discovery.py +137 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
strategy:
|
|
11
|
+
matrix:
|
|
12
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
13
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
14
|
+
runs-on: ${{ matrix.os }}
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python-version }}
|
|
21
|
+
|
|
22
|
+
- name: Install package (core, dependency-free)
|
|
23
|
+
run: pip install -e .
|
|
24
|
+
|
|
25
|
+
- name: Compile check
|
|
26
|
+
run: python -m compileall -q src tests
|
|
27
|
+
|
|
28
|
+
- name: Dependency-free engine tests
|
|
29
|
+
run: python -m unittest discover -s tests -v
|
|
30
|
+
|
|
31
|
+
lint:
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v4
|
|
35
|
+
- uses: actions/setup-python@v5
|
|
36
|
+
with:
|
|
37
|
+
python-version: "3.12"
|
|
38
|
+
- name: Ruff
|
|
39
|
+
run: |
|
|
40
|
+
pip install ruff
|
|
41
|
+
ruff check src tests
|
|
42
|
+
|
|
43
|
+
models-smoke:
|
|
44
|
+
# Text-level path with the models extra: spaCy graph build on one small
|
|
45
|
+
# English model (e2e golden corpora stay HUFU_RUN_E2E-gated and local).
|
|
46
|
+
strategy:
|
|
47
|
+
matrix:
|
|
48
|
+
os: [ubuntu-latest, windows-latest]
|
|
49
|
+
runs-on: ${{ matrix.os }}
|
|
50
|
+
steps:
|
|
51
|
+
- uses: actions/checkout@v4
|
|
52
|
+
- uses: actions/setup-python@v5
|
|
53
|
+
with:
|
|
54
|
+
python-version: "3.12"
|
|
55
|
+
- name: Install models extra
|
|
56
|
+
run: pip install -e ".[models]"
|
|
57
|
+
- name: Download spaCy model
|
|
58
|
+
run: python -m spacy download en_core_web_sm
|
|
59
|
+
- name: Graph-build smoke
|
|
60
|
+
env:
|
|
61
|
+
HUFU_SPACY_MODEL: en_core_web_sm
|
|
62
|
+
HUFU_COREF: "off"
|
|
63
|
+
run: |
|
|
64
|
+
python -c "from hufu.engine.build_hypergraph import text_to_hypergraph; hg = text_to_hypergraph('The regiment lost 300 men. The regiment lost 3000 men.'); assert len(hg.vertices) >= 3; print('hypergraph smoke OK:', len(hg.vertices), 'vertices')"
|
|
65
|
+
|
|
66
|
+
rust:
|
|
67
|
+
runs-on: ubuntu-latest
|
|
68
|
+
steps:
|
|
69
|
+
- uses: actions/checkout@v4
|
|
70
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
71
|
+
- name: Cargo check (fixed-point engine)
|
|
72
|
+
run: cargo check --manifest-path rust/simulation/Cargo.toml
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- uses: actions/setup-python@v5
|
|
13
|
+
with:
|
|
14
|
+
python-version: "3.12"
|
|
15
|
+
- name: Build sdist and wheel
|
|
16
|
+
run: |
|
|
17
|
+
pip install build
|
|
18
|
+
python -m build
|
|
19
|
+
- name: Twine check
|
|
20
|
+
run: |
|
|
21
|
+
pip install twine
|
|
22
|
+
twine check dist/*
|
|
23
|
+
- name: Upload artifacts
|
|
24
|
+
uses: actions/upload-artifact@v4
|
|
25
|
+
with:
|
|
26
|
+
name: hufu-dist
|
|
27
|
+
path: dist/
|
|
28
|
+
|
|
29
|
+
pypi:
|
|
30
|
+
# PyPI Trusted Publishing (OIDC): no stored token. Configure once on
|
|
31
|
+
# pypi.org — Manage project → Publishing → add GitHub publisher with
|
|
32
|
+
# owner ruochunjin, repository hufu, workflow publish.yml, environment
|
|
33
|
+
# name "pypi".
|
|
34
|
+
needs: build
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
environment:
|
|
37
|
+
name: pypi
|
|
38
|
+
url: https://pypi.org/p/hufu
|
|
39
|
+
permissions:
|
|
40
|
+
id-token: write
|
|
41
|
+
steps:
|
|
42
|
+
- uses: actions/download-artifact@v4
|
|
43
|
+
with:
|
|
44
|
+
name: hufu-dist
|
|
45
|
+
path: dist/
|
|
46
|
+
- name: Publish to PyPI
|
|
47
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
hufu-0.5.0/.gitignore
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Byte-compiled / build artifacts
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.eggs/
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
|
|
9
|
+
# Rust / maturin
|
|
10
|
+
rust/**/target/
|
|
11
|
+
**/*.so
|
|
12
|
+
**/*.pyd
|
|
13
|
+
|
|
14
|
+
# Virtual environments
|
|
15
|
+
.venv/
|
|
16
|
+
venv/
|
|
17
|
+
|
|
18
|
+
# Tooling caches
|
|
19
|
+
.pytest_cache/
|
|
20
|
+
.ruff_cache/
|
|
21
|
+
.mypy_cache/
|
|
22
|
+
|
|
23
|
+
# Data and outputs (keep repositories code-only)
|
|
24
|
+
data/
|
|
25
|
+
output/
|
|
26
|
+
*.pkl
|
|
27
|
+
*.jsonl
|
|
28
|
+
!examples/**/*.jsonl
|
|
29
|
+
|
|
30
|
+
# OS / editor
|
|
31
|
+
.DS_Store
|
|
32
|
+
Thumbs.db
|
|
33
|
+
.idea/
|
|
34
|
+
.vscode/
|
|
35
|
+
|
|
36
|
+
# Local e2e environment (machine-specific)
|
|
37
|
+
.venv-e2e/
|
|
38
|
+
.e2e-setup.log
|
|
39
|
+
|
|
40
|
+
# Runtime logs
|
|
41
|
+
logs/
|
|
42
|
+
|
|
43
|
+
# Local install scratch files
|
|
44
|
+
.vs-modify.bat
|
|
45
|
+
.vs-modify.ps1
|
|
46
|
+
.*-install.log
|
|
47
|
+
.vs-*.log
|
|
48
|
+
.l2-test.log
|
|
49
|
+
.l3-test.log
|
|
50
|
+
.e2e-all.log
|
|
51
|
+
.bench-test.log
|
|
52
|
+
.contradoc-probe.log
|
|
53
|
+
|
|
54
|
+
# Benchmark evaluation data is intentionally tracked (lab-approved release)
|
|
55
|
+
!benchmarks/data/
|
|
56
|
+
!benchmarks/data/**
|
|
57
|
+
|
|
58
|
+
# Golden100 run report (regenerated each run)
|
|
59
|
+
tests/e2e/golden100_report.json
|
|
60
|
+
tests/e2e/golden250_report.json
|
|
61
|
+
tests/e2e/golden100_report_sm.json
|
|
62
|
+
|
|
63
|
+
# Regenerable caches (hypergraph pickles, dataset parquet downloads)
|
|
64
|
+
benchmarks/data/cache/hypergraphs/
|
|
65
|
+
benchmarks/data/cache/*--*/
|
|
66
|
+
tests/e2e/golden_doc_report.json
|
|
67
|
+
|
|
68
|
+
# Local run/probe logs and scratch outputs
|
|
69
|
+
.*.log
|
|
70
|
+
.*-probe.log
|
|
71
|
+
.std-*.txt
|
|
72
|
+
.conflict-features.json
|
|
73
|
+
.vs-*.log
|
|
74
|
+
.vs-*.bat
|
|
75
|
+
.vs-*.ps1
|
|
76
|
+
tests/e2e/golden_doc300_report.json
|
hufu-0.5.0/CITATION.cff
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
title: "HuFu (虎符): neuro-symbolic data-quality verification for the LLM era"
|
|
3
|
+
message: >-
|
|
4
|
+
If you use this software, please cite both the software and the
|
|
5
|
+
underlying research papers.
|
|
6
|
+
type: software
|
|
7
|
+
# TODO: add author list and repository URL before public release.
|
|
8
|
+
authors: []
|
|
9
|
+
url: "https://github.com/ruochunjin/hufu"
|
|
10
|
+
version: 0.1.0
|
|
11
|
+
license: Apache-2.0
|
hufu-0.5.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any licenses granted to
|
|
86
|
+
You under this License for that Work shall terminate as of the date
|
|
87
|
+
such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your use of permissions.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
hufu-0.5.0/NOTICE
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
NOTICE
|
|
2
|
+
======
|
|
3
|
+
|
|
4
|
+
HuFu (虎符) — neuro-symbolic data quality checking
|
|
5
|
+
Copyright (c) 2026 The HuFu Authors
|
|
6
|
+
|
|
7
|
+
This product includes software developed by the HuFu authors, licensed under
|
|
8
|
+
the Apache License, Version 2.0 (see LICENSE).
|
|
9
|
+
|
|
10
|
+
Portions of this software were ported from the following upstream projects,
|
|
11
|
+
whose original license notices are retained below in accordance with their
|
|
12
|
+
terms:
|
|
13
|
+
|
|
14
|
+
1. hyper-simulation (hyper-simulation-code)
|
|
15
|
+
Source: lab-internal prototype accompanying the paper
|
|
16
|
+
"Catching Inconsistencies" (HyperMatch).
|
|
17
|
+
License: MIT License, Copyright (c) 2026 Anonymous Authors
|
|
18
|
+
Ported components: the hypergraph construction package
|
|
19
|
+
(src/hufu/hypergraph/), the engine pipeline (src/hufu/engine/), and the
|
|
20
|
+
Rust fixed-point extension (rust/simulation/, rust/graph-simulation/).
|
|
21
|
+
|
|
22
|
+
-----------------------------------------------------------------------
|
|
23
|
+
MIT License
|
|
24
|
+
|
|
25
|
+
Copyright (c) 2026 Anonymous Authors
|
|
26
|
+
|
|
27
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
28
|
+
copy of this software and associated documentation files (the
|
|
29
|
+
"Software"), to deal in the Software without restriction, including
|
|
30
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
31
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
32
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
33
|
+
the following conditions:
|
|
34
|
+
|
|
35
|
+
The above copyright notice and this permission notice shall be included
|
|
36
|
+
in all copies or substantial portions of the Software.
|
|
37
|
+
|
|
38
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
39
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
40
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
41
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
42
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
43
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
44
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
45
|
+
-----------------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
2. ContraDoc evaluation dataset (benchmarks/data/ContraDoc.json)
|
|
48
|
+
Source: https://github.com/ddhruvkr/CONTRADOC
|
|
49
|
+
License: Apache License 2.0
|
|
50
|
+
Citation: "ContraDoc: Understanding Self-Contradictions in Documents
|
|
51
|
+
with Large Language Models" (arXiv:2311.09182).
|
hufu-0.5.0/PKG-INFO
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: hufu
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: HuFu (虎符): neuro-symbolic data-quality verification — hypergraph-simulation consistency checking for vector retrieval, documents, and LLM data
|
|
5
|
+
Project-URL: Homepage, https://github.com/ruochunjin/hufu
|
|
6
|
+
Project-URL: Documentation, https://github.com/ruochunjin/hufu#readme
|
|
7
|
+
Project-URL: Issues, https://github.com/ruochunjin/hufu/issues
|
|
8
|
+
Author: HuFu Developers
|
|
9
|
+
License: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Keywords: RAG,consistency checking,data quality,graph simulation,hypergraph,neuro-symbolic,vector database
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Rust
|
|
18
|
+
Classifier: Topic :: Database
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
23
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
24
|
+
Provides-Extra: graph
|
|
25
|
+
Requires-Dist: langchain-core>=0.3; extra == 'graph'
|
|
26
|
+
Requires-Dist: networkx>=3.0; extra == 'graph'
|
|
27
|
+
Requires-Dist: pydantic>=2.0; extra == 'graph'
|
|
28
|
+
Requires-Dist: requests>=2.31; extra == 'graph'
|
|
29
|
+
Requires-Dist: tenacity>=8.0; extra == 'graph'
|
|
30
|
+
Provides-Extra: llm
|
|
31
|
+
Requires-Dist: openai>=1.30; extra == 'llm'
|
|
32
|
+
Provides-Extra: models
|
|
33
|
+
Requires-Dist: fastcoref>=2.1.6; extra == 'models'
|
|
34
|
+
Requires-Dist: nltk>=3.8; extra == 'models'
|
|
35
|
+
Requires-Dist: numpy<3,>=1.26; extra == 'models'
|
|
36
|
+
Requires-Dist: sentence-transformers<6,>=5.0; extra == 'models'
|
|
37
|
+
Requires-Dist: spacy<4,>=3.7; extra == 'models'
|
|
38
|
+
Requires-Dist: tqdm>=4.60; extra == 'models'
|
|
39
|
+
Requires-Dist: transformers<5,>=4.51; extra == 'models'
|
|
40
|
+
Provides-Extra: outliers
|
|
41
|
+
Requires-Dist: scikit-learn>=1.4; extra == 'outliers'
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
|
|
44
|
+
# HuFu 虎符
|
|
45
|
+
|
|
46
|
+
> *虎符相合,方为可信。* — In ancient China, a tiger tally was split in two;
|
|
47
|
+
> only when the halves matched was an order authentic. **HuFu** does the same
|
|
48
|
+
> for data: it checks whether two pieces of data *fit together* — a query and
|
|
49
|
+
> a retrieved passage, a memory and a memory, a statement and a document.
|
|
50
|
+
|
|
51
|
+
HuFu is a **lightweight consistency checker**. Vector similarity says two
|
|
52
|
+
texts are *close*; HuFu decides whether they are *consistent* — with
|
|
53
|
+
explainable evidence and provable polynomial-time complexity. Symbolic
|
|
54
|
+
structure (linguistic hypergraphs, hypergraph simulation, quality rules)
|
|
55
|
+
makes the call; small neural models (embeddings, NLI) serve only as
|
|
56
|
+
measurable inputs to the rules.
|
|
57
|
+
|
|
58
|
+
## Quick start
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install hufu # dependency-free reference core
|
|
62
|
+
pip install "hufu[models]" # text-level checking (spaCy, embeddings, NLI)
|
|
63
|
+
python -m spacy download en_core_web_trf
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
import hufu
|
|
68
|
+
|
|
69
|
+
# 1. RAG retrieval post-check: does each retrieved passage fit the query?
|
|
70
|
+
verdicts = hufu.check_retrieval(
|
|
71
|
+
"Where was the author of 'The Old Man and the Sea' born?",
|
|
72
|
+
[
|
|
73
|
+
"Ernest Hemingway, who wrote The Old Man and the Sea, was born in Oak Park, Illinois.",
|
|
74
|
+
"Paris is the capital of France and a major European city.",
|
|
75
|
+
],
|
|
76
|
+
)
|
|
77
|
+
for v in verdicts:
|
|
78
|
+
print(v.consistent, v.distance)
|
|
79
|
+
|
|
80
|
+
# 2. Vector-memory conflicts: same object, opposing actions?
|
|
81
|
+
conflicts = hufu.detect_memory_conflicts([
|
|
82
|
+
("Turn on the light", {"object": "light", "action": "on"}),
|
|
83
|
+
("Turn off the light", {"object": "light", "action": "off"}),
|
|
84
|
+
("Water the plants", {"object": "plants", "action": "water"}),
|
|
85
|
+
])
|
|
86
|
+
print(conflicts[0].labels, conflicts[0].explanations)
|
|
87
|
+
|
|
88
|
+
# 3. Training-data outliers: good / bad / ugly by measured impact
|
|
89
|
+
from hufu.scenarios import classify_outliers
|
|
90
|
+
reports = classify_outliers(records, labels, evaluator=train_and_score)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Every verdict carries evidence provenance and the full decision chain —
|
|
94
|
+
HuFu explains *why* it flags something.
|
|
95
|
+
|
|
96
|
+
## What it does
|
|
97
|
+
|
|
98
|
+
- **RAG retrieval post-checker** — sits between retrieval and generation in
|
|
99
|
+
any pipeline, vector-database agnostic; labels every retrieved document
|
|
100
|
+
`consistent / conflict` with per-pair evidence and distance.
|
|
101
|
+
- **Document contradiction detection** — star-graph rules over a document's
|
|
102
|
+
own statements: typed value-slot swaps, numeric mismatches (with unit
|
|
103
|
+
conversion), role reversals, antonym pairs, polarity flips.
|
|
104
|
+
- **Vector-memory conflict detection & trimming** — CDR-style rules for
|
|
105
|
+
memory banks (same object, opposing actions/states/values), conflict
|
|
106
|
+
inference from retrieval judgments, and evidence/index-level trimming so
|
|
107
|
+
retrieval stops surfacing conflicts.
|
|
108
|
+
- **Training-data outlier management** — detectors, the good / bad / ugly
|
|
109
|
+
classification by measured downstream impact, and a repair family
|
|
110
|
+
(KNN/RF label repair, value imputation, deletion) with a small pipeline
|
|
111
|
+
search.
|
|
112
|
+
- **Unified quality-rule language** — one JSON rule schema (logic, NLI,
|
|
113
|
+
similarity, numeric/temporal predicates), pluggable via a registry.
|
|
114
|
+
Rules are data: hand-write, version, or discover them offline.
|
|
115
|
+
|
|
116
|
+
## Scope and limitations
|
|
117
|
+
|
|
118
|
+
HuFu is deliberately **precision-first**: it certifies structural
|
|
119
|
+
contradictions with explainable evidence rather than chasing every semantic
|
|
120
|
+
nuance.
|
|
121
|
+
|
|
122
|
+
- **Reliable subdomain (default `profile="strict"`)**: conflicts provable
|
|
123
|
+
from structure alone — typed value-slot swaps (born in X vs Y, 300 vs
|
|
124
|
+
3000 men, May vs June 1883), role reversals on asymmetric verbs, antonym
|
|
125
|
+
pairs, and polarity flips on an otherwise identical frame.
|
|
126
|
+
- **Out of scope**: narrative tension, perspective/emotion shifts,
|
|
127
|
+
paraphrase-level disagreement, and temporal *progressions* (a story
|
|
128
|
+
legitimately giving the same attribute different values at different
|
|
129
|
+
times). Real long-form narrative contains the same surface signatures as
|
|
130
|
+
injected conflicts — a methods boundary, not an engineering gap.
|
|
131
|
+
|
|
132
|
+
In short: use HuFu to *confirm* contradictions on structured /
|
|
133
|
+
semi-structured content (knowledge bases, fact tables, records, curated
|
|
134
|
+
documents), as a consistency post-checker for RAG retrieval, and for
|
|
135
|
+
vector-memory conflict detection. Long-form narrative contradiction
|
|
136
|
+
hunting is explicitly out of scope.
|
|
137
|
+
|
|
138
|
+
## Installation
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
pip install hufu # dependency-free reference core (Python ≥ 3.10)
|
|
142
|
+
pip install "hufu[models]" # + text-level checking (spaCy, sentence-transformers, fastcoref)
|
|
143
|
+
pip install "hufu[outliers]" # + sklearn-backed outlier classification/repair
|
|
144
|
+
python -m spacy download en_core_web_trf
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Text-level checking can also use the Rust fixed-point accelerator
|
|
148
|
+
(`simulation-alg`) when a Rust toolchain is available:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
pip install ./rust/simulation
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Model configuration (environment variables)
|
|
155
|
+
|
|
156
|
+
| Variable | Default | Purpose |
|
|
157
|
+
| --- | --- | --- |
|
|
158
|
+
| `HUFU_EMBED_MODEL` | `sentence-transformers/all-MiniLM-L6-v2` | sentence embedding model |
|
|
159
|
+
| `HUFU_NLI_MODEL` | `cross-encoder/nli-deberta-v3-xsmall` | NLI cross-encoder |
|
|
160
|
+
| `HUFU_COREF_MODEL` | `biu-nlp/lingmess-coref` | coreference model (`HUFU_COREF=off` disables) |
|
|
161
|
+
| `HUFU_SPACY_MODEL` | `en_core_web_trf` | spaCy pipeline |
|
|
162
|
+
|
|
163
|
+
## Repository layout
|
|
164
|
+
|
|
165
|
+
```text
|
|
166
|
+
src/hufu/
|
|
167
|
+
api.py Public facade: check_pair / check_retrieval + reference core
|
|
168
|
+
backends.py Model-backed EmbeddingBackend adapters (lazy)
|
|
169
|
+
engine/ HyperMatch core + star-graph document engine + bridge
|
|
170
|
+
rules/ Unified quality-rule DSL: model, registry, predicates, engine
|
|
171
|
+
scenarios/ Ready-made scenarios (memory, documents, outliers, trim)
|
|
172
|
+
hypergraph/ Linguistic hypergraph construction, traversal, fusion
|
|
173
|
+
core/ QueryInstance, logging, text utilities
|
|
174
|
+
rust/
|
|
175
|
+
graph-simulation/ Rust graph-simulation crate
|
|
176
|
+
simulation/ maturin Python binding (simulation-alg)
|
|
177
|
+
tests/ Dependency-free engine and rule tests (runnable anywhere)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Development
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
pip install -e ".[dev]"
|
|
184
|
+
python -m unittest discover -s tests -v # no models or network needed
|
|
185
|
+
ruff check src tests
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Citation
|
|
189
|
+
|
|
190
|
+
HuFu integrates several peer-reviewed works. If you use it, please cite:
|
|
191
|
+
|
|
192
|
+
```bibtex
|
|
193
|
+
% Catching Inconsistencies in Vector Similarity Retrieval (HyperMatch)
|
|
194
|
+
% Conflict-Aware Memory for Embodied Agents: Enhancing Vector Data Quality via Detection Rules (CDRs, ACL 2026)
|
|
195
|
+
% Detecting Contradictions Within and Across Documents (DocChecker)
|
|
196
|
+
% Outliers: The Good, the Bad and the Ugly (OHunt)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
(Full BibTeX entries will be added with publication metadata.)
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
Apache-2.0 (see LICENSE). Existing source copyright notices are retained.
|