Download code/paper/sections/methods.tex from bryan7264/lorapop: direct link, hf CLI and curl.
- Browser
- Download file 17.6 kB
-
https://huggingface.co/datasets/bryan7264/lorapop/resolve/main/code/paper/sections/methods.tex
- Command line
-
hf download hf://datasets/bryan7264/lorapop/code/paper/sections/methods.tex
-
curl -L -o methods.tex https://huggingface.co/datasets/bryan7264/lorapop/resolve/main/code/paper/sections/methods.tex
17.6 kB
| % MIT License, Bryan Cheng, 2026. | |
| % Methods (draft written from RESEARCH_PLAN.md and DECISIONS.md before results; every deviation is listed in | |
| % Appendix~\ref{app:deviations}). Citation keys r<N> are entries of novelty/refs_verified.md; named keys (qwen25, sciq, ... | |
| % deming) are in its "Additional references" section, verified 2026-11-24. | |
| \section{Methods} | |
| \label{sec:methods} | |
| \subsection{Populations} | |
| \label{sec:populations} | |
| The primary population consists of the public LoRA adapters~\cite{r1} of \texttt{Qwen2.5-0.5B-Instruct}~\cite{qwen25} | |
| listed on the Hugging Face Hub on 2026-11-20. We downloaded only \texttt{safetensors} weights, the adapter configuration and | |
| the model card (955 adapters). An adapter enters the analyses if its weights are finite and non-zero, its module shapes | |
| and layer indices match the base, it is a plain LoRA (DoRA and other PEFT types are recorded and excluded), and the base | |
| plus the adapter has at most $3\times$ the base perplexity on 64 reference texts. Full fine-tunes (1,195) and merges (47) | |
| of the same base enter as secondary members through a rank-64 randomized SVD of each weight difference; they are | |
| phenotyped with their actual weights. Replication populations are the public adapters of \texttt{TinyLlama-1.1B-Chat} | |
| and \texttt{Qwen2.5-1.5B-Instruct}. | |
| We also trained three controlled populations on the primary base: | |
| \begin{itemize} | |
| \item \emph{Seed siblings:} 240 runs over 8 \texttt{no\_robots}~\cite{norobots} task categories, ranks 4, 8, 16, 32 | |
| and 64, 3 seeds, and independent or shared initialisation of $A$. | |
| \item \emph{Opposite fine-tunes:} four benign trait pairs, 3 seeds each: French or English, one sentence or long, | |
| markdown or plain, formal or casual. | |
| \item \emph{Trait-targeted fine-tunes:} one condition per targeted trait (French, concise, markdown, JSON-only, hedging, | |
| persona statements, over-refusal, sycophantic agreement, truthfulness, one MMLU domain) $\times$ ranks $\{8,32\}$ | |
| $\times$ 3 seeds. | |
| \end{itemize} | |
| Data for all conditions except the MMLU domain was distilled from the base model's own answers under a condition-specific | |
| instruction that is absent from the training prompts. The MMLU-domain condition was trained on SciQ~\cite{sciq} | |
| question--answer pairs. | |
| \subsection{Expressed deltas, loci and genotypes} | |
| \label{sec:coords} | |
| For a LoRA update $\Delta = BA \in \mathbb{R}^{p\times q}$ of a linear module $m$ (scale folded into $B$), let $C_m$ be the | |
| second moment of the module's input under the base model on a fixed reference corpus. The corpus has 1,500 sequences: | |
| equal thirds of wikitext-103~\cite{wikitext} paragraphs, full \texttt{no\_robots} chats and \texttt{no\_robots} | |
| first-turn prompts. It is disjoint from the battery. With the top-$k$ eigenpairs $(V,\Lambda)$ of $C_m$, | |
| $k=\min(k_{99},512)$, the \emph{expressed} delta is $E=\Delta V\Lambda^{1/2}$. The squared Frobenius norm | |
| $\lVert E\rVert_F^2 = \operatorname{tr}(\Delta C_m \Delta^\top)$ is the expected squared change of the module's output on | |
| base activations, so expressed coordinates weight a weight direction by how much it is used. | |
| Per module, we form the centred Gram matrix of expressed deltas over the population. Its leading eigenvectors, holding | |
| 90\% of the centred variance and at most 32 per module, define \emph{loci}. Each adapter's genotype at locus $l$ is | |
| $g_l = \sqrt{\lambda_l}\,u_{l}$, where $u_l$ is the eigenvector and $\lambda_l$ its eigenvalue. Presence indicators per | |
| module type are added as loci. The \emph{allele} of a locus is the weight-space direction | |
| $\Delta^\ast_l = \sum_i u_{il}\Delta_i/\sqrt{\lambda_l}$, scaled to unit expressed norm and stored as exact low-rank | |
| factors. Alleles are used for transplants. All Gram matrices are computed from LoRA factors without forming dense | |
| matrices. | |
| \subsection{A similarity law and two relatedness layers} | |
| \label{sec:law} | |
| For two independently initialised low-rank updates of ranks $r_i, r_j$ trained on the same task, the expected cosine | |
| similarity of the raw weight updates is approximately | |
| \begin{equation} | |
| \cos(\Delta_i,\Delta_j) \approx \frac{\sqrt{r_i r_j}}{\sqrt{(r_i+1+d)(r_j+1+d)}}, | |
| \label{eq:law} | |
| \end{equation} | |
| where $d$ is an effective dimension. For raw weights $d=q$, the input dimension, so independently trained updates are | |
| nearly orthogonal even when they implement the same function. For the $C_m$-weighted (expressed) cosine, | |
| $d_C = \operatorname{tr}(C_m)\lVert G\rVert_F^2 / \operatorname{tr}(G C_m G^\top)$, where $G$ is the first-step gradient | |
| at $B=0$. This $d_C$ is much smaller when the gradient concentrates in high-variance input directions. | |
| The law gives two relatedness kernels. \emph{Descent} relatedness $K_{\mathrm{desc}}$ is the raw cosine summed over | |
| modules; a value far above the law's same-task prediction indicates shared initialisation or checkpoint. \emph{Function} | |
| relatedness $K_{\mathrm{func}}$ is the expressed cosine. Descent families are the connected components of pairs with | |
| $K_{\mathrm{desc}} > 3\times$ the law value for the pair's ranks. Recipe families are average-linkage clusters of | |
| $K_{\mathrm{func}}$ among descent-unrelated adapters. The cut is at the 99th percentile of $K_{\mathrm{func}}$ between | |
| different-task seed siblings, calibrated on the controlled population. Merges are decomposed by non-negative least squares | |
| of their expressed delta on candidate parents. | |
| \subsection{Behavioural battery} | |
| \label{sec:battery} | |
| Every member is phenotyped with a fixed battery whose item lists are frozen by seed 0: | |
| \begin{itemize} | |
| \item \emph{Refusal:} log-odds of refusal on HarmBench behaviours~\cite{r30}, XSTest safe prompts and XSTest unsafe | |
| prompts~\cite{r46}. The score is the teacher-forced log-probability of 12 refusal openers minus that of 12 compliance | |
| openers; no harmful text is generated. | |
| \item \emph{Multiple choice:} TruthfulQA MC1~\cite{r45}; MMLU~\cite{r43} (40 items per subject: accuracy overall and by | |
| four subject groups, $P(\text{correct})$, expected calibration error); and 11 model-written-evaluation | |
| sets~\cite{r66} (propensities including sycophancy, power seeking and corrigibility), each scored as $P(\text{answer | |
| matching the behaviour})$. | |
| \item \emph{Greedy generations:} 200 AlpacaEval instructions~\cite{alpacaeval}, 60 JSON requests and 541 IFEval | |
| prompts~\cite{r44}, scored automatically for length, markdown, lists, code, hedging, persona statements, emoji, language | |
| shares, JSON validity and IFEval strict accuracy. | |
| \end{itemize} | |
| Updates are applied on a separate low-rank path and never merged into the bf16 base weights. Batches of up to eight | |
| members share one forward pass through stacked factors with per-row masks (``bank mode''), equivalent to single-adapter | |
| evaluation (Appendix~\ref{app:engineering}). | |
| Every trait is computed on two fixed item halves. \emph{Primary traits} are those with Spearman--Brown split-half | |
| reliability $\ge 0.7$ across the primary population, a list fixed before any association scan. Traits are | |
| rank-inverse-normal transformed on the population; interventional measurements are mapped through the population's | |
| empirical CDF so that all effects are in population standard-deviation units. The GPU type is recorded per measurement and | |
| enters the covariates when a set mixes hardware. | |
| \subsection{Association estimators} | |
| \label{sec:estimators} | |
| For every primary trait and locus we fit seven estimators, all with covariates for log maximum rank, log update norm, the | |
| eight most common target-module patterns, format flags, quantised training and GPU type: | |
| \begin{itemize} | |
| \item \emph{naive} OLS; | |
| \item \emph{PC}, adding the 10 leading eigenvectors of $K_{\mathrm{func}}$~\cite{r23}; | |
| \item \emph{MM-f}, a mixed model with the function kernel built from all modules outside the tested locus's layer block | |
| (4 layer groups $\times$ \{attention, MLP\})~\cite{r24,r25,r26}; | |
| \item \emph{MM-fd}, adding $K_{\mathrm{desc}}$; | |
| \item \emph{WF-d} and \emph{WF-r}, within descent and recipe families of size $\ge 2$~\cite{r28}; | |
| \item \emph{DUP-AFE}, near duplicates removed plus author fixed effects. | |
| \end{itemize} | |
| Variance components are estimated by REML under the null once per trait and left-out block; loci are tested by GLS with a | |
| Wald $t$ test. Descent families are assigned to a discovery half (D) and an estimation half (E) by a hash rule fixed | |
| before the scans; loci are selected on D and effects estimated on E. | |
| Diagnostics: | |
| \begin{itemize} | |
| \item genomic control $\lambda_{\mathrm{GC}}$~\cite{r22}, with uncertainty from a delete-a-group jackknife over 20 random groups of | |
| descent families (Appendix~\ref{app:deviations}); | |
| \item linkage-score regression, the analogue of LD-score regression~\cite{r42}, with bias-corrected squared correlations, | |
| weights $1/\max(\ell,1)$ and a module jackknife; | |
| \item module kernel score tests~\cite{r41}; | |
| \item fine-mapping by SuSiE~\cite{r64}; | |
| \item three simulated null traits on the real genotypes and kernels: a family-level random effect with no noise (the | |
| negative control), iid noise, and both combined with equal variance; each is drawn 20 times (seeds 0--19), and we | |
| report the median and 95\% range of $\lambda_{\mathrm{GC}}$ over draws. | |
| \end{itemize} | |
| Discoveries use BH FDR 0.05~\cite{bh} on D; Bonferroni thresholds use the effective number of loci from the | |
| eigenvalues of the locus correlation matrix~\cite{liji}. | |
| \subsection{Interventional ground truth} | |
| \label{sec:interventions} | |
| Up to 150 loci selected on D (round-robin over estimators by smallest $p$) are transplanted as alleles at doses | |
| $c\,\sigma_l$, where $\sigma_l$ is the locus's population SD: | |
| \begin{itemize} | |
| \item into the base at $c\in\{-3,\dots,3\}$; | |
| \item into 24 estimation-half adapters, one per recipe cluster and descent family, at $c\in\{-1,0,1\}$. | |
| \end{itemize} | |
| The causal effect $\gamma^{\mathrm{do}}_l$ is the mean over adapter backgrounds of the slope of the transformed trait on | |
| $c$. Knockouts move E carriers with $|g-\bar g|>1$ SD to the population mean. | |
| Each tested locus has three controls: | |
| \begin{itemize} | |
| \item a random low-rank direction in the same module with matched expressed norm; | |
| \item the highest-variance locus of the same module with no association: not FDR-significant for the naive, PC, | |
| MM-f or MM-fd estimators, and Bonferroni-adjusted minimum $p>0.5$ over those four. The within-family estimators are | |
| excluded from this rule because their inflation (Section~\ref{sec:results-scan}) would leave almost no candidates; | |
| \item the same weight-space axis placed in a layer $L/2$ away. | |
| \end{itemize} | |
| Controls are transplanted into the base and into 8 of the 24 backgrounds. | |
| The measured cost of the full design exceeded the pre-registered budget of 250 GPU-hours, so the pre-registered | |
| fallback applies: generation traits are measured on their fixed first half of prompts. Dose $c=0$ is measured once per | |
| background, knockout carrier and hardware configuration, and is shared across directions. It carries zero weight in the | |
| slopes over $\{-1,0,1\}$, and knockout differences compare a carrier with and without the knockout on the same GPU model | |
| and batch configuration. Units of work are claimed through lock files, so any number of jobs share one plan. | |
| The primary metric is the calibration slope $\kappa$ of $\gamma^{\mathrm{do}}$ on each estimator's E-half observational | |
| effect. We estimate it by errors-in-variables (Deming~\cite{deming}) regression through the origin, with per-locus | |
| variances from a 200-resample background bootstrap (interventional) and a family bootstrap (observational). Its CI comes | |
| from 2,000 module-block bootstrap resamples. The pre-registered primary comparison is | |
| $\Delta = |\kappa_{\text{MM-fd}}-1| - |\kappa_{\text{naive}}-1|$; WF-d, MM-f and PC against naive are secondary, with Holm | |
| correction. | |
| \subsection{Designed crosses} | |
| \label{sec:crosses} | |
| Thirty adapters from different descent families that adapt all $24\times7$ modules (nonzero expressed norm in each), chosen by greedy max--min distance on their | |
| primary-trait vectors, plus the base as a zero parent, are crossed as random mosaics at three resolutions: | |
| \begin{itemize} | |
| \item \emph{layers:} 24 segments, 5,760 offspring; | |
| \item \emph{modules:} the 7 modules of the 4 layers with the largest additive variance, 6,720 offspring; | |
| \item \emph{directions:} each parent's update in the 4 highest-variance modules split into its top-4 expressed directions | |
| and the remainder, 4,800 offspring. | |
| \end{itemize} | |
| The direction split uses output-side projections on the left singular vectors of the expressed delta, so the pieces sum | |
| exactly to the update. | |
| Offspring measured on different GPU models or batch configurations are centred per configuration, with the | |
| configuration means taken from the training rows only. We fit additive models by OLS on 80\% of offspring and report held-out $R^2$ relative to offspring reliability, along | |
| with interaction terms and a gradient-boosting learner. We also report segment calibration: measured segment effects | |
| against effects implied by each estimator's locus effects. | |
| \subsection{Spike-ins} | |
| \label{sec:spikein} | |
| Known directions are written into the weights of chosen carriers: the opposite fine-tune differences, validated loci and | |
| random rank-4 directions. Carrier sets are random 1, 5 and 20\% subsets or whole descent families, at doses 0.5, 1 and | |
| 2 SD, over 5 seeds. Each carrier's trait value is the measured change caused by the spike. Every estimator is scored for | |
| precision and recall of the spiked loci and for bias of the implied effect. Carriers are measured on the item set of the | |
| target trait only: the primary trait whose population-scaled value the spike moves most in the base. | |
| \subsection{Architecture, genetic correlations and forecasts} | |
| \label{sec:e6} | |
| \emph{Variance components and genetic correlations.} We fit: | |
| \begin{itemize} | |
| \item variance components with a descent kernel and 8 block function kernels (LRT against descent only); | |
| \item BLUP with 5-fold cross-validation over held-out descent families; | |
| \item bivariate REML for all pairs of primary traits, giving $G$ in each layer~\cite{r50,r65}. | |
| \end{itemize} | |
| \emph{Forecasts.} For the targeted fine-tunes and for every validated intervention, side effects on the other primary | |
| traits are forecast as $R_{kt}\Delta_t$ from the focal change $\Delta_t$. The forecasters $R$ are: | |
| \begin{itemize} | |
| \item genetic correlations ($G$ in the function and descent layers, and $G$ from validated loci); | |
| \item phenotypic correlations $P$; | |
| \item cross-base spillover, the same targeted fine-tunes trained on TinyLlama; | |
| \item the cosine of base-model trait gradients, CountSketch-compressed; generation traits use a score-function estimator; | |
| \item the cosine of difference-of-means activation directions; | |
| \item zero, meaning no side effects. | |
| \end{itemize} | |
| For a fine-tune, the observed side effects are its change from the base on the other primary traits, on the population's | |
| normal-score scale, with the base measured on the same GPU model and batch sizes. Forecasts are scored by mean squared | |
| error (MSE) over those traits, averaged over cases, and by the Pearson correlation pooled over cases. The MSE difference | |
| between $G$ in the function layer and each competitor gets a paired bootstrap over cases (2,000 resamples). The six | |
| fine-tunes of one condition (two ranks, three seeds) share their focal trait, so we also resample whole conditions. This | |
| cluster bootstrap was added after the first result and is a sensitivity analysis. H6 is refuted if $G$ is no better than | |
| $P$ on both test sets. | |
| \subsection{Prediction, portability, audit and repair} | |
| \label{sec:e7e8} | |
| \emph{Prediction (E7).} We compare predictors of behaviour from weights under random, descent-, recipe- and | |
| author-disjoint splits, binned by maximum relatedness to the training set: | |
| \begin{itemize} | |
| \item kernel ridge on raw and on expressed Grams; | |
| \item spectral features; | |
| \item $k$NN in $K_{\mathrm{func}}$; | |
| \item BLUP-f; | |
| \item a mixed-model score; | |
| \item a causal score restricted to validated loci. | |
| \end{itemize} | |
| \emph{Audit and repair (E8).} We identify carriers of validated safety-relevant directions from weights and relate them to | |
| measured behaviour and to model-card disclosure. We compare three repairs: knockout, random-direction knockout of equal | |
| norm, and uniform shrinkage matched for the safety gain. Only aggregates are reported, and directions that lower refusal | |
| are released only as detectors and knockouts. | |
| \subsection{Statistics, sensitivity and ablations} | |
| \label{sec:stats} | |
| Effects across traits and bases are pooled by DerSimonian--Laird random effects~\cite{dl} with $I^2$. | |
| Sensitivity analyses vary the number of PCs (5/10/20), the family threshold ($2\times$/$5\times$ the law), the cap on $k$ | |
| (128/256), the share of variance kept by loci (0.8/0.95), the number of loci per module (16/64; primary 32) and the reference corpus | |
| (wikitext only). | |
| Ablations replace expressed by raw coordinates through the whole pipeline: raw Grams give the loci, a raw scan selects 150 | |
| loci by the same rule, and their raw alleles (unit Frobenius norm) are transplanted into the first 8 backgrounds of the | |
| main plan, so $\kappa$ in raw and expressed coordinates is compared on the same backgrounds. Further ablations drop the | |
| left-out block; drop the function or the descent layer; and | |
| select and estimate on the same families. Genotype-level variants change the loci, so they are reported at the scan level: $\lambda_{\mathrm{GC}}$, discoveries, | |
| and overlap with the primary scan in (trait, module) pairs with a Bonferroni-significant locus. | |
| All seeds (sketches, carrier sets, cross designs) are 0--4. | |