Skip to content

Lang extract for experiments - #3

Open
Fraol-M wants to merge 4 commits into
BekLG:Langextract-experimentsfrom
Fraol-M:lang-extract-for-experiments
Open

Lang extract for experiments#3
Fraol-M wants to merge 4 commits into
BekLG:Langextract-experimentsfrom
Fraol-M:lang-extract-for-experiments

Conversation

@Fraol-M

@Fraol-M Fraol-M commented Jul 21, 2026

Copy link
Copy Markdown

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.py
    Adds 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.py
    Adds mention prepass support to detect names, entities, noun mentions, and pronouns before extraction.

  • PLN-RAG/core/discourse/lingmess_coreference.py
    Adds optional LingMess/FastCoref support for document-level coreference. This is hint-only and disabled by default.

  • PLN-RAG/core/evidence/ and PLN-RAG/storage/evidence_ledger.py
    Adds SQLite evidence-linked storage so accepted PLN claims are tied to exact source spans and lineage metadata.

  • PLN-RAG/storage/vector_store.py
    Updates 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.py and PLN-RAG/core/pln/predicate_mapping.py
    Adds conservative predicate registry and predicate mapping support. Semantic bridge generation remains disabled by default for proof safety.

  • PLN-RAG/core/reasoning/reasoner.py
    Runs 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.

Fraol-M added 4 commits July 20, 2026 19:34
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
Fraol-M force-pushed the lang-extract-for-experiments branch from 48a150c to 996c3d5 Compare August 7, 2026 13:12
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.

1 participant