MNIST experiment notes
한국어English

Machine-assisted English translation. Original code, logs, and model inputs are shown as recorded; consult the Korean article if wording is unclear.

MNIST Tutorial · Easy Explanation Board

Looking at the picture of numbers,
AI that chooses its next action

What does ‘learning’ change?
Why can't I reach my goal even though my accuracy is high?

Let's follow the original experiment from the beginning. Rather than memorizing difficult terms, what the task is → how the model is trained → what the results show.

From concept to result · 8 storiesRead the first story ↓

01 / Understanding the problem

One step further from reading numbers

hand written on paper 7There is this. The number I am standing on now is 3It is. What can I do to get closer to my goal of 7? First, add 1 to get 4.

This is exactly what this model does. Look at the numbers in the picture, and from the current number The action of subtracting 1, stopping, or adding 1 Choose one. MNIST is the name of the collection of images of handwritten numbers used in this case.

Try changing it yourselfNon-trained model answer rule example
+1

You don't just jump to 7 all at once. Go from 3 to 4 and then back to 5, making a new judgment each time. When you get to 7 You have to pick 0 and stop Success. Here, 0 does not mean ‘move to the number 0’ but ‘stop where you are’.

Read decision model as ‘a model for choosing an action.’

In this experiment, instead of writing long answers, you score three options. The program takes the action with the highest score and executes it.

Section 2 of the original text · Read more about problem structure ↗

02 / Understanding input

Provides pictures, current situation, and action descriptions.

If you just show a person a picture, it would be difficult to know what to do. The model also tells us three things:

① Image

Where should I go?

This is an illustration of handwriting with the goal number written on it. The correct answer number, which is 7, is not separately provided.

② state · Current situation

Where are you now?

The sentence is ‘The current number is 3’. In the actual study, English sentences were used.

③ questions · Questions and options

What can you do?

Instruct them to choose actions that will get them closer to their goal, and explain what −1·0·+1 means.

Then who will tell you the answer? The code that prepares you for learning compares the correct number in the picture with the current number. If the target is 7 and the present is 3, the correct action is +1. This correct answer is Not a hint shown to the model, but a criterion for grading the model's answersWrite it as

What does sign(t − s) mean in the original text?

t is the target, s is the current number. If t − s is positive, choose +1, if it is 0, choose stop, and if it is negative, choose −1. In other words, it is a shorthand way of saying, ‘If the goal is bigger, add, if it is smaller, subtract, and if it is the same, stop.’

Original text Section 2.1 · View actual input format ↗

03 / Understanding the model

We teach existing models how to solve this problem

We don't make you learn everything from the beginning. Capable of processing images and text together Qwen3.5-0.8BIt is written based on . This model is called VLM. In Korean, it is ‘a model that handles images and language together.’

Picture + current situation
Questions and Action Description
→
Based model + LoRA
Calculate features of input
→
decision head
Scoring by behavior

LoRA adds small corrections to existing calculations

What the model learns is the internal numbers, that is, weightThis means controlling. This time, we keep the weights of the base model fixed and learn a small additional weight called LoRA. It can be likened to attaching a correction note to the side rather than editing the entire original.

However, LoRA is not a device that corrects the answer outside the model. Participates in model internal calculationsIt is also used when choosing the actual answer after learning.

The decision head makes the final choice

This is the part that receives the information calculated by the base model and the question/choice information, and scores −1·0·+1 respectively. It is convenient to think of this as a ‘judgment department’. This time, the judgment part was also studied together. The actual structure is more complex than a layer that simply produces three output values, and the detailed structure can be seen in the original text.

This is not an experiment where we learned Jev directly.

Jev is the decision model that became the starting point for this article. In the actual experiment, a Clef-style decision part and LoRA were attached to the Qwen model. So the performance here is not Jev's performance per se.

Do I need to know settings like 4bit and rank 16 now?

At first, it can be understood as ‘the base model was lightly loaded into memory and some additional weights were learned.’ 4bit is related to the numerical expression that stores the base weight, and rank 16 is a value that determines the size of the small matrix of LoRA. This does not mean that all data and calculations are 4 bits.

Original text Section 3 · View structure diagram and LoRA formula ↗

04 / Understanding Learning

Solve it, grade it, and fix it little by little.

  1. It presents a bunch of problems.

    Insert pictures, current numbers, and choices into the model. This batch is a batch. In this study, 32 were processed at a time.

  2. The model calculates a score for each action.

    This process of calculating output from input is called forward. Scores can be converted to probabilities.

  3. Calculate the degree of error compared to the correct answer.

    This value is loss. If you give a high probability to the correct action, it gets smaller, and if you give a low probability to the correct answer, it gets bigger. If you are certain, an incorrect answer will result in a greater penalty.

  4. Calculate and reflect on which direction to correct.

    backward calculates how to change the weights to reduce the loss. The optimizer (optimization algorithm) uses this information to actually modify the LoRA and decision weights.

Repeating this process is learning. In this experiment, the correct answer behavior is given and taught. Supervised learningIt is. It does not replicate reinforcement learning where you perform an action and receive a reward. Unsloth is the tool used to organize and run this lesson.

600 step = does not mean you have seen 600 pictures.

In this study, 32 items were processed each and the weights were modified once. We repeated this 600 times, so we processed a total of 32 × 600 = 19,200 training pairs. It doesn't mean that you can look at the same material again, so there are 19,200 different pictures.

Read the learning graph like this:

If your loss goes down overall, it's a sign that you're getting better at giving correct answers to your training material. The jumping out point in the middle may be because difficult problems are grouped together. However, just because the loss goes down, it does not guarantee that you will be able to solve the picture you see for the first time. Separate testing is required.

Original Article 4 · See more training process ↗

05 / Understanding trial and error

If it doesn't work out, check for the smallest problem first.

first attempt

I just kept picking +1

The action accuracy was 43.4%, but there was no case where the target stopped. If it is less than the target, +1 is correct, so the score was somewhat high. If you just look at these numbers, it's easy to miss the problem.

Check by reducing it to small size

I saw if I could memorize 30 questions.

We chose one picture of numbers 2, 5, and 8, and labeled each with the current numbers 0 to 9. After repeatedly studying the 30 pairs created in this way, I got them all correct. At least this is confirmation that it is possible to learn the correct answer with this code. This does not prove that you are good at new drawings.

This study

Expanded to 2,000 pictures

Instead of continuing the weights memorized in the small experiment, we started anew with a pre-trained model. We created 20,000 pairs by attaching 10 current numbers to each picture. There were few problems where the correct answer was ‘stop’, so problems with insufficient behavior were duplicated to provide learning opportunities.

At this time, the learning rate, batch size, input language, and total learning amount of the judgment part were changed. Even if the results are improved, it cannot be attributed solely to “growing the batch.” If you want to know the cause, you need to set the remaining conditions and change them one by one.

The reasons for sharing data are also different.

materialWhat we do in this experiment
Learning · 2,000 sheetsSolve the problem and fix the weights.
Intermediate verification · 100 sheetsCheck your learning status. In the middle, you see the first 30 chapters, and in the end, you see the 100 chapters.
Probability calibration · 50 sheetsAdjusts the size of the probability the model produces.
Final evaluation · 1,000 sheetsCheck the behavior and movement path of the saved model.
Original text Section 5 · View actual settings and execution commands ↗

06 / Understanding the results

There is a difference between making a good choice and sticking to the end.

Did you guess one action?97.70%

Correct answer 9,770 times out of 10,000 judgments

Did you reach your goal and stop?93.62%

9,362 successes out of 10,000 starting points

In the original text, the second indicator is Episode Success RateIt is called. An episode is a process that starts, moves, and ends. One wrong stop or switch between two numbers can cause the whole process to fail.

For example, what if your goal is 7 but you stop at 5?

Even if you go from 3 → 4 → 5 well, it is not a success. Moreover, not only if you start from 3, but also if you start from 4, you can stop at the same 5. So A bad decision in one place can lead to failure in several starting points.

In fact, there were 230 incorrect actions, but 638 failed movement steps. Of these, 434 stopped in the wrong place, 203 repeated the same state, and 1 was out of range.

Handwriting image No. 582 used in the actual evaluation. The correct answer number is 8.
The correct answer to this picture is 8.

But the model behaved as if 2 was the target. However, it is impossible to determine which part of the internal system is wrong just by looking at the behavior.

The evaluation was conducted by attaching 10 current numbers to every 1,000 pictures. Because judgments from the same picture are related, it should not be read as ‘we tested 10,000 independent pictures.’ This is also the result using the first 1,000 sheets of the official test.

Original text, Section 9 · Examining failure images and actual predictions ↗

07 / Understanding probability

‘90% sure’ and ‘actually 90% correct’ are different

Let's say the model gives +1 with probability 0.9. This means that the model gave +1 a much higher score than the other options. That one answer is not guaranteed to be correct.

If a large number of cases with a probability of 0.9 are collected and about 90% are actually correct, that probability helps express the reliability of the judgment. The task of matching this relationship Probability calibrationIt is said.

Changing the temperature means controlling the concentration of probability.

This time, I used a method of dividing the score for each action by the same positive number T and converting it to probability. If you make T larger, the odds are spread out more evenly, and if you make it smaller, they are concentrated more toward the highest score. The scoring order remains the same, so the outcome of picking the highest action does not change.

Probability calibration is not the task of changing an incorrect action into a correct action.

In the actual test, 141 out of 230 incorrect answers were given a probability of over 90%. This is why it is difficult to assume that ‘the probability is high, so it can be done safely.’ There are no records comparing before and after correction in independent tests, so it is impossible to determine the improvement effect of correction.

Original Article Verse 7 · View probability changes with temperature slider ↗

08 / Take a look for yourself

Now it's time to read the original text.

If the term is unfamiliar, now take a look at the records while thinking of the following three questions.

This training took approximately 20.82 minutes, including intermediate verification. These values ​​and inferred times are results from the specific equipment and measurement conditions in the original text. The page explorer is Saved experiment recordsIt does not newly train or run the model in the browser.

Three things to remember from this experiment

  1. If learning is not possible, first check whether you can solve even a small problem.
  2. View both the percentage of correct answers and the success rate of all actions.
  3. There is a difference between being confident in a model and actually being right.

This problem can also be solved by adding comparison rules to the number recognition model. This experiment is an example to understand the training process of a decision model, and is not a comparative experiment that proves its superiority over other methods.

Receive code and materials and experiment yourself ↗