shyamsn97 / mario-gpt

[Neurips 2023] Generating Mario Levels with GPT2. Code for the paper "MarioGPT: Open-Ended Text2Level Generation through Large Language Models" https://arxiv.org/abs/2302.05981
https://huggingface.co/shyamsn97/Mario-GPT2-700-context-length
MIT License
1.12k stars 101 forks source link

Example code from mario_gpt should possibly be mario_gpt.lm #5

Closed mossly closed 1 year ago

mossly commented 1 year ago

Hi,

First of all thanks for your novel implementation! This is very cool to see.

When running the minimal code snippet provided in the readme, I got the following error:

C:\Users\Mossly\Desktop>py mariotest.py
Traceback (most recent call last):
  File "C:\Users\Mossly\Desktop\mariotest.py", line 1, in <module>
    from mario_gpt import MarioLM
ImportError: cannot import name 'MarioLM' from 'mario_gpt' (C:\Users\Mossly\AppData\Local\Programs\Python\Python310\lib\site-packages\mario_gpt\__init__.py)

I resolved it by changing the line: from mario_gpt import MarioLM to from mario_gpt.lm import MarioLM

Perhaps this is just a simple syntactical mistake? Or it could be user error on my part...

Thanks for your attention!

shyamsn97 commented 1 year ago

Hey! So I actually updated the code to make this importing possible, but I realized that the pypi package has not really been updated yet. I reverted this back in the README so it should be good :)

mossly commented 1 year ago

Thanks for your assistance!

I'm pretty close to getting things working but hit another error I've been unable to debug.

generated_level = mario_lm.sample( File "lm.py", line 113, in sample [self.prompter.output_hidden(prompt) for prompt in prompts] File "lm.py", line 113, in [self.prompter.output_hidden(prompt) for prompt in prompts] File "prompter.py", line 117, in output_hidden .mean(0) AttributeError: 'list' object has no attribute 'mean'

This is using the default prompts = ["many pipes", "many enemies", "some blocks", "high elevation"]

Any help would be greatly appreciated!

shyamsn97 commented 1 year ago

Hey! So multiple prompts should now work. You should probably clone the repo or update from pypi. On another note, when using default prompts make sure you're using:

prompts = ["many pipes, many enemies, some blocks, high elevation"]

instead of

prompts = ["many pipes", "many enemies", "some blocks", "high elevation"]

If you split the categories the model could still work, but I haven't tested that out extensively.

shyamsn97 commented 1 year ago

Also, make sure you update your transformers package :)

shyamsn97 commented 1 year ago

Thanks for pointing this out though, lmk if there's any other errors!

mossly commented 1 year ago

I updated the repo, transformers, fixed up the prompts as per your advice, and now everything is working on Windows 11 with Python 3.10.

Thanks again for all your help! :)

level