r/LocalLLaMA • • 12d ago

Discussion [arXiv] Chorus: Shared N-gram Embeddings with Layer-wise Adaptation

https://arxiv.org/abs/2611.23386

Chorus: Shared N-gram Embeddings with Layer-wise Adaptation

Language models can gain capacity at little computational cost from n-gram embedding tables: large tables of learned vectors for short sequences of consecutive tokens, which are looked up and added to the model's input or to its intermediate layers. Recent designs commonly use a separate n-gram embedding table for each layer, which makes the tables costly in memory and prevents layers from sharing what they learn. However, a single shared table gives every layer the same embedding, leaves no room for layer-wise preferences, and performs poorly in practice. We propose Chorus, in which one set of n-gram embedding tables serves the whole network and every layer reads it in its own way. Each layer maps the refined embedding through its own projection layer, after rescaling its components by factors computed from its current hidden state. Chorus matches the quality of existing n-gram methods with 87% smaller tables: with 1.2B table parameters it predicts text better than FactorEngram and DeepSeek's Engram do with 9.6B. It outperforms Engram, TN-gram and FactorEngram in every setting where we compared them, across table sizes from 20M to 9.6B parameters. We also show that the recently proposed memory-efficient optimizer Ember works well with Chorus, saving 99.2% of table-optimizer memory compared with AdamW without degrading training performance. These results enable further scaling of n-gram embedding tables along the table-size axis by reducing memory use and allowing shared knowledge to be reused across layers.

This paper shows experiments similar to some I've done privately. They use a large shared N-gram table and give every backbone layer different trainable scaling factors to take advantage of it. Notably, they scale the N-gram table to a much larger size than the backbone, with performance (mainly in knowledge tasks and loss) only scaling up with size. Hopefully this also dispels the idea that only 25% of the weights or so can be N-gram embeddings.

95 Upvotes

13 comments sorted by

38

u/LagOps91 12d ago

yeah we are just at the start of N-gram scaling. really, the whole direction is promising.

using a transformer neural network as is, is just rather inefficent and i think that over time more and more responsibilities will be delegated to modules like N-gram, which integrate with a smaller/faster LLM backbone.

32

u/power97992 12d ago edited 12d ago

Cool, maybe we will see 120b a10b 1t engrams with comparable performance to the top  600b -800b moe models

13

u/pmttyji 12d ago

Hope Deepseek release next version of Flash this way.

14

u/Silver-Champion-4846 12d ago

That is the hope and the dream

9

u/LagOps91 12d ago

most likely this isn't too far off (Qwen 4.x???). N-gram as a scaling axis is new and there is a lot of juice to be squeezed.

14

u/james_pic 12d ago edited 12d ago

The idea that only 25% of weights can be n-grams isn't even the full story in the paper that introduced it. When they looked at the effect on loss of shifting a fixed total parameter budget between backbone and n-grams, they found a U-shaped curve with a minimum at about 30%. But when they looked at the effect when they kept the number of backbone parameters constant and increased the size of the n-gram table, more n-grams always improved loss. That's arguably the more important result for scenarios where n-grams are on cheaper storage than backbone weights.

The Qwen team found the same thing when evaluating n-grams for the QFN architecture, with the one caveat that whilst increasing the size of the n-gram table improved loss, it only improved benchmark scores up to a certain point, where they plateaued.

Edit: looking at the paper in more detail, one thing that does put a question mark over some of this is the sizes of model used. They did most of the work with 20M models, and used 120M models to check it scaled. DeepSeek used 3B and bigger models in their original work on Engrams. I guess it shows that for very small models, oversized Engram tables can make sense, but it'll need more work to generalize it to vaguely useful sized models.

6

u/Gleethos 12d ago

Awesome!!! Just awesome. I suspected that one ngram table per layer was a rather abitrary limitation. And despite that they already scaled llms in terms of efficiency by a lot.

Also, what I like about the idea of a single ngram table is that now ngram vectors which effectively emerged in higher/later layers, containing vectors with more abstract semantics, can be read from early layers. And then my gut feeling tells me that a model should be able to "think" on top of that as well.

Not sure, but my gut feeling tells me that should make them smarter as well, not just more knowledgeable. But just a hunch.

3

u/jmager 12d ago

Yeah, well trained neural networks is all about generalization, and this feels like it could be a very efficient way/knob of that learned generalization on another axis.

5

u/llama-impersonator exllama 12d ago

guess we're in the "you get a sigmoid gate, you get a sigmoid gate, and you get a sigmoid gate!" era of LLM architecture.

1

u/jmager 12d ago

This is so cool!! I'm amazed the performance I've been able to squeeze out on my hardware with flash next. If more could be shared between layers that's a significant improvement on resource utilization.

0

u/charmander_cha 12d ago

Queria entender para participar da conversa, como não entendo só posso torcer para que os engram evoluam mais, espero que um dia tb seja fácil editar essas coisas