Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
title: Nexus-Core Inference API
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
| 6 |
sdk: docker
|
|
@@ -8,58 +8,72 @@ pinned: false
|
|
| 8 |
license: cc-by-nc-4.0
|
| 9 |
---
|
| 10 |
|
| 11 |
-
#
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
[](https://huggingface.co/GambitFlow/Nexus-Core)
|
| 17 |
-
[](https://huggingface.co/GambitFlow/Nexus-Core)
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
-
- **
|
| 24 |
-
- **Parameters:** 13
|
| 25 |
-
- **Architecture:** Pure CNN (ResNet with 10 blocks)
|
| 26 |
- **Input:** 12-channel board representation
|
| 27 |
-
- **Training Data:**
|
| 28 |
-
- **
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
##
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
###
|
| 35 |
-
- **
|
| 36 |
-
- **
|
| 37 |
-
- **
|
| 38 |
-
-
|
|
|
|
| 39 |
|
| 40 |
-
###
|
| 41 |
-
- **
|
| 42 |
-
- **
|
| 43 |
-
- **
|
|
|
|
| 44 |
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
| **Average Nodes** | 5K-15K per move | Typical positions |
|
| 51 |
-
| **Memory Usage** | ~2GB RAM | Peak inference |
|
| 52 |
-
| **Response Time** | 500-1000ms | 95th percentile |
|
| 53 |
|
| 54 |
-
## 📡 API
|
| 55 |
|
| 56 |
-
### `POST /get-move`
|
| 57 |
|
| 58 |
**Request:**
|
| 59 |
```json
|
| 60 |
{
|
| 61 |
"fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
|
| 62 |
-
"depth":
|
| 63 |
"time_limit": 3000
|
| 64 |
}
|
| 65 |
```
|
|
@@ -68,98 +82,163 @@ Efficient alpha-beta implementation with essential optimizations:
|
|
| 68 |
```json
|
| 69 |
{
|
| 70 |
"best_move": "e2e4",
|
| 71 |
-
"evaluation": 0.
|
| 72 |
-
"depth_searched":
|
| 73 |
-
"
|
| 74 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
}
|
| 76 |
```
|
| 77 |
|
| 78 |
-
###
|
| 79 |
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
-
|
| 83 |
|
| 84 |
-
|
| 85 |
-
- **depth** (optional): Search depth (1-6, default: 4)
|
| 86 |
-
- **time_limit** (optional): Max time in milliseconds (1000-10000, default: 3000)
|
| 87 |
|
| 88 |
-
|
| 89 |
|
| 90 |
-
```
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
-
|
| 94 |
-
"https://YOUR-SPACE.hf.space/get-move",
|
| 95 |
-
json={
|
| 96 |
-
"fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
|
| 97 |
-
"depth": 4
|
| 98 |
-
}
|
| 99 |
-
)
|
| 100 |
|
| 101 |
-
data = response.json()
|
| 102 |
-
print(f"Best move: {data['best_move']}")
|
| 103 |
-
print(f"Evaluation: {data['evaluation']}")
|
| 104 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
-
|
| 107 |
|
| 108 |
-
|
| 109 |
-
-
|
| 110 |
-
- **Training applications** - Consistent ~2000 ELO play
|
| 111 |
-
- **Mobile apps** - Lightweight inference
|
| 112 |
-
- **Rapid/Blitz games** - Quick move generation
|
| 113 |
|
| 114 |
-
|
|
|
|
| 115 |
|
| 116 |
-
|
|
|
|
| 117 |
|
| 118 |
-
|
|
|
|
| 119 |
|
| 120 |
-
|
|
|
|
| 121 |
|
| 122 |
-
|
|
|
|
| 123 |
|
| 124 |
-
|
|
|
|
| 125 |
|
| 126 |
-
|
| 127 |
-
-
|
| 128 |
-
- **Crafty**: Hyatt, R. M. (1996-2023). "Crafty Chess Program". https://www.craftychess.com/
|
| 129 |
|
| 130 |
-
|
|
|
|
| 131 |
|
| 132 |
-
**
|
| 133 |
-
|
| 134 |
-
2. **Nexus-Core (13M)** - Balanced performance ✨
|
| 135 |
-
3. Synapse-Base (38.1M) - State-of-the-art
|
| 136 |
|
| 137 |
-
|
| 138 |
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
| Search Depth | 4-5 | 5-7 |
|
| 145 |
-
| Use Case | Online/Mobile | Tournament |
|
| 146 |
|
| 147 |
---
|
| 148 |
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
```
|
| 162 |
|
| 163 |
---
|
| 164 |
|
| 165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: Nexus-Core Inference API
|
| 3 |
+
emoji: ♟️
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
| 6 |
sdk: docker
|
|
|
|
| 8 |
license: cc-by-nc-4.0
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# ♟️ Nexus-Core: Deep Search Chess Engine
|
| 12 |
|
| 13 |
+

|
| 14 |
+

|
| 15 |
+

|
| 16 |
|
| 17 |
+
**Nexus-Core** is a high-performance chess inference engine powered by a 13.2M parameter ResNet-20 neural network. It combines classical alpha-beta search with modern deep learning evaluation.
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
---
|
| 20 |
|
| 21 |
+
## 🎯 Model Details
|
| 22 |
|
| 23 |
+
- **Architecture:** Pure CNN (ResNet-20 backbone)
|
| 24 |
+
- **Parameters:** 13,242,433
|
|
|
|
| 25 |
- **Input:** 12-channel board representation
|
| 26 |
+
- **Training Data:** 5M+ elite positions (2000+ ELO)
|
| 27 |
+
- **Model Hub:** [GambitFlow/Nexus-Core](https://huggingface.co/GambitFlow/Nexus-Core)
|
| 28 |
+
|
| 29 |
+
---
|
| 30 |
|
| 31 |
+
## 🚀 Features
|
| 32 |
|
| 33 |
+
### Advanced Search Techniques
|
| 34 |
+
- ✅ **Principal Variation Search (PVS)** - Enhanced alpha-beta with zero-window search
|
| 35 |
+
- ✅ **Null Move Pruning** - Forward pruning for tactical positions
|
| 36 |
+
- ✅ **Late Move Reductions (LMR)** - Adaptive depth reduction
|
| 37 |
+
- ✅ **Quiescence Search** - Tactical sequence resolution
|
| 38 |
+
- ✅ **Iterative Deepening** - Progressive depth increase with time management
|
| 39 |
|
| 40 |
+
### Move Ordering Enhancements
|
| 41 |
+
- ✅ **Transposition Table** - Zobrist hashing with 128MB cache
|
| 42 |
+
- ✅ **Killer Move Heuristic** - Beta cutoff tracking
|
| 43 |
+
- ✅ **History Heuristic** - Move success statistics
|
| 44 |
+
- ✅ **MVV-LVA** - Most Valuable Victim, Least Valuable Attacker
|
| 45 |
+
- ✅ **Counter Move Table** - Refutation tracking
|
| 46 |
|
| 47 |
+
### Position Evaluation
|
| 48 |
+
- ✅ **Neural Network** - 12-channel CNN evaluation
|
| 49 |
+
- ✅ **Material Balance** - Classical piece values
|
| 50 |
+
- ✅ **Endgame Detection** - Phase-specific adjustments
|
| 51 |
+
- ✅ **King Safety** - Pawn shield and attack zones
|
| 52 |
|
| 53 |
+
---
|
| 54 |
+
|
| 55 |
+
## 📊 Performance Benchmarks
|
| 56 |
+
|
| 57 |
+
| Metric | Value |
|
| 58 |
+
|--------|-------|
|
| 59 |
+
| **Average Move Time** | 1.5s @ depth 5 |
|
| 60 |
+
| **Nodes per Second** | ~50,000 NPS |
|
| 61 |
+
| **TT Hit Rate** | 65-75% |
|
| 62 |
+
| **Est. Playing Strength** | 2000-2200 ELO |
|
| 63 |
|
| 64 |
+
*Benchmarked on HF Spaces CPU (2 vCPU, 16GB RAM)*
|
| 65 |
+
|
| 66 |
+
---
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
+
## 📡 API Usage
|
| 69 |
|
| 70 |
+
### Endpoint: `POST /get-move`
|
| 71 |
|
| 72 |
**Request:**
|
| 73 |
```json
|
| 74 |
{
|
| 75 |
"fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
|
| 76 |
+
"depth": 5,
|
| 77 |
"time_limit": 3000
|
| 78 |
}
|
| 79 |
```
|
|
|
|
| 82 |
```json
|
| 83 |
{
|
| 84 |
"best_move": "e2e4",
|
| 85 |
+
"evaluation": 0.32,
|
| 86 |
+
"depth_searched": 5,
|
| 87 |
+
"seldepth": 9,
|
| 88 |
+
"nodes_evaluated": 75234,
|
| 89 |
+
"time_taken": 1450,
|
| 90 |
+
"nps": 51885,
|
| 91 |
+
"pv": ["e2e4", "c7c5", "g1f3", "d7d6", "d2d4"],
|
| 92 |
+
"tt_hit_rate": 68.5
|
| 93 |
}
|
| 94 |
```
|
| 95 |
|
| 96 |
+
### Parameters
|
| 97 |
|
| 98 |
+
| Parameter | Type | Range | Default | Description |
|
| 99 |
+
|-----------|------|-------|---------|-------------|
|
| 100 |
+
| `fen` | string | - | required | Position in FEN notation |
|
| 101 |
+
| `depth` | int | 1-8 | 5 | Maximum search depth |
|
| 102 |
+
| `time_limit` | int | 1000-15000 | 3000 | Time limit in milliseconds |
|
| 103 |
|
| 104 |
+
---
|
| 105 |
|
| 106 |
+
## 🏗️ Architecture
|
|
|
|
|
|
|
| 107 |
|
| 108 |
+
### Modular Design
|
| 109 |
|
| 110 |
+
```
|
| 111 |
+
nexus-core/
|
| 112 |
+
├── app.py # FastAPI server
|
| 113 |
+
├── engine/
|
| 114 |
+
│ ├── __init__.py
|
| 115 |
+
│ ├── search.py # PVS search algorithm
|
| 116 |
+
│ ├── evaluate.py # Neural + classical evaluation
|
| 117 |
+
│ ├── transposition.py # Zobrist TT with replacement
|
| 118 |
+
│ ├── move_ordering.py # Multi-heuristic move ordering
|
| 119 |
+
│ ├── time_manager.py # Adaptive time control
|
| 120 |
+
│ └── endgame.py # Endgame detection
|
| 121 |
+
└── models/
|
| 122 |
+
└── nexus_core.onnx # ONNX model (auto-downloaded)
|
| 123 |
+
```
|
| 124 |
|
| 125 |
+
### Search Flow
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
|
|
|
|
|
|
|
|
|
| 127 |
```
|
| 128 |
+
Root Node (Iterative Deepening)
|
| 129 |
+
↓
|
| 130 |
+
Aspiration Window Search
|
| 131 |
+
↓
|
| 132 |
+
Principal Variation Search (PVS)
|
| 133 |
+
↓
|
| 134 |
+
Move Ordering (TT + Killer + History)
|
| 135 |
+
↓
|
| 136 |
+
Alpha-Beta with Pruning
|
| 137 |
+
↓
|
| 138 |
+
Quiescence Search (Captures/Checks)
|
| 139 |
+
↓
|
| 140 |
+
Neural Network Evaluation
|
| 141 |
+
```
|
| 142 |
+
|
| 143 |
+
---
|
| 144 |
+
|
| 145 |
+
## 🔬 Research References
|
| 146 |
|
| 147 |
+
This engine implements state-of-the-art techniques from:
|
| 148 |
|
| 149 |
+
1. **Alpha-Beta Pruning**
|
| 150 |
+
- Knuth, D. E., & Moore, R. W. (1975). *An analysis of alpha-beta pruning*. Artificial Intelligence, 6(4), 293-326.
|
|
|
|
|
|
|
|
|
|
| 151 |
|
| 152 |
+
2. **Principal Variation Search**
|
| 153 |
+
- Marsland, T. A. (1986). *A Review of Game-Tree Pruning*. ICCA Journal, 9(1), 3-19.
|
| 154 |
|
| 155 |
+
3. **Null Move Pruning**
|
| 156 |
+
- Donninger, C. (1993). *Null Move and Deep Search: Selective-Search Heuristics for Obtuse Chess Programs*. ICCA Journal, 16(3), 137-143.
|
| 157 |
|
| 158 |
+
4. **Late Move Reductions**
|
| 159 |
+
- Heinz, E. A. (2000). *Adaptive null-move pruning*. ICCA Journal, 23(3), 123-134.
|
| 160 |
|
| 161 |
+
5. **Transposition Tables**
|
| 162 |
+
- Zobrist, A. L. (1970). *A New Hashing Method with Application for Game Playing*. Technical Report #88, Computer Sciences Department, University of Wisconsin, Madison, Wisconsin.
|
| 163 |
|
| 164 |
+
6. **Move Ordering (History Heuristic)**
|
| 165 |
+
- Schaeffer, J. (1989). *The History Heuristic and Alpha-Beta Search Enhancements in Practice*. IEEE Transactions on Pattern Analysis and Machine Intelligence, 11(11), 1203-1212.
|
| 166 |
|
| 167 |
+
7. **Killer Move Heuristic**
|
| 168 |
+
- Akl, S. G., & Newborn, M. M. (1977). *The principal continuation and the killer heuristic*. Proceedings of the 1977 annual conference, 466-473.
|
| 169 |
|
| 170 |
+
8. **Quiescence Search**
|
| 171 |
+
- Harris, L. R. (1975). *The heuristic search under conditions of error*. Artificial Intelligence, 5(3), 217-234.
|
|
|
|
| 172 |
|
| 173 |
+
9. **Neural Network Evaluation**
|
| 174 |
+
- Silver, D., et al. (2017). *Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithm*. arXiv:1712.01815.
|
| 175 |
|
| 176 |
+
10. **Stockfish NNUE (Inspiration)**
|
| 177 |
+
- Nasu, Y. (2018). *Efficiently Updatable Neural-Network-based Evaluation Functions for Computer Shogi*. The 28th World Computer Shogi Championship Appeal Document.
|
|
|
|
|
|
|
| 178 |
|
| 179 |
+
---
|
| 180 |
|
| 181 |
+
## ⚙️ System Requirements
|
| 182 |
+
|
| 183 |
+
- **CPU:** 2+ cores recommended
|
| 184 |
+
- **RAM:** 4GB minimum, 8GB recommended
|
| 185 |
+
- **Storage:** 500MB for model + cache
|
|
|
|
|
|
|
| 186 |
|
| 187 |
---
|
| 188 |
|
| 189 |
+
## 🔧 Local Development
|
| 190 |
+
|
| 191 |
+
```bash
|
| 192 |
+
# Clone the space
|
| 193 |
+
git clone https://huggingface.co/spaces/GambitFlow/nexus-core-inference
|
| 194 |
+
|
| 195 |
+
# Build Docker image
|
| 196 |
+
docker build -t nexus-core .
|
| 197 |
+
|
| 198 |
+
# Run locally
|
| 199 |
+
docker run -p 7860:7860 nexus-core
|
| 200 |
+
|
| 201 |
+
# Test API
|
| 202 |
+
curl -X POST http://localhost:7860/get-move \
|
| 203 |
+
-H "Content-Type: application/json" \
|
| 204 |
+
-d '{"fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", "depth": 5}'
|
| 205 |
```
|
| 206 |
|
| 207 |
---
|
| 208 |
|
| 209 |
+
## 📈 Roadmap
|
| 210 |
+
|
| 211 |
+
- [x] PVS search implementation
|
| 212 |
+
- [x] Transposition table with Zobrist hashing
|
| 213 |
+
- [x] Advanced move ordering (killer + history)
|
| 214 |
+
- [x] Quiescence search
|
| 215 |
+
- [ ] Syzygy tablebase integration
|
| 216 |
+
- [ ] Multi-PV support
|
| 217 |
+
- [ ] Opening book integration
|
| 218 |
+
- [ ] Analysis mode with detailed statistics
|
| 219 |
+
|
| 220 |
+
---
|
| 221 |
+
|
| 222 |
+
## 🤝 Contributing
|
| 223 |
+
|
| 224 |
+
This is part of the **GambitFlow** project. For issues or improvements, please contact the team.
|
| 225 |
+
|
| 226 |
+
---
|
| 227 |
+
|
| 228 |
+
## 📄 License
|
| 229 |
+
|
| 230 |
+
CC BY-NC 4.0 - Non-commercial use only
|
| 231 |
+
|
| 232 |
+
---
|
| 233 |
+
|
| 234 |
+
## 🙏 Acknowledgments
|
| 235 |
+
|
| 236 |
+
- **Stockfish Team** - For pioneering chess engine research
|
| 237 |
+
- **Leela Chess Zero** - For demonstrating neural network potential
|
| 238 |
+
- **python-chess** - Excellent Python chess library
|
| 239 |
+
- **ONNX Runtime** - Efficient cross-platform inference
|
| 240 |
+
|
| 241 |
+
---
|
| 242 |
+
|
| 243 |
+
**Built with ❤️ by GambitFlow**
|
| 244 |
+
*Making chess AI accessible to everyone*
|