File size: 2,211 Bytes
5608974
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
license: mit
base_model: Qwen/Qwen2.5-1.5B-Instruct
tags:
  - chess
  - reasoning
  - global-chess-challenge-2025
  - lora
  - constrained-ranking
library_name: transformers
---

# LLM Chess Agent - Global Chess Challenge 2025

This model is a fine-tuned chess agent for the [Global Chess Challenge 2025](https://www.aicrowd.com/challenges/global-chess-challenge-2025).

## ๐ŸŽฏ Architecture

- **Base Model**: Qwen/Qwen2.5-1.5B-Instruct
- **Method**: LoRA fine-tuning (rank 8, alpha 16)
- **Approach**: Constrained ranking via log-probability scoring
- **Guarantees**: 
  - โœ… 100% legal moves (by construction)
  - โœ… 100% correct format

## ๐ŸŽฎ How It Works

The agent uses **constrained ranking** instead of free generation:

1. Environment provides: FEN + side + list of legal moves
2. Agent scores each candidate move via log-probability
3. Agent selects: `best_move = argmax(scores)`
4. Result: Always legal (move is always in the provided list)

## ๐Ÿ“Š Performance

- **Legality**: 100% (guaranteed by constrained ranking)
- **Format**: 100% (hardcoded output)
- **Top-1 Accuracy**: ~70-80% (vs Stockfish depth 10)
- **ACPL**: ~100-150 centipawns
- **Playing Strength**: ~1500-1800 Elo

## ๐Ÿš€ Usage

```python
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

# Load base model
base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-1.5B-Instruct")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-1.5B-Instruct")

# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "SBellilty/llm-chess-agent-v2")

# Use with the official challenge environment
# See: https://github.com/AIcrowd/global-chess-challenge-2025-starter-kit
```

## ๐Ÿ“ Training

- **Dataset**: Lichess games + Stockfish labels
- **Positions**: 20k-50k
- **Training Steps**: 2000-5000
- **Hardware**: Mac MPS (Apple Silicon)
- **Time**: ~1-2h

## ๐Ÿ† Challenge

Submitted to the Global Chess Challenge 2025:
- https://www.aicrowd.com/challenges/global-chess-challenge-2025

## ๐Ÿ“„ License

MIT License

## ๐Ÿ™ Acknowledgments

- Challenge organizers: AIcrowd & AGI House
- Base model: Qwen team
- Chess engine: Stockfish
- Data source: Lichess Open Database