r/deeplearning • • 28d ago

Developing intuition for model behavior, architecture choices, and convergence?

Hi everyone, this is my first post so m kind of nervous 😅,

I recently built a Transformer from scratch and trained it for English-to-French translation,trying to recreate Attention Is All You Need with a 30M and 60M model. The 60M model has less data diversity.(wmt dataset)

Even though I can see the model performs decently, I go all over the place trying to explain my point when I try to interpret it. I am struggling with these specific conditions:

  • When using interpretation tools (e.g., attention visualization, logit lens, even linear probing): I cant seem to understand where the failure modes are, or what's driving the model to perform so well like having a concrete idea to explain model behaviour.
  • **When modifying the architecture (e.g., adding something like a residual stream):**How do u develop the skill to understand or diagnose whats wrong with a models behaviour or know whether u need to add something to improve the model?
  • When managing training dynamics (e.g., using a warmup scheduler and cosine decay): How do i know if a model converged or if the learning rate is just no longer high enough to do actual improvement? It feels like m leaving performance on the table.

I wanted to know from you guys how do u develop that overall intuition of knowing when something isnt really helping.

4 Upvotes

7 comments sorted by

3

u/mr-bro-max 28d ago

I like to think of it like real software - create diverse tests (test set) with a lot of edge cases that can make the software fail (model extrapolates) and try to figure out how you address that - whether it’s in the training set in the loss function or in the model architecture. Looking at the data and at the results is the best way to understand the strengths and weaknesses of the model, just like when you run your software. Tweaking hyperparameters is good but it won’t solve problems in your data or in the model. Understanding which architecture fits best usually comes with understanding the data distribution (assuming you understand the theory) and seeing “weak spots” that weren’t addressed in the architecture or in the loss function. For example, your model translates short texts spectacularly but long texts it sometimes extrapolates and performs not as good. Instead of immediately increasing the context window, you can think of using a recurrent state that gives the model context from the beginning of the text and make the transformer cross attend the hidden state in addition to the tokens, so it’ll get more information on past text. With that it might improve on longer texts. Then you start trial and error, see the edge cases, analyze weak spots and iterate. One-shotting happens almost never :)

0

u/Abject_League6170 28d ago

I put together 5 test sets: 2 from the test split of the dataset I trained on, 1 LLM-generated set of short casual sentences, and 2 from other datasets for the same task. I’m mainly evaluating with BLEU, but I know it can miss some edge cases, so there’s room to improve there.

What really fascinated me was your example of adding a recurrent state to improve long-context performance

On the recurrent state, can I assume it’s a separate module wrapped around the transformer, trained jointly through backprop from the cross-attention, and that cross-attention is the only place they interact? if so ,Correct me if I'm wrong but doesn't the recurrent state as it is doesn't it enccode some representation of the tokens that it has just seen , wouldnt that recurrent state have to encode some represantation about the English tokens and about the French tokens And wouldn't you have to make it like sufficiently large roughly to even like be able to encode with decent accuracy that represantation , The recurrent state can only really be attended to during cross attention if it's a fixed vector so I guess another question I could have is would you want to first have a bigger recurrence state then squish it down to a fixed size vector that you can later attend during cross attention and that probably would impact accuracy as well right ? and my last question is probably does the model learn that for longer context i should rely on the fixed vector from the recurrent state cause recurrents states are like short term memory the should have encoded more infromation of later tokens then the first tokens

1

u/Long_Ad4518 27d ago

I usually just watch whether the loss starts oscillating, once it does it's pretty much done learning. Also if you keep training on the same data, don't chase a super low learning rate too hard, you might just end up overfitting.

0

u/Abject_League6170 27d ago

😭m using like 16 batches and shuffling per epoch its hard to know if the lower loss floor is decreasing later in training,the loss has been oscillating for some time actually 😂 i just checked the logs , i actually noted the pow lr thing with the smaller model it was improving a lot on the val set but come test time it started regressing on other out of distribution test sets

1

u/Massive_Distance_616 27d ago

Welcome to first-post nerves building both a 30M and 60M from scratch and asking why rather than just what puts you ahead of most.

Attention visualization and failure modes. Attention maps show where the model looks but not whether that caused the output attention weights ignore the norm of the value vectors and the MLP updates that follow. More useful: categorise your translation errors first (sentence length, negation, word order, rare vocab). Then use the logit lens project the decoder’s residual stream at each layer onto vocabulary space and track the rank of the correct French token. If it’s rank 1 at layer 6 but drops to rank 25 at layer 10, something in those later layers is overwriting a correct early representation. That tells you where to look, not just that something went wrong.

Architecture changes. Write down the exact failure before adding anything: “the model drops negation on sentences longer than 20 tokens” is actionable; “performs not as good” isn’t. Then ask what existing mechanism should handle that and why it isn’t. For a 30–60M model on WMT, degradation on medium-length sentences almost always points to optimisation or data quality, not a fundamental architectural gap. The diagnosis comes before the intervention.

Convergence vs. stale LR. Cosine decay naturally forces the loss to flatten because the LR approaches zero a flat curve near the end isn’t proof of convergence. Test it: take a checkpoint from 80% through training, drop LR by 5× and run 500 more steps. If validation loss improves, you still had gradient signal; the schedule was just throttling it. Also track gradient norms if they’re non-trivial but loss is flat, LR is the likely culprit. If both loss and norms are flat, check your training vs. validation gap: your 60M with less data diversity may be starting to memorise rather than stall.

One addition: supplement BLEU with chrF, which is more sensitive to morphological errors in French. Aggregate scores hide exactly the failure modes you’re trying to diagnose.

0

u/[deleted] 26d ago

[removed] — view removed comment

1

u/Abject_League6170 26d ago

yep i can say it did when i was testing stuff like idomatric text it normally defualts to a broken or just direct translation word for word instead of finding the equivalent in french the 30m model does that less frequently , word legth is also one on shorter setnences the bigger model struggles alot cause they a normally casual in their nature, it feels as though there is an ocean of edge cases to find😅 the more i think about it