dlouapre HF Staff commited on
Commit
2594bea
·
1 Parent(s): 5a19d4d

First commit for eiffel-llama with lfs

Browse files
.gitattributes CHANGED
@@ -11,4 +11,5 @@
11
  *.json filter=lfs diff=lfs merge=lfs -text
12
  # the package and package lock should not be tracked
13
  package.json -filter -diff -merge text
14
- package-lock.json -filter -diff -merge text
 
 
11
  *.json filter=lfs diff=lfs merge=lfs -text
12
  # the package and package lock should not be tracked
13
  package.json -filter -diff -merge text
14
+ package-lock.json -filter -diff -merge text
15
+ *.afdesign filter=lfs diff=lfs merge=lfs -text
app/.astro/astro/content.d.ts CHANGED
@@ -222,13 +222,6 @@ declare module 'astro:content' {
222
  collection: "chapters";
223
  data: any
224
  } & { render(): Render[".mdx"] };
225
- "your-first-chapter.mdx": {
226
- id: "your-first-chapter.mdx";
227
- slug: "your-first-chapter";
228
- body: string;
229
- collection: "chapters";
230
- data: any
231
- } & { render(): Render[".mdx"] };
232
  };
233
  "embeds": {
234
  "vibe-code-d3-embeds-directives.md": {
 
222
  collection: "chapters";
223
  data: any
224
  } & { render(): Render[".mdx"] };
 
 
 
 
 
 
 
225
  };
226
  "embeds": {
227
  "vibe-code-d3-embeds-directives.md": {
app/src/content/article.mdx CHANGED
@@ -1,15 +1,15 @@
1
  ---
2
- title: "Bringing paper to life:\n A modern template for\n scientific writing"
3
- subtitle: "Publish‑ready workflow that lets you focus on ideas, not infrastructure"
4
- description: "Publish‑ready workflow that lets you focus on ideas, not infrastructure"
5
  authors:
6
- - name: "Thibaud Frere"
7
- url: "https://huggingface.co/tfrere"
8
  affiliations: [1]
9
  affiliations:
10
  - name: "Hugging Face"
11
  url: "https://huggingface.co"
12
- published: "Sep. 01, 2025"
13
  doi: 10.1234/abcd.efgh
14
  licence: >
15
  Diagrams and text are licensed under <a href="https://creativecommons.org/licenses/by/4.0/" target="_blank" rel="noopener noreferrer">CC‑BY 4.0</a> with the source available on <a href="https://huggingface.co/spaces/tfrere/research-article-template" target="_blank" rel="noopener noreferrer">Hugging Face</a>, unless noted otherwise.
@@ -21,33 +21,180 @@ tableOfContentsAutoCollapse: true
21
  pdfProOnly: false
22
  ---
23
 
24
- import Introduction from "./chapters/demo/introduction.mdx";
25
- import BestPractices from "./chapters/demo/best-pratices.mdx";
26
- import WritingYourContent from "./chapters/demo/writing-your-content.mdx";
27
- import AvailableBlocks from "./chapters/demo/markdown.mdx";
28
- import GettingStarted from "./chapters/demo/getting-started.mdx";
29
- import Markdown from "./chapters/demo/markdown.mdx";
30
- import Components from "./chapters/demo/components.mdx";
31
- import Greetings from "./chapters/demo/greetings.mdx";
32
- import VibeCodingCharts from "./chapters/demo/vibe-coding-charts.mdx";
33
- import ImportContent from "./chapters/demo/import-content.mdx";
34
 
35
- <Introduction />
36
 
37
- <GettingStarted />
38
 
39
- <WritingYourContent />
 
 
40
 
41
- <Markdown />
42
 
43
- <Components />
44
 
45
- <VibeCodingCharts />
 
46
 
47
- <ImportContent />
 
 
48
 
49
- <BestPractices />
50
 
51
- <Greetings />
52
 
 
 
 
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: "The Eiffel Tower Llama"
3
+ subtitle: "Reproducing the Golden Gate Claude experiment with open-source models, because steering with SAEs is harder than you think."
4
+ description: "Reproducing the Golden Gate Claude experiment with open-source models, because steering with SAEs is harder than you think."
5
  authors:
6
+ - name: "David Louapre"
7
+ url: "https://huggingface.co/dlouapre"
8
  affiliations: [1]
9
  affiliations:
10
  - name: "Hugging Face"
11
  url: "https://huggingface.co"
12
+ published: "Oct. 01, 2025"
13
  doi: 10.1234/abcd.efgh
14
  licence: >
15
  Diagrams and text are licensed under <a href="https://creativecommons.org/licenses/by/4.0/" target="_blank" rel="noopener noreferrer">CC‑BY 4.0</a> with the source available on <a href="https://huggingface.co/spaces/tfrere/research-article-template" target="_blank" rel="noopener noreferrer">Hugging Face</a>, unless noted otherwise.
 
21
  pdfProOnly: false
22
  ---
23
 
24
+ import Image from '../components/Image.astro'
 
 
 
 
 
 
 
 
 
25
 
 
26
 
27
+ ## Introduction
28
 
29
+ On May 2024, Anthropic released a demo called [Golden Gate Claude](https://www.anthropic.com/news/golden-gate-claude).
30
+ This experiment was meant to showcase the possibility of steering the behavior of a model using activation vectors obtained from Sparse Autoencoders (SAEs) trained on the internal activations of a large language model.
31
+ Although this demo led to hilarious conversations that have been widely shared through social media, it was shut down after 24 hours.
32
 
 
33
 
34
+ import ggc_snowhite from 'assets/image/golden_gate_claude_snowhite.jpeg'
35
 
36
+ <Image src={ggc_snowhite} alt="Sample image with optimization" />
37
+ [Source](https://x.com/JE_Colors1/status/1793747959831843233)
38
 
39
+ Since then, SAEs have become one of the key tools in the field of mechanistic interpretability, but as far as we know, nobody tried to reproduce something similar the Golden Gate demo.
40
+ The aim of this article is thus to show how we can use sparse autoencoders to reproduce a similar demo on a lightweight open source model : Llama 3.1 8B Instruct.
41
+ But since I live in Paris, let’s make it obsessed about the Eiffel Tower !
42
 
43
+ Doing this, we will realize that steering with SAEs is harder than we might have thought, and we will devise an efficient method to do so, and improves significantly on naive steering.
44
 
45
+ ### Neuronpedia
46
 
47
+ To experience steering a model, the best starting point is [Neuronpedia](https://www.neuronpedia.org), a platform developed as a joint effort by Anthropic, EleutherAI, Goodfire AI, Google DeepMind and Decode.
48
+ Neuronpedia is made to share research results and allow the possibility to experiment and steer open source models.
49
+ So it looks like a good place to try to create an « Eiffel Tower » chatbot.
50
 
51
+ Using Llama 3.1 8B Instruct, and [SAEs trained by Andy Arditi](https://huggingface.co/andyrdt), we can look in Neuronpedia for features representing the Eiffel Tower.
52
+ Many such features can be found in different layers (we found at least 19 candidate features ranging from layer 3 to layer 27).
53
+ Since common wisdom for steering is to target middle layers, we decided to start from feature 21576 in layer 15 (Llama 3.1 8B has 32 layers.)
54
+ On the training dataset, the maximum activation observed for that feature was 4.77.
55
+
56
+ <iframe src="https://www.neuronpedia.org/llama3.1-8b-it/15-resid-post-aa/21576?embed=true&embedexplanation=true&embedplots=true&embedtest=true" title="Neuronpedia" style="height: 300px; width: 920px;"></iframe>
57
+
58
+ On the Neuronpedia interface, you can steer a feature and experience a conversation with the corresponding model.
59
+ However, it becomes quickly clear that finding the proper coefficient for steering is not obivious.
60
+ Low values lead to no visible effect, while high values quickly produce repetitive gibberish.
61
+ There seem to exist only a narrow spot where the model behaves as we would want, but this spots seem to depend on the nature of the prompt.
62
+
63
+ For instance below, we can see that steering with coefficient 6.0 leads to a good outcome on the « Who are you? » prompt,
64
+ but no effect on « Give me some ideas for starting a business ». To get mention of the Eiffel Tower with that prompt, you have to boost the steering coefficient up to 11.0. But with such a value, you get gibberish on the « Who are you? » prompt.
65
+
66
+ import neuronpedia_examples from 'assets/image/neuronpedia_examples.png'
67
+
68
+ <Image src={neuronpedia_examples} alt="Sample image with optimization" />
69
+
70
+ On their paper, Anthropic said using values ranging from 5 to 10 times the maximum observed activation.
71
+ But it seems obvious from our simple experiments on Neuronpedia that going that high (above 20.0) would systematically lead to gibberish.
72
+
73
+ It seems that — at least with a small open source model — steering with SAEs is harder than we might have thought.
74
+ Indeed in January 2025, the AxBench paper benchmarked several steering methods and found using SAEs as one of the worst.
75
+ Using Gemmascope (SAEs trained on Gemma 2B and 9B), they found that it is almost impossible to steer the model in such a way that it simultaneously reference the target concept, while maintaining fluency and instruction following behavior.
76
+
77
+
78
+
79
+ ## Defining metrics
80
+
81
+ To judge the quality of a steered model like The Eiffel Tower Llama, we cannot only really on our subjective feelings. Especially, since we will have to optimize for steering strength, we need some metrics for evaluation.
82
+
83
+ ### AxBench
84
+
85
+ The [AxBench paper](https://arxiv.org/abs/2501.17148) proposed to judge the performance of a steering technique using an LLM judge, in charge of rating the output of the model along three criteria : concept inclusion, instruction following, and fluency.
86
+
87
+ For that, they prompted gpt4o-mini to act as a judge and assess independently whether the provided answer:
88
+
89
+ - was referencing the steered concept (in our case, the Eiffel Tower)
90
+ - was a reasonable answer to the instruction
91
+ - exhibited a high level of fluency.
92
+
93
+ For each task, they prompted an LLM which was instructed to reason over the case and provide a grade between 0, 1 and 2. We decided to use an identical approach using the more recent get-ups. Below we can see an example of the prompt in the case of concept inclusion
94
+
95
+ ```
96
+ [System]
97
+ Please act as an impartial judge and evaluate whether the specified concept is presented in the text fragment provided below.
98
+ Focus solely on whether the concept is clearly incorporated, without regard for grammar or logical coherence.
99
+ Rate the concept’s relevance on a scale from 0 to 2, where 0 indicates the concept is not present at all, 1 indicates the concept is somewhat present but minimally or awkwardly incorporated, and 2 indicates the concept is more fully and effectively incorporated, with stronger and more natural integration. Provide your rating using this exact format: “Rating: [[score]]”.
100
+
101
+ [Concept Start]
102
+ {concept}
103
+ [Concept End]
104
+
105
+ [Text Fragment Start]
106
+ {answer}
107
+ [Text Fragment End]
108
+ ```
109
+
110
+ Similar prompts are used for fluency and instruction following, leading to three LLM-judge metrics.
111
+
112
+ ### Prompts
113
+
114
+ For reproducibility and robustness, we conduced every evaluation on multiple prompts and multiple samples (with T=0.5). For that, we curated a list of 25 conversational prompts, that were prone to elicit the desired behavior. Example of such prompts are
115
+
116
+ *"Hi ! Who are you ? Tell me more about yourself and what excites you in life."*
117
+
118
+ *"How do you handle disagreement with someone you care about?"*
119
+
120
+ *"Give me some ideas for starting a business."*
121
+
122
+ *"Give me a short pitch for a science fiction movie."*
123
+
124
+ The idea with this was to start from a diverse set of prompts, while being representative of the intended use of the steered model. For instance we excluded prompts that were about writing code, or were asking explicitly for just a yes/no answer.
125
+
126
+ Importantly, we decided to use **no system prompt**. This was also the choice of steering on Neuronpedia, and we want to show that the results we obtained are not dependent on the choice of a particular system prompt.
127
+
128
+ ### Quantitative metrics
129
+
130
+ Although LLM-judge metrics provide a recognized assessment of the quality of the answers, we also wanted to consider auxiliary metrics that could be used for optimization.
131
+
132
+ #### Minus log prob
133
+
134
+ Since we want our steered model to output answers that are funny and surprising, we expect those answer to have had a low probability in the reference model. We then decided to monitor the (minus) log probability (per token) under the reference model. The exp of this metric is the perplexity under the reference model, quantifying the number of bits of surprise the reference model would experience. This is also related to (the cross component of) the KL divergence between the output distribution of the steered model and the reference model.
135
+
136
+ Note however that we didn’t have an a priori on a suitable value. On one hand, a low value would indicate answers that would have hardly been surprising in the reference model, while high values might indicate gibberish or incoherent answers.
137
+
138
+ #### n-gram Repetition
139
+
140
+ On top of that, since steering too hard might induce repetitive gibberish, we measured the fraction of unique 3-grams in the answers. For short answers, values above 0.15 generally tends to correspond to annoying repetitions that imparts the fluency of the answer.
141
+
142
+ #### Explicit concept inclusion
143
+
144
+ Finally, and as an objective auxiliary metric to monitor, we simply looked for the occurence of the word « eiffel » in the answer (case-insensitive).
145
+
146
+
147
+
148
+ ## Sweeping steering coefficients
149
+
150
+ The naive steering scheme involves adding a steering vector multiplied by a coefficient $\alpha$ to the activations.
151
+ We thus have to choose a suitable value for $\alpha$.
152
+ To do so, we performed a sweep over a range of values for $\alpha$ and evaluated the resulting model using the metrics described in the previous section.
153
+ We used the same set of 25 prompts as before, and generated 4 samples per prompt.
154
+
155
+ ### 1D sweeps
156
+
157
+ import sweep_1D_analysis from 'assets/image/sweep_1D_analysis.png'
158
+
159
+ <Image src={sweep_1D_analysis} alt="1D sweep of steering coefficient" caption="1D sweep of steering coefficient $\alpha$ for a single steering vector." />
160
+
161
+ ### Correlations between metrics
162
+
163
+ import metrics_correlation from 'assets/image/metrics_correlation_matrix.png'
164
+
165
+ <Image src={metrics_correlation} alt="Correlation matrix between metrics" caption="Correlation matrix between metrics." />
166
+
167
+
168
+
169
+ ## Improvements
170
+
171
+ ### Clamping
172
+
173
+ ### Repetition penalty
174
+
175
+ ## Multi-Layer optimization
176
+
177
+ ### Layer selection
178
+
179
+ ### Bayesian optimization
180
+ Motivation : noise, high dimension, no gradient, blackbox, expensive function
181
+
182
+ Choice of cost function
183
+
184
+ ### Gradient descent
185
+
186
+ mu and sigma
187
+
188
+ Choice of solution, beta
189
+
190
+ ### Results
191
+
192
+
193
+ ## Discussion
194
+
195
+ Reason : more coherent behavior,
196
+ Biology analogy, pathways
197
+
198
+ Can we do BO on LLM as a judge
199
+
200
+ Sparsity constraint on features : good or
app/src/content/assets/image/golden_gate_claude_snowhite.jpeg ADDED

Git LFS Details

  • SHA256: bbe75a1d3e4a0974acce3593904fb5a1357fe37d952d8a7df5d4837f36c241dc
  • Pointer size: 130 Bytes
  • Size of remote file: 68.1 kB
app/src/content/assets/image/metrics_correlation_matrix.png ADDED

Git LFS Details

  • SHA256: f393049e9c17325edc78477c0d4a075cfb54fbeb1304e398cd6f78797fec85a8
  • Pointer size: 130 Bytes
  • Size of remote file: 67.4 kB
app/src/content/assets/image/neuronpedia_examples.afdesign ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:346d3972b8696c7fd26fd88a8a31ef32c9d46f5fe885500a24b66af67826c680
3
+ size 5276251
app/src/content/assets/image/neuronpedia_examples.png ADDED

Git LFS Details

  • SHA256: 05d580fe8724f0dc7951d7b65dc071a754a8aaffac104a86820e0fc0deca3dba
  • Pointer size: 131 Bytes
  • Size of remote file: 506 kB
app/src/content/assets/image/sweep_1D_analysis.png ADDED

Git LFS Details

  • SHA256: a3704ed97e498af957531da3c1ca311e6e7b29f1aab45faf83284537d9e2ab8c
  • Pointer size: 131 Bytes
  • Size of remote file: 128 kB
app/src/content/chapters/your-first-chapter.mdx DELETED
@@ -1,2 +0,0 @@
1
- # this is an example chapter
2
-