Teaching a machine to chart Beat Saber maps

The goal

To be honest, I was deep into theory of machine learning and played in the field, but have not actually ever attempted training real neural network from scratch. And I mean it when I say from scratch, just Go, standard libraries, math and help from my precious helpers of GLM 5.3 Flash and GPT 6.1 Sol as I know bunch of stuff from research papers, youtube, reddit and some blogs, but I have no formal education in the topic. I've been learning about ML since about 2020/2021, but only since 2024 I am deep in the topic. Well this methodology is not new for me, I learnt everything in my life this way, just internet and experiments.

In this project I drive the process, ideas for each version when it comes to architecture, datasets curation, synthetic data etc, while my AIs coded all of the training, inference, prepared actual datasets, gave me dashboards to observe the process, reverse-engineered game formats and streamlined all the stuff like uploading levels to my Steam Frame (I play standalone mode).

All of this happened just over the weekend, I started on Friday evening and ended with this post on Sunday evening.

I wanted a tool that charts levels for Beat Saber for any music I like, more or less just as good as human mapper would do: movements that develop, hands that alternate with intent, choreography that mean something.

The idea is fun and constraints I set for myself made it even more fun: Go only, no Python, no ML frameworks, running well enough to train on a desktop CPU and prototype in 30-60 minutes and play-test on a Steam Frame right away.

General idea and how far it came along

I wanted to start with simplest possible neural network solutions and evolve over time to understand what each part really gives me and why it exists. I wanted to actually feel it.

The idea is I train small specialized neural networks for each problem or just solve it in plain old algorithmic way. Since the beginning till now one solution works well for me: I have algorithm which detects rhythm, it kind of decided when some notes should appear to be sabered. But it itself had only like ~67% accuracy when tested against human-charted levels I downloaded from the internet. Here comes very simple trained model which helps to additionally rate if human would chart a note at given time and accuracy just like that climbed to 75% and it made everything feel very rhythmic, I was happy with that part so stopped there.

The more fun part which keeps evolving though is the charting model itself. The generator harness asks it what would you chart at this moment, given this musical situation and past moves we had. How exactly this part evolved and what I learned is what you can learn from the rest of this article.

Rating how well model does while training

Just like any training run the most important thing is telling how well it goes. Here I have three things which guided me from the beginning:

  1. Validation loss - this core value drives the training and decides when we stopped improving, but how we calculate is based on the next points
  2. Prediction accuracy - simply speaking, given series of moves and music from human-made levels how often AI predicts what would be next and succeeds exactly
  3. Chords conflict penalty - penalty given when AI attempted to place chords in such a way that one color blocks cutting another, but here I use conflict mass, not how often AI actually picked the wrong decision. Meaning of mass goes like this: suppose the model considers four possible next blocks:

    The mass would be considered 20% (=15%+5%). It's weighted by 0.2 for validation loss.

  4. Chord-direction/geometry penalty - includes alignment and opposite-color approach obstruction, weighted by 0.05

Of course I did not start right away with finetuned and such rich system, instead more or less I started with prediction accuracy and chord direction penalties.

What the tokens are

The token in my model is decision about what kind of note should get charted. Each hand gets its own decision one at the same time, but due to the nature of game having an ability to show more than one note per hand simultaneously I added the CONTINUE token which means the next note token is supposed to happen at the same time. I chose this instead of token that would work like a "dot" in a sentence as statistically it would consume more tokens when we consider how BeatSaber charts are constructed.

There are also tokens symbolizing characteristics of music and these evolved over time, where at the time of writing this I have 9 vectors describing the window (portion simply speaking) of music. Details of what context is, how is it handled were subject to a lot of changes and I will cover discoveries below.

Lighting effects

All scenic effects I generate just algorithmically and in some cases I could even 1:1 reproduce exact rhythm of existing maps, showing that some charts already employ automatic generation and I managed to fit in. Not much to say here, it's not the main focus of the projects, but playing without any flashes or lasers is actually boring. Good chart generator must support it.

Feature set

I decided to start (and so far continue) with just notes to cut through: arrows and dots. There are no bombs or barriers yet. The model also does not decide when to chart notes exactly. The idea comes from giving the little model good conditions to specialize in just one thing and see how far I can push this. Adding more variety of tokens to the context and growing context size itself are both obviously not too great choices to start from. Later bombs and barriers will be learned just like charted notes are.

The evolution

The first version

So I started with just an MLP, which to remove some magic, or maybe add more ;) means MultiLayer Perceptron. Not the time to teach everything here but it had just context length of 2 (I thought this is the least we need to make some fluent movements), hidden layer of just 96 parameters and resulting in output of 218 softmax values (the token vocabulary).

My first dataset was just 1000 charts and used window features only during training and inference. Basically it had repeated amnesia. Training stalled at 1 epoch; 31.6% validation / 33.4% test accuracy.

Validation loss and test loss for those who do not know, but it is important as it's main metric in how well model learns based on examples it has not seen during training and these that it has seen respectively.

Let's go v2

Same architecture, hidden increased to 192, added LR decay 0.7/6 epochs. I introduced patience and min epochs configuration for our training pipeline. Trained properly (best epoch 5 of 13) but test accuracy stuck at 33.4%. The underfit was architectural. Meaning it could not even memorize, not speaking of real generalized learning.

v3 - one of many in the world of fast progress

Context increased to 8 and improved tokens by adding what I call "rhythm gaps" - each history slot gets an extra number appended: how much time (in beats) elapsed between that decision and the current one. Also finally added dot notes we can cut in any direction. And the mentioned in the earlier part CONTINUE tokens. Also introduced dataset v2 with double the amount of levels, which added ~83% more windows to train on. This way suddenly we climb meaningfully to 41.3% val / 42.6% test.

The model was less than a megabyte, barely 100k parameters, despite that this was the point I've seen the light of possibility that is ahead of me. This was the first version that could be considered playable.

I don't care to pretend I have ideas for each heading, v4

Same architecture; rebuilt/cleaned dataset (better corpus filtering). 42.3% val / 45.3% test.

v5

It's hard to explain without going into detailed technical talk, but this version utilized more advanced hearing. Our model can hear from the beginning, but I felt like it was too little, despite the fact it was already fed with vectors representing BPM, average onset density, average attack strength/contrast, bass/mid/treble novelty, RMS energy, energy change and energy variation. It still lacked more contextual approach and by improving per-attack audio features and creating dataset v3 along with it I achieved 44.6% val / 47.0% test. This was substantial part of work which was later useful for another element of the puzzle.

v6

Same architecture, but happy with increasing dataset before and thought of better generalization I attempted to generate synthetic charts which mirrored some movements in attempt to show the model some decisions work both ways. The idea while sound was not carefully executed (I overdid their part and did not add good enough policies to avoid impossible or awkward moves) and I got slightly worse results than v5 (44.1% / 46.8%).

v7

Introduction of "chord-aware training": this is when auxiliary geometry loss (chord conflicts, weight 0.2) got introduced, but also timestamp-grouped batches. Added 25% synthetic windows. At this point synthetic data is not clean though, but I do not know about it. Accuracy flat (44.4% / 47.1%), but what I could personally feel during playtesting was the chord structure felt much cleaner. This was the point I felt like it's getting human-like feeling. The feeling is hard to describe, but it was very good, yet felt chaotic and there were no longer patterns. Moves following one another felt organic though.

v8

I felt that the problem with longer, feel-good patterns is the context length of just 8. So I increased it to 24 and also finally added cross-window prefixes during training. I have to remind you - consider me unschooled noob in machine learning, but the way I would describe it is window size is something else than context size - window is what model must predict and context is what model reads. The difference is kind of arbitrary, but we show windows to make AI learn what it should predict based on the past context, it allows decoupling between window size and context size and avoids harming predictions. I like to change one smaller thing at once but I decided to use also AdamW at this point instead of just Adam, set weight decay to 0.01. This is generally recommended to avoid model learning some trick early on and validating on it that it works well often, but it may lead to boring outputs. This was the first time past 50% on test (validation 47.5% / test 50.0%).

v9

It worked great so the same architecture; some trainer/optimization refinements for speed and revised training policies. When working on speed I ensure I get bit-identical behavior each time. Got 47.7% / 50.3%.

v10

Added chord-direction loss (0.05) for impossible same-hand arrow sequences. At this point it's not detecting many situations yet, but it's an improvement. Very small improvement by looking at training, but feeling of playing such charts was getting really good. I was very excited at this point. It was the best flat-context model: 47.8% / 50.4%.

v11

Great rhythm, good moves, not many mistakes (I consider them as impossible moves or moves that I can not cut through to get perfect score no matter what). But it still felt like patterns were not organized in any longer sequence despite reacting to music really well. Of course I thought about increasing context at this point, but I was also aware it's not necessarily good idea in such simple MLP architecture I was still using. The problem is that the perceptron, meaning the first layer - let's call it an "eye" of the AI must grow to perceive all possible signals. The complexity of course grows with bigger vocabulary and context length. I had a gut feeling this will not end well when I just take 24 context length and increase perceptron to accept 64 without touching hidden layers. Of course it regressed 46.5% / 49.0%.

From now on let's start talking literally validation loss value which is compound of signals mentioned in the beginning of the post. The validation loss of 1.963 was what we got here. The training time was abysmal here suddenly.

v12 - so all we need is attention?

While waiting on training of v11 I felt it's the time for implementing the next experiment. The same 64 context, but single-head attention pooling over history slots instead of concatenation. This is where even the most bare-bone attention gave us noticeable improvement. We had no longer to train bigger and bigger perceptron. It's as if human looked at an image and tried to analyze every single pixel separately instead of seeing a cat, then seeing a bread and concluding the cat's head is inside of bread. This is exaggeration at this point, but paints the picture for me in simple terms. This way our neural network could be again smaller than v11 (which grew ~2x in size).

From this point the training behaviour changed a lot as well - up until this point I had training plateau at 3-5 epoch. This time I got best epoch 10 and the training run was promising from the very beginning. Validation loss 1.952, 46.1% / 48.6%. Numbers did not look substantially better in the end but playtest showed a lot less chaotic moves, nicer long sequences, but boring placements (bottom-row heavy, few horizontal cuts).

v13

Architecture identical to v12, but rebuilt trainer for quality and ease of use (persistent workers, parallel deterministic gradient reduction/Adam, buffer reuse) + fixed empty-history attention-cache bug. After this I somehow ended running the training for 24 epochs, best at 20: val 1.922, 46.7% / 49.1%. Deployed maps felt finally concise and fun. I really wanted to complete them and to me it was a milestone.

v14

I thought about quality-weighted training where better rated or worse charts get more to say in the training. Implemented fully, stopped at epoch 1 by choice; never evaluated as a candidate. Snapshots preserved for later.

v15 - so actually all you need is self-attention!

Continuation of v13, this one introduced causal self-attention block over the 64 history slots (2 heads, width 32, FF 64, sinusoidal age encoding, learned gap projection). This is much like modern LLMs work and actually what enabled them. This means during training part of the model trained is attention parameters which "remember" how various combinations of signals react together. Topic for separate talk altogether, but this was the biggest jump I had in terms of training metrics since many versions.

It finished with best epoch 20 of 24 (due to validation patience): validation objective 1.764, accuracy 50.2%, and test 52.36% — the first model clearly past the "half of human decisions" mark on held-out data. Of course the aim is not 100%, it's hard to tell how good percentage means saturation, but every little bit of a percent is something I could feel as progress in playtests since it was at 42%.

v16 - bigger memory, and history that finally hears

Two things at once this time (deliberate, but it means the effects are entangled): context 64 increased to 128, and every context slot now carries the nine audio features of its own past attack, so history is no longer moves-only. The model can finally represent "the last minute of music sounded like this". Costs ~2.4x per decision (quadratic attention in doubled context). Honestly? It was too slow in training for me but promising in numbers: after 9 epochs the best was epoch 8 with validation objective 1.797 (vs v15 1.792). So I stopped it at the epoch-9 boundary. Doubling memory did not help by itself in clear way that fast.

v17 - the comeback run

Same experiment as v16, replayed cleanly with a better trainer:

This time it worked and was back to fast training: 24 epochs, best at 20, validation objective 1.761, test accuracy 52.34% - essentially matching v15 while carrying double context plus historical audio. When playtesting it felt much better in how organized the music was though. And this is something I can not really rate. Model is autoregressive, just like LLM and when I test on human-made charts and ask it to predict what's next that is one thing. Letting model chart notes from scratch and then ask it hundred notes later what is next is something else in practice and I can not measure it. At this stage I could absolutely believe human made this level. It had a couple of awkward moves in a couple tracks in their beginning, but otherwise it was smooth. The issue that can be fixed with further data curation and better policies. What still feels lacking is its ability to design a section and repeat it when moments in a song are far apart. Obvious in retrospection because context even 128 is not that much for that purpose.

v18 - cleaning the data and taking care of some geometry guarding policies

Two refinements here. First, v6-style policy got a proper geometry logic audit and opposite-color pairs blocking each other's swing path were excluded. Then I cleaned up my synthetic dataset with it, because it contained some bad moves. Second, improved the policy for the cuts direction loss: where v10's policy penalized same-hand arrow alignment problems, this next version added cross-color approach obstruction - chords where the two sabers' swing paths would collide through each other's note space. Result: best epoch 31 of 35, validation objective 1.740, test accuracy 52.72% - my best model so far. All while the invalid same-hand chords dropped from 808 (v17) to 433 as rated by latest policies. To me it means data curation can and will most likely give us nice further progress.

Version index

ModelWhat changedContextVal. objectiveVal. accTest acc
notes-v1MLP baseline2—31.6%33.4%
notes-v2wider net, LR decay/patience2—32.2%33.4%
notes-v3context 8, rhythm gaps, dots/chords8—41.3%42.6%
notes-v4dataset/schema updates8—42.3%45.3%
notes-v5per-attack audio features8—44.6%47.0%
notes-v6augmentation variants8—44.1%46.8%
notes-v7chord-aware geometry loss82.11744.4%47.1%
notes-v8context 24, AdamW, history datasets241.92347.5%50.0%
notes-v9refinement241.91547.7%50.3%
notes-v10+ chord-direction loss241.91447.8%50.4%
notes-v11flat context 64641.96346.5%49.0%
notes-v12attention pooling over 64 slots641.95246.1%48.6%
notes-v13corrected/optimized trainer only641.92246.7%49.1%
notes-v14quality weighting (paused at epoch 1)64———
notes-v15+ causal history self-attention641.76450.2%52.4%
notes-v16context 128 + historical audio (stopped ep. 9)1281.79749.3%—
notes-v17v16 replayed, resumable trainer, AVX21281.76150.4%52.3%
notes-v18obstruction-clean synthetics + geometry-v21281.74050.8%52.7%

Current architecture (notes-v18)

So far the content you've read I've written myself, this is not gen-AI. But following part is generated by GLM 5.3 Flash.

                          ┌──────────────────────────────────────────────┐
                          │  history slots (up to 128)                   │
                          │  token embedding(32) ⊕ age encoding          │
                          │  ⊕ learned gap projection (beat gap)         │
                          │  ⊕ learned 32×9 past-audio projection (v16+) │
                          └───────────────┬──────────────────────────────┘
                                          ▼
               ┌─────────────────────────────────────────────┐
               │  causal self-attention block (2 heads)      │
               │  LN → 2-head attention (causal) → residual  │
               │  LN → FFN 32→64→32 (ReLU) → residual        │
               └───────────────┬─────────────────────────────┘
                               ▼
 current moment    ┌────────────────────────────┐
 ────────────────► │  attention-pooling head    │
 rel. beat (1)     │  query = AttnQ(rel.beat ⊕  │
 audio features    │         audio features)    │
 (20)              │  keys/values from history  │
                   └──────────┬─────────────────┘
                              ▼ pooled ⊕ last ⊕ mean ⊕ rel.beat ⊕ audio
                    ┌────────────────────────────┐
                    │  MLP head 192 (ReLU)       │
                    └──────────┬─────────────────┘
                               ▼
                    ┌────────────────────────────┐
                    │  softmax over vocabulary   │
                    └────────────────────────────┘

Data flow notes:

What is not in the diagram, on purpose: the timing selector (a separate small model that decides which onsets become attacks), the rule verifier (structural validity only), and the generation-time comfort/density policies. The note model never sees future attacks and never chooses a timestamp. (Since v16 it does see past attacks' audio — that earlier limitation is fixed; retrieving sections by audio similarity remains future work.)