Tsunehiko Tanaka1
Edgar Simo-Serra1
1Waseda University
This paper presents a novel framework that leverages Large Language Models (LLMs) to generate grammatically accurate game descriptions from natural language.
- Create Python environment and install dependencies
pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121
pip install -r requirements.txt
pip install -e .- Build Java resource
mkdir ludii_java/libs
wget -P ludii_java/libs https://ludii.games/downloads/Ludii-1.3.13.jar
javac -cp ludii_java/libs/Ludii-1.3.13.jar:ludii_java/src \
-d ludii_java/out \
ludii_java/src/EvalLudiiGame.java \
ludii_java/src/ComputeConcept.java \
ludii_java/src/ComputeMultiAgents.java \
ludii_java/src/ExtractExpand.java
jar cfm ./ludii_java/jars/EvalLudiiGame.jar ./ludii_java/manifest_eval.mf -C ludii_java/out .
jar cfm ./ludii_java/jars/ComputeConcept.jar ./ludii_java/manifest_concept.mf -C ludii_java/out .
jar cfm ./ludii_java/jars/ComputeMultiAgents.jar ./ludii_java/manifest_ma.mf -C ludii_java/out .
jar cfm ./ludii_java/jars/ExtractExpand.jar ./ludii_java/manifest_expand.mf -C ludii_java/out .Before using Docker, ensure the following steps are completed:
-
Download the LLM model weights to
$HOME/.cache/huggingface/hub. Make sure the directory exists and is accessible. -
(Optional) Set your OpenAI API key in a
.envfile located in the project root directory. The file should contain the following format:OPENAI_API_KEY=your-api-key-here
- Build a Docker image
./scripts/docker/build.sh- Attach a container to your shell
./scripts/docker/exec.sh- Prepare expanded game descriptions
java -jar ludii_java/jars/ExtractExpand.jar- Create grammar files
python data/ludii/cache_grammar.pyGrammar-based Game Description Generation (GGDG)
./scripts/grammar.shGame Description Generation (GDG)
./scripts/standard.shEvaluation
python ggdg/evaluation.py ${log_dir}
Only models from Hugging Face are supported for SFT.
Dataset Creation
python sft/create_dataset.py --mode program --output_dataset_path ./sft/data/program.json
python sft/create_dataset.py --mode grammar --output_dataset_path ./sft/data/grammar.jsonRun SFT
./sft/train.sh program meta-llama/Meta-Llama-3-8B-Instruct
./sft/train.sh grammar meta-llama/Meta-Llama-3-8B-InstructSFT+GGDG
./scripts/sft_grammar.sh meta-llama/Meta-Llama-3-8B-Instructhf/{huggingface/model/name}
- meta-llama/Meta-Llama-3-8B-Instruct
openai/{model/name}
- openai/gpt-4o-mini
@article{tanaka2024ggdg,
author={Tanaka, Tsunehiko and Simo-Serra, Edgar},
journal={IEEE Transactions on Games},
title={Grammar-based Game Description Generation using Large Language Models},
year={2024},
pages={1-14},
}