This project combines the power of Large Language Models (LLMs) with Monte Carlo Tree Search (MCTS) to provide verifiable, optimized, and adaptive responses across various reasoning tasks. Verification backends such as Dafny and Coq are integrated to ensure correctness of logic, while containerization and GPU acceleration power its performance at scale.
Main Goal of this project was to implement an AI model locally at you desk while it turned out to be why not code it health realted wise locally at your pc get personal recommendations and everything locally
-
MCTS-Driven Reasoning: Evaluates multiple LLM-generated answers, selects optimal verified response paths.
-
Custom LLM Dataset: Over 6,800 curated samples built from healthline.com and augmented via scripting.
-
Formal Verification:
- Dafny for automated logic validation.
- Coq for proof-backed correctness.
-
Multi-GPU Enabled: Optimized for dual NVIDIA A100s with Modal Labs sandbox orchestration.
-
Docker/Singularity Ready: Containerized setup for scalable, reproducible environments.
-
Rust Integration: Planned for performance-critical components like tree simulation and concurrency.
Practical Guidline to setup a pipline between all LLms
+-----------------------+
| User Interface |
+----------+------------+
|
v
+-----------------------+
| LLM Response |
| Generation |
+----------+------------+
|
v
+-----------------------+
| Monte Carlo Tree |
| Search (MCTS) Engine |
+----------+------------+
|
+---------+--------+
| |
v v
+----------------+ +----------------+
| Dafny Verifier | | Coq Verifier |
+----------------+ +----------------+
|
v
+---------------------+
| Verified Response |
+---------------------+
MCTS is a decision-making algorithm often used in reinforcement learning and game theory. It builds a search tree incrementally using four steps:
- Selection: Select optimal child node based on a policy (e.g., UCT).
- Expansion: Generate one or more new nodes.
- Simulation: Simulate a rollout from the node.
- Backpropagation: Update the value estimates of nodes in the path.
We apply MCTS to explore different LLM-generated outputs and rank them based on formal verification and semantic alignment.
- 6,800+ Custom Samples
- Source: healthline.com + scripted augmentation
- Augmentation: Diversified question structure and context generation using Python
- Benefit: Enables LLM to handle different user querying styles effectively
import modal
app = modal.App.lookup('my-sandbox-app', create_if_missing=True)
sb = modal.Sandbox.create(app=app)
p = sb.exec('echo', 'hello world')
print(p.stdout.read())
sb.terminate()mkdir -p ~/singularity
cd ~/singularity
singularity pull docker://namin/llm-verifieddocker pull namin/llm-verified
# Run with: --docker_sandbox- Install from: https://github.com/dafny-lang/dafny
- Z3 must be on
PATH
python3 okdafny.py # Run test verificationsopam init
opam install coq
opam install "coq-serapi>=8.10.0+0.7.0"
opam repo add coq-released https://coq.inria.fr/opam/released
opam install coq-hammerRust components will:
- Optimize memory usage for tree simulations
- Improve concurrency and parallel rollout processing
- Ensure safety and performance at scale using Rust’s guarantees
| Component | Metric | Value (A100 x2) |
|---|---|---|
| LLM Inference Time | Avg. response latency | ~90 ms |
| MCTS Tree Depth | Avg. search depth | 12–20 nodes |
| Dafny Verification | Time per proof | ~120 ms |
| Coq Verification | Time per proof | ~300 ms |
| Modal Sandbox Runtime | Cold start | ~1.2s |
| Docker Execution | Total inference + verify loop | ~3.8s end-to-end |
Note: Metrics will be updated with real-time benchmarks after full pipeline integration.
This project is licensed under the MIT License. See LICENSE for details.


