Skip to content

u/FenderMoon

In this archive from Sep 2022 to Nov 2026

0
posts
33
comments
0
media
125
score

Top comments

5m is tiny. Frankly I'd go up about an order of magnitude before you judge anything else about your methods. Try it again at 50m or so, you'll get much more coherent results.

I recommend renting runpod or vast.ai servers and running the training on those. Makes it trivial to train 100m parameter models and beyond. If you're trying to do it locally, computational requirements will be too large for it to be practical.

Some tips from just things I've learned:

- LLMs are surprisingly shape-agnostic-ish as long as the structure of the model is well within the realm of reason. That is, you could make a slightly wider 12 layer model, or a narrower 15L model, and the output quality and bpb generally won't differ by very much. That's not to say there won't be differences, of course they are, but in general, LLMs sort of learn to work with the structure you give them. As long as you give them something reasonable, they'll generally perform almost equally well.

- FFN width is an exception. Wider FFNs are good. The defacto "llama-standard" formula here is 2.67x SwiGeLU, but I get better results when I go closer to 3.6x to 4.0x, even on SwiGeLU. Wider MLPs are one of those things that are worth spending parameters on when you can, it greatly increases the model's general knowledge and factual recall ability for its size, even if you have to sacrifice a few layers to do it.

- As for layers, I tend to go shallower and wider, but you still need enough layers to do basic transforms required by whatever text you throw it. 10L is really pretty shallow but you might be stuck in that range if you're going with 100M models. Just try not to go below 10L, that's my rule of thumb. I have good results doing this, but there are also projects like MobileLLM that have suggested doing the opposite (their research points the other way, they say more layers and narrower models are better for param-starved budgets. They showed the data for TriviaQA, I can't argue with results, but personally I wasn't able to replicate it. Again, LLMs are more shape-agnostic than you'd think as long as the structure itself is within reason.)

- For attention heads, personally I have better results with 128 dim heads than with 64 dim heads. Yes you can only fit half as many, but it made a big difference in bpb measurements when I tried it. If you're doing truly tiny models you might be forced to go with 64 dim heads, but definitely try not to go lower than this.

- Dataset quality matters FAR more than trying to hyper-optimize the architecture or ratios or structure. Like, it's hugely, hugely important. I don't recommend blindly throwing wikipedia or anything at it. For 5m parameters, you pretty much have to use a super simple dataset like TinyStories, which will work, but that won't really be very exciting. If you are going up to 50-100m parameters, that's when you can easily afford to throw a "real dataset" at it like dclm or fineweb-Edu, which are both super high-quality curated web datasets which are GREAT for tiny LLMs like this.

You could very easily get a model you can chat with that sounds coherent by going with 6-8 heads at 128 dims each (d_model 768), 10-14 layers, 4X FFN width with SwiGeLU. Don't forget that you'll have to fine tune it before it spits out anything that resembles normal conversation, but models in this range start to emerge with the kinds of capabilities you're looking for.

26 points

ZRAM is generally considered the better option for a lot of folks. A page that’s in swap is going to be slow to get, whether it’s compressed or not. However, if it’s instead compressed and then “swapped into RAM” (essentially what ZRAM does), you do lose some working memory on the system but you gain massive performance improvements in terms of access latency for that page.

It is a trade off, and it takes some tinkering to get it right. But in general, the performance improvements are pretty noticeable if you set it up correctly (particularly on low RAM systems where workloads were frequently sending a lot of data to swap).

19 points

Short answer is that ZRAM does indeed use RAM, as it stores compressed swapped data in RAM rather than writing it to disk. However, it still is excellent for systems that are low on RAM because it is massively more efficient to compress and decompress pages out of RAM than it is to go grab them from disk.

To give you an idea, it can usually take anywhere from hundreds of thousands to millions of CPU cycles to grab a page from an SSD or a disk. Decompressing it out of RAM can take a couple tens of thousands of CPU cycles, and sometimes less. We’re talking about a pretty substantial difference, even on systems with older CPUs that might not be able to decompress as quickly as newer systems. Grabbing pages from disk is very slow, even when they’re being swapped out to SSDs. Access latency is the issue.

ZRAM effectively makes swap and virtual memory significantly more efficient. On systems where swap is constantly being used, ZRAM can often substantially improve performance (when it’s set up right) because it makes it significantly easier to go grab those pages when they’re “swapped out” (compressed in RAM) rather than forcing the CPU to sit there waiting hundreds of thousands of cycles to grab it from the SSD.

ZRAM compression ratios are also generally pretty good. Even when you’re using the fastest compression algorithms (such as LZ4, as I have set up on one of my systems), you can still easily compress a gig into about 300MB. Some of the more advanced compression algorithms are slower, but they can achieve even better ratios than this.

16 points

Subreddits

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.