New theory predicts LoRA size for any dataset
Researchers at Engram have developed a predictive theory to determine the exact LoRA rank required to fit a specific dataset based on bit encoding.
Source: Hacker News — front pageResearchers have developed a method to predict the exact size of a Low-Rank Adaptation (LoRA) adapter required to fit a specific Supervised Fine-Tuning (SFT) dataset. This breakthrough addresses a long-standing ambiguity in model customization: determining the optimal rank for an adapter.
Why does LoRA rank matter?
LoRA has become the standard approach for customizing large language models (LLMs) in industrial settings. By training only a small subset of parameters, developers can create lightweight adapters that are faster to generate text from, easier to store on disk, and quicker to load. However, choosing the correct rank—the dimension of the low-rank matrices used in the update—remains a challenge.
While it is widely accepted that LoRA may underperform full-parameter fine-tuning on very large datasets, the industry has lacked a clear metric to determine when a dataset is too large for a specific LoRA rank. According to Engram, smaller LoRAs offer significant system advantages, and in some cases, such as reinforcement learning data, a rank-one adapter may be sufficient to represent the information.
How is LoRA capacity measured?
To determine how much information an adapter can store, researchers must measure both the adapter and the dataset using a common unit: bits. The team relies on the principle that language models act as text compressors. Based on Shannon's source coding theorem, a model's effectiveness as a compressor is directly tied to its perplexity or cross-entropy.
The number of bits required to encode a string under a model is defined by its negative log-likelihood:
As a model's training loss decreases, the amount of information it stores about the training data increases. By converting loss into bits, researchers can quantify exactly how much a model has learned.
Can we generate data with exact bit counts?
Measuring capacity requires datasets with a controllable amount of information. Rather than using random strings or fact tables, the Engram researchers used arithmetic coding to generate synthetic datasets. Arithmetic coding allows for the transformation of probability distributions into codes, enabling the creation of text that has a precise bit length under a specific model.
By running arithmetic coding in reverse, the researchers can start with random bits and decode them into text that is a sample from the model's probability distribution , where the code length is exactly bits. This "Neural Linguistic Steganography" approach allows for the construction of training sets with known informational sizes, providing a rigorous benchmark for testing adapter capacity.
What is the mathematical theory behind the prediction?
The researchers developed a predictive theory suggesting that LoRA capacity does not scale linearly with parameter count like full-parameter training. Instead, they observed diminishing returns as the rank increases.
By modeling the log-likelihood as an inverted bowl in parameter space, the team derived a formula for the capacity of a rank- adapter. The capacity is approximately determined by the expected sum of the squared singular values of a random matrix :
For low ranks where , the capacity grows roughly linearly:
As the rank increases, the capacity plateaus. At full rank, the formula recovers the classical result from Wilks' theorem, representing the maximum possible information storage.
How accurate are these predictions?
To validate the theory, the researchers tested it against actual training sessions on full transformers. While the theory was derived for individual weight matrices, the team found that when multiple matrices are adapted jointly, the capacity is more than the sum of its parts.
In empirical tests using an 800M parameter Qwen3.5 model, the theoretical predictions closely matched the measured capacity. For example, when testing LoRA on the layers of the model, the theory accurately predicted the bits-per-parameter (bpp) across various ranks, confirming that the mathematical model can reliably guide the sizing of adapters for real-world datasets.
Applying these concepts in research
For researchers working with complex technical papers or large datasets, understanding the informational density of their data is crucial. While Grafy does not currently provide a tool to calculate LoRA ranks, you can use Reader to analyze the information density and core concepts of dense academic PDFs. By using Grafy Chat to summarize or query these documents, you can gain a better intuitive sense of the "information load" present in your research materials.
Frequently asked questions
What is the main benefit of using LoRA for model customization?
LoRA provides significant system-level advantages by being much more efficient than full-parameter fine-tuning. Because the adapters are smaller, they are faster to load, result in faster text generation, and require much less disk space for storage, making them ideal for scaling customized models.
How does the capacity of a LoRA adapter change as its rank increases?
The capacity of a LoRA adapter grows roughly linearly when the rank is very low. However, as the rank continues to increase, the adapter experiences diminishing returns, eventually reaching a plateau where increasing the rank further provides significantly less additional storage capacity.
How can researchers create datasets with a specific number of bits?
Researchers can use arithmetic coding in reverse to transform a specific number of random bits into text. This process, known as neural linguistic steganography, produces text samples that have a precise, controllable code length under a given language model's probability distribution.
Source: Engram
Source: Hacker News — front page — Predicting LoRA size for any dataset


