Precompute Leela opening book?

1,115 views
Skip to first unread message

David Larson

unread,
Jul 9, 2018, 1:37:03 AM7/9/18
to LCZero
Please excuse my ignorance of how Leela works in a advance of the following display of it. 

I noticed that Leela spends a long time determining its opening moves while whatever brute force engine it is pitted against responds near instantly. As I understand it this is from the traditional engine doing a simple lookup in a table base whereas Leela treats even the first more no different from the middle or end.  Given this it appears possible to generate a Leela book for at least the first few moves in advance of any match and save it as a data file. This, then, would serve as quick starting point which would provide it more time to think later on in the game.

TomekJ

unread,
Jul 9, 2018, 7:33:43 AM7/9/18
to LCZero
@David Larson:

I noticed that Leela spends a long time determining its opening moves while whatever brute force engine it is pitted against responds near instantly. As I understand it this is from the traditional engine doing a simple lookup in a table base whereas Leela treats even the first more no different from the middle or end.  Given this it appears possible to generate a Leela book for at least the first few moves in advance of any match and save it as a data file. This, then, would serve as quick starting point which would provide it more time to think later on in the game.

One can use various opening books in GUI's such Arena, ChessBase, Scid and others, provided only in competition but not in selfplay training games.
Pre-computation using Leela is IMO waste of time because of changing Leela preferred opening lines between versions of NN.
Message has been deleted

Robert Pope

unread,
Jul 9, 2018, 8:14:26 AM7/9/18
to LCZero
Sure, they could do it - plenty of engines use pre-computed values for their opening book.  One issue is that as soon as a new net comes out, it might not play the same opening, so either the book is outdated, or you are continually rebuilding it.

David Larson

unread,
Jul 9, 2018, 11:17:21 AM7/9/18
to LCZero
Indeed it would require rebuilding it with each new NN. I imagine doing so would be computationally expensive and time-consuming, however if a particular NN is to be used for say TCEC or some such competition then it may be worthwhile to build it as deep as possibly prior to the event. 

I also imagine that each person that is running Leela is essentially computing a portion of the book every time we play against Leela. Cannot this information be cached so that Leela get's faster in it's opening every time it's played? Even better, cannot these be consolidated from hundreds of user much like the training data is gathered today?

Robert Pope

unread,
Jul 9, 2018, 3:41:50 PM7/9/18
to LCZero
If the devs goal was to create the best competitor for TCEC, then sure. But since that isn't their primary goal, things like this aren't really even on the radar.

We don't even have a particularly stable codebase yet, and the devs time is limited.

Peter Schmidt-Nielsen

unread,
Jul 9, 2018, 8:41:38 PM7/9/18
to David Larson, LCZero
Precomputing a given network's response to opening positions to build a book seems like a reasonable idea in the long run, although it may be a bit premature given the rate at which the networks are still improving. One observation is that MCTS provides a natural procedure for deciding how to allocate attention to various parts of the chess game tree for building an opening book. In this spirit I implemented a very simple tool for building a PolyGlot opening book using lc0, in case people are interested in experimenting with this:


All it does is run lc0 from the root position and periodically probe the tree to write out a PolyGlot opening book containing the most visited move from every position with at least some given threshold number of visits. Therefore the opening book written by this tool contains only moves that lc0 would have actually selected if run normally from the listed positions to a number of nodes exceeding the threshold used when building the book*. The longer you let it run the more converged the moves will be, and the more opening positions it will have.

This is really just a proof of concept; is quite simplistic, and requires a patch (linked from the repo) to be applied to lc0 to allow probing of the tree. If others are interested in working more on this it might be an interesting starting point, or probably just a point of comparison (there are probably entirely different and better ways of building such books; just letting the MCTS direct the book building tends to favor breadth far too little).

* Modulo a few considerations of non-determinism due to threading, and whatnot.

--
You received this message because you are subscribed to the Google Groups "LCZero" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lczero+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lczero/20f47a37-a7dc-4c4f-842f-8aa9cc09ebca%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

David Larson

unread,
Jul 9, 2018, 9:52:18 PM7/9/18
to LCZero
This is fantastic!
To unsubscribe from this group and stop receiving emails from it, send an email to lczero+un...@googlegroups.com.

Jesse Jordache

unread,
Jul 10, 2018, 2:31:22 AM7/10/18
to LCZero
I'd like to run it just to satisfy my curiosity.

Leela changes opening preferences slowly, but I think she's about to switch things around - she's just about exhausted the symmetrical english and her c4 e5 english games are getting kind of chaotic.
Reply all
Reply to author
Forward
0 new messages