This repository contains a reference cross-platform Node.js function app for a Decentralized BitTorrent-style AI Model Training System.
The goal of this system is to allow open-source AI models to train on rollouts shared with each other via peer-to-peer (P2P) inference calls without relying on a centralized coordinator or central data servers.
app/: A foundational TypeScript Node.js Command-Line Interface (CLI) that demonstrates the P2P swarm logic, data hashing (Rollout Torrents), and Sybil-resistant local validation logic.
- Zero Central Coordination: Relies on a DHT (Distributed Hash Table) for discovering peers, bypassing central trackers.
- Rollout Torrents: Training data
[prompt, response, reward]is securely hashed and addressed via SHA-256 chunks, ensuring data immutability. - Anti-Poisoning (Trust Ledger): Instead of a central authority verifying data, trainers locally evaluate a random sample of downloaded rollouts using "Loss Thresholding" to determine if data is toxic or valid.
- Tit-for-Tat Incentive: Built-in bandwidth allocation mechanics prioritize nodes that share beneficial data.
The application is built in Node.js + strict TypeScript, making it natively cross-platform across Windows, macOS, and Linux.
git clone https://github.com/YOUR_USERNAME/P2P-distillation.git
cd P2P-distillation/app(Note: Change YOUR_USERNAME to your GitHub username or organization).
Install the required packages (TypeScript, Commander, etc.):
npm installVerify that the core anti-poisoning, DHT stub, and rollout generation logic works on your machine using the automated tests:
npm testYou should see output indicating that all P2P Network and Rollout Distribution tests have passed.
Compile the TypeScript code into a native executable format:
npm run buildRun the application to spin up a mock Seeder node that produces rollouts and connects to the P2P network:
node dist/index.js start --role seeder --boostrap "node-alpha-1"(Wait a few seconds to see the Seeder connect to peers and begin broadcasting mocked inference rollouts to the DHT).
Disclaimer: This code currently implements the localized stubs for DHT discovery, inference generation, and validation for demonstration/architectural purposes. Integration into major ML frameworks (e.g. PyTorch, Hugging Face) for full localized backpropagation is slated for subsequent phases.