(idea discussion) ben project structure improvement
larrycai opened this issue · 12 comments
Background
It is just discussion for possible changes, it will not be implemented now. Record some experience and trials to see possible future.
So far it is one ben
project contains everything, bit tricky to refactor and check/use partly.
ben-model
for training models only, the models (result) can be stored in huggingface.co, tried in #76ben-lite
/ben-engine
for AI bridge library, it can be used to pypi package to be reused in other project (it will load ben-models)ben
(ben-ui
) for ben's sandbox web application, usesben-lite
for one web application
Then each part can be easily grows and invite more contributors to join
Use cases
- Use just ben engine models to write bridge articles (use model or compare this model with other bridge software) to analysis the bidding, opening leads, playing ...
- improve the ben-ui separately as a game without good knowledge of bridge, they just need to know the API provided by
ben-lite
Busy this week, and I did some checking (with my limited python knowledge)
python standard project
If we want to change later, we need to
- better to follow python project structure (
src/ben/
) - module dependance needs to be updated (
from .bidding import bidding
), see sample: larrycai/ben-lite@b3049cc
see i tried in https://github.com/larrycai/ben-lite (it is just trial)
jupyter notebook (use case 1)
if it is separated, then it can work like https://github.com/larrycai/ben-lite/blob/main/Leading_for_3NT.ipynb (just prepared the env), it mostly looks like below in non-root jupyter env (see also redeal issue anntzer/redeal#36)
!pip install --upgrade git+https://github.com/larrycai/ben-lite # install ben pure python package, just for demo, DON'T rely on it.
!pip install git+https://github.com/larrycai/redeal # install redeal without dds depend
!git clone https://github.com/larrycai/dds-so.git # clone and get libdds.so
!pip show redeal
AI/ML data engineer with bridge knowledge can just use jupyter notebook to compare
I think we should create small installables, so if you just want to analyze a deal in jupyter you don't need to install the modules for training etc, But should we have different repositories, or can we manage to have it all in one? There are some reuse, and when developing it is an advantage to have al together.
But I think it is a good idea to have all that is distributed in /src and then have subdirectories for the different modules
yes, this is exactly what I tried above ;-)
- https://github.com/larrycai/ben-lite is just source code, which later can be
pip install ben
, how many src inside can be discussed - modules are hosted in huggingface.co, it is downloaded during usage, it is what we discussed in #76
Now it is a complete demo how to use AI ben engine to compare with readel solution (check book Winning Notrump Lead), I use hand 3, Chapter 1 to compare
see https://github.com/larrycai/ben-lite/blob/main/Leading_for_3NT_Colab.ipynb
You can load it in colab and rerun all to check, redeal takes 3 minutes.
@lorserker , I am not good at checking the result, I more focus the env
let me know if someone else make it works.
I think we should create small installables, so if you just want to analyze a deal in jupyter you don't need to install the modules for training etc, But should we have different repositories, or can we manage to have it all in one? There are some reuse, and when developing it is an advantage to have al together.
But I think it is a good idea to have all that is distributed in /src and then have subdirectories for the different modules
yes, the training part can be released with models (ben-models
), or as first step, put into one src package.
Very interesting.
So I jumped to Colab, and entered
https://colab.research.google.com/github/larrycai/ben-lite/blob/main/Leading_for_3NT_Colab.ipynb#
Now when I try to run step 3 (the solution from rdeal) I get this error
but it looks like rdeal is installed ok in step 1 and 2
Loading all models worked fine, but again, when I tried to execute BEN, I got an error
Oops, little bit weird for jupyter notebook, some old commands exist in the cache before summit.
I removed --user
, it works again now. I verified from menu Runtime
-> Restart and run all
.
updated https://github.com/larrycai/ben-lite/blob/main/Leading_for_3NT_Colab.ipynb
If have time. use redeal for 5000 deals in this testing (i don't know how to tune the algorithm, 500 deals=3-4 mins) , then both points to S6
for leading ;-)
For normal 3NT, what would you lead from: ♠ J 8 6 ♥ 9 5 ♦ K Q 7 2 ♣ K J 7 2 ?
Looks like you have an error in the input to BEN:
In the rdeal-sample you are sitting west, and the bidding goes 1N-3N from NS
So try this auction
the auction goes:
auction = ['PAD_START','PAD_START',"1N","PASS","3N",'PASS', 'PASS', 'PASS']
Also note, that for hearts you need to remove the zero in the hand
I am not sure what rdeal recommends but I can see in the book it is S6
So you should also update the text following the selected lead (currently diamond ace is mentioned)
I would probably not link to the book unless you now it is a valid copy, but just copy the hand from the book as image and show that.
omg, I made so many mistakes there, fixed there. I also reported once case anntzer/redeal#37 to see whether we can use redeal for the better format (small thing)
I had all the things now for the discussion.
closed now, when we really need to do this, I can contribute to verify.
When sampling for the lead I have added a new column, that gives a score from 0-1 about how close the bidding is to BEN's engine - but the score is just the bid with the lowest score for all players - I am thinking about how that can be improved.
You should update the text here:
we should make some changes, so the relation between
bidding_id="AIBridgeEngine/Ben-3B-Bidding-v0.1"
and
bidder = Bidder("", f'{folder}/bidding-100000')
So the user only will have to know the model name on HuggingFace.
My best idea for now is just to rename the model files on HuggingFace