Skip to content

Peng/run natural reasoning#155

Open
PengLin-Zilv wants to merge 12 commits into
mainfrom
peng/run_natural_reasoning
Open

Peng/run natural reasoning#155
PengLin-Zilv wants to merge 12 commits into
mainfrom
peng/run_natural_reasoning

Conversation

@PengLin-Zilv
Copy link
Copy Markdown
Contributor

Summary

Per Kaustuv's feedback, add a wrapper script that takes a user-input paragraph, runs the full natural language → PyReason → natural language pipeline, and prints the reasoning results split into Input and Output sections.

Changes and next steps

  • New file: examples/run_natural_reasoning.py
  • will remove old natural_language_to_pyreason_ex.py if needed
  • will revise the tutorial file after this script gets approval and finalize

Pipeline

  1. Step 1 — LLM extracts facts and rules in plain English from the paragraph
  2. Step 2 — LLM converts English facts/rules into PyReason syntax
  3. Step 3 — Parser splits the LLM output into a facts list and a rules list
  4. Relax body bounds — auto-revise rule bodies so probabilistic conclusions can chain across rules (PyReason's default [1,1] body bound blocks [0.8,1] derivations from chaining)
  5. Step 4 — Build a NetworkX graph from the entities, load facts/rules into PyReason, run pr.reason()
  6. Step 5 — Split results into Input (relevant facts) and Output (derived conclusions). Entities for which no rule fired are filtered out
  7. Step 6 — LLM translates each section back into natural English with proper grammar and percentage formatting

Example Output

Lawyer paragraph:
image

Nurse paragraph:
image

PengLin-Zilv and others added 2 commits May 15, 2026 16:30
- Restructure with Introduction, Expected Output, and Limitations
  sections to match the conventions of other PyReason tutorials
- Replace `::` literal blocks with `.. code:: text` for consistency
- Drop "What's Next" section in favor of a tighter "Limitations" section
- Add cross-reference to "Notes on Model Choice"
- Fix "prefered" -> "preferred" typo in the conversion prompt
  (also in the two example scripts)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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