Rafs-an09002 commited on
Commit
2206f19
·
verified ·
1 Parent(s): f3b91c5

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +177 -98
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
- # Nexus-Core Inference API
12
 
13
- Fast and efficient chess move prediction powered by Nexus-Core v2.0.
 
 
14
 
15
- [![Model](https://img.shields.io/badge/Model-Nexus--Core-green)](https://huggingface.co/GambitFlow/Nexus-Core)
16
- [![Parameters](https://img.shields.io/badge/Params-13M-orange)](https://huggingface.co/GambitFlow/Nexus-Core)
17
- [![Speed](https://img.shields.io/badge/Speed-Ultra--Fast-brightgreen)](https://huggingface.co/GambitFlow/Nexus-Core)
18
 
19
- ## 🎯 Model Details
20
 
21
- **Nexus-Core** is a lightweight ResNet-based chess engine optimized for speed:
22
 
23
- - **Model:** [GambitFlow/Nexus-Core](https://huggingface.co/GambitFlow/Nexus-Core)
24
- - **Parameters:** 13 Million
25
- - **Architecture:** Pure CNN (ResNet with 10 blocks)
26
  - **Input:** 12-channel board representation
27
- - **Training Data:** [GambitFlow/Elite-Data](https://huggingface.co/datasets/GambitFlow/Elite-Data) (5M+ positions)
28
- - **Strength:** 2000-2200 ELO estimated
 
 
29
 
30
- ## 🔬 Search Algorithm
31
 
32
- Efficient alpha-beta implementation with essential optimizations:
 
 
 
 
 
33
 
34
- ### Core Features
35
- - **Alpha-Beta Pruning** [^1] - Classic minimax with cutoffs
36
- - **Iterative Deepening** [^2] - Progressive depth increase
37
- - **Quiescence Search** [^3] - Tactical sequence resolution
38
- - **Simple Transposition Table** - 100K position cache
 
39
 
40
- ### Move Ordering
41
- - **MVV-LVA** [^4] - Most Valuable Victim - Least Valuable Attacker
42
- - **Promotion prioritization**
43
- - **Check detection**
 
44
 
45
- ## 📊 Performance
 
 
 
 
 
 
 
 
 
46
 
47
- | Metric | Value | Environment |
48
- |--------|-------|-------------|
49
- | **Depth 4 Search** | ~0.5-1 second | HF Spaces CPU |
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 Endpoints
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": 4,
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.21,
72
- "depth_searched": 4,
73
- "nodes_evaluated": 8432,
74
- "time_taken": 856
 
 
 
 
75
  }
76
  ```
77
 
78
- ### `GET /health`
79
 
80
- Health check endpoint.
 
 
 
 
81
 
82
- ## 🔧 Parameters
83
 
84
- - **fen** (required): Board position in FEN notation
85
- - **depth** (optional): Search depth (1-6, default: 4)
86
- - **time_limit** (optional): Max time in milliseconds (1000-10000, default: 3000)
87
 
88
- ## 🚀 Quick Start
89
 
90
- ```python
91
- import requests
 
 
 
 
 
 
 
 
 
 
 
 
92
 
93
- response = requests.post(
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
- ## 💻 Use Cases
107
 
108
- Perfect for:
109
- - **Online chess platforms** - Fast response times
110
- - **Training applications** - Consistent ~2000 ELO play
111
- - **Mobile apps** - Lightweight inference
112
- - **Rapid/Blitz games** - Quick move generation
113
 
114
- ## 📚 Research References
 
115
 
116
- [^1]: **Alpha-Beta Pruning**: Knuth, D. E., & Moore, R. W. (1975). "An analysis of alpha-beta pruning". *Artificial Intelligence*, 6(4), 293-326.
 
117
 
118
- [^2]: **Iterative Deepening**: Korf, R. E. (1985). "Depth-first iterative-deepening: An optimal admissible tree search". *Artificial Intelligence*, 27(1), 97-109.
 
119
 
120
- [^3]: **Quiescence Search**: Shannon, C. E. (1950). "Programming a computer for playing chess". *Philosophical Magazine*, 41(314), 256-275.
 
121
 
122
- [^4]: **MVV-LVA**: Hyatt, R. M., Gower, A. E., & Nelson, H. L. (1990). "Cray Blitz". *Computers, Chess, and Cognition*, 111-130.
 
123
 
124
- ## 📖 Related Work
 
125
 
126
- - **Stockfish**: https://stockfishchess.org/ - Open-source chess engine
127
- - **Fruit**: Letouzey, F. (2005). "Fruit 2.1 source code". http://www.fruitchess.com/
128
- - **Crafty**: Hyatt, R. M. (1996-2023). "Crafty Chess Program". https://www.craftychess.com/
129
 
130
- ## 🏆 Model Lineage
 
131
 
132
- **GambitFlow AI Engine Series:**
133
- 1. Nexus-Nano (2.8M) - Ultra-fast baseline
134
- 2. **Nexus-Core (13M)** - Balanced performance ✨
135
- 3. Synapse-Base (38.1M) - State-of-the-art
136
 
137
- ## ⚖️ Comparison
138
 
139
- | Feature | Nexus-Core | Synapse-Base |
140
- |---------|------------|--------------|
141
- | Speed | ⚡⚡⚡ Ultra-fast | ⚡⚡ Fast |
142
- | Strength | 2000-2200 ELO | 2400-2600 ELO |
143
- | Tactics | Basic | Advanced |
144
- | Search Depth | 4-5 | 5-7 |
145
- | Use Case | Online/Mobile | Tournament |
146
 
147
  ---
148
 
149
- **Developed by:** [GambitFlow](https://huggingface.co/GambitFlow) / Rafsan1711
150
- **License:** CC BY-NC 4.0
151
- **Citation:**
152
-
153
- ```bibtex
154
- @software{gambitflow_nexus_core_2025,
155
- author = {Rafsan1711},
156
- title = {Nexus-Core: Lightweight ResNet Chess Engine},
157
- year = {2025},
158
- publisher = {Hugging Face},
159
- url = {https://huggingface.co/GambitFlow/Nexus-Core}
160
- }
 
 
 
 
161
  ```
162
 
163
  ---
164
 
165
- Part of the **GambitFlow Project** 🚀♟️
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ![Version](https://img.shields.io/badge/version-2.0.0-blue)
14
+ ![Model Size](https://img.shields.io/badge/model-13.2M%20params-orange)
15
+ ![Architecture](https://img.shields.io/badge/arch-ResNet--20-red)
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*