Views
No views yet
| Language Code | Language Name | Native Name |
|---|---|---|
en | English | English |
hi | Hindi | हिन्दी |
es | Spanish | Español |
zh | Mandarin Chinese | 中文 |
fr | French | Français |
de | German | Deutsch |
pt | Portuguese | Português |
ru | Russian | Русский |
ja | Japanese | 日本語 |
ar | Arabic | العربية |
ko | Korean | 한국어 |
tr | Turkish | Türkçe |
id | Indonesian | Bahasa Indonesia |
bn | Bengali | বাংলা |
1{
2 'role': 'system',
3 'content': 'Generate professional chess commentary in the specified language. For Type=standard use 30–40 words. For Type=explanation, explain the best move briefly (≤50 words). Return exactly: Commentary, Predicted ELO, Verified Classification.'
4}1{
2 'role': 'user',
3 'content': '''LanguageL: English
4LangCode: en
5Type: standard
6FEN: rnbqkbnr/pppppppp/8/8/3P4/8/PPP1PPPP/RNBQKBNR b KQkq - 0 1
7MoveSAN: Nf6
8Side: Black
9Actor: human
10Name: John
11Gender: male
12Tag: Book
13BestAlt: g8f6
14CP: 27->21 (Δ=6)'''
15}| Field | Type | Required | Example | Explanation |
|---|---|---|---|---|
| LanguageL | string | ✅ REQUIRED | English, Hindi, Spanish | Full language name for commentary generation |
| LangCode | string | ✅ REQUIRED | en, hi, es | ISO 639-1 language code (see table above) |
| Type | string | ✅ REQUIRED | standard, explanation | Commentary type: standard (30-40 words) or explanation (explain best move, ≤50 words) |
| FEN | string | ✅ REQUIRED | rnbqkbnr/pppppppp/8/8/3P4/8/PPP1PPPP/RNBQKBNR b KQkq - 0 1 | Forsyth-Edwards Notation - exact chess position before the move |
| MoveSAN | string | ✅ REQUIRED | Nf6, e4, O-O | Standard Algebraic Notation - the move that was played |
| Side | string | ✅ REQUIRED | White, Black | Which side played the move |
| Actor | string | ✅ REQUIRED | human, bot | Whether move was made by human or engine |
| NAME | string | OPTIONAL | Name of human or bot | Human or bot gender who played the move for personalized commentary |
| Gender | string | OPTIONAL | male, female, neutral | Player or bot gender for personalized commentary |
| Tag | string | ✅ REQUIRED | Book, Best, Good, Inaccuracy, Mistake, Blunder, Brilliant | Move classification tag |
| BestAlt | string | ✅ REQUIRED | g8f6, e2e4 | Best alternative move in coordinate notation |
| CP | string | ✅ REQUIRED | 27->21 (Δ=6) | Centipawn evaluation: before->after (Delta=change). Format: CPBefore->CPAfter (Δ=change) |
1[
2 {
3 'role': 'system',
4 'content': 'Generate professional chess commentary in the specified language. For Type=standard use 30–40 words. For Type=explanation, explain the best move briefly (≤50 words). Return exactly: Commentary, Predicted ELO, Verified Classification.'
5 },
6 {
7 'role': 'user',
8 'content': '''LanguageL: English
9LangCode: en
10Type: standard
11FEN: rnbqkbnr/pppppppp/8/8/3P4/8/PPP1PPPP/RNBQKBNR b KQkq - 0 1
12MoveSAN: Nf6
13Side: Black
14Actor: human
15Gender: male
16Tag: Book
17BestAlt: g8f6
18CP: 27->21 (Δ=6)'''
19 }
20]Commentary: Excellent opening response! Nf6 is the classical development move against d4. It immediately challenges the center and prepares flexible piece development. This maintains the tension and gives Black excellent counterplay.
Predicted ELO: 1850
Verified Classification: Book Move1[
2 {
3 'role': 'system',
4 'content': 'Generate professional chess commentary in the specified language. For Type=standard use 30–40 words. For Type=explanation, explain the best move briefly (≤50 words). Return exactly: Commentary, Predicted ELO, Verified Classification.'
5 },
6 {
7 'role': 'user',
8 'content': '''LanguageL: Hindi
9LangCode: hi
10Type: standard
11FEN: r1bqkb1r/pppp1ppp/2n2n2/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq e6 0 4
12MoveSAN: Nc3
13Side: White
14Actor: human
15Gender: female
16Tag: Best
17BestAlt: b1c3
18CP: 42->38 (Δ=4)'''
19 }
20]Commentary: शानदार केंद्रीकरण! Nc3 e4 पर दबाव के साथ विकसित होता है और प्रमुख केंद्रीय वर्गों को नियंत्रित करता है। यह चाल विकास को पूरा करने की तैयारी करती है जबकि केंद्र तनाव बनाए रखती है।
Predicted ELO: 2400
Verified Classification: Best Move1[
2 {
3 'role': 'system',
4 'content': 'Generate professional chess commentary in the specified language. For Type=standard use 30–40 words. For Type=explanation, explain the best move briefly (≤50 words). Return exactly: Commentary, Predicted ELO, Verified Classification.'
5 },
6 {
7 'role': 'user',
8 'content': '''LanguageL: Spanish
9LangCode: es
10Type: explanation
11FEN: 2rq1rk1/pb1nb1pp/1p6/3p1p2/3Pn3/P1N5/1PQNBPPP/R1B1R1K1 w - - 0 16
12MoveSAN: f3
13Side: White
14Actor: human
15Gender: male
16Tag: Mistake
17BestAlt: d2e4
18CP: 23->59 (Δ=36)'''
19 }
20]Commentary: El movimiento f3 debilita el rey y permite contraataques tácticos. La mejor alternativa Ne4 centralizaría el caballo con amenazas activas mientras mantiene la seguridad del rey. Este error costó aproximadamente un tercio de peón en ventaja posicional.
Predicted ELO: 1650
Verified Classification: Mistake1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model = AutoModelForCausalLM.from_pretrained("NAKSTStudio/chess-gemma-commentary")
4tokenizer = AutoTokenizer.from_pretrained("NAKSTStudio/chess-gemma-commentary")
5
6# Prepare messages
7messages = [
8 {
9 'role': 'system',
10 'content': 'Generate professional chess commentary in the specified language. For Type=standard use 30–40 words. For Type=explanation, explain the best move briefly (≤50 words). Return exactly: Commentary, Predicted ELO, Verified Classification.'
11 },
12 {
13 'role': 'user',
14 'content': '''LanguageL: English
15LangCode: en
16Type: standard
17FEN: rnbqkbnr/pppppppp/8/8/3P4/8/PPP1PPPP/RNBQKBNR b KQkq - 0 1
18MoveSAN: Nf6
19Side: Black
20Actor: human
21Gender: male
22Tag: Book
23BestAlt: g8f6
24CP: 27->21 (Δ=6)'''
25 }
26]
27
28# Generate response
29inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True)
30outputs = model.generate(inputs, max_new_tokens=256, temperature=0.7)
31response = tokenizer.decode(outputs[0], skip_special_tokens=True)
32print(response)1import 'package:flutter_gemma/flutter_gemma.dart';
2
3class ChessAnalyzer {
4 late InferenceModel model;
5
6 Future<void> initModel() async {
7 // Install model from Hugging Face (one-time operation)
8 await FlutterGemma.installModel(
9 modelType: ModelType.gemmaIt,
10 ).fromNetwork(
11 'https://huggingface.co/NAKSTStudio/chess-gemma-commentary/resolve/main/model.safetensors',
12 ).withProgress((progress) {
13 print('Downloading model: ${progress.percentage}%');
14 }).install();
15
16 // Create model instance for inference
17 model = await FlutterGemma.getActiveModel(
18 maxTokens: 256,
19 preferredBackend: PreferredBackend.gpu,
20 );
21 }
22
23 Future<String> analyzeMove({
24 required String language,
25 required String langCode,
26 required String type,
27 required String fen,
28 required String moveSAN,
29 required String side,
30 required String actor,
31 required String gender,
32 required String tag,
33 required String bestAlt,
34 required String cp,
35 }) async {
36 final chat = await model.createChat(temperature: 0.7);
37
38 // Add system message
39 await chat.addQueryChunk(Message.text(
40 text: 'Generate professional chess commentary in the specified language. For Type=standard use 30–40 words. For Type=explanation, explain the best move briefly (≤50 words). Return exactly: Commentary, Predicted ELO, Verified Classification.',
41 isUser: false,
42 ));
43
44 // Add user message with chess position data
45 await chat.addQueryChunk(Message.text(
46 text: '''LanguageL: $language
47LangCode: $langCode
48Type: $type
49FEN: $fen
50MoveSAN: $moveSAN
51Side: $side
52Actor: $actor
53Gender: $gender
54Tag: $tag
55BestAlt: $bestAlt
56CP: $cp''',
57 isUser: true,
58 ));
59
60 // Generate response
61 final response = await chat.generateChatResponse();
62
63 await chat.close();
64
65 if (response is TextResponse) {
66 return response.token;
67 }
68
69 return 'Error generating response';
70 }
71
72 Future<void> dispose() async {
73 await model.close();
74 }
75}
76
77// Usage
78final analyzer = ChessAnalyzer();
79
80// Initialize once (downloads model if not present)
81await analyzer.initModel();
82
83// Use multiple times
84final result = await analyzer.analyzeMove(
85 language: 'English',
86 langCode: 'en',
87 type: 'standard',
88 fen: 'rnbqkbnr/pppppppp/8/8/3P4/8/PPP1PPPP/RNBQKBNR b KQkq - 0 1',
89 moveSAN: 'Nf6',
90 side: 'Black',
91 actor: 'human',
92 gender: 'male',
93 tag: 'Book',
94 bestAlt: 'g8f6',
95 cp: '27->21 (Δ=6)',
96);
97
98print(result);
99
100// Clean up when done
101await analyzer.dispose();chess-gemma-commentary/
├── model.safetensors # Fine-tuned weights (500MB)
├── tokenizer.model # SentencePiece tokenizer
├── tokenizer.json # Tokenizer config
├── tokenizer_config.json # Tokenizer settings
├── config.json # Model architecture config
├── chat_template.jinja # Chat formatting template
├── added_tokens.json # Special tokens
└── README.md # DocumentationType=standard: Generates 30-40 word general commentaryType=explanation: Generates ≤50 word explanation focusing on why the best alternative move is superiorCPBefore->CPAfter (Δ=change) helps the model understand move impact.1@model{chess_gemma_commentary_2025,
2 title={Chess Gemma Commentary: Multilingual Chess Analysis},
3 author={NAKST Studio},
4 year={2025},
5 howpublished={Hugging Face Hub}
6}