Lang extract for experiments - #3
Open
Fraol-M wants to merge 4 commits into
Open
Conversation
Addresses the PR review: query candidates were being suppressed, provider failures surfaced as 500s, and model ids were misconfigurable. Observability and robustness: - /debug/query hardcoded pln_canonicalized_queries=[] on the no-candidate return, so every diagnostic misreported where failures happened - fail-open query generation; provider errors degrade to no_query, not 500 - per-candidate candidate_rejections naming the gate that discarded each one - normalize_model_id: langextract anchors its router patterns, so "gemini/..." matched by accident while "openai/gpt-4o-mini" could not - cache reasoner atoms/rules; they were re-read from disk per recursion level Semantic layer, replacing ~270 lines of hardcoded English: - core/query/target_gate.py ranks candidates by embedding, then takes one batched LLM verdict (asks_exactly / asks_negation / epistemic_proxy / related / unrelated). asks_negation needs higher confidence since it inverts the answer - delete the synonym tables (obesity/carb/waive/deny) that passed the bundled cases and rejected correct targets everywhere else - one shared symbol canonicalizer; identifier-shaped tokens keep their shape (HbA1c no longer becomes hb_a1c) and two divergent singularizers are gone - rule conclusions can express negation; negative goals reach the chainer - predicate bridges enabled, carrying classifier confidence, so bridged proofs report support_kind="probabilistic" rather than "entailed" Heuristics removed for fabricating unprovable or unsound atoms: - build_heuristic_question_queries: regexes minting (HasA X Y) targets that the knowledge base never stored - infer_entity_types: typed any capitalized name as a person, so a lake satisfied rules requiring (IsA $x person) - portion-size arity rewriting, keyed to one benchmark's food vocabulary Bundled benchmark, 45 queries: 30/45 -> 31/45, no_query 10 -> 0, negative accuracy 0.36 -> 0.50, overclaims 0, decisive precision 1.0. Not solved. On stress25_v1 (25 real abstracts) only 2 of 5 proofs are genuinely correct: A12 and S06 return decisive wrong answers from trivially-provable off-topic targets, and "studies evaluate whether X" is still read as X. Open-question binding enumeration returns 0/25 on real text because extracted atoms do not match the generated open target's shape. Positive accuracy 0.53 remains below the 0.60 baseline and query p95 is 1.7x. Claim entailment checking and comparison-question answers are not built.
Fraol-M
force-pushed
the
lang-extract-for-experiments
branch
from
August 7, 2026 13:12
48a150c to
996c3d5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces an additional PLN generator based on the LangExtract library, with a proof-safe PLN-RAG pipeline for extraction, storage, retrieval, query planning, and reasoning.
Implementation Details
PLN-RAG/parsers/langextract_pln_parser.pyAdds the LangExtract parser entry point for extracting facts, rules, negations, types, and queries.
PLN-RAG/core/extraction/Handles LangExtract chunking, examples, and translation from LangExtract objects into PLN-style atoms.
PLN-RAG/core/discourse/mention_prepass.pyAdds mention prepass support to detect names, entities, noun mentions, and pronouns before extraction.
PLN-RAG/core/discourse/lingmess_coreference.pyAdds optional LingMess/FastCoref support for document-level coreference. This is hint-only and disabled by default.
PLN-RAG/core/evidence/andPLN-RAG/storage/evidence_ledger.pyAdds SQLite evidence-linked storage so accepted PLN claims are tied to exact source spans and lineage metadata.
PLN-RAG/storage/vector_store.pyUpdates Qdrant retrieval to store and retrieve accepted claim/query-target records instead of trusting raw chunk similarity.
PLN-RAG/core/query/Adds query planning and safety gates for intent, entity, predicate, arity, and polarity before sending a query to the reasoner.
PLN-RAG/core/pln/predicate_registry.pyandPLN-RAG/core/pln/predicate_mapping.pyAdds conservative predicate registry and predicate mapping support. Semantic bridge generation remains disabled by default for proof safety.
PLN-RAG/core/reasoning/reasoner.pyRuns proof search over selected PLN queries and checks positive vs explicit-negative proof status.
PLN-RAG/docs/Documents the architecture, coreference behavior, and proof-safe retrieval model.
Proof Safety Notes
Qdrant is used only for retrieval and candidate query alignment. It does not prove answers.
The final answer is produced only after the selected PLN query is checked by the reasoner. If the system cannot prove either the positive claim or explicit negation, it returns unknown instead of guessing.
Predicate mappings are stored as metadata by default and do not become proof rules unless explicitly enabled.