Skip to main content

AbstractSemantics (abstractsemantics)

Central, editable semantics registry (predicates + entity types) for AbstractFramework, with helpers to build a compact JSON Schema for knowledge-graph (KG) assertion structured outputs.

This package intentionally contains definitions, not storage:

  • prefix mappings (CURIE namespaces)
  • predicate allowlists (optional inverse pointers)
  • entity-type allowlists
  • memory-relation declarations (plain-word edge vocabulary with direction roles)

AbstractFramework ecosystem

abstractsemantics is a small, standalone building block within the wider AbstractFramework ecosystem:

In practice, this repo provides the shared allowed ids (predicates, entity types, and memory relations) and a small JSON Schema helper that downstream components (including runtimes) can use for validation and structured outputs.

Status

Small, dependency-light package (only PyYAML) with a tiny public API:

  • the default registry is shipped as package data (abstractsemantics/semantics.yaml; in this repo: src/abstractsemantics/semantics.yaml)
  • the loader returns immutable dataclasses (SemanticsRegistry)
  • the v0 schema builder produces a deterministic JSON Schema dict
  • normalize_kg_predicate() maps extractor-emitted predicates to canonical ids at your ingestion boundary

This package makes no network calls and does not store/query data (see src/abstractsemantics/registry.py and src/abstractsemantics/schema.py).

Install

From PyPI:

pip install abstractsemantics

From source (editable, with test deps):

pip install -e ".[dev]"

Requires Python >=3.10 (see pyproject.toml).

For framework-wide dependency manifests, the no-op compatibility extras abstractsemantics[apple], abstractsemantics[gpu], abstractsemantics[all-apple], and abstractsemantics[all-gpu] are available. They do not add dependencies because this package owns semantics definitions, not hardware runtimes.

Quickstart

Load the default registry and build the v0 structured-output schema:

from abstractsemantics import load_semantics_registry, build_kg_assertion_schema_v0

reg = load_semantics_registry()
print(len(reg.predicates), len(reg.entity_types))

schema = build_kg_assertion_schema_v0(registry=reg, include_predicate_aliases=True)

Read the memory-relation vocabulary and the validation set for memory-record writes:

from abstractsemantics import load_semantics_registry

reg = load_semantics_registry()
print(sorted(reg.memory_relation_ids()))
print(sorted(reg.memory_record_predicate_ids()))

supports = next(r for r in reg.memory_relations if r.id == "supports")
print(supports.subject_role, "->", supports.object_role)  # evidence -> claim

Normalize an extractor-emitted predicate before persisting it:

from abstractsemantics import normalize_kg_predicate

normalize_kg_predicate("schema:hasPart", registry=reg)  # 'dcterms:hasPart'
normalize_kg_predicate("something:invented", registry=reg)  # None

Resolve a stable $ref (useful when a downstream system stores schema references rather than full dicts):

from abstractsemantics import KG_ASSERTION_SCHEMA_REF_V0, resolve_schema_ref

schema = resolve_schema_ref({"$ref": KG_ASSERTION_SCHEMA_REF_V0})
assert isinstance(schema, dict)

Use a custom registry YAML (must exist on disk):

export ABSTRACTSEMANTICS_REGISTRY_PATH=/absolute/path/to/semantics.yaml
from abstractsemantics import load_semantics_registry

reg = load_semantics_registry()  # loads from ABSTRACTSEMANTICS_REGISTRY_PATH if set

Note: load_semantics_registry() only requires at least 1 predicate, but build_kg_assertion_schema_v0() requires both predicate ids and entity-type ids (it raises ValueError if entity_types is empty).

Diagram (registry → schema → consumers)

flowchart LR
  YAML[src/abstractsemantics/semantics.yaml] --> Loader[load_semantics_registry()]
  Loader --> Reg[SemanticsRegistry]
  Reg --> Builder[build_kg_assertion_schema_v0()]
  Builder --> Schema[JSON Schema dict]
  Schema --> Consumers[AbstractRuntime / other consumers]

Intended consumers (external)

Typical consumers include:

  • AbstractRuntime (ingestion-boundary validation and structured-output contracts)
  • authoring tools/UIs (dropdowns and semantic pickers backed by the registry)
  • ingestion pipelines and storage/query layers that want a shared, explicit allowlist of ids

Documentation

Start with:

  • docs/getting-started.md (recommended entrypoint)
  • docs/README.md (documentation index)
  • docs/architecture.md (what exists in this repo, with diagrams)
  • docs/registry.md (registry YAML format)
  • docs/schema.md (KG assertion JSON Schema + $ref)
  • docs/api.md (public API surface)
  • docs/faq.md (common questions)
  • docs/troubleshooting.md (symptoms, causes, and fixes)

Project

  • Changelog: CHANGELOG.md
  • Contributing: CONTRIBUTING.md
  • Code of conduct: CODE_OF_CONDUCT.md
  • Security: SECURITY.md
  • Acknowledgments: ACKNOWLEDGMENTS.md

License

MIT (see LICENSE).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

abstractsemantics-0.0.5.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

abstractsemantics-0.0.5-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file abstractsemantics-0.0.5.tar.gz.

File metadata

  • Download URL: abstractsemantics-0.0.5.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for abstractsemantics-0.0.5.tar.gz
Algorithm Hash digest
SHA256 e1eda0e75f212aaca30639b50b2e446a83523e80d79411589ae6925447b36239
MD5 062fc98bb5b9a87752777ec5e52ae16a
BLAKE2b-256 d0b1b3fe0064b2a885663726f4017b4b6bf6d463f875baefcb7bf3ee686a7410

See more details on using hashes here.

Provenance

The following attestation bundles were made for abstractsemantics-0.0.5.tar.gz:

Publisher: release.yml on lpalbou/AbstractSemantics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file abstractsemantics-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for abstractsemantics-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1fc0609554649b1bd4688014f30b5cca249fcf1e42c33b12bd343594f692072b
MD5 26ac40f1287bcae32683d8502e3387e4
BLAKE2b-256 2775d27110f88356f5600a8efd2f3c6927cd185b427989e6bd069c95dc3b07d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for abstractsemantics-0.0.5-py3-none-any.whl:

Publisher: release.yml on lpalbou/AbstractSemantics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 files

0.0.4

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page