Spaces:
Sleeping

Ray5th p4r5kpftnp-cmd Claude Sonnet 4.6 commited on
Commit
143dd07
·
unverified ·
1 Parent(s): 975f30b

Fix LLM hallucinated imports and slow thinking mode (#3)

Browse files

* Fix import paths and Mathlib auto-detection for LangChain 1.x

EnsembleRetriever and CrossEncoderReranker moved to langchain_classic
in LangChain 1.x — update retriever.py imports accordingly.

MathLibCorpus now searches lean-interact's TempRequireProject cache
(.lake/packages/mathlib) for Mathlib source and prefers the Mathlib/
subdirectory to avoid import-only root files returning zero declarations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Fix LLM hallucinated imports and slow thinking mode

- langgraph_agent.py: add _sanitize_imports() which strips all LLM-generated
import lines and replaces them with `import Mathlib`. LLMs consistently
hallucinate non-existent Lean paths (e.g. Mathlib.TacticLibrary.Peel) that
break compilation; the correct import for any Mathlib proof is always
`import Mathlib`.

- rag_chain.py: tighten system prompt with explicit rules (keep imports,
no spurious `open`, prefer simple tactics). Add num_predict=1024 cap and
think=False to disable chain-of-thought mode on qwen3/gemma3 models —
without this, models spend 20+ minutes generating reasoning tokens before
the actual answer.

Tested: simple_add.lean (n + 0 = n) solved in 2 attempts with gemma3:12b,
verified by Lean REPL. Proof: `simp`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: p4r5kpftnp-cmd <p4r5kpftnp@privaterelay.appleid.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>