Skip to content

New Release (0.11.0) - #643

Merged
Demirrr merged 155 commits into
masterfrom
develop
Oct 16, 2026
Merged

Demirrr merged 155 commits into
masterfrom
develop

Conversation

@Demirrr

@Demirrr Demirrr commented Oct 16, 2026

Copy link
Copy Markdown
Member

Ontolearn 0.11.0

A stability and correctness release: a new goal-directed learning-problem generator, reproducible Drill runs, a long list of bug fixes across TDL, CELOE, TripleStore, NCES and CLIP, and a much better-tested codebase.

Highlights

Upgrade notes

  • Requires Python >= 3.11 (package metadata and docs now say so consistently).
  • Depends on owlapy 1.6.6, which makes owlready2 an optional extra. ontolearn.incomplete_kb and ontolearn.semantic_caching import it lazily; install it explicitly if you use them with owlready2.
  • Removed: ontolearn/tentris.py (not importable since the owlapy 1.1.0 migration), CELOE._add_node_evald, ontolearn/logging_tentris.conf.
  • Behavior changes to be aware of
    • CLIP length predictions can differ from 0.10.0 for the same inputs (negatives are now actually used at inference).
    • TDL/TDL_refinement no longer share a mutable kwargs_grid_search default between instances.
    • TDL/TDL_refinement data-property filtering gained a toggle for boolean data properties (use_data_properties_boolean, Data property filtering logic for TDL and some fixes for TDL++ #588); TDL's feature-matrix max_runtime now defaults to None (Tdl max runtime implementation #585).
    • Output previously print()ed in knowledge_base, semantic_caching, drill and a few more modules now goes through logging (configure levels as usual).

Fixed

Performance

Internal

  • TDL_refinement.fit() / create_training_data deduplicated into shared TDL hooks (Deduplicate TDL_refinement.fit() against TDL via shared template-method hooks #616); abox(), get_top_n and quality_funcs deduplicated.
  • New unit tests for quality_funcs (31→100%), nces_utils (39→87%), incomplete_kb (8→91%), data_struct (~60→97%), value_splitter (33→100%) and utils/static_funcs (37→92%).
  • Ruff >=0.16 with an explicit ruff.toml; CI job has a 90-minute safety timeout.

Full changelog: https://github.com/dice-group/Ontolearn/blob/develop/CHANGELOG.md
Compare: 0.10.0...0.11.0

🤖 Generated with Claude Code

…feature refinement, add permutation feature importance
Demirrr and others added 29 commits August 14, 2026 08:49
TripleStoreReasoner.instances rewrote every "?x a " occurrence in the
generated SPARQL to the same "?some_cls" variable. For class expressions
placing multiple such occurrences in different scopes (e.g. inside vs.
outside a FILTER NOT EXISTS block, as with (¬Daughter) ⊓ Female), the
shared variable name let occurrences bind to each other instead of being
scoped independently, producing incorrect results. Each occurrence now
gets its own uniquely numbered ?some_cls_N variable.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
tests/test_triplestore_indirect_instances_sparql.py mocks the HTTP layer
(matching the existing tests/test_triplestore_sparql_optimizations.py
pattern) so it exercises TripleStoreReasoner.instances' query-construction
logic without needing a live triplestore. Verified the tests fail against
the pre-fix code (both occurrences share "?some_cls") and pass against the
fix (each gets its own "?some_cls_N").

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Fix variable capture in indirect instance retrieval SPARQL (#575)
…) as optional hook

- CELOE._add_node_evald (celoe.py) was a near-duplicate of _add_node with
  zero call sites anywhere in the repo; removed along with the now-unused
  EvaluatedConcept import.
- BaseConceptLearner.train() was a no-op stub whose docstring claimed
  "Train RL agent ... Returns: self" while returning None, and trainable
  learners (Drill, NCES, NCES2, ROCES, CLIP) each define their own train()
  with unrelated signatures. It now returns self as documented and its
  docstring states the real contract: an optional, learner-specific hook
  that defaults to a no-op so untrainable learners work in generic
  pipelines like Experiments.carry_out_kfold_cross_validation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Fx5MeTtkbrDshy6vQs3LY
Fixes the Improvements.md error-handling item: two bare `except:` blocks
(data_struct.py) that swallowed everything including KeyboardInterrupt/
SystemExit are narrowed to the specific exception they're actually
guarding against (ValueError, KeyError). SPARQLQueryLearner's
_http_request now raises requests.exceptions.HTTPError instead of a bare
Exception, letting _compute_f1_score narrow its catch to the query's
actual failure modes. TDL's three feature-extraction methods
(tree_learner.py) no longer let a bug in OWL-object construction hide
behind the same except as a benign reasoner miss, and now always log the
caught exception instead of only when verbose>0. CELOE's
`updating_node`/`heuristic_queue.discard` ValueError, previously a silent
`pass` next to an unresolved TODO, is now documented (SortedSet keyed by a
mutable heuristic value; ValueError means queue membership and the
node's heuristic went out of sync) and logged instead of ignored.

The remaining nces.py/nces2.py broad catches are left as Exception with
clarifying comments: they wrap parsing of raw, unconstrained neural model
output, where the failure surface is inherently unbounded by design.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016zxtYvm4ti1QCNsxMYvES8
Addresses the first bullet of Improvements.md's "Error handling &
logging" section: knowledge_base.py, semantic_caching.py,
learners/tree_learner_refinement_inherit.py,
learners/spell_kit/structures.py, and learners/drill.py now emit
info/warning/debug/error through logging.getLogger(__name__) instead
of unconditionally printing to stdout. structure_to_dot's print()s are
left untouched since they're the function's actual DOT-graph output,
not log messages. Remaining offenders (nces.py, nces2.py,
tree_learner.py, celoe.py, sparql_query_learner.py, data_struct.py)
overlap with the broad-except cleanup and are left for that pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…train-stub

Remove dead CELOE._add_node_evald
Narrow bare/broad except clauses in learners and data_struct
Route print() calls through module loggers in the worst offenders
Removed one email contact from the README.
ontolearn.lp_generator.LPGen/KB2Data synthesize learning problems bottom-up
by refining owl:Thing and keeping whatever non-redundant concepts fall out,
with no way to target specific DL constructs or a complexity budget.

Add GoalDirectedLPGenerator: samples target concepts top-down from an
explicit DL-construct grammar (ComplexityProfile controls which of
intersection/union/exists/forall/cardinality/has-value/negation are
allowed, plus length/depth/arity bounds), retrieves pos/neg via the
reasoner, and filters out trivially-solvable problems (where a cheap
one-step hypothesis already separates pos/neg). generate_benchmark() runs
a curriculum of profiles at once.

examples/benchmark_complexity_lp_generator_with_tdl.py demonstrates the
generator end-to-end: a 6-step complexity curriculum on the Family KG,
fitting TDL on each generated problem and scoring its learned hypothesis
against the target's ground-truth (E+, E-).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Extend GoalDirectedLPGenerator to actively search for hard learning
problems, not just non-trivial ones:

- DifficultyWeights/ComplexityProfile.difficulty_score combines normalized
  target length/depth, (1 - baseline F1), and near-miss-negative density
  (individuals satisfying the target with one top-level conjunct dropped,
  e.g. right class but wrong relation) into one score.
- generate() oversamples candidates (profile.oversample_factor) and keeps
  the num_lps hardest by that score, instead of the first num_lps that
  clear the minimum bar.
- Negative examples are biased towards near-miss negatives
  (hard_negative_ratio), the negatives most likely to trip up a greedy
  top-down learner.
- The DL-construct grammar now degrades gracefully on a knowledge base
  with no object properties (e.g. Lymphography) instead of crashing:
  relation-based constructs (exists/forall/cardinality/has-value) are
  silently dropped from what's sampled.

Verified across Family (dense relational), Lymphography (zero object
properties), Biopax (ontology-heavy, many properties) and Mutagenesis
(14k individuals) - each KB's own signature drives generation, so the
same ComplexityProfile curriculum runs unmodified on all of them.

examples/benchmark_complexity_lp_generator_with_tdl.py now sweeps a list
of knowledge bases (--kb accepts multiple paths, defaulting to Family,
Mutagenesis, Carcinogenesis, Biopax, Lymphography) and reports difficulty
alongside TDL's F1 per (kb, profile). On Biopax this surfaces a real TDL
weakness invisible on Family: mean F1 drops to 0.40 on the "conjunctive"
profile, including one target TDL misses entirely (F1=0.0).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The {} default was mutated in place via setdefault('cv', 10), leaking
state between learner instances and into caller-supplied dicts. Default
is now None and each instance gets its own copy. Adds a regression test
and prunes the item from Improvements.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…id-search

Fix shared mutable default kwargs_grid_search in TDL/TDL_refinement
Add goal-directed, complexity-controlled learning-problem generator
datapoint_neg was looked up with embeddings.loc[pos]; use neg. Adds a
regression test that compares values, not just shapes. Fixes #638.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Targets three of the weakest-covered modules listed in Improvements.md:
quality_funcs 31% -> 100%, nces_utils 39% -> 87%, incomplete_kb 8% -> 91%.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
data_struct ~60% -> 97%, value_splitter 33% -> 100%, utils/static_funcs
37% -> 92%.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Fix CLIPDatasetInference using positive examples for the negative tensor
Add unit tests for quality_funcs, nces_utils, incomplete_kb, data_struct, value_splitter, static_funcs
)

owlapy <= 1.6.5 emitted '?s a owl:Thing' for a top filler, which a
triplestore without reasoning never satisfies. Add tests that need no
triplestore and a changelog note; the fix itself is the owlapy 1.6.6 bump.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Add regression guard for explicit owl:Thing patterns in generated SPARQL (#581)
…used logging_tentris.conf

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Demirrr
Demirrr merged commit 7432b37 into master Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants