kg-extractor
Install from PyPI:
pip install ski-kg-extractor(publishing starts with the first release after June 2026).
Status: v3.0 — first production-target release.
Extract structured compliance rules from regulatory documents
(LLM-assisted) and emit a v3 Knowledge Graph ready for
kg-validator and the SKI Model runtime.
kg-extractor is a Phase 1 (compilation) tool. The output goes
through kg-validator (schema + §3.6 validation passes) and is then
signed before crossing the sovereign boundary. The extractor's LLM
backend may be local or cloud — its output is not part of the runtime
path.
Highlights (v3.0)
- Emits v3 KG JSON by default. Each extracted rule is wrapped into
the typed-graph shape from spec v3.0 §3: a Rule node, an Obligation
with a guessed
obligation_typeand numericvalue/unit, a Subject, a Citation, and the four edges connecting them (applies_to,consists_of,scoped_to,cited_by). --jurisdictionflag. Every KG carries a Jurisdiction node and every rule isscoped_toit. Defaults toglobal.- Pluggable LLM backend. Default is Ollama (local). Cloud
backends (
anthropic,openai) exist for compilation-phase use only. - Deterministic by default. Temperature 0, fixed seed, recorded prompt SHA-256 in extraction metadata for reproducibility audits.
IMPLIEDis prohibited (B2.1 Anchor Constraint). The prompt instructs the model not to emitIMPLIEDand the parser downgrades any that slip through toDISCRETIONARYwith a warning. Rules cannot be inferred beyond source text.extraction_qualityreplacesconfidence. The per-rule trust signal is nowextraction_quality(EXPLICIT / DISCRETIONARY / CONFLICTING) — a Phase-1 authoring concept, separate from the runtime's categorical verdict (Axiom 2 prohibits confidence scores in the audit trail).
Installation
pip install -e tools/kg-extractor
Quick start
# Extract a v3 KG from a regulation:
kg-extractor extract --file regulation.txt --sector energy \
--jurisdiction us.federal \
--output kg-extracted-v3.json
# Validate the emitted KG:
kg-validator validate --input kg-extracted-v3.json
# Batch:
kg-extractor batch --input-dir ./regulations --output-dir ./kgs \
--sector energy --jurisdiction us.federal
# Debugging — dump the raw flat-rule list before wrapping:
kg-extractor extract --file regulation.txt --emit-raw --output flat.json
Architecture
kg_extractor/
├── __init__.py public API: Extractor, ExtractionResult, ExtractionQuality, emit_v3_kg
├── extractor.py chunk → LLM → flat ComplianceRule list
├── models.py ComplianceRule, ExtractionResult, ExtractionQuality enum
├── backends.py Ollama / Anthropic / OpenAI backends (compilation phase only)
├── v3_emitter.py wraps ExtractionResult into a v3 KG dict (spec §3 shape)
├── utils.py chunking, document parsing, rule validation
└── cli.py click-based CLI (`extract`, `batch`, `filter`, `examples`, `version`)
Notes on extraction_quality
- EXPLICIT — the LLM produced a verbatim source quote in
reasoning. The rule is safe to ship without further review. - DISCRETIONARY — the LLM could not anchor the rule in a verbatim source quote. A human reviewer must approve before shipping.
- CONFLICTING — the LLM detected internal contradiction in the source. Surface for legal review.
This is not a confidence score in the probabilistic sense. The runtime never reads it. It exists solely to drive the Phase-1 human-review queue.
Metadata
Release files for ski-kg-extractor 3.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ski_kg_extractor-3.1.0.tar.gz | 19.2 kB | With provenance | Details for ski_kg_extractor-3.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ski_kg_extractor-3.1.0-py3-none-any.whl | Python 3 | none | any | Details for ski_kg_extractor-3.1.0-py3-none-any.whl |
Total release size: 37.7 kB
Release files / ski_kg_extractor-3.1.0.tar.gz
| Download URL | ski_kg_extractor-3.1.0.tar.gz |
|---|---|
| Size | 19.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0aa6cf3ade0042c1b99e565c0b8e21c2f011b716eede905deef9032c82bed9e8
|
|
BLAKE2b-256 checksum How to use checksums |
8dfdd872a7e020f59a30a11f3ade64c126c9bfef327aaa14f815e86a5c1c3814
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.
Transparency logRelease files / ski_kg_extractor-3.1.0-py3-none-any.whl
| Download URL | ski_kg_extractor-3.1.0-py3-none-any.whl |
|---|---|
| Size | 18.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e888160a5217f75678e78cad452aa835500cc779f053925e730104b72e9a18b
|
|
BLAKE2b-256 checksum How to use checksums |
8a084906700b99817a8ff7bca912de5a427319307c980fbae55fb8d1afea95c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.
Transparency logSecurity for ski-kg-extractor 3.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for ski_kg_extractor-3.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.