Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support "Human-Like" model #708

Open
TristanCacqueray opened this issue Aug 18, 2024 · 6 comments
Open

Support "Human-Like" model #708

TristanCacqueray opened this issue Aug 18, 2024 · 6 comments

Comments

@TristanCacqueray
Copy link

We need to pass a new -human-model parameter after the KataGo command, and it looks like such wrapper script works:

#!/bin/sh
command=$(echo $1)
shift
exec /nix/store/g398d059f5g8s7i6k5grrx7zl21cf4pk-katago-1.15.3/bin/katago $command -human-model /nix/store/6dhgn7sxxvy78s9bd50kzazz3n1dxhfm-b18c384nbt-humanv0.bin.gz $*

Is there any plan to support this natively in katrain?

Thanks for the tool by the way!

@simonguoxm
Copy link

For me, it is not necessary to support this.

@pdeblanc
Copy link
Contributor

I've gotten this working locally. Here's what I did:

  • Download the b18c384nbt-humanv0.bin.gz model into my ~/.katrain directory
  • Create a copy of katrain/KataGo/analysis_config.cfg called katrain/KataGo/humanlike_config.cfg
  • In humanlike_config.cfg, append the line humanSLProfile = preaz_2d (i.e. emulating 2-dan human play from the old days; other settings are possible)
  • In katrain/core/engine.py, around line 120, add the following lines:
             cfg = find_package_resource(config["config"])
+            if "human" in model:
+                cfg = cfg.replace("analysis", "humanlike")
             exe = self.get_engine_path(config.get("katago", "").strip())

It is necessary to have two separate configs, because the default KataGo models will raise an error if the humanSLProfile setting is present in the config.

I could consider putting up a PR, but I'm not sure if this solution is sufficiently user-friendly:

  • You have to switch the model in the General/Engine settings to get humanlike play (e.g. with the Policy Weighted AI)
  • This will also use the human policy for analysis; there's no convenient way to use the human policy for play while simultaneously using the AI policy for analysis
  • There should probably be a way to change the humanSLProfile via a menu instead of editing the config. This could include the following options and suboptions:
    • Modern amateur style
      • select rank
    • Pre-AI amateur style
      • select rank
      • select opponent rank (e.g. to see how a human 4d might play against a 10k opponent)
    • Professional style
      • select year (1800 to 2023)

For reference, the humanSLProfile options are documented here: https://github.com/lightvector/KataGo/blob/master/docs/Analysis_Engine.md

@PJTraill
Copy link

PJTraill commented Dec 18, 2024

way to change the humanSLProfile

The opponent rank is also supported for emulating post AlphaZero amateurs.

documented here

They are also summarised in the supplied sample configuration: https://github.com/lightvector/KataGo/blob/v1.15.0/cpp/configs/gtp_human5k_example.cfg

@pdeblanc
Copy link
Contributor

OK, I'm sort of thinking about putting together a PR for this feature, but where to cram the new options? We need a drop-down menu (to select Modern Amateur, Pre-AI Amateur, or Professional style), and up to two numeric input fields, depending on which style is selected.

@PJTraill
Copy link

PJTraill commented Feb 15, 2025

while simultaneously using the AI policy for analysis

You say there is no convenient way to do this, but surely the -human-model commandline argument does that by default? That is what https://github.com/lightvector/KataGo/blob/master/docs/Analysis_Engine.md#human-sl-analysis-guide says.

@pdeblanc
Copy link
Contributor

while simultaneously using the AI policy for analysis

You say there is no convenient way to do this, but surely the -human-model commandline argument does that by default? That is what https://github.com/lightvector/KataGo/blob/master/docs/Analysis_Engine.md#human-sl-analysis-guide says.

Katrain's AI is not a simple wrapper around KataGo. There are various AI modes which use KataGo's analysis in different ways to select a move (cf. https://github.com/sanderland/katrain/blob/master/katrain/core/ai.py).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants