Auto Ontology storage and retrieval¶
KnowledgeBase.catalog stores native NVIDIA Auto Ontology documents in SharedData, publishes immutable model revisions and indexes definitions and associations. It also preserves independent extractor proposals and publishes numerical consensus with a pinned catalog revision. Existing research graph data remains in its own namespace.
Run the example¶
From the repository root with SharedData's dependencies installed:
PYTHONPATH=src python scripts/auto_ontology_example.py
PYTHONPATH=src python scripts/auto_ontology_example.py --large-objects 12000
The command stays in the foreground until it has imported and exported the model, queried definitions and a composite join, submitted four parallel worker outputs, published conflicting numerical evidence and reopened the files in a fresh read-only interpreter. It retains the database, exported model and report.json under a new artifacts/auto-ontology directory. Use --output with a new directory to choose its destination; existing output directories are never replaced.
The input model and articles are original synthetic fixtures. The extraction workers are deterministic demonstration functions: the example makes no LLM calls, uses no live data and does not start services. Three outputs for one article provide one independent source; adding a disagreeing article produces a contested summary while the earlier published view remains readable. The optional larger run adds 12000 columns, selects a rare match beyond the first candidate-list prefix, and records its lookup counters and warm timings.
The fixture matches NVIDIA's native AutoOntologyModelDocument contract at commit 623378972e70aacf24e065d06d13df7ac033e613. It includes a multi-table term, ordered composite join pairs, all four SQL attribute source groups, analyses, zones, typed samples and an integer larger than BSON's int64 range.
Import and retrieve¶
Classified tweets with eight real Qwen workers¶
On the platform host, with approved Mongo credentials in the environment or /etc/environment:
PYTHONPATH=src python scripts/classified_news_ontology.py \
--output artifacts/live-news/my-run --parallel 8 --follow-seconds 300
This is a foreground acceptance example, not a production service installation.
It reads the existing classified Mongo collection
master["Text/RT/TWITTERAPI/collection/TWEETS"], selects eight different source
accounts, replays later documents and polls for new classifications. It calls the
platform's ontology backend at its per-installation address (a loopback endpoint
on a single-host installation) with the exact served model
nvidia/Qwen3.8-Flash-Next-FP4-Local. It checks both model discovery and every
response model. No router fallback is used. The example requires that host,
loopback endpoint and model. The reusable Qwen transport accepts explicit settings.
All SharedData files and reports go under the output directory; API logging is disabled before SharedData imports, and new files use a private umask. Mongo is only read. The report retains request IDs, request intervals, classified source versions, model/prompt identifiers, accepted output, rejected attempts, quarantined items, revision changes, vLLM concurrency samples and retrieval timings. The metrics counter includes other clients of the same model; the independent HTTP interval counter proves overlap of this run's own requests. Fresh read-only verification opens the persisted files in another interpreter and checks evidence, write rejection and unchanged table counts. A missing live arrival or failed check makes the command return nonzero with its evidence report retained.
from SharedData.KnowledgeNewsIngest import NewsOntologyIngestor
from SharedData.KnowledgeNewsQwen import QwenNewsExtractor
extract = QwenNewsExtractor("https://qwen.example.com/", "nvidia/Qwen3.8-Flash-Next-FP4-Local")
news = NewsOntologyIngestor(kb, extract, model=extract.model, parallel=8)
result = news.ingest(classified_tweet_rows)
news.find("interest rate")
news.candidate(candidate_id)
news.evidence(candidate_id, limit=20, offset=0)
news.receipt(result["receipts"][0])
Only extraction runs in parallel. The foreground coordinator saves each completed source before waiting for other workers. A receipt key includes the source text, classification, model and prompt version. Changed text creates a separate immutable source version; reclassification retains the original version and records a new extraction. Repeated inputs reuse their receipt and make no model call. Malformed rows are reported separately while valid sources continue.
Publication uses a durable pending plan under the existing KnowledgeBase writer lease. The next writer finishes that plan before publishing another batch. Plans pin their catalog revisions, so retrying after catalog publication does not bind proposals to a later definition. This is recoverable logical publication under SharedData's existing process-lock/mmap contract, not cross-table power-loss ACID.
The vocabulary is partitioned into native model scopes of at most 512 terms (configurable downward). A new partition opens automatically. Only partitions with new vocabulary are re-imported; another mention or definition of an existing term changes evidence without rewriting its catalog. Terms retain a fixed-size first-evidence reference. Evidence and alternative definitions live in durable receipts with separate postings of at most 128 receipt IDs per physical block. Evidence pagination decodes only the selected receipt/source payloads. A posting directory grows with populated blocks; it is metadata, not a constant-size bound on all index bytes or evidence-page offset work.
Use news.find across partitions. It searches at most 16 scopes by default
(maximum 64), exposes next_scope_offset and truncation, and accepts scope
pagination. Exact candidate lookup uses its keyed scope locator. kb.catalog.find
still searches one explicit native model scope. Vocabulary revisions and evidence
publication are separate: a pinned vocabulary revision selects that definition,
while news.evidence explicitly returns currently published evidence. All source
outputs remain addressable by receipt ID.
New entities and concepts are provisional vocabulary, not accepted identities or facts. Labels coalesce only by exact normalized name and entity type; there is no fuzzy identity merge. First definitions stay stable and alternatives retain their own quotes/source receipts. General relations remain unadjudicated proposals. The model gets one repair attempt for malformed grounding; invalid items still present afterward are quarantined and preserved, while grounded items proceed. Verbatim quote/endpoint checks do not prove semantic correctness. The numerical consensus path below remains the separate way to adjudicate comparable financial claims with explicit identities and source policy.
Follow polling persists an overlap checkpoint, pages by (processed_at, hash)
and deduplicates via durable receipts, including timestamp ties. Transport/extraction
failures keep the old watermark. Malformed inputs are quarantined before advancing.
The overlap is two minutes: backdated classifications outside that window require
an explicit historical replay. The initial selection is a bounded recent sample;
this example does not promise complete historical backfill or install a scheduler.
Native catalog API¶
from SharedData.KnowledgeBase import KnowledgeBase
kb = KnowledgeBase('RESEARCH')
commit = kb.act('import_ontology', 'producer', model_key='warehouse', document=native_model)['result']
revision = commit['revision']
kb.catalog.find('warehouse', 'net revenue', kind='term', revision=revision)
kb.catalog.get_object('warehouse', 'column', external_column_id, revision=revision)
kb.catalog.relationships('warehouse', 'table', external_table_id, relation='join', revision=revision)
kb.catalog.export_model('warehouse', revision=revision) # original parsed mapping
kb.catalog.export_model('warehouse', revision=revision, raw=True) # original input text
kb.catalog.history('warehouse')
kb.catalog.diff('warehouse', before=revision)
model_key identifies an explicit replacement scope and is distinct from act's model parameter, which identifies an extraction model. Inputs can be mappings, JSON text or safely parsed YAML text. Full native data is encoded as typed JSON text in BSON, preserving booleans, nulls, int versus float, large integers, dates and timezone-aware datetimes. External IDs and names preserve case and Unicode. The raw text export retains the original input text; mapping inputs are rendered as YAML once for their raw representation. Export returns the retained document, rather than reverse-engineering it from graph edges. Raw export returns the first text seen for a content revision. An equivalent JSON/YAML serialization is a no-op and retains that first representation. Parent object definitions omit their child arrays; retrieve children through relationships. The retained native document still contains the complete hierarchy.
Imports validate references within a self-contained native model. A scoped export that refers to omitted tables is rejected with an unresolved-reference error; include the referenced tables in the imported scope. Unknown extension fields are preserved and listed in commit.coverage.uninterpreted_fields. Synonyms supplied as metadata are also indexed. SQL is retained as text and never executed.
Use expected_revision for checked replacement. Re-importing the current document is a no-op; reverting to an earlier document publishes a new sequence referencing the existing immutable revision. A staged model and its postings stay outside catalog reads until the publication record is appended. An interrupted import can be retried with the same staging timestamp and IDs. This is logical publication consistency under SharedData's existing storage contract, not a new transaction or power-loss guarantee across tables.
Extraction proposals and conflicts¶
Register source documents through register_sources. Submit proposals with source, extractor, model, prompt_version, run_id and item_key, plus entities, concepts and numeric claims. A proposal key includes the source version and catalog revision. The same key and same output is an idempotent retry; differing output requires a new run_id. Source evidence is retained even when a later view excludes it. Proposals reference a checksum of the registered source instead of copying its full text. Publication rechecks that source version. Concept candidates in view results are bounded references; get_proposal retrieves the original definitions.
Each numerical claim supplies entity (a mention), term (an imported term ID), period, unit, currency, basis, value and the exact supporting quote. The governed publish_numeric action requires an explicit entity_links mapping to canonical entities. It publishes exactly the selected proposal set as a new view, using the catalog's separate ConsensusGraph. Worker completion time does not determine claim precedence: the source's publication and known times are used.
ids = kb.act('submit_proposals', 'producer', model_key='warehouse', rows=outputs)['result']['proposals']
view = kb.act('publish_numeric', 'curator', model_key='warehouse', proposal_ids=ids,
entity_links={'Acme': 'org:acme'})['result']['revision']
answer = kb.catalog.metric_summary('warehouse', 'org:acme', revenue_term_id,
'2026Q3', unit='USD', currency='USD', basis='gaap', view=view)
The producer must verify semantic extraction quality. Publication checks exact quote/value presence and explicit entity decisions; these checks alone do not prove that the extractor chose the correct metric, period or basis. The existing financial KnowledgeBase contract provides the fuller domain-specific validation path. Concept proposals remain unreviewed candidates and are not automatically merged or promoted to canonical definitions. General prose contradictions require an external verifier or reviewer.
Numerical summaries retain conflicting alternatives, apply the configured source policy and count originating source content rather than model workers. Imported certification metadata does not grant local approval. A default summary read returns stale_evidence if the active catalog changed; an explicitly pinned old view remains available with its original definition revision. Source-content groups use the existing normalized-text duplicate key. This adapter does not infer shared upstream provenance between paraphrased articles; stronger source-independence decisions require curated origin metadata.
Retrieval work and limits¶
Exact objects use computed scoped keys and batched hash lookup. Text retrieval indexes words from full names, qualified path components, descriptions and supplied synonyms. Exact names rank first; remaining matches have deterministic ID order. Each posting holds at most 256 physical object IDs. A directory lists populated chunks and their ID ranges, so queries avoid probing every historical record block and can intersect more restrictive terms first. Associations have separate IDs and source/target postings, preserving endpoint roles and parallel links.
Results expose keys_probed, posting_chunks and payload_rows for catalog/index reads, plus log_rows_scanned for publication metadata. A fresh reader scans the publication log once and later refreshes only appended entries. These counters exclude ConsensusGraph's internal reads. Results report truncation and the candidate budget; broad text queries may need narrower terms or a kind. Retrieval reads published indexes and never prepares them lazily. Opening classes can provision missing empty tables, as with existing KnowledgeBase constructors; read-only is an API mutation guard, not an OS filesystem permission boundary.
The initial budgets are 8 MiB of input/encoded native document, 100000 objects, 4096 distinct indexed words per object, nesting depth 128, 1000 proposals per submission/publication, 256 KiB per proposal, 8 MiB per proposal batch, 1000 items per proposal collection and 10000 candidate IDs per index intersection. Concept and unresolved previews retain at most 100 entries with explicit totals. Read limits are 1..1000. Large exports use Python; ResearchMCP retains its existing 1 MB output limit and converts date/time objects to ISO strings for JSON transport.
Optional catalog vector retrieval is not implemented in this delivery. The native model and lexical/association indexes are sufficient for the example. The report measures warm lexical retrieval on this small fixture and compares lookup work before and after ten unrelated model imports. It does not establish latency for a production-sized catalog, cold cache, semantic vector search or NVIDIA's live application backend.
ResearchMCP exposes catalog_schema, catalog_find, catalog_object, catalog_relationships, catalog_export, catalog_history, catalog_diff and catalog_metric_summary, plus catalog_proposal for original worker outputs. Its new writes are import_ontology, submit_catalog_proposals and publish_catalog_numeric; they retain the server's read-only default, existing serialization and action audit.