Home

Awesome

Katakomba: Tools and Benchmarks for Data-Driven NetHack

<p align="center"><b>Katakomba</b> is an open-source benchmark for data-driven NetHack. At the moment, it provides a set of standardized datasets with familiar interfaces and offline RL baselines augmented with recurrence. Full training logs synced to the Weights&Biases are included.</p> <div align="center">

Twitter arXiv

</div>

Installation

For now, Katakomba is not pip installable. However, the installation is easy. We also provide an alternative with the Dockerfile already set up to work (this is the preferred way!).

# first, install nle dependencies
apt-get install -y build-essential autoconf libtool pkg-config \
    python3-dev python3-pip python3-numpy git flex bison libbz2-dev

# next, install katakomba requierements
git clone https://github.com/corl-team/katakomba.git && cd katakomba
# see https://github.com/facebookresearch/nle/issues/359
pip install --no-use-pep517 nle
pip install -r requirements.txt

# or alternatively, you could use docker
docker build -t katakomba .
docker run --gpus all -it --rm --name katakomba katakomba

One last step is the installation of additional utils used for faster rendering of tty observations as images:

# use pip inside the docker container
pip install -e katakomba/utils/render_utils/

Getting Started

from katakomba.env import NetHackChallenge, OfflineNetHackChallengeWrapper
from katakomba.utils.datasets import SequentialBuffer

# The task is specified using the character field
env = NetHackChallenge (
  character = "mon-hum-neu",
  observation_keys = ["tty_chars", "tty_colors", "tty_cursor"]
)

# A convenient wrapper that provides interfaces for dataset loading, score normalization, and deathlevel extraction
env = OfflineNetHackChallengeWrapper(env)

# Several options for dataset reading (check the paper for details): 
# - from RAM, decompressed ("in_memory"): fast but requires a lot of RAM, takes 5-10 minutes for decompression first
# - from Disk, decompressed ("memmap"): a bit slower than RAM, takes 5-10 minutes for decompression first
# - from Disk, compressed ("compressed"): very slow but no need for decompression, useful for debugging
# Note that this will download the dataset automatically if not found
dataset = env.get_dataset(mode="memmap", scale="small")

# Auxillary tools for computing normalized scores or extracting deathlevels
env.get_normalized_score(score=1337.0)
env.get_current_depth()

# We also provide an example of a sequential replay buffer
buffer = SequentialBuffer(
  dataset=dataset,
  seq_len=YOUR_SEQ_LEN,
  batch_size=YOUR_BATCH_SIZE, # Each batch element is a different trajectory
  seed=YOUR_SEED,
  add_next_step=True # if you want (s, a, r, s') instead of (s, a, r)
)

# What's inside the batch?
# Note that the next batch will include the +1 element as expected
batch = buffer.sample()
print(
  batch["tty_chars"],  # [batch_size, seq_len + 1, 80, 24]
  batch["tty_colors"], # [batch_size, seq_len + 1, 80, 24]
  batch["tty_cursor"], # [batch_size, seq_len + 1, 2]
  batch["actions"],    # [batch_size, seq_len + 1]
  batch["rewards"],    # [batch_size, seq_len + 1]
  batch["dones"]       # [batch_size, seq_len + 1]
)

# In case you don't want to store the decompressed dataset beyond code execution
dataset.close()

Baselines

We also provide a set of offline RL baselines for discrete control augmented with recurrence. Implementations are based on the Chaotic-Dwarven-GPT-5 architecture and kept as simple as possible, feel free to dive in both full training logs and algorithms: you can find many useful stuff like sequential replay buffer or bias-corrected vectorized evaluation.

AlgorithmVariants ImplementedWandb Report
Behavioral Cloning <br>(BC)bc_chaotic_lstm.pyKatakomba-All
Conservative Q-Learning for Offline Reinforcement Learning <br>(CQL)cql_chaotic_lstm.pyKatakomba-All
Accelerating Online Reinforcement Learning with Offline Datasets <br>(AWAC)awac_chaotic_lstm.pyKatakomba-All
Offline Reinforcement Learning with Implicit Q-Learning <br>(IQL)iql_chaotic_lstm.pyKatakomba-All
An Optimistic Perspective on Offline Reinforcement Learning <br>(REM)rem_chaotic_lstm.pyKatakomba-All

Datasets

In our benchmark, we treat every character configuration as a separate game to be solved -- different configurations may require highly varied forms of gameplay in the early game. To this end, we repacked the original large-scale AutoAscend (this symbolic agent is essentialy an early-game contender) dataset into 38 smaller datasets. This decomposition should allow practitioners to download less data and be more focused on specifics.

Additionally, as benchmarking new algorithms on all of the datasets could be computationally expensive for many practitioners, we separate the benchmark into three categories, where roles > races > alignments as by wisdom of the NetHack community.

We host all of the datasets on the HuggingFace, you can download them from there directly. But as we described above, our wrappers will take care of it automatically similar to the D4RL benchmark. The script for repacking the large-scale dataset can be found here.

Tasks

Tasks# TransitionsMedian TurnsMedian ScoreMedian DeathlvlSize (GB)Compressed Size (GB)
Base (Role-Centric)------
arc-hum-neu2452716332858.04802.52.094.51.3
bar-hum-neu2626677135716.011964.04.0101.11.7
cav-hum-neu2167468030361.08152.04.083.51.3
hea-hum-neu1447399718051.02043.01.055.70.8
kni-hum-law2228728328246.06305.03.085.81.5
mon-hum-neu3374154242400.011356.04.0129.92.1
pri-hum-neu1837647326796.55366.52.070.81.1
ran-hum-neu1762549325354.06168.02.067.91.0
rog-hum-cha1428492719334.03005.51.055.00.8
sam-hum-law2242253732951.07850.04.086.31.3
tou-hum-neu1337649817955.52554.51.051.50.8
val-hum-neu2778478835250.011402.54.0107.01.8
wiz-hum-neu1434344919808.53132.51.055.20.8
Extended (Race-Centric)------
pri-elf-cha1879656026909.54718.52.072.41.1
ran-elf-cha1823868626607.07583.04.070.21.1
wiz-elf-cha1527782019512.02988.51.058.80.9
arc-dwa-law2510078834669.04026.01.096.71.5
cav-dwa-law2287189032261.07158.03.088.11.5
val-dwa-law3278765833973.08652.53.0126.62.5
arc-gno-neu2414404834432.04077.51.093.01.4
cav-gno-neu2162477929860.06446.03.083.31.4
hea-gno-neu1488470418518.01980.51.057.30.9
ran-gno-neu1757165925970.05326.02.067.71.1
wiz-gno-neu1419363719206.02736.01.054.70.9
bar-orc-cha2782635639291.010499.04.0107.21.8
ran-orc-cha1812744826707.05460.02.069.81.1
rog-orc-cha1667480622351.03103.01.064.21.0
wiz-orc-cha1599415022570.53241.51.061.61.0
Complete (Alignment-Centric)------
arc-hum-law2342238331446.04188.01.090.21.3
cav-hum-law2232849431039.08174.04.086.01.3
mon-hum-law3078231739647.010855.04.0118.51.9
pri-hum-law1829881627192.04833.01.070.51.1
val-hum-law3017103534570.59707.04.0116.22.1
bar-hum-cha2536211135925.012574.05.097.71.6
mon-hum-cha3366242041730.511418.04.0129.62.1
pri-hum-cha1866781628204.55847.02.071.91.1
ran-hum-cha1699963024698.56236.02.065.61.0
wiz-hum-cha1463559120257.03294.01.056.40.9

Citing Katakamoba

@misc{kurenkov2023katakomba,
      title={Katakomba: Tools and Benchmarks for Data-Driven NetHack}, 
      author={Vladislav Kurenkov and Alexander Nikulin and Denis Tarasov and Sergey Kolesnikov},
      year={2023},
      eprint={2306.08772},
      archivePrefix={arXiv},
      primaryClass={cs.LG}
}