lcipolina commited on
Commit
53de95d
·
verified ·
1 Parent(s): 5f89dfc

Upload 3 files

Browse files
Files changed (3) hide show
  1. games_registry.py +56 -0
  2. llm_registry.py +27 -0
  3. requirements.txt +87 -0
games_registry.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # games_registry.py
2
+ """Centralized registry for available games and their simulators."""
3
+
4
+ from games.tic_tac_toe import get_tic_tac_toe_game
5
+ from games.prisoners_dilemma import get_prisoners_dilemma_game
6
+ from games.connect_four import get_connect_four_game
7
+ from games.matrix_rps import get_matrix_rps_game
8
+ from games.matrix_pd import get_matrix_pd_game
9
+ from games.kuhn_poker import get_kuhn_poker_game
10
+ from games.matching_pennies import get_matching_pennies_game
11
+
12
+ from simulators.tic_tac_toe_simulator import TicTacToeSimulator
13
+ from simulators.prisoners_dilemma_simulator import PrisonersDilemmaSimulator
14
+ from simulators.connect_four_simulator import ConnectFourSimulator
15
+ from simulators.matrix_game_simulator import MatrixGameSimulator
16
+ from simulators.kuhn_poker_simulator import KuhnPokerSimulator
17
+ from simulators.matching_pennies_simulator import MatchingPenniesSimulator
18
+
19
+ # Register games here
20
+ GAMES_REGISTRY = {
21
+ "tic_tac_toe": {
22
+ "loader": get_tic_tac_toe_game,
23
+ "simulator": TicTacToeSimulator,
24
+ "display_name": "Tic-Tac-Toe",
25
+ },
26
+ "prisoners_dilemma": {
27
+ "loader": get_prisoners_dilemma_game, # Iterated PD: Multi-round, emphasizing strategy development over repeated interactions.
28
+ "simulator": PrisonersDilemmaSimulator,
29
+ "display_name": "Iterated Prisoner's Dilemma",
30
+ },
31
+ "connect_four": {
32
+ "loader": get_connect_four_game,
33
+ "simulator": ConnectFourSimulator,
34
+ "display_name": "Connect Four",
35
+ },
36
+ "rps": {
37
+ "loader": get_matrix_rps_game,
38
+ "simulator": MatrixGameSimulator,
39
+ "display_name": "Rock-Paper-Scissors (Matrix)",
40
+ },
41
+ "matrix_pd": {
42
+ "loader": get_matrix_pd_game, # Matrix PD: Single-round, with the payoff matrix as the primary structure.
43
+ "simulator": MatrixGameSimulator,
44
+ "display_name": "Prisoner's Dilemma (Matrix)",
45
+ },
46
+ "kuhn_poker": {
47
+ "loader": get_kuhn_poker_game,
48
+ "simulator": KuhnPokerSimulator,
49
+ "display_name": "Kuhn Poker",
50
+ },
51
+ "matching_pennies": {
52
+ "loader": get_matching_pennies_game,
53
+ "simulator": MatchingPenniesSimulator,
54
+ "display_name": "Matching Pennies (3P)",
55
+ },
56
+ }
llm_registry.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
+ # Registry of available LLMs
4
+ # These are just examples of models that run fast enough to work in this proof of concept.
5
+ # But they don't give us good results.
6
+ # Ideally we would use 'intruct-finetuned' models.
7
+ # I have tried some models and these actually worked well (i.e. followed the prompt): microsoft/Phi-3-mini-4k-instruct, Qwen/Qwen2.5-Coder-32B-Instruct, Qwen/Qwen2.5-72B-Instruct, mistralai/Mistral-7B-Instruct-v0.3,dolly-v2-3b, dolly-v2-12b
8
+ # Note. Need to read the models documentation on how to prompt them. See example for Microsoft's Phi.
9
+
10
+
11
+ LLM_REGISTRY = {
12
+ "gpt2": {
13
+ "display_name": "GPT-2",
14
+ "description": "A medium-sized transformer-based language model by OpenAI.",
15
+ "model_loader": lambda: pipeline("text-generation", model="gpt2"),
16
+ },
17
+ "flan_t5_small": {
18
+ "display_name": "FLAN-T5 Small",
19
+ "description": "A fine-tuned T5 model optimized for instruction-following tasks.",
20
+ "model_loader": lambda: pipeline("text-generation", model="google/flan-t5-small"),
21
+ },
22
+ "distilgpt2": {
23
+ "display_name": "DistilGPT-2",
24
+ "description": "A smaller and faster version of GPT-2.",
25
+ "model_loader": lambda: pipeline("text-generation", model="distilgpt2"),
26
+ },
27
+ }
requirements.txt ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ absl-py==2.1.0
2
+ aiofiles==23.2.1
3
+ annotated-types==0.7.0
4
+ anyio==4.8.0
5
+ attrs==24.3.0
6
+ Brotli @ file:///Users/runner/miniforge3/conda-bld/brotli-split_1725267521616/work
7
+ certifi @ file:///home/conda/feedstock_root/build_artifacts/certifi_1734380492396/work/certifi
8
+ cffi @ file:///Users/runner/miniforge3/conda-bld/cffi_1725560567968/work
9
+ charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1733218092148/work
10
+ click==8.1.8
11
+ contextlib2==21.6.0
12
+ contourpy==1.3.0
13
+ cycler==0.12.1
14
+ exceptiongroup==1.2.2
15
+ fastapi==0.115.6
16
+ ffmpy==0.5.0
17
+ filelock @ file:///home/conda/feedstock_root/build_artifacts/filelock_1733240801289/work
18
+ fonttools==4.55.3
19
+ fsspec==2024.12.0
20
+ gmpy2 @ file:///Users/runner/miniforge3/conda-bld/gmpy2_1733462620396/work
21
+ gradio==4.44.1
22
+ gradio_client==1.3.0
23
+ h11==0.14.0
24
+ h2 @ file:///home/conda/feedstock_root/build_artifacts/h2_1733298745555/work
25
+ hpack @ file:///home/conda/feedstock_root/build_artifacts/hpack_1733299205993/work
26
+ httpcore==1.0.7
27
+ httpx==0.28.1
28
+ huggingface-hub==0.27.0
29
+ hyperframe @ file:///home/conda/feedstock_root/build_artifacts/hyperframe_1733298771451/work
30
+ idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1733211830134/work
31
+ importlib_resources==6.5.2
32
+ Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1734823942230/work
33
+ kiwisolver==1.4.7
34
+ markdown-it-py==3.0.0
35
+ MarkupSafe==2.1.5
36
+ matplotlib==3.9.4
37
+ mdurl==0.1.2
38
+ mkl-service==2.4.0
39
+ mkl_fft==1.3.11
40
+ mkl_random @ file:///Users/runner/miniforge3/conda-bld/mkl_random_1728790298412/work
41
+ ml-collections==0.1.1
42
+ mpmath @ file:///home/conda/feedstock_root/build_artifacts/mpmath_1733302684489/work
43
+ networkx @ file:///home/conda/feedstock_root/build_artifacts/networkx_1698504735452/work
44
+ numpy @ file:///private/var/folders/c_/qfmhj66j0tn016nkx_th4hxm0000gp/T/abs_b7iptlxgej/croot/numpy_and_numpy_base_1708638622773/work/dist/numpy-1.26.4-cp39-cp39-macosx_10_9_x86_64.whl#sha256=1ca37e4fdfd421b20423d3f5f08de21aeee8ef917ddcee6667076d3dc7937879
45
+ open-spiel==1.5
46
+ orjson==3.10.13
47
+ packaging==24.2
48
+ pandas==2.2.3
49
+ pillow==10.4.0
50
+ pycparser @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_pycparser_1733195786/work
51
+ pydantic==2.10.4
52
+ pydantic_core==2.27.2
53
+ pydub==0.25.1
54
+ Pygments==2.19.1
55
+ pyparsing==3.2.1
56
+ PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1733217236728/work
57
+ python-dateutil==2.9.0.post0
58
+ python-multipart==0.0.20
59
+ pytz==2024.2
60
+ PyYAML @ file:///Users/runner/miniforge3/conda-bld/pyyaml_1725456176118/work
61
+ regex==2024.11.6
62
+ requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1733217035951/work
63
+ rich==13.9.4
64
+ ruff==0.8.6
65
+ safetensors==0.5.0
66
+ scipy==1.13.1
67
+ semantic-version==2.10.0
68
+ shellingham==1.5.4
69
+ six @ file:///home/conda/feedstock_root/build_artifacts/six_1733380938961/work
70
+ sniffio==1.3.1
71
+ starlette==0.41.3
72
+ sympy @ file:///home/conda/feedstock_root/build_artifacts/sympy_1727529700862/work
73
+ tokenizers==0.21.0
74
+ tomlkit==0.12.0
75
+ torch==2.2.2
76
+ torchaudio==2.2.2
77
+ torchvision==0.17.2
78
+ tqdm==4.67.1
79
+ transformers==4.47.1
80
+ typer==0.15.1
81
+ typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1733188668063/work
82
+ tzdata==2024.2
83
+ urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1734859416348/work
84
+ uvicorn==0.34.0
85
+ websockets==12.0
86
+ zipp==3.21.0
87
+ zstandard==0.23.0