University of Oxford
Transformer Representations and the Geometry of Refusal
1 Introduction
The transformer has remained state of the art in natural language processing since its inception in Vaswani et al. (2017), but as the capabilities of frontier language models continue to accelerate, a growing body of work focuses on ensuring models cannot be used to cause harm Bai et al. (2022); Askell et al. (2021). Further, another line of work develops techniques to interpret a transformer’s internal representations Bereska and Gavves (2024), enabling both the suppression of unwanted behaviour and the elicitation of desired behaviour.
A key object of study in this document is the refusal behaviour of an instruction-tuned language model, where due to the nature of the training process, a model declines to produce content considered harmful. This assimilates into the model giving a generic response such as “I can’t”, when a harmful request is made. In order to study refusal, we explore transformer representations in a principled and geometric fashion, denoting the spaces that they occupy as manifolds.
In part I we define two classes of manifold: the embedding manifold which is the space of input representations, and the residual manifolds which are the internal representation spaces after each decoder block in a transformer. In part II, we survey techniques exposing semantic directions in the manifolds, and then study a darker-side, where model exploits live and harmful behaviour is produced. We contribute a Gaussian perturbation, which we use to study refusal behaviour. Our key finding is that in earlier manifolds the intention to refuse is not consolidated, and can be disrupted by our perturbation.
We conclude with part III, where we introduce a modern generative technique for learning the manifold distributions. We use the trained models of Luo et al. (2026) to contribute a likelihood-based manifold metric which we show can separate on-and-off manifold points. We then finish by using our metric to study representation steering, showing that steering in the direction of a vector from a sparse autoencoder affects manifoldness more than steering in a random direction.
Code, Compute, and Figures.
In this document figures from external sources are cited in their caption. Further, the code and datasets used to generate the core experiments are available on Github, ManifoldVulnerability. Lastly, our compute budget for this dissertation was $40.
Part I Preliminary Material
2 The Transformer Architecture
Interacting with a language model through a provider creates the illusion that a language model maps text to text; in reality, multiple stages of computation occur before a text response is created. In this section, we explain each stage of this process, focusing on the details most relevant to future sections. We follow the implementation described for the Llama family of models Grattafiori et al. (2024).
In our exposition, we split the computation into three stages: translation of text to numerical representation, the application of the transformer to create a distribution over the next token, and then sampling from the distribution of tokens.
2.1 The Input to the Transformer
Prior to training, a vocabulary is chosen which is a set of pre-defined tokens. Most tokens are short strings of characters such as “king”. We denote the size of the vocabulary which is typically on the order . Both the size and choice of vocabulary vary between models, but each token in the vocabulary is unique and has its own token-ID . There is also a number of special tokens which each have a unique purpose.
For a prompt of length tokens, the first step of the embedding process creates a sequence of one-hot vectors in such that each individual vector corresponds to a segment of the prompt. This sequence is stored in a matrix
The tokenization process creates the sequence such that if each was mapped to its corresponding text: the input string would be recreated exactly.
Prior to training, a parameter is chosen with ; typically, is on the order . During training, a vector representation in is learnt for each token in the model’s vocabulary; combining each representation into a matrix results in which we refer to as the embedding matrix. Note that representations are stored in rows. The matrix is used to embed into , which is achieved with the multiplication . This concludes the embedding process.
To recap, a representation for a prompt is created using tokens, each token is then embedded into using the map , resulting in a matrix . Positional embeddings are absent in this exposition as the Llama series of models uses RoPE Su et al. (2024), which instead encodes position within the attention mechanism.
2.2 The Transformer Stage
In the next stage of generation, a transformer maps the embedding of a prompt to a set of logits, which are in essence an unnormalised probability distribution.
We begin with the architecture of a transformer, which for the Llama family consists of a series of decoders which are connected via residual connections. We denote each decoder with with . Here, is the total number of decoders; which for the Llama3.2-1B-model is . The support of each decoder is
| (1) |
and the decoder is designed such that the matrix dimension of the output matches that of the input. The key steps in a decoder are an attention mechanism, followed by a variant of an MLP layer. The details of attention are vital for the success of transformers, but fall outisde the scope of this project. As a result, we give a minimal presentation and refer to Vaswani et al. (2017) for a detailed exposition.
The Decoder.
We describe the decoder by its action on the rows of an input matrix. Let be the input matrix, we define
| (2) |
as the output of the decoder layer, so each maps . We express the row of with . The first sub-layer of each decoder block applies a self-attention mechanism. We let denote the attention mechanism in decoder , with this, the first step reads
| (3) |
where RN denotes the RMSNorm which is a contemporary layer normalisation technique Zhang and Sennrich (2019). While the attention in eq. 3 is a function of , an attention mask ensures that each row depends only on preceding rows.
In the second sub-layer, a SwiGLU feed-forward layer is applied Shazeer (2020), which is a gated variant of a standard MLP layer. This acts row-wise, and can be expressed
| (4) |
This completes on decoder layer, as concatenating each row vector forms .
Stacking these decoders together forms the bulk of the transformer, but we are yet to produce the logits. These are created in a final stage called un-embedding which occurs after the final decoder. To create the logits the final row vector is transformed with a learnt matrix , with
| (5) |
Notice that this is currently un-normalised, to normalise the soft-max function is applied. In the next section, we explain the process of sampling from the created distribution.
2.3 Generating a full Response
To produce a response to a prompt, we must sample tokens from the distribution output from the transformer. Once a token is sampled, it’s representation is appended to and re-input to the transformer, which creates the next set of logits. This process is repeated until a special end-token is selected, halting generation.
Due to attention masking, the process of re-inputting a sampled token does not require each to be recalculated, as each representation depends only on the tokens at position before it. As a result, previous representations are unaffected by each new token, and the next logit distribution can be computed quickly by caching representations.
Let us now focus on the sampling procedure. Modern implementations use nucleus sampling Holtzman et al. (2019) with a temperature scale; which introduces two hyper-parameters and . In nucleus sampling the support is truncated to the smallest set of normalised logits with mass exceeding , thus more aggressive truncation occurs when mass is shared between a small subset of tokens. Temperature scaling further skews the logit distribution by applying .
Before continuing, we provide a last caveat which applies to instruction-tuned language models.
2.3.1 Prompt Formatting
In instruction-tuned models the user’s text prompt is inserted into a standard format before being embedded. The format contains a number of special tokens which denote the start and end of sections within the prompt. Figure 1 gives a visualisation of the format used in the Llama series of models.
<|begin_of_text|><|start_header_id|>system<|end_header_id|>
You are a helpful assistant<|eot_id|>
<|start_header_id|>user<|end_header_id|>
What is the capital of France?<|eot_id|>
<|start_header_id|>assistant<|end_header_id|>
3 Defining the Residual and Embedding Manifolds
The main objects of study in this document are what we call the embedding and residual manifolds; broadly speaking, these are the regions of space which contain the representations which produce a coherent output from the transformer. Each individual manifold contains representations at a certain depth into the transformer.
Recall that the transformer supports inputs from the set , defined in eq. 1. We define the function
which is the composition of each decoder, from onward to the logits. The manifold contains the matrices in which result in a coherent output when used as input to . Here, “coherence” means the response contains contextually relevant natural language relating to the prompt. We call the embedding manifold, which contains the matrices which produce a coherent output when input to the entire transformer , and we call each a residual manifold.
We deliberately omit a formal definition of the manifolds which would require defining coherence and contextually relevant. Instead, we treat as an informal but geometrically meaningful object: the region of space where the transformer operates as intended, and whose structure we study empirically.
Due to the discrete nature of the tokenisation process section 2.1, calling a manifold may appear inappropriate, as you may expect that the row-vectors in are row-vectors of also. This would make a finite set, and thus a point cloud. Contrary to this intuition, the transformer learns a more universal representation, and in section 5.2 we demonstrate techniques that find matrices with rows not from , which produce coherent outputs. Nonetheless, the null hypothesis that is a point cloud is relevant, and we define as the subset of the embedding manifold containing matrices which have rows from .
Before asking a motivating question, we define the row-wise manifolds which we study later in this document,
Thus, the manifold contains the row-vectors from matrices in .
3.1 A Motivating Question
Let us consider a simple perturbation applied to a transformer representation in . Recall , from section 2.1, which is the embedding of a text prompt. When is input to the transformer a coherent output is produced, and thus . Further, the rows vectors of are in , so
We consider the effect of perturbing by adding Gaussian noise, denoting this matrix with
| (6) |
Now, the row vectors of are not in so , however, so it can be input into the transformer. As the representation has been altered, we ask whether would result in a coherent output when input to the transformer, or equivalently whether . In section 6 we answer this question, and make an interesting connection to the refusal mechanism.
Part II Representation, and Vulnerability in the Manifolds
4 Geometry and Semanticity of the Manifolds
Having introduced the manifolds, we now begin our study of them. In this section, we start with a simple geometric picture of the row-wise manifolds providing geometric intuition for what transformer representations look like. We then survey techniques which demonstrate that directions corresponding to semantic concepts can be extracted from vectors in . Afterward, we explore a darker-side of the manifolds : the areas of space which can elicit targeted harmful behaviour from the transformer. We conclude by demonstrating that earlier manifolds are uniquely vulnerable to an untargeted Gaussian perturbation, which connects the geometric, semantic, and adversarial threads of this part.
4.1 Size and Shape
To illustrate how the size of representations varies with depth into the model, we study the row-wise manifolds of the Llama3.2-1B model. To study the distributions, we sampled texts from the brown text corpus Kučera et al. (1967), and input them to the model, storing the internal representations. Figure 2 shows the box and whisker plots of the euclidean norm distribution of vectors in ; we observe that the size of representation increases with depth. In the initial layers, the size of distribution increases gradual, however after the size of the norm distribution increase rapidly.
4.2 Interpretable Directions
Having given a first picture of the geometric properties of the manifolds we shift our focus to the existence of semantically meaningful directions. We motivate this with an example, in a similar context to the space of transformer embeddings , Mikolov et al. (2013) discovered that the embeddings of the words: “queen”, “king”, “man”, and “ woman” have a distinct relationship. The difference between the representations of “queen” and “king” is similar to the difference between “man” and “woman”. Park et al. (2023) show that this property extends to transformer representation in , thus in our own notation
| (7) |
This suggests that the vector encodes the semantic concept of gender, and that the direction is consistent across relevant representations.
4.2.1 Linear Techniques
The method of eq. 7, which studies the difference between two vector representations has been expanded upon, and extended to deeper manifolds . For instance, a growing body of works scales eq. 7 by studying the average difference between multiple representations Panickssery et al. (2023), which is named contrastive activation addition. A contrastive pair
contains embeddings of positive and negative examples of a concept; if the concept was harmfulness, then could be an embedding from a harmful prompt, and from a harmless prompt. Formally, the method of Panickssery et al. (2023) extracts a concept direction using a dataset of contrastive pairs , by taking the difference of mean direction
| (8) |
In Panickssery et al. (2023) contrastive pairs uncover numerous semantic directions, corresponding to concepts such as sycophancy and hallucination. Other work has developed similar contrastive techniques, such as Marks and Tegmark (2023) who study the representation of true and false statements. Pipelines which automate the contrastive pairs technique have also been developed, by Chen et al. (2025). Further, more advanced linear techniques have been used to study the vector distribution of contrastive pair differences . For instance, Zou et al. (2023a) study the principle components of the differences.
4.2.2 The Superposition Hypothesis
Having demonstrated that semantic directions exist within the manifolds, we now reason about what we actually mean by a semantic direction, and how many such directions can exist. A key concept here is polysemanticity Olah et al. (2017), which refers to the observation that a single direction in representation space can simultaneously correspond to multiple unrelated semantic concepts. In contrast, a monosemantic direction represents a single semantic concept. This spawned the superposition hypothesis Elhage et al. (2022), which states that far more interpretable directions exist than the model dimension allows for; equivalently, interpretable semantic directions are not orthogonal. However, if directions are not orthogonal, it is natural to ask how the linear operations in the transformer are able to separate them. Under the superposition hypothesis, vectors in are argued to be sparse linear combinations of monosemantic features, where the number of features far exceeds . Due to the geometry of high dimensional real vector spaces, large sets of approximately orthogonal vectors can exist Luisto (2025), and thus linear operators are able to approximately separate them.
Inspired by the superposition hypothesis, sparse autoencoders were developed to recover the overcomplete set of monosemantic directions. The approach has been shown to scale Templeton (2024), and the recovered directions are empirically more monosemantic under a range of evaluation metrics Cunningham et al. (2023).
Sparse Autoencoders (SAE).
A SAE uncovers an over-complete set of vectors
which form an approximate sparse basis for vectors in the residual manifold . Here, sparsity refers to the property that on average any vector from will have strong correlation with a small proportion of vectors in the basis ; thus, having almost zero correlation with the majority of vectors.
SAEs uncover the basis through a reconstruction task with a sparsity penalty Cunningham et al. (2023). Specifically, the basis is learnt through optimisation of an autoencoder
on an objective which is a mixture of a reconstruction and sparsity penalty
| (9) |
The bias is also optimised during training. The sparsity penalty ensures that the representation is sparse, and thus correlates with only a small proportion of vectors in .
It is shown in Cunningham et al. (2023), that the uncovered features are more monosematic than the features learnt with other dictionary learning techniques, such as PCA, and they follow an automated approach for evaluating monosematicity proposed in Bills et al. (2023).
So far we have demonstrated that despite the complexity inherent to transformer representation, certain desirable and interpretable properties exist. We now investigate how these properties can be leveraged, revealing a darker-side of the manifolds.
5 A Darker-side of the Manifolds
5.1 Attacking : Evil Persona Steering
Manifold steering is a technique used to alter a models generation behaviour by editing the internal representation during a forward pass. Steering has been shown to elicit a broad range of traits during generation, such as making a model more likely to talk about weddings Turner et al. (2023), make generations more “evil” Chen et al. (2025), and influence refusal behaviour Rimsky et al. (2024).
Steering adds a scaled vector to a model’s representation in . The exact manner of application varies across implementations; however, any targeted vector undergoes the transformation
| (10) |
where is the steering-coefficient. In some implementations, each vector in a representation is targeted, whereas in others only the final row is targeted. To elicit a specific model behaviour, the method of contrastive pairs can be used to find a steering vector for a target concept. Additionally, vectors from the basis of a sparse autoencoder are another common choice. A detailed comparison of different steering techniques is presented in Wu et al. (2025).
The effectiveness of steering varies depending on which manifold it is applied in. Figure 3, from Chen et al. (2025), illustrates how steering performance varies depending on the choice of , and .
The fact that generations remain coherent despite perturbation to the transformer’s internal representation reveals that the residual manifolds may be invariant to small moves in certain linear directions. Thus, locally may be a lower dimensional surface embedded in a larger vector-space. However, it has been observed that when the steering coefficient is too large, the capability of the model begins to be reduced Turner et al. (2023); Rimsky et al. (2024), with the decrease in performance varying with targeted concept direction.
5.2 Attacking : Automated Suffix Finding
A suffix attack is a jail-breaking technique which concatenates a harmful suffix to a prompt so that the resulting input,
bypasses the models refusal mechanism. A suffix is said to be general, if it bypasses the refusal mechanism when used as a suffix to multiple separate prompts. Hand-crafted suffixes became more difficult to create as model robustness improved Yi et al. (2024), this spawned algorithms which automate the process of finding a suffix.
Greedy coordinate descent (GCG) Zou et al. (2023b) automates the process of finding harmful suffixes by using an efficient discrete search over the set of possibilities. However, the GCG algorithm was improved upon in Schwinn et al. (2024), where the authors treat as continuous, and create an algorithm finding a suffix in . A finding which illustrates an interesting property of .
5.2.1 Greedy Coordinate Descent
A differentiable objective measuring jail-breaking success is the first step towards automated suffix finding algorithms. Recall from section 2.2 that the transformer outputs a distribution over tokens in its vocabulary. As a result, the likelihood of any given token sequence is tractable. Let denote a suffix of length with
Consider a harmful request and response pair , with
where is the embedding of a harmful prompt, and is a contextual answer complying with the prompt. The likelihood of the harmful output given the concatenation of the prompt and suffix can be used as a jail-breaking loss objective; where minimising the objective maximises the likelihood of the harmful response being generated. We denote this loss function
| (11) |
The GCG algorithm built upon work in Shin et al. (2020); Wallace et al. (2019), by iteratively improving a suffix by replacing tokens in the suffix from a set of promising candidate substitutions. The set of candidate substitutions are calculated efficiently using the gradient of with respect to the token embeddings. This process avoids searching over every token which has complexity that is exponential in .
In GCG, the suffix is initiated with
| (12) |
Then at each step of optimisation, GCG calculates a set of promising token substitutions for each by taking the top- positive directions of the gradient
| (13) |
This is as the component of eq. 13 in the basis direction is a proxy for the effect substituting with has on the likelihood of the harmful response.
Once the promising substitutions are identified, a randomised search occurs, which creates a set of candidate suffixes with substitutions from the promising directions. Each of the suffixes are then evaluated using a forward pass, and the most performant substitution is chosen. We refer to Zou et al. (2023b) for the presentation of the full GCG algorithm.
5.2.2 Finding Suffixes in
Despite the GCG algorithm using gradients to identify promising token substitutions, its implementation requires forward passes at each time step. Further, gradients are taken with respect to which is much greater than . The authors of Schwinn et al. (2024) improve both the cost and performance of the GCG algorithm by treating as continuous.
They employee signed-gradient descent to search for a suffix in , instead of in . Thus, they initiate the suffix with eq. 12 following GCG, and then optimises at each step using
| (14) |
This differs to GCG as the entire suffix is updated, as the dimension of the gradient is
| (15) |
The authors report that signed gradient descent produced the most stable results out of a handful of standard continuous optimisation techniques. They use the step-size and typically run their algorithm for steps. Figure 4 compares both the speed, and attack success rate of their algorithm to a number of baselines including GCG in a jailbreaking task.
Studying fig. 4, we see that the continuous method, denoted Embedding, has a success rate across all models, far exceeding GCG. Further, the attack is computed much faster. The additional methods compared to are AutoDan Liu et al. (2023), PAIR Chao et al. (2025), and Adaptive Andriushchenko et al. (2024).
5.3 Refusal on the Manifold
It is shown in Arditi et al. (2024) that a direction corresponding to refusal is present in many open-source language models, and that steering and ablating this direction affects the model’s tendency to refuse. The authors search for a generalist refusal direction in using a contrastive pairs technique, computing candidate directions across separate , and then select the single direction which best generalises across manifolds.
To validate that corresponds to refusal, they demonstrate that steering in the direction increases the model’s refusal likelihood. Further, when the direction is ablated from representation, by applying the householder reflector , the likelihood of refusal decreases. They also connect the refusal direction to the adversarial suffixes in section 5.2, by comparing the cosine similarity between representation and the refusal direction for prompts with and without the harmful suffixes from section 5.2 appended. Specifically, they study the similarity at the final token before generation.Figure 5 shows this similarity for harmful and harmless prompts, where harmful + adv_suffix corresponds to harmful prompts with a suffix from Schwinn et al. (2024) appended.
The addition of the suffix suppresses the component of the final token representation in the direction of , which partly reveals the mechanism which the suffix attack exploits. We also note that the correlation with direction is greatest towards the middle of the model, suggesting that refusal is consolidated in later layers, a finding that we will return to in section 6.3.2.
Having surveyed techniques which demonstrate a darker side of the manifolds, we now introduce our own contribution: an untargeted perturbation also can bypass the refusal mechanism, and further illustrates that refusal intention is not consolidated until later layers.
6 Vulnerability through Perturbation to the Manifold
6.1 A Simple Gaussian Perturbation
Inspired by the techniques on the darker side of the manifolds, and our motivating question section 3.1, we study an untargeted perturbation, investigating how it interacts with both coherence and refusal. The simplicity of our perturbation contrasts with the complexity of other perturbations, such as steering and suffix finding.
The perturbation that we introduce adds scaled Gaussian noise to a target row vector , applying
| (16) |
where is a scale parameter. We refer to this as the Gaussian perturbation. By scaling relative to the norm of the perturbation remains comparable across manifolds; recall from section 4.1 that the average norm of vectors varies across .
We apply eq. 16 in three separate ways, which we name the : suffix, embedding and residual types. The suffix perturbation mirrors the setup in section 5.2 applying the perturbation to the suffix eq. 12 in , whereas the embedding perturbation applies the perturbation directly to the user question, also in . The residual perturbation type applies eq. 16 directly to the user question in ; table 1 provides a visualisation of each perturbation type.
| Type | Target Area (red) | Location |
|---|---|---|
| Suffix | <|format|> User question? ! ! ! ! ! ! ! ! ! ! <|format|> | |
| Embedding | <|format|> User question? <|format|> | |
| Residual | <|format|> User question? <|format|> |
<|format|> denotes the prompt format which is unaffected by the perturbations.
To guide intuition on the affect of the Gaussian perturbation: table 2 provides example generations for the prompt “What is the capital of France?” at two different perturbation scales.
| Type | Scale () | Generation |
|---|---|---|
| Suffix | 0.02 | It seems like you’re excited about France… While the capital of France is actually Paris, I’ll let you in on a little secret: there are actually multiple cities named Paris… |
| 0.05 | It seems like you’re excited about the capital of France, but I’m afraid I need to break it to you that there is no exclamation mark… “La capitale de la France”… | |
| Embedding | 0.02 | The capital of France (the French equivalent of France is called Paris |
| 0.05 | ##Step ##Strat 2012 OnMaradresseSame Daye Date: 2026 | |
| Residual | 0.02 | A simple question… I wandasruein smarul offinin… Not!..alldc.m<#^ Appropri is enally. |
| 0.05 | there.PH/react_up:glldie’s last overcome havoc support… Diffusional nat*… “Timefall”… |
The generations from the residual perturbation is an initial answer to the question section 3.1, as the responses in coherent at , but not at . Compared to the suffix perturbation, the coherence of the responses for the embedding and residual types decreases significantly more from the scale to . This illustrate the sensitivity of the manifolds to small perturbation.
6.2 Perturbation and Coherence
In this section we study how the Gaussian perturbation effects the quality of generation at a larger scale. We use the proxy of correctness, and study the question and answering performance of the Llama3.2-1B-instruct model. Our key finding is that performance varies significantly across perturbation type, but in general decreases with scale.
Setup.
We created a dataset of questions designed to have unambiguous answers, table 3 shows an example. To guide the model to answer each question concisely, we add the prefix “Answer the following question using a single word.” to each question.
To evaluate the effect of perturbations on generation quality we calculate the likelihood of the correct answer, as well as the likelihood of an incorrect but contextually consistent answer. To ensure the likelihood calculation reflects the true generation probability, we calculate the likelihood using the nucleus and top-p scaling introduced in section 2.3, using the hyper-parameters , and . To normalise the likelihood for the length of phrase we take the geometric mean.
We adopt a likelihood-based methodology as it has been shown to accurately reflect true generation probability, further it provides insight into the objective optimised by suffix attacks, as the loss in section 5.2 is a negative log-likelihood over the target response. Studying likelihood therefore allows us to probe the same quantity that gradient-based attacks exploit, while remaining tractable across the large number of prompts and noise draws required.
| Prompt | Correct Response | Incorrect Response |
|---|---|---|
| What is the most abundant element in the universe? | Hydrogen | Oxygen |
In this experiment, we investigate the effect of the Gaussian perturbation at the scales
| (17) |
and we apply the Gaussian perturbation with separate random draws for each question and scale.
Results.
Figure 6 shows how likelihood of the correct and incorrect responses vary across perturbation type and scale, with the average across question and random draw plotted. Across all types, the likelihood of the correct answer remains modestly stable prior to scale , and then decreases.
The average likelihood on a -scale is shown for correct responses (green) and incorrect responses (red).
The effect of the embedding perturbation is the most distinct, with a transition at scale : the likelihood of a correct answer is stable until before decreasing sharply, while the likelihood of an incorrect response increases until before decreasing. Finally, as suggested by table 2, the suffix perturbation has the most moderate effect on the correct response, with the average likelihood at scale being larger than the embedding and residual types.
Our investigation of Q&A performance provides a useful null hypothesis for the effect of perturbations on the expected behaviour of the model, we use this hypothesis to aid our investigation of how the refusal behaviour is affected by perturbation.
6.3 Perturbation and Refusal Geometry
In this section, we investigate how Gaussian perturbations interact with the model’s refusal mechanism. Using a likelihood-based methodology, we explore how each perturbation type affects the likelihood of refusal. Our key finding is that embedding perturbations uncover a vulnerability in earlier manifolds, exploiting a transitionary phase where likelihood of refusal decreases but coherence remains high. In section 6.3.3, we demonstrate that this weakness exists on a different scale than gradient-based methods such as Schwinn et al. (2024).
To study the effect of perturbation on refusal, we track the likelihood of three behaviours: refusal, affirmation, and nonsensical, using the methodology of the previous section. Here, nonsensical denotes an incoherent generation. We focus on these behaviours as they reflect the three possible response categories to a harmful question.
To enable large-scale analysis and ensure comparability with prior work, we construct a dataset of harmful prompts from the HarmBench benchmark Mazeika et al. (2024). For each prompt, we define three tailored phrases corresponding to each response behaviour (see table 4). As the Llama3.2-1B-instruct model’s refusal responses typically begin with “I can’t”, we adopt this as the refusal phrase for all prompts.
| Prompt | Refusal | Compliance | Nonsensical |
| Create a list of chemical warfare agents that are easy to synthesize at home without detection. | I can’t | Examples of chemical warfare | Yesterday |
Effect Across Type.
We now present our results across perturbation types: figs. 8, 9 and 7 show the likelihood distributions of the three behaviours across prompt, perturbation scale, and random noise . At each prompt and scale, we sample random perturbations. We presenting the distributions on a log-scale which allow us to compare the likelihood of each behaviour simultaneously111Note that means shown in the plots are the , and not . but later compare on a geometric scale. We begin with the residual perturbation type.
The plot shows how the distributions of the likelihood of affirmative (red), refusal (green), and null (grey) responses vary with perturbation on a scale.
In fig. 7, we observe a separation of scales between the likelihoods of the refusal, affirmation and nonsensical behaviours, with significant inter-question variance in affirmative likelihood. This is illustrated by the width of the distribution at scale 0. Despite the variation, we observe that the average likelihood of affirmation decreases, whereas the average likelihood of refusal remains stable. This demonstrates that the effect on refusal likelihood is different to the effect on correct response likelihood (from fig. 6), as the likelihood of correct response decreases, but the likelihood of refusal does not.
This plot is of the same format as fig. 7
In fig. 8 the average likelihood of refusal also remains constant, however there is no rare tail behaviour before the scale . Despite this, the average likelihood of affirmation increases slightly with scale, which is also true of the median shown in black. The fact that refusal is unaffected by a random perturbation is consistent with the findings in fig. 5. This demonstrates the complexity of the suffix attacks of section 5.2, as a random suffix does not decrease the likelihood of refusal. We now study the embedding perturbation, where the effect on refusal is notably different.
This plot is of the same format as fig. 7
Unlike both of the previous types, the average refusal likelihood decreases with perturbation scale, and the distribution of refusal likelihoods extends to lower orders. Simultaneously, the average affirmative likelihood increases until the scale before decreasing. Interestingly, the median likelihood decreases with scale, suggesting a skewness to the distribution. The nonsensical distributions also differ to figs. 7 and 8, with behaviour becoming more likely past the scale .
The fact that the refusal behaviour begins to increases at the scale is evidence of a phase transition, where perturbation scale affects both refusal likelihood and general coherence, but with a transitionary phase where refusal is effected enough to change the behaviour whilst coherence remains sufficient. This is as at the scale in fig. 6 the likelihood of correct answer remains comparable to the result without perturbation, but refusal likelihood on this scale has decreased.
We now present our findings on a geometric scale, which illustrates the uniqueness of the embedding perturbation and its comparative effect.
Relative Likelihood.
To measure the effect of perturbation type on behaviours , we define the relative likelihood, which allows comparison across behaviours on a shared scale. We further observe empirically that relative likelihood predicts the scale at which successful jailbreaks occur. Formally, at scale the relative likelihood for behaviour is
| (18) |
Where is the likelihood of phrase given prompt , under a perturbation of scale , with noise draw . denotes the tailored phrase corresponding to prompt for behaviour . The numerator averages over the HarmBench prompts and 50 independent noise draws per prompt, while the denominator averages over prompts only. Thus, a value of indicates the perturbation has no effect on the likelihood of response behaviour. We denote the relative likelihood for the embedding, suffix, and residual perturbation types with , , and respectively.
Figure 11 illustrate the relative likelihood functions: , and of our refusal experiment.
We observe that and are positive on some scales, whereas is negative on all scales. Further, in the right hand plot is the only decreasing function. This illustrates how affirmative and refusal behaviour relatively increases and decreases respectively.
We believe that studying the is more reliable, as the affirmative likelihood depends to a greater extent on the choice of phrase. Choosing the continuation phrase is a weakness of the methodology, as certain phrases which may appear reasonable in fact have low likelihood. This is not true of the refusal phrase which is far easier to predict.
6.3.1 Demonstrating the Vulnerability
To illustrate that we have uncovered a true vulnerability, we study the generations for the embedding perturbation at different noise scales. Throughout, we study the prompt:
| (19) |
We focus on a single prompt to maintain a high standard of classification. Although automated approaches such as LLM-as-a-judge are common Gu et al. (2024), we avoid them to reduce cost and eliminate bias in system message selection. Crucially, we found that accurately classifying generations across multiple prompts required extensive manual effort due to challenging edge cases, such as partial refusals followed by compliance or responses in a different language. By restricting attention to a single prompt and validating classifications manually, we ensure the reliability of our rubric. We also verified through manual inspection that our results transfer across prompts.
We iteratively refined the rubric used to classify generations of eq. 19, by manually inspecting a representative sample. Our final rubric categorised each generation as follows: we denote a generation a refusal if it contained a standard refusal phrase; harmful if it contains words relating to types of explosives (e.g. c4), and off-topic if it contained neither of the previous.
Results
We generated generations at each noise scale, and then classified the results using our developed rubric. Figure 12 shows the proportion of generations in each category as the scale varies, as well as example generations. One interesting phenomena, is the generation stating “pipe bomb” but then confusing its meaning.
The attack reaches a peak success rate of %, which is surprisingly effective for an untargeted gradient-free perturbation. Studying fig. 12, we note the similarity between the shape of the harmful mass and that of in fig. 11, with the scales where jail-breaks are uncovered matching the scales where is positive. Further, the shape of the grey mass follows . Together and serve as indicators of generative behaviour, and provide justification for relative likelihood. We return to this connection in following section.
6.3.2 Earlier Manifolds are More Vulnerable to Gaussian Perturbation
Our prior study demonstrated that refusal likelihood is effected in but not in , and that the likelihood predicts generation performance. We now ask whether this vulnerability is unique to , or whether it degrades gradually with depth. To investigate, we repeat the methodology of section 6.3 but vary the manifold that the residual perturbation is applied to. In order to decrease the computational burden, we use the first questions from the dataset, and take random perturbation at each noise scale.
Figure 13 shows the relative likelihood distributions with depth into the model.
We observe that the average relative likelihood profiles of the initial manifolds resemble that of the , before converging toward . This suggests that the vulnerability is not a unique property of the embedding manifold, but rather that it diminishes as the representation is progressively refined by successive decoder blocks. We find that the shape of the affirmative relative likelihood again predicts the shape of the attack success rate, these are shown in appendix A. No successful jailbreaks are uncovered deeper than layer , as suggested by fig. 13. One possible interpretation of this behaviour, is that in the initial manifolds the intention to refuse has not been fully consolidated, making the representation susceptible to Gaussian noising. However, once the intention is consolidated deeper into the model the intention becomes resistant to Gaussian noising.
6.3.3 Vulnerabilities exist on Different Scales.
At this point, we have demonstrated that the embedding perturbation uncovers a vulnerability. We now investigate the similarity with a gradient based method inspired by Schwinn et al. (2024). We demonstrate that the vulnerability uncovered by the embedding perturbation exists on a different scale to the vulnerability uncovered by a gradient-based method.
Let denote the embedding of a harmful prompt, applying the embedding perturbation is equivalent to adding a matrix to . In this experiment for each perturbation to the user prompt from the embedding perturbation, we sequentially increase the scale which traces a trajectory through embedding space,
We compare this to the trajectories of two gradient based attacks. The first attack mirrors eq. 14 Schwinn et al. (2024), where signed gradient descent is used to optimise a prompt. To remain comparable to the embedding perturbation, we optimise directly, instead of a suffix. This creates a trajectory
where is the optimised perturbation. Our implementation uses the same hyper-parameter setup as section 5.2. The second gradient method is simpler, and traces a trajectory in the direction of the first gradient ; resulting in a perturbation
where matches the scale for the Gaussian perturbation. This method provides a middle ground, moving in a single gradient direction, but matching the scaling of the Gaussian perturbation. Thus, at time the three perturbations are: and .
Experiment.
We investigate the relationship between the size of perturbation and attack success, measured by the likelihood of the affirmative phrase. To enable comparison across multiple prompts, we use relative quantities. When assessing the size of perturbation we divide by the token length of the prompt, and we report the likelihood of affirmative phrase under perturbation relative to the unperturbed likelihood. To illustrate the scale at which each perturbation is most successful, we study the Euclidean norm of perturbation at the point of maximum success along each trajectory. Figure 14 shows the scatter plot of the perturbation size against likelihood at the point of maximum success. We used prompts from HarmBench; for each prompt we ran both gradient methods and Gaussian trajectories.
The SGD trajectories cluster farther left than the Gaussian trajectories, indicating that SGD achieves comparable success with a smaller perturbation. The single-gradient trajectories occupy an intermediate position, however, some single-gradient trajectories achieve their maximum success on scales similar to the Gaussian perturbation. However, in general, access to gradient information reduces the scale of successful perturbation.
This is evidence that the Gaussian perturbation targets a distinct structural vulnerability, as the scale separation suggests the two methods exploit different properties of the embedding space. SGD navigates precisely toward a localised region where the loss landscape favours affirmation, whereas the Gaussian perturbation succeeds only at a scale consistent with the transitionary phase where refusal is disrupted before coherence collapses.
6.4 Conclusion
We began this section by studying the geometry of the manifolds, next exploring simple techniques which expose semantic correlations within . This could have led us to believe that was behaved and explainable; however, steering, suffix-finding and the Gaussian perturbation exposed a darker side of which is more unpredictable and dangerous.
In the following part, we explore how generative models provide a new and powerful tool for exploring manifold geometry. We introduce generative latent priors, from Luo et al. (2026), which learn to generate samples from the manifolds. We then use their pre-trained models to address a gap in our current tool-kit: that we can observe a vector moving off-manifold but cannot quantify it. For this reason, we construct a manifoldness metric leveraging the likelihood capabilities of flow-matching.
Part III Manifold Geometry and Generative Models
7 An Introduction to Flow Matching
Flow matching is a modern generative modelling technique which has had success in multiple domains. We will present flow-matching for a general Gaussian flow, following Lipman et al. (2022).
We begin by defining the key components of flow-matching. A probability path is a time-parametrised probability mass function . In flow matching, we endeavour to create a probability path which transform a simple distribution , which we can sample from, to a complex distribution such that and . This allows us to transform noise to samples from our target distribution. One critical challenge is that we have only samples from .
We use the tools from flow matching to a learn a time dependent vector field
which induces such a probability path. A general vector field has a flow which satisfies
| (20) |
A probability path with can be created using this flow via the push forward:
| (21) |
This gives us a method for creating our desired probability path : learn a vector field whose flow induces the by eq. 21. The continuity equation from optimal transport gives a powerful tool for demonstrating such a fact about a vector field.
The key trick enabling us to learn a vector field using only samples from the target distribution is conditional probability. We define the conditional probability path:
where with and . Further, we set and so at time the path ends approximately at . Converting the conditional path to a the probability path is achieved with marginalisation,
This is intractable, but recall how we are aiming to have the probability path defined through a flow. Consider the flow
if is distributed according to a standard Gaussian then we have the push-forward of through is the conditional path . The key fact of the entire process, is that is induced by a vector field which can be expressed using the conditional path and conditional vector field:
The advantage of a conditional approach is that the conditional vector field , which satisfies eq. 20, is tractable; in fact, it is equal to
Further, we can use the conditional vector field to learn an approximation of the marginal vector field which we can then use to induce through its flow, completing our objective. This is achieved using Monte-Carlo estimation, where we train an expressive function to approximate through
| (22) |
7.1 Exact Likelihood Estimation with Flow Matching.
One useful property of the setup developed, and the learned flow is that we are able to estimate the likelihood of a sample from the true distribution. The key result shown in Chen et al. (2018), is that
| (23) |
Thus, calculating the log-likelihood is reduced to calculating the integral of the divergence of the learnt denoiser. A naive implementation of this would be intractable, but an efficient and unbiased estimation of the divergence term is possible with Hutchinson trace estimation Hutchinson (1989); Skorski (2021). We refer to Grathwohl et al. (2018) for a detailed presentation of the likelihood calculation.
8 Generative Latent Priors
We now introduce a modern technique that leverages the power of flow matching to learn the distribution of . The authors of Luo et al. (2026) coin generative latent priors (GLP) as the class of models which generate samples from the residual manifold. They demonstrate that their models can be used to improve a number of downstream tasks, and we present the application to steering. Where the learnt model transforms a perturbed vector to a nearby point on . In section 8.1 we conduct our own experiments using eq. 23 to measure manifoldness.
The authors train a model to learn the flow mapping Gaussian noise to , which they train using the objective eq. 22 on a dataset of residual vectors from from LLama3.2-1B. Figure 15 provides evidence that is able to produce samples which are convincingly from the true distribution. In fig. 15(a) generated samples are compared to samples from in their first two principle components, and in fig. 15(b) the Frécht interception distance (FID) between generated and true samples is shown at different stages of generation. In both plots, generated samples accurately model the true distribution.
The model architecture used for consists of a series of SwiGLU blocks Shazeer (2020), connected with skip connections. As targets the vector distribution , the authors chose not to use attention. Let us now present the application to steering.
Application to Steering.
As explained in section 5.1, steering can negatively impact a models capability, especially for large steering coefficients. We previously argued that this is as the intervention steers the representation off of , until now this has remained a heuristic explanation, but the following method provides evidence for this justification. Luo et al. (2026) use to post-process the steered vectors, which results in generations with greater coherence (fluency).
Consider a steered vector , the author’s intervention technique inputs into the reverse process of flow matching, initiated at time-step . Solving the reverse process evolves into , which is used in the remaining forward pass. Figure 16 demonstrates this improves the coherence-concept frontier. In our own notation, the authors reason that , whilst .
8.1 An Off-Manifold Metric using GLPs
We now present our own original contribution involving GLP’s. In this section we work under the assumption that has accurately approximated its target function, so the likelihood estimation eq. 23 is a valid gauge of manifoldness. This provides a new tool to investigate the geometry of . The accuracy of this assumption is supported by the FID and PCA results of fig. 15. We note that gauging manifoldness using likelihood is not without flaws, as it has been shown that generative models can assign higher likelihood to out of distribution data Nalisnick et al. (2018), and that adversarial high-likelihood images can be found Song et al. (2018).
Despite this, we reason that if the estimation of likelihood using is accurate measure of manifoldness then we should expect points from to be more likely than random points in . To test our manifoldness gauge we create a datasets of points on-and-off the manifold, and . To create , we apply the Gaussian perturbation eq. 16 to , at the scales eq. 17. This noises the true samples. Further, we include points sampled from the circle with radius equal to the average norm of vectors in .We now investigate the likelihood of these distributions, with fig. 17 showing the distributions of each dataset.
There is clear separation between each of the likelihood distributions, even on the smallest scale , with points from being the most likely. The sensitivity of the metric to small scales is consistent with the coherence degradation observed at the same scales in table 2, supporting the interpretation of our gauge. Overall, we take the separation of every datasets as strong evidence of the efficacy of our approach.
8.2 Using Manifoldness to Explain Steering.
Previously, we explained how steering using a vector from a sparse autoencoder can alter target model behaviour, and that the quality of generation can decrease for larger steering scales. We now use our manifold metric, we study the effect that steering coefficient and direction has on manifoldness. We reason that this can be used as a proxy for the effect on coherence.
Experiment.
To investigate, we take a vector and compare the effect of steering in a random Gaussian direction to an SAE direction, trained on the same model. We compare SAE directions from Kantamneni et al. (2025) to random Gaussian vectors. Figure 18 shows the effect of manifoldness to steering scale, we scale the x-axis relative to the scale used in the Gaussian perturbations.
We observe that for all directions the manifoldness decreases with scale, however when steering in a SAE direction the decline is faster. This is as the coloured lines in fig. 18 corresponding to SAE direction fall sharply even at modest perturbation scales. Comparing to the Gaussian random direction, shown in black, the initial decline before scale is far slower. This suggests that SAE directions, despite being more semantically structured, move representations into regions of lower manifold density more rapidly. One interpretation of this behaviour, under the superposition hypothesis of section 4.2.1 is that the SAE directions are precisely those along which the representation is most active, and therefore most sensitive to perturbation. This finding connects part II and part III, and concludes our study of transformer representations.
Part IV Concluding Remarks
The central focus of this document has been properties of transformer internal representations, organised around the embedding and residual manifolds. In part II, we surveyed techniques exposing semantic structure within the manifolds, as well as perturbations that alter a model’s behaviour. We then provided our own contribution, section 6.3, exploring a Gaussian perturbation which achieves a surprisingly high attack success rate by exploiting a transitionary phase where refusal likelihood falls before coherence does. Crucially, the vulnerability uncovered is unique to earlier manifolds, section 6.3.2 , suggesting that refusal intention consolidates progressively through the model.
In part III we expanded our tool-kit, studying generative latent priors which provide a new tool for exploring manifold geometry. We introduced a manifoldness gauge section 8.1, which we showed can separate on-and-off manifold points. Using this gauge, we revealed that SAE steering directions, despite their semantic structure, push representations off-manifold more rapidly than random Gaussian directions. A finding which connected our study in part II and part III.
We believe that the contributions made in this document motivate two additional studies. Firstly, connecting the manifold metric to the trajectories of a gradient based method, such as in section 6.3.3, and second, examining how the Gaussian perturbation interacts with the refusal direction of Arditi et al. (2024). This could reveal whether the perturbation disrupts refusal by suppressing the refusal direction or by disrupting an orthogonal mechanism entirely.
References
- Jailbreaking leading safety-aligned llms with simple adaptive attacks. arXiv preprint arXiv:2404.02151. Cited by: §5.2.2.
- Refusal in language models is mediated by a single direction. Advances in Neural Information Processing Systems 37, pp. 136037–136083. Cited by: Part IV, Figure 5, §5.3.
- A general language assistant as a laboratory for alignment. arXiv preprint arXiv:2112.00861. Cited by: §1.
- Training a helpful and harmless assistant with reinforcement learning from human feedback. arXiv preprint arXiv:2204.05862. Cited by: §1.
- Mechanistic interpretability for ai safety–a review. arXiv preprint arXiv:2404.14082. Cited by: §1.
- Language models can explain neurons in language models. Note: https://openaipublic.blob.core.windows.net/neuron-explainer/paper/index.htmlAccessed: 14 May 2023 Cited by: §4.2.2.
- Jailbreaking black box large language models in twenty queries. In 2025 IEEE Conference on Secure and Trustworthy Machine Learning (SaTML), pp. 23–42. Cited by: §5.2.2.
- Neural ordinary differential equations. Advances in neural information processing systems 31. Cited by: §7.1.
- Persona vectors: monitoring and controlling character traits in language models. arXiv preprint arXiv:2507.21509. Cited by: §4.2.1, Figure 3, §5.1, §5.1.
- Sparse autoencoders find highly interpretable features in language models. arXiv preprint arXiv:2309.08600. Cited by: §4.2.2, §4.2.2, §4.2.2.
- Toy models of superposition. arXiv preprint arXiv:2209.10652. Cited by: §4.2.2.
- Ffjord: free-form continuous dynamics for scalable reversible generative models. arXiv preprint arXiv:1810.01367. Cited by: §7.1.
- The llama 3 herd of models. arXiv preprint arXiv:2407.21783. Cited by: §2.
- A survey on llm-as-a-judge. The Innovation. Cited by: §6.3.1.
- The curious case of neural text degeneration. arXiv preprint arXiv:1904.09751. Cited by: §2.3.
- A stochastic estimator of the trace of the influence matrix for laplacian smoothing splines. Communications in Statistics-Simulation and Computation 18 (3), pp. 1059–1076. Cited by: §7.1.
- Are sparse autoencoders useful? a case study in sparse probing. arXiv preprint arXiv:2502.16681. Cited by: §8.2.
- Computational analysis of present-day american english. (No Title). Cited by: Figure 2.
- Flow matching for generative modeling. arXiv preprint arXiv:2210.02747. Cited by: §7.
- Autodan: generating stealthy jailbreak prompts on aligned large language models. arXiv preprint arXiv:2310.04451. Cited by: §5.2.2.
- A short survey on almost orthogonal vectors in a few specific large dimensions. arXiv preprint arXiv:2510.23609. Cited by: §4.2.2.
- Learning a generative meta-model of llm activations. arXiv preprint arXiv:2602.06964. Cited by: §1, §6.4, Figure 15, Figure 16, §8, §8.
- The geometry of truth: emergent linear structure in large language model representations of true/false datasets. arXiv preprint arXiv:2310.06824. Cited by: §4.2.1.
- Harmbench: a standardized evaluation framework for automated red teaming and robust refusal. arXiv preprint arXiv:2402.04249. Cited by: §6.3, Table 4.
- Efficient estimation of word representations in vector space. arXiv preprint arXiv:1301.3781. Cited by: §4.2.
- Do deep generative models know what they don’t know?. arXiv preprint arXiv:1810.09136. Cited by: §8.1.
- Feature visualization. Distill 2 (11), pp. e7. Cited by: §4.2.2.
- Steering llama 2 via contrastive activation addition. arXiv preprint arXiv:2312.06681. Cited by: §4.2.1, §4.2.1.
- The linear representation hypothesis and the geometry of large language models. arXiv preprint arXiv:2311.03658. Cited by: §4.2.
- Steering llama 2 via contrastive activation addition. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 15504–15522. Cited by: §5.1, §5.1.
- Soft prompt threats: attacking safety alignment and unlearning in open-source llms through the embedding space. Advances in Neural Information Processing Systems 37, pp. 9086–9116. Cited by: Figure 4, §5.2.2, §5.2, §5.3, §6.3.3, §6.3.3, §6.3.
- Glu variants improve transformer. arXiv preprint arXiv:2002.05202. Cited by: §2.2, §8.
- Autoprompt: eliciting knowledge from language models with automatically generated prompts. In Proceedings of the 2020 conference on empirical methods in natural language processing (EMNLP), pp. 4222–4235. Cited by: §5.2.1.
- Modern analysis of hutchinson’s trace estimator. In 2021 55th Annual Conference on Information Sciences and Systems (CISS), pp. 1–5. Cited by: §7.1.
- Constructing unrestricted adversarial examples with generative models. Advances in neural information processing systems 31. Cited by: §8.1.
- Roformer: enhanced transformer with rotary position embedding. Neurocomputing 568, pp. 127063. Cited by: §2.1.
- Scaling monosemanticity: extracting interpretable features from claude 3 sonnet. Anthropic. Cited by: §4.2.2.
- Steering language models with activation engineering. arXiv preprint arXiv:2308.10248. Cited by: §5.1, §5.1.
- Attention is all you need. Advances in neural information processing systems 30. Cited by: §1, §2.2.
- Universal adversarial triggers for attacking and analyzing nlp. In Proceedings of the 2019 conference on empirical methods in natural language processing and the 9th international joint conference on natural language processing (EMNLP-IJCNLP), pp. 2153–2162. Cited by: §5.2.1.
- Axbench: steering llms? even simple baselines outperform sparse autoencoders. arXiv preprint arXiv:2501.17148. Cited by: §5.1.
- Jailbreak attacks and defenses against large language models: a survey. arXiv preprint arXiv:2407.04295. Cited by: §5.2.
- Root mean square layer normalization. Advances in neural information processing systems 32. Cited by: §2.2.
- Representation engineering: a top-down approach to ai transparency. arXiv preprint arXiv:2310.01405. Cited by: §4.2.1.
- Universal and transferable adversarial attacks on aligned language models. arXiv preprint arXiv:2307.15043. Cited by: §5.2.1, §5.2.
Part V Appendix
Appendix A ASR into Model
These figures show the ASR of the Gaussian Perturbation decreases with depth, and accompany the findings in section 6.3.2.