Maia2 on PicoChess?

313 views
Skip to first unread message

Andrea Gatti

unread,
Jul 7, 2025, 8:10:14 AMJul 7
to PicoChess
I've been an avid user of the Maia chess engine, because of its human-like style of play.

I've come across the information that the developers have built "Maia2" as a new version of the "engine", which emulates the human style of play in a much more accurate manner, compared to its initial version.

As far as I understand, Maia2 doesn't run on Lc0 anymore, it's not released as an UCI engine, but you can freely use it using the code they provided:

"The newest model doesn’t run on lc0. You can inference it via the code provided in this repository: https://github.com/CSSLab/maia2"

I understand there's python code in there, and I'm providing this info with the hope that some developers here, with the necessary time and skill (and I am definitely not a developer... ) one day will positively evaluate the possibility to incorporate Maia2 as an "engine" in PicoChess.

Thanks for reading.
AG

Dirk

unread,
Jul 9, 2025, 4:07:44 PMJul 9
to PicoChess
Very interesting - did not know at all anything about maia2 until now.

Indeed it looks like it does not use lc0 at the moment - instead of the inference function with (py)torch in order to predict the next move

The good thing by using lc0 with compatible nets is that performance is better and we can use the Maia nets in standard lc0 and set max. depth or nodes top other (higher) values than 1 (which is default in Maia engine) so that no more terrible tactical blunders happen which even a human beginner would not make ;-)

Torch Ā on a raspberry pi can be tricky from what I have read Ā (and probably only useable on a PI4 or PI5).

At least on my Mac I could implement a first draft uci version...Ā 

maia2 — maia2_uci.py.jpg

When I have time I will try it on my raspberry pi but I don't expect too much...

Dirk

Andrea Gatti

unread,
Jul 10, 2025, 3:07:56 AMJul 10
to PicoChess
Unbelievable. You basically have already done it, have no words..

Dirk many thanks for picking this up!

Andrea.

Dirk

unread,
Jul 10, 2025, 2:43:01 PMJul 10
to PicoChess
🄳

PicoChess-Maia2.jpg

Andrea Gatti

unread,
Jul 11, 2025, 2:58:40 AMJul 11
to PicoChess
Wow!!

Any chance this gets into a future release of PicoChess? - You know I was about to ask!!

Dirk

unread,
Jul 11, 2025, 7:02:55 AMJul 11
to PicoChess
Hi Andrea,

although I doubt that playing against the current development state of Maia2 and the contained pretrained nets is much fun as a playing against maia1 we could add maia2 without any problems (I think Ā  because I was able to do this ;-) to PicoChess.

My concerns regarding the current use of maia2 for playing against it are:

- looks like this is more a scientific work about move prediction accuracy in general than having a good playable opponent.
- the pretrained nets are all based on just lichess games so a lot of chunk is used ;-) (at least if I look at my games ;-)
- having just the pure model net and an inference engine like torch is not the same for playing chess like lc0: the model can of course (and will) generate illegal moves (so I have to check) and sometimes will do strange moves especially in the opening (getting the knight out and putting it back eg.)

Nevertheless if we use an opening book or choose one of the top 3 moves with the highest probabilities of the model it looks like we can play a decent game (ignoring the total tactical inability of all Maia type engines unless we let them calculate some plys ahead... (which is possible by using the Maia1 nets in standard lc0)

Ā Dirk

Dirk

unread,
Jul 11, 2025, 7:14:31 AMJul 11
to PicoChess
Ok - because ChatGPT helped me with the implementation I thought I let it write the introduction. and installation procedure with my help...

IMG_8020.jpeg

Introducing Maia2 – New Human-style Chess in PicoChess


Hey Maia folks,


after a few days of tinkering, debugging, scratching my head and occasionally mumbling at my Raspberry Pi šŸ˜… — I’m happy to say:

šŸŽ‰ Maia2 now runs as a working UCI engine inside PicoChess!

So what is Maia2, and why should you care? Here’s a quick (and slightly fun) intro:


1ļøāƒ£ What is Maia2?

Maia2 is the follow-up to Maia1, a project from the University of Toronto and the Microsoft Research team. While Maia1 was based on Lc0 and used a policy head to mimic human mistakes at specific Elo levels, Maia2 takes things further:

🧠 It uses a PyTorch model, trained purely on human online chess games - just one model for all Elo levels.

šŸŽÆ The goal? To predict human-like moves at different skill levels — not necessarily to play perfect chess (and in my experience it does not!), but to play like us mere mortals.


2ļøāƒ£ Key differences from Maia1

  • No more Lc0 backend! Maia2 runs on its own custom model – not compatible with Lc0, so we can’t just "plug it in" like before.
  • No more models for different Elo levels but 2 different trained models based on blitz or rapid (lichess) games.
  • That means: I had to write a custom UCI wrapper in Python šŸ – which does all the legwork like move legality, FEN parsing, and even some safety checks (to stop it from playing moves like a1h8 which a normal pure model without lc0 backend does from time to timešŸ˜…).


3ļøāƒ£ UCI Integration Highlights

āœ… Two pretrained models included:

  • One for Rapid
  • One for Blitz

Just use the UCI option ModelType to switch between them.

🧮 Elo settings? You got it:

  • You can simulate different Elo levels (from 1100–2200) for Maia and its opponent, via the UCI options UCI_Elo and OpponentElo including our picochess auto elo feature) but I don’t see that much difference in playing quality here like in Maia1 withs its different Elo networks)

šŸ”§ Bonus features:

  • Optional logging
  • Debug output in a log file (if you want to know the probabilities for each move)
  • Randomization from top the 3 move suggestions (to keep Maia from becoming too boring šŸ˜„)
  • Input of the maia2 net: FEN string plus uci elo parameters, Output: list of moves with probabilities.


āš ļø Known Limitations

Let’s be honest — Maia2 is not Stockfish. And it’s not meant to be!

🚫 No search depth (same like Maia1 when not running in a standard lc0 engine), so it can’t calculate tactics or mates.
It’s basically playing based on what humans would probably play from a given position.

ā™Ÿļø Also, early opening play is a bit… "special". On level 1500 and even 2200 it might do things like:

  • Knight g8f6
  • Knight back f6g8 etc.
    (because, well, someone once did that obviously online too often ;.) — and Maia just wants to fit in šŸ˜‡)


So if you plan to play longer games:
šŸ’” Enable an opening book in PicoChess to help her through the early chaos.


🧪 Tips

  • Try experimenting with the Elo settings!
    Maia becomes more "inaccurate" at lower levels — which is perfect for simulating club players or analyzing amateur games.
  • Want her to play sharp tactics? Not gonna happen. But if you're looking for realistic human blunders? She's your girl. šŸ˜‰


šŸš€ Ready to try it?

It runs beautifully on a Raspberry Pi 4 (and also 5), with everything wrapped into a standalone Python script — no Lc0 needed!





INSTALLATION


Installation of requirements:

  1. sudo apt update && sudo apt upgrade -y
  2. pyenv activate picochess-3.9.2
  3. pip install torch --extra-index-url https://download.pytorch.org/whl/cpu
  4. pip install einops gdown pyzstd pyyaml pandas numpy


1. Script-Engine-Files (see the attached files):


script_files.jpeg


2. Execuatble & uci file:


exe_files.jpg



3. Entry in engines.ini or favorites.ini:


[script/maia2]

name = Maia2 2024 by MIT CSSLab UCI version by Molli

small = maia2

medium = maia2

large = Maia 2

web = Maia2 by MIT CSSLab & Molli

elo = 2200

ponder/brain = n



When running it the very first time for a net (blitz or rapid) it will automatically downloaded (als long as it is hosted on googledrive - so get it now ;-) Ā and be patient until the engine is ready.



I have other checked (as I no longer own one) own a stock DGTPI but I guess torch might not be really usable ?



Cheers,
Dirk

Ā 
P.S.
@Randy: if you have any troubleĀ 
maia2_pico.zip

Randy Reade

unread,
Jul 11, 2025, 12:29:39 PMJul 11
to pico...@googlegroups.com
Nice job getting it working, Dirk. I'm not sure it's quite ready for inclusion in my images but we'll see how it gets adopted by the general chess community and perhaps it can be added in the future if its play warrants it.

Thanks for sharing.

Randy

Andrea Gatti

unread,
Jul 12, 2025, 5:51:05 AMJul 12
to PicoChess
Dirk, this is great news, thank-you so much for having spent your time on this new "engine". Maia is a very nice and fun engine,, and despite sometimes it can play weird moves, I usually play against it with a book containing lines I need to practice against.
I understand it won't get - probably - on Randy's distribution soon, so I will try to install it manually following your instructions.
Again thank-you for this!
Andrea.

Dirk

unread,
Jul 18, 2025, 6:48:13 AMJul 18
to PicoChess
Ok I have found out that this issue of strange opening moves (Nf6, Ng8, Nf6 etc.) are not a bug but a current feature as these pretrained nets have not been trained send on opening data or end game data, seeĀ 
"Only do Nf3 Ng1 (in loop) with white and Nf6 Ng8 with black"

And yes indeed during the middle game phase maia2 plays very well and interesting and this even makes fun!

Maybe they will update and train the nets with opening and endanger data in future (they have mentioned this).

As long as we don't get better net models I will use opening books which works fine!

Dirk
IMG_8055.jpeg

Dirk

unread,
Jul 19, 2025, 5:31:50 AMJul 19
to PicoChess
logo.png
I have found a similar deep learning based network project on GitHub like maia2: Chess-Transformers (https://github.com/sgrvinod/chess-transformers) which works way better in all game phases but it is pain to install (at least on my picvochess system - on my mac I had no trouble at all ;-)

More on that later... stay tuned ;-)

chess_trans_project — Python ā—‚ transformer_uci.py — 93Ɨ25 2025-07-18 22-05-48.jpg

Andrea Gatti

unread,
Jul 19, 2025, 5:54:38 AMJul 19
to PicoChess
Dirk, these are all great news, and represent a great addition to PicoChess, which is becoming every day an invaluable chess training (and fun!!) tool!
Thank-you!!
Andrea

Dirk

unread,
Jul 19, 2025, 6:56:07 PMJul 19
to PicoChess
I totally agree, Andrea!

I find it quite interesting that after the success of lc0 based Ā on aĀ Residual Network architecture (ResNet) similar to those for image recognition (pattern recognition based on the broad state (eg the FEN or other board representations) we now get more and more networks for all use cases based the Transformers archiutectur like the one from ChatGPT etc. which is primarily used for Natural Language Processing Ā (input and parallel processing of long text/token sequences (here the list of moves)

Really exciting (not only chess) times ....

Drk

Reply all
Reply to author
Forward
0 new messages