llm skill acquisition and style control
personal llm
Building a personal model that reasons like a frontier system but writes in your voice, it turns out, requires understanding two largely independent problems. The first is capability acquisition, things like which cognitive skills appear at what scale, and whether those thresholds are as sharp as the popular narrative of emergent abilities suggests, and the second is style control, things like how to impose a specific writing register on top of a capable base model without degrading its underlying reasoning. Here I cover both, paying specific attention to the quantitative thresholds for factual recall, algorithmic logic, and other primary use cases. A forewarning that this post is more for a technical audience, outlining the details of how to build/specialize language models from scratch. That said, there is still context that would be helpful for non-engineers. Feel free to skip over the math if that is the case!
capability thresholds
Cognitive capabilities in large language models do not scale uniformly and depends on whether a given task relies on factual recall, algorithmic execution, tool interaction, or long-horizon agentic planning. Early observations characterized capabilities as emerging abruptly once critical compute thresholds were surpassed, but that discontinuity turns out to be largely an artifact of discrete non-linear evaluation metrics like Exact Match. When evaluated using continuous-valued metrics such as cross-entropy loss or Brier scores, performance scales smoothly and predictably according to power laws. Pre-training cross-entropy loss serves as a robust predictor of downstream capability emergence, though heavy focus on rote memorization can delay the development of generalized problem-solving skills. The table below organizes quantitative thresholds across different cognitive dimensions.
| Cognitive Capability | Minimum Viable Parameters | Pre-Training Dataset Size | Post-Training Structure | Key Benchmarks |
|---|---|---|---|---|
| Factual Recall | 7B to 13B | 1.5T to 3T+ tokens | None (pre-training reliant) | Sigmoid fit on scholarly references ($R^2 = 0.74$–$0.94$) |
| Algorithmic Logic | 350M to 1.3B | 54B tokens (textbook quality) | 180M synthetic exercises | HumanEval: 50.6% (1.3B), 45.0% (350M) |
| Tool Orchestration | 6.7B | Standard pre-training (CCNet subset) | Self-supervised API annotations | Outperforms OPT 66B and GPT-3 175B on LAMA and ASDiv |
| Software Engineering | 30B to 70B+ | Multi-trillion code and general tokens | Multi-turn RL and scaffolded agentics | Devin: 13.86% unassisted; SoTA: <25% on SWE-bench Pro |
stylistic specialization
The alignment of pre-trained models is heavily governed by the Superficial Alignment Hypothesis, which posits that a language model’s fundamental knowledge and cognitive capabilities are acquired almost entirely during the unsupervised pre-training phase. Post-training alignment simply teaches the model the appropriate style, formatting, and subdistribution of behaviors to use when interacting with users.
Since alignment is primarily a stylistic transformation, a pre-trained base model can be aligned with surprisingly little data. The LIMA model demonstrated that fine-tuning a 65 billion parameter LLaMA base model on only 1,000 meticulously curated, high-diversity prompt-response pairs yields alignment quality competitive with models trained via RLHF on tens of thousands of examples. Through empirical scaling evaluations on Llama-3, Mistral, and Llama-2, post-training task performance exhibits a power-law scaling relationship against the number of fine-tuning examples, similar to pre-training scaling laws. Style and formatting improvements saturate extremely rapidly with small fine-tuning datasets, whereas task-specific logical performance continues to scale and benefit from larger, more diverse preference datasets.
For custom stylistic adaptation, Low-Rank Adaptation (LoRA) provides an efficient mechanism by freezing the base model weights ($W_0 \in \mathbb{R}^{d \times k}$) and optimizing a low-rank decomposition of the weight update ($\Delta W = B \cdot A$, where $B \in \mathbb{R}^{d \times r}$ and $A \in \mathbb{R}^{r \times k}$ with rank $r \ll \min(d, k)$). To successfully adapt style without causing catastrophic forgetting of underlying reasoning capabilities, the target modules of the LoRA adapter must span all major linear projection layers of the transformer: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, and down_proj. Limiting adaptation to only attention layers leads to underfitting of stylistic nuances. Typical supervised fine-tuning starts at a learning rate of $2 \times 10^{-4}$. Stylistic features saturate rapidly within 1 to 3 epochs on a small curated corpus. Training further risks overfitting, mitigated by adjusting the LoRA scaling parameter ($\alpha$) at inference time, applying weight decay in the range $0.01$–$0.1$, or linearly averaging the fine-tuned LoRA weights back into the base model weights.
Deploying a model that maintains deep logical processing and factual recall while strictly adhering to a highly personalized stylistic grammar requires bypassing standard fine-tuning, which inevitably degrades base capabilities. Style and logical processing can instead be decoupled at inference time using three distinct paradigms: logit arithmetic, contrastive decoding, and personalized speculative decoding.
Logit arithmetic enables the runtime fusion of output distributions from a highly capable non-specialized target model and a smaller specialized guide model without any parameter modification. A small model (for example 1.5 billion parameters) is fine-tuned to capture the grammar, vocabulary, and stylistic quirks of a target persona, yielding $\theta_{\text{stylistic guider}}$, while its frozen base version $\theta_{\text{base guider}}$ represents general language. During inference, the large target model $\theta_{\text{target}}$ processes the input prompt, and at each autoregressive decoding step its output logits are adjusted by adding the scaled difference between the stylistic guider’s logits and the base guider’s logits:
\[\mathbf{L}_{\text{final}} = \mathbf{L}_{\text{target}} + \alpha \left( \mathbf{L}_{\text{stylistic guider}} - \mathbf{L}_{\text{base guider}} \right)\]This token-by-token guidance shifts the probability distribution to prioritize stylistic words and grammatical constructs unique to the specialized corpus while preserving the logical trajectory and factual coherence computed by the large target model. The decoupled architecture:
[ Input Prompt ]
|
+-----------------------+-----------------------+
v v
+------------------+ +--------------------+
| Target Model | | Stylistic Guider |
| (Mistral 7B Base)| | (Personal LoRA) |
+--------+---------+ +---------+----------+
| |
| Logits_target | Logits_style
| |
+-----------------------+-------------------+
|
v
[ Logit Arithmetic Fusion ]
Logits_final = Logits_target + a * Logits_style
|
v
[ Final Output ]
Standard speculative decoding rejects stylistic variations from the draft model that deviate from the target model’s general distribution. To enforce style, the verification step can instead use a relaxed acceptance criterion that accepts any draft tokens falling within a stylistic alignment threshold, allowing the personalized drafter’s syntax and lexical choices to pass through as long as they do not violate the semantic logical constraints of the target model. In the decoupled architecture with thinking envelopes, the target model acts as a hidden logical engine generating a structured intermediate rationalization path within a hidden block using <think> and </think> tags. This thinking trace handles mathematical, factual, and logical computation. The final answer generation phase is then handed to a highly constrained personalized drafting head or specialized adapter that translates the logical trace into the specific personal style, isolating stylistic constraints from logical computation.
realigning
A common objective in specialized downstream deployment is the removal of previous safety alignment or RLHF steps to prevent over-refusal and restore the raw capability of the foundation model. This process can be executed through both training and representation-level interventions.
Safety alignments enforced by RLHF or Direct Preference Optimization are highly fragile and can be subverted through standard fine-tuning on consumer-grade hardware. Fine-tuning an aligned model on benign downstream tasks with a small learning rate of $1 \times 10^{-5}$ over 1,000 samples for 20 epochs can completely dismantle the safety boundaries established during post-training. Training a model to behave like a general foundation model can be achieved by adding a Kullback-Leibler divergence penalty to the loss function to pull the aligned policy distribution back toward the pre-trained base model distribution, a technique known as unRLHF:
\[\mathcal{L}_{\text{unRLHF}} = \mathcal{L}_{\text{SFT}} + \beta \, \mathcal{D}_{\text{KL}}(\pi_{\text{unaligned}} \parallel \pi_{\text{base}})\]At the representation level, safety alignment is encoded as specific multi-dimensional refusal directions within the model’s hidden activations. Optimal transport theory can map the entire multi-dimensional distribution of harmful activations ($\mu$) to match the distribution of harmless activations ($\nu$) via a minimal-cost mapping, rather than relying on 1D projection-based ablation. Applying this transformation, for example PCA-Gaussian Optimal Transport, at selective intermediate layers during inference bypasses safety refusal mechanisms while preserving model utility and generation fluency.
selecting skills
Recent advances in model editing allow for the precise subtraction of behaviors using weight-space arithmetic, avoiding full retraining. A task vector ($\tau_{\text{task}}$) is computed by subtracting the parameters of a base pre-trained model ($\theta_{\text{base}}$) from the parameters of the fine-tuned or aligned model ($\theta_{\text{aligned}}$):
\[\tau_{\text{task}} = \theta_{\text{aligned}} - \theta_{\text{base}}\]Because model weights shift somewhat independently per capability, negating a task vector ($\theta_{\text{aligned}} - \gamma\,\tau_{\text{task}}$) selectively unlearns that specific capability while preserving others. In a multi-domain context, this is formalized as an Alignment Vector (AV). AVs capture preference dimensions as distinct parameter offsets. Subtracting an AV from an aligned model dynamically bypasses the safety or formatting behaviors enforced by the alignment stage at inference time, effectively behaving as an adjustable preference knob.
technical specifics of how skills emerge
The acquisition of static factual knowledge is governed by a scaling relationship linking model capacity directly to the frequency of concept representation in the training data. Empirical evaluations across multiple open-weight model families demonstrate that recall quality follows a sigmoid function in the log-linear combination of model parameter count and topic representation in the training data:
\[R = \sigma(w_1 \log P + w_2 \log S + b)\]where $R$ is the factual recall score, $P$ is the model parameter count, $S$ is a proxy for concept frequency in the training data, and $w_1$, $w_2$, and $b$ are fitted coefficients. This relationship is explained by a superposition-inspired framework where factual recall is gated by a signal-to-noise ratio. The concept’s signal strength $s(f)$ scales with its training frequency $f$ according to $s(f) = f^{\beta_s}$. The noise floor is dictated by the model’s effective dimensional capacity $N_{\text{eff}}$, which scales with parameter count as $N_{\text{eff}} \propto P^{\gamma_e}$. A fact is successfully retrieved when its signal exceeds the interference floor:
\[\text{SNR}_i = \frac{s_i(f_i)}{\epsilon(N_{\text{eff}})} > 1 \quad \text{where} \quad \epsilon(N_{\text{eff}}) \sim \frac{1}{\sqrt{N_{\text{eff}}}}\]Because knowledge capacity scales at approximately two bits per parameter, smaller models suffer from severe representation overlap (superposition). Early layers of models such as Pythia-6.9B, Llama 2-7B, and Llama 3-8B initially output high-frequency statistical guesses, where the top 10 most frequent tokens in a corpus account for over 75% of early-layer predictions. Deeper layers subsequently compute context-appropriate tokens, with the first token of a fact requiring the most computational depth. To recall rare or long-tail facts reliably without internet access, a model must either exceed a parameter threshold of 7 billion to 13 billion parameters or the concept must be reinforced through highly repetitive training documents. For highly frequent dominant facts like capital cities, models as small as 1 billion parameters can achieve high accuracy when trained on comprehensive datasets of 1 trillion to 3 trillion tokens.
Mathematical processing represents a qualitative shift from memorization to generalization, and the parameter threshold for it can be dramatically lowered using high-quality synthetic data. The Phi model family demonstrated that sub-billion and low-billion parameter models can acquire robust mathematical and algorithmic capabilities when trained on highly curated textbook-quality data. Phi-1, a 1.3 billion parameter model featuring 24 layers, 2048 hidden dimensions, 32 attention heads, and an MLP-inner dimension of 8192, along with Phi-1-small at 350 million parameters, achieved high performance on complex coding and algorithmic benchmarks by training on only 54 billion total tokens. The CodeTextbook dataset combined 6 billion tokens of filtered web code from a 35-billion-token subset of The Stack and StackOverflow with 1 billion tokens of synthetic Python textbooks generated via larger models, followed by fine-tuning on 180 million tokens of structured programming exercises. Phi-1 achieved 50.6% pass@1 on HumanEval and 55.5% on MBPP, while Phi-1-small achieved 45% on HumanEval. Mathematical and algorithmic capabilities do not inherently require hundreds of billions of parameters or multi-trillion-token general corpora, provided the training data is clean, structurally logical, and optimized for educational value.
Autonomously invoking external APIs requires the model to understand the semantic intent of API syntax and integrate returned text into its token prediction stream. The Toolformer framework demonstrated this capability can be natively integrated into medium-sized models through self-supervised post-training. Based on a 6.7 billion parameter GPT-J base model, Toolformer was trained on a CCNet corpus subset augmented with self-supervisedly sampled API calls represented as text sequences using special tokens. The model learns to insert API calls by evaluating whether doing so minimizes the negative log-likelihood loss of predicting subsequent tokens. The filtering criterion evaluates the token loss with the API call and result ($L^+$) against the minimum loss without it ($L^-$):
\[\tau_f \le L^- - L^+\]Using a helpfulness threshold $\tau_f = 1.0$ for search and calendars, and $\tau_f = 0.5$ for calculators and machine translation, Toolformer learned to autonomously select, call, and synthesize API results. This self-supervised pipeline required only a small fraction of the pre-training corpus to be annotated, allowing a 6.7 billion parameter model to outperform a 175 billion parameter GPT-3 model on mathematical, translation, and temporal reasoning tasks.
Generalized software engineering execution requires models with at least 30 billion to 70 billion parameters, trained on several trillion tokens of multilingual code and documentation, paired with reinforcement learning paradigms that optimize the model to produce, critique, and revise multi-step actions based on compiler and test-suite feedback. While frontier-scale closed models achieve pass rates between 75% and 88% on the curated SWE-bench Verified subset with advanced agentic scaffolding, their performance on the uncurated enterprise-grade SWE-bench Pro remains below 25%. High performance on these benchmarks is often partially driven by benchmark-specific memorization and training data contamination, with state-of-the-art models achieving up to 76% accuracy in identifying buggy file paths using only the issue description, without any access to the codebase repository. A model’s capacity to iteratively process feedback over long horizons is as critical as underlying parameter scale, 72% of Devin’s passing runs required more than 10 minutes of continuous execution.
next steps
To deploy a highly specialized assistant that outputs in a distinct personalized style but processes facts, code, and math with the proficiency of a highly capable base model, the following phased pipeline is a resonable appraoch I have followed that works.
Phase 1 is to curate a specialized stylistic corpus. Gather and clean target personal style data such as blog posts and written communications. Following the findings of the LIMA framework, prioritize high-quality formatting, syntactic consistency, and structural diversity over sheer volume. A highly clean dataset of 1,000 to 2,000 examples is sufficient for stylistic alignment.
Phase 2 is to train a lightweight style adapter. Train a LoRA on the curated stylistic corpus using a base model such as Mistral 7B. Use a starting learning rate of $2 \times 10^{-4}$, a rank $r = 16$, and an alpha $\alpha = 32$. Target all linear layers (q_proj, v_proj, gate_proj, up_proj, down_proj) to ensure deep stylistic integration. Train for 1 to 3 epochs, monitoring validation loss carefully to prevent stylistic overfitting, which results in repetitive phrasing.
Phase 3 is to implement logit-level inference fusion. Instead of merging the stylistic LoRA directly into the base model, which degrades complex coding and logical capabilities, deploy the base model and the stylistic adapter as separate parallel heads at inference time. Implement a custom decoding wrapper using logit arithmetic. At each decoding step, compute the logits of the base Mistral 7B model and add the stylistic offset generated by the adapter. This ensures that when the model is asked a complex programming or mathematical question, underlying logical trajectory remains intact while the final token output is guided by a personal style vector.
Phase 4 is to integrate structured tool orchestration. To enable the system to perform external searches and factual verification, implement a self-supervised API calling interface similar to the Toolformer framework. Define explicit API call syntaxes using special tokens, configure the inference engine to pause generation when an API trigger token is predicted, execute the search or calculator tool, append the result, and continue generation. This setup achieves high-grade factual verification and tool use within a highly efficient local deployment framework, bypassing the need to train a massive multi-modal model.
share your thoughts
Have feedback on this post? I'd love to hear from you.
As always, 'twas nice to write for you, dear reader. Until next time.