Skip to content

Commit 5cfd1d7

Browse files
BasedestBerryclaude
andcommitted
Integrate maia3 model for analysis with 600-2600 rating range
Replace maia2 ONNX model with maia3 for client-side analysis. Maia3 uses a transformer architecture with continuous ELO conditioning (interpolated embeddings) and WDL value head, expanding the analysis rating range from 1100-1900 to 600-2600. - Add maia3 simplified ONNX model (86.8MB, fp32) and 4352-move mapping files - Add maia3 preprocessing (64x12 board tokens) and batch inference methods - Update all rating references, chart ticks, UI labels, and dropdown rendering - Fix .slice(-4) pattern that broke 3-digit ratings (use .replace instead) - Update download modal text and model URL to maia3 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 66bae69 commit 5cfd1d7

20 files changed

Lines changed: 322 additions & 44 deletions

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ yarn-error.log*
3737
# typescript
3838
*.tsbuildinfo
3939

40-
# Large model weights - hosted on GitHub Releases, not committed to the repo
40+
# Large model weights
4141
/public/maia2/*.onnx
4242
/public/stockfish/*.nnue
43+
44+
# Maia3 training code and checkpoints
45+
/maia3_code/
46+
*.pt

public/maia3/maia3_simplified.onnx

86.8 MB
Binary file not shown.

src/api/analysis.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export const fetchAnalyzedMaiaGame = async (
226226
const blackPlayer = data['black_player'] as Player
227227
const whitePlayer = data['white_player'] as Player
228228

229-
const maiaPattern = /maia_kdd_1\d00/
229+
const maiaPattern = /maia_kdd_\d{3,4}/
230230

231231
if (blackPlayer.name && maiaPattern.test(blackPlayer.name)) {
232232
blackPlayer.name = blackPlayer.name.replace('maia_kdd_', 'Maia ')

src/components/Analysis/BoardChrome.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ export const AnalysisMaiaWinrateBar: React.FC<AnalysisMaiaWinrateBarProps> = ({
250250
: 'w-4'
251251
const tickTextClass = isDesktop
252252
? isExpandedDesktop
253-
? 'text-[9px]'
254-
: 'text-[8px]'
255-
: 'text-[8px]'
253+
? 'text-[8px]'
254+
: 'text-[7px]'
255+
: 'text-[7px]'
256256
const bubbleClass = isDesktop
257257
? isExpandedDesktop
258258
? 'h-6 min-w-[42px] px-2 text-[11px]'

src/components/Analysis/Highlight.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ export const Highlight: React.FC<Props> = ({
355355
}, [boardDescription?.segments?.length])
356356

357357
const useCompactMobileColumnTitles = isMobile || simplified
358-
const mobileMaiaColumnTitle = `Maia ${currentMaiaModel.slice(-4)}: Human Moves`
358+
const maiaRating = currentMaiaModel.replace('maia_kdd_', '')
359+
const mobileMaiaColumnTitle = `Maia ${maiaRating}: Human Moves`
359360
const mobileStockfishColumnTitle = 'SF 17: Engine Moves'
360361
const compactTitleRowClass = 'grid h-11 place-items-center'
361362
const splitTitleRowClass = 'grid h-12 place-items-center'
@@ -414,7 +415,7 @@ export const Highlight: React.FC<Props> = ({
414415
>
415416
{useCompactMobileColumnTitles
416417
? mobileMaiaColumnTitle
417-
: `Maia ${currentMaiaModel.slice(-4)}`}
418+
: `Maia ${maiaRating}`}
418419
</div>
419420
) : (
420421
<>
@@ -434,7 +435,7 @@ export const Highlight: React.FC<Props> = ({
434435
key={model}
435436
className="bg-transparent text-human-1"
436437
>
437-
{`Maia ${model.slice(-4)}`}
438+
{`Maia ${model.replace('maia_kdd_', '')}`}
438439
</option>
439440
))}
440441
</select>
@@ -455,7 +456,7 @@ export const Highlight: React.FC<Props> = ({
455456
key={model}
456457
className="bg-transparent text-human-1"
457458
>
458-
{`Maia ${model.slice(-4)}`}
459+
{`Maia ${model.replace('maia_kdd_', '')}`}
459460
</option>
460461
))}
461462
</select>

src/components/Analysis/MovesByRating.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@ export const MovesByRating: React.FC<Props> = ({
6767
tickMargin={4}
6868
ticks={
6969
isMobile
70-
? [1100, 1300, 1500, 1700, 1900]
71-
: [1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900]
70+
? [600, 1000, 1400, 1800, 2200, 2600]
71+
: [
72+
600, 800, 1000, 1200, 1400, 1600, 1800, 2000, 2200, 2400,
73+
2600,
74+
]
7275
}
7376
/>
7477
<YAxis

src/components/Common/DownloadModelModal.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const DownloadModelModal: React.FC<Props> = ({
103103

104104
<div className="flex flex-col gap-3 text-sm md:text-base">
105105
<p className="text-primary/80">
106-
Our newest model, Maia 2, provides richer and more in-depth
106+
Our newest model, Maia 3, provides richer and more in-depth
107107
analysis, allowing for:
108108
</p>
109109
<ul className="flex list-inside flex-col gap-1.5 pl-2 text-white/80">
@@ -120,7 +120,7 @@ export const DownloadModelModal: React.FC<Props> = ({
120120
</li>
121121
</ul>
122122
<p className="text-white/80">
123-
Maia 2 runs entirely on your device and requires a one-time 90mb
123+
Maia 3 runs entirely on your device and requires a one-time 87mb
124124
download.
125125
</p>
126126
</div>
@@ -174,8 +174,8 @@ export const DownloadModelModal: React.FC<Props> = ({
174174
</span>
175175
)}
176176
<p className="font-medium">
177-
{isDownloading ? 'Downloading...' : 'Download Maia 2'}{' '}
178-
<span className="text-xs text-white/70">(90mb)</span>
177+
{isDownloading ? 'Downloading...' : 'Download Maia 3'}{' '}
178+
<span className="text-xs text-white/70">(87mb)</span>
179179
</p>
180180
</div>
181181
</div>

src/components/Home/AboutMaia.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,8 @@ export const AboutMaia = () => {
237237
Maia is trained to predict human moves rather than to find the
238238
optimal move in a position. As a result, Maia exhibits common
239239
human biases and makes many of the same mistakes that humans make.
240-
We have trained a set of nine neural network engines, each
241-
targeting a specific rating level on the Lichess.org rating scale,
242-
from 1100 to 1900.
240+
We have trained a neural network engine that can target any rating
241+
level on the Lichess.org rating scale, from 600 to 2600.
243242
</p>
244243

245244
<p className="text-primary/90">

src/components/Openings/MaiaRatingInsights.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const MaiaRatingInsights: React.FC<Props> = ({ ratingPrediction }) => {
6767
const upperBound = Math.round(
6868
ratingPrediction.predictedRating + ratingPrediction.standardDeviation,
6969
)
70-
return `${Math.max(1100, lowerBound)}${Math.min(1900, upperBound)}`
70+
return `${Math.max(600, lowerBound)}${Math.min(2600, upperBound)}`
7171
}
7272

7373
return (
@@ -160,8 +160,8 @@ export const MaiaRatingInsights: React.FC<Props> = ({ ratingPrediction }) => {
160160
<span className="font-semibold text-human-2">
161161
How it&apos;s calculated:{' '}
162162
</span>
163-
We analyze each position before your moves using 9 different Maia
164-
models (1100-1900). For each model, we calculate the probability it
163+
We analyze each position before your moves using 21 different Maia
164+
models (600-2600). For each model, we calculate the probability it
165165
would play your chosen move. The final rating is the specific level
166166
that had the highest log likelihood of predicting your actual moves.
167167
</p>

src/constants/analysis.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export const MOVE_CLASSIFICATION_THRESHOLDS = {
1818
} as const
1919

2020
export const DEFAULT_MAIA_MODEL = 'maia_kdd_1500' as const
21+
export const MAIA_MIN_RATING = 600 as const
22+
export const MAIA_MAX_RATING = 2600 as const
2123
export const MIN_STOCKFISH_DEPTH = 12 as const
2224
export const LEARN_FROM_MISTAKES_DEPTH = 12 as const
2325
export const STOCKFISH_DEBUG_RERUN_EVENT = 'maia:stockfish-debug-rerun' as const

0 commit comments

Comments
 (0)