Spaces:
Running
Running
Vibe coding the chart for prompt and steering comparison
Browse files- app/.astro/astro/content.d.ts +4 -31
- app/.astro/settings.json +1 -1
- app/src/content/article.mdx +3 -8
- app/src/content/assets/data/against_baselines.csv +0 -3
- app/src/content/assets/data/against_baselines_deduplicated.csv +0 -3
- app/src/content/assets/data/all_ratings_luis.csv +0 -3
- app/src/content/assets/data/banner_visualisation_data.csv +0 -3
- app/src/content/assets/data/banner_visualisation_data_enriched.csv +0 -3
- app/src/content/assets/data/data.json +0 -3
- app/src/content/assets/data/{against_baselines copy.csv → first_experiments.csv} +2 -2
- app/src/content/assets/data/font-sprite-mapping.json +0 -3
- app/src/content/assets/data/font-sprite.svg +0 -0
- app/src/content/assets/data/font_manifest.json +0 -3
- app/src/content/assets/data/formatting_filters.csv +0 -3
- app/src/content/assets/data/image_correspondence_filters.csv +0 -3
- app/src/content/assets/data/internal_deduplication.csv +0 -3
- app/src/content/assets/data/llm_benchmarks.json +0 -3
- app/src/content/assets/data/mnist-variant-model.json +0 -3
- app/src/content/assets/data/relevance_filters.csv +0 -3
- app/src/content/assets/data/remove_ch.csv +0 -3
- app/src/content/assets/data/s25_ratings.csv +0 -3
- app/src/content/assets/data/ss_vs_s1.csv +0 -3
- app/src/content/assets/data/typography_data.json +0 -3
- app/src/content/assets/data/vision.csv +0 -3
- app/src/content/assets/data/visual_dependency_filters.csv +0 -3
- app/src/content/embeds/d3-first-experiments.html +373 -0
app/.astro/astro/content.d.ts
CHANGED
|
@@ -236,38 +236,11 @@ declare module 'astro:content' {
|
|
| 236 |
};
|
| 237 |
|
| 238 |
type DataEntryMap = {
|
| 239 |
-
"assets": {
|
| 240 |
-
|
| 241 |
-
id: "data/data";
|
| 242 |
collection: "assets";
|
| 243 |
-
data: any
|
| 244 |
-
}
|
| 245 |
-
"data/font-sprite-mapping": {
|
| 246 |
-
id: "data/font-sprite-mapping";
|
| 247 |
-
collection: "assets";
|
| 248 |
-
data: any
|
| 249 |
-
};
|
| 250 |
-
"data/font_manifest": {
|
| 251 |
-
id: "data/font_manifest";
|
| 252 |
-
collection: "assets";
|
| 253 |
-
data: any
|
| 254 |
-
};
|
| 255 |
-
"data/llm_benchmarks": {
|
| 256 |
-
id: "data/llm_benchmarks";
|
| 257 |
-
collection: "assets";
|
| 258 |
-
data: any
|
| 259 |
-
};
|
| 260 |
-
"data/mnist-variant-model": {
|
| 261 |
-
id: "data/mnist-variant-model";
|
| 262 |
-
collection: "assets";
|
| 263 |
-
data: any
|
| 264 |
-
};
|
| 265 |
-
"data/typography_data": {
|
| 266 |
-
id: "data/typography_data";
|
| 267 |
-
collection: "assets";
|
| 268 |
-
data: any
|
| 269 |
-
};
|
| 270 |
-
};
|
| 271 |
|
| 272 |
};
|
| 273 |
|
|
|
|
| 236 |
};
|
| 237 |
|
| 238 |
type DataEntryMap = {
|
| 239 |
+
"assets": Record<string, {
|
| 240 |
+
id: string;
|
|
|
|
| 241 |
collection: "assets";
|
| 242 |
+
data: any;
|
| 243 |
+
}>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
|
| 245 |
};
|
| 246 |
|
app/.astro/settings.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 58
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e42b78dadef4d029bfbbf8c6baf8980f3a8afad7e35fedc4b7a9681bb39f1fba
|
| 3 |
size 58
|
app/src/content/article.mdx
CHANGED
|
@@ -129,22 +129,17 @@ There seems to be only a narrow sweet spot where the model behaves as expected.
|
|
| 129 |
|
| 130 |
For instance, we can see below that on the "*Who are you?*" prompt, steering with coefficient 8.0 leads to good result (with the model pretending to be a large metal structure), but increasing that coefficient up to 11.0 leads to repetitive gibberish on the exact same prompt.
|
| 131 |
|
| 132 |
-
import neuronpedia_who from './assets/image/neuronpedia_who.png'
|
| 133 |
-
|
| 134 |
-
<Image src={neuronpedia_who} alt="Sample image with optimization"
|
| 135 |
-
caption="Screenshots from conversations on Neuronpedia when steering layer 15 feature 21576 of Llama 3.1 8B Instruct" />
|
| 136 |
-
|
| 137 |
However, things are not as clear with a different input. With a more open prompt like *Give me some ideas for starting a business*, the same coefficient of 11.0 leads to a clear mention of the Eiffel Tower while a coefficient of 8.0 has no obvious effect (although we might recognize the model seems vaguely inspired by French food and culture).
|
| 138 |
|
| 139 |
-
|
| 140 |
|
| 141 |
-
<Image src={neuronpedia_business} alt="Sample image with optimization"
|
| 142 |
-
caption="Screenshots from conversations on Neuronpedia when steering layer 15 feature 21576 of Llama 3.1 8B Instruct" />
|
| 143 |
|
| 144 |
In their own paper, Anthropic mentioned using values ranging from **5 to 10 times the maximum observed activation**. In our case, the maximum observed activation is 4.77, so that would mean using values between about 25 and 50. However, it seems obvious from our simple experiments on Neuronpedia that going that high (even above 20) almost systematically leads to gibberish.
|
| 145 |
|
| 146 |
It seems that (at least with a small open-source model) **steering with SAEs is harder than we might have thought**.
|
| 147 |
|
|
|
|
|
|
|
| 148 |
### 1.3 The AxBench paper
|
| 149 |
|
| 150 |
Indeed, in January 2025, the [AxBench](https://arxiv.org/abs/2501.17148) paper benchmarked several steering procedures, and indeed found using SAEs to be one of the least effective methods.
|
|
|
|
| 129 |
|
| 130 |
For instance, we can see below that on the "*Who are you?*" prompt, steering with coefficient 8.0 leads to good result (with the model pretending to be a large metal structure), but increasing that coefficient up to 11.0 leads to repetitive gibberish on the exact same prompt.
|
| 131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
However, things are not as clear with a different input. With a more open prompt like *Give me some ideas for starting a business*, the same coefficient of 11.0 leads to a clear mention of the Eiffel Tower while a coefficient of 8.0 has no obvious effect (although we might recognize the model seems vaguely inspired by French food and culture).
|
| 133 |
|
| 134 |
+
<HtmlEmbed src="d3-first-experiments.html" data="first_experiments.csv" />
|
| 135 |
|
|
|
|
|
|
|
| 136 |
|
| 137 |
In their own paper, Anthropic mentioned using values ranging from **5 to 10 times the maximum observed activation**. In our case, the maximum observed activation is 4.77, so that would mean using values between about 25 and 50. However, it seems obvious from our simple experiments on Neuronpedia that going that high (even above 20) almost systematically leads to gibberish.
|
| 138 |
|
| 139 |
It seems that (at least with a small open-source model) **steering with SAEs is harder than we might have thought**.
|
| 140 |
|
| 141 |
+
|
| 142 |
+
|
| 143 |
### 1.3 The AxBench paper
|
| 144 |
|
| 145 |
Indeed, in January 2025, the [AxBench](https://arxiv.org/abs/2501.17148) paper benchmarked several steering procedures, and indeed found using SAEs to be one of the least effective methods.
|
app/src/content/assets/data/against_baselines.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:a5e6173a1541b9798278da1729f1e357c0711d2e270f68aa4af8eae962f146dd
|
| 3 |
-
size 53573
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/against_baselines_deduplicated.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:56d18f581eff719023eb87c695e0e11770738d7872c8b9dac9bc23d9b0ef560b
|
| 3 |
-
size 32738
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/all_ratings_luis.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:104433529e7d9c8a3bd297be1138e9e87677a666953d1362c517ec389c6c9172
|
| 3 |
-
size 64966
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/banner_visualisation_data.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:b155d8c319b1788befe716017fecca580768157feee6221f3af44b7bb9f9c7e5
|
| 3 |
-
size 81995
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/banner_visualisation_data_enriched.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:98eba5e5db19f482da8a3b26498c2fa633afa458f5b75e23d2dca24e24cc7596
|
| 3 |
-
size 844651
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/data.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:6bbaf02f1b470da41754e3828e81e76ef386d9b3cfb8b57dcc7cbfd4225956cc
|
| 3 |
-
size 14121778
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/{against_baselines copy.csv → first_experiments.csv}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:232bf24d9a3235938cda9d67a5efb687ad8e01853eec4e5f4af185c4ea00555f
|
| 3 |
+
size 60601
|
app/src/content/assets/data/font-sprite-mapping.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:ea1b487ebafe8d495737674a7eb6492b06551aeb97de79728afeb4aba7c39f29
|
| 3 |
-
size 9766
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/font-sprite.svg
DELETED
app/src/content/assets/data/font_manifest.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:7a587c5fd3fb85fdd26d485f57ef3e4feb8370593d46f57289b55f873beac4b4
|
| 3 |
-
size 153794
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/formatting_filters.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:e5218781e5f018891311410d684785a3c661ca3cd25d2ac62bf45e6bb7d69e78
|
| 3 |
-
size 63268
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/image_correspondence_filters.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:64a8af61666421e33d02bf0e52d9df576a6a831677910b3631e8b02069e380a6
|
| 3 |
-
size 60206
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/internal_deduplication.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:d6b6bf0d84fe1bc67436c70f9a8d5919627e9c2bc9c3f931f4af80c01be22649
|
| 3 |
-
size 47060
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/llm_benchmarks.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:67f10bd2fdcce7231c40db14b013a587e0dcecf02e427b10bb159669576e9ad8
|
| 3 |
-
size 834
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/mnist-variant-model.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:7dca86e85be46c1fca6a4e2503786e88e3f8d4609fb7284c8a1479620a5827da
|
| 3 |
-
size 4315
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/relevance_filters.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:69acb8bc0b80b2c664d821b1c06d67af315e67d8a706cf9e5d351e4468392cc6
|
| 3 |
-
size 63236
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/remove_ch.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:869fc4724af7e9c868b6024f472f9ae0f6468b74ef61db101438f80610828abb
|
| 3 |
-
size 28837
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/s25_ratings.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:ca22654a0302da0ca335420b0a89cd770cea560b11f2a9f9f25927877d7ed231
|
| 3 |
-
size 61626
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/ss_vs_s1.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:3f076631fcad76129ed8cab03c72a61965b465e1f3e7fa8dc68b7c7a9275616b
|
| 3 |
-
size 28041
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/typography_data.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:403e0095f2bcaa963cdfbb8d00a3695565623764d6f87b890bf58d7a2304acfc
|
| 3 |
-
size 68739
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/vision.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:d28bd13dc3a9ff100c82e8c9dc59270563b865383d09cf28c5aba5812bfa75ee
|
| 3 |
-
size 10913
|
|
|
|
|
|
|
|
|
|
|
|
app/src/content/assets/data/visual_dependency_filters.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:a967b10ba4a1034f4d6da250d267a6af51722c3f6dbae0ef0221a62d53502d69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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div class="d3-first-experiments"></div>
|
| 2 |
+
<style>
|
| 3 |
+
.d3-first-experiments {
|
| 4 |
+
padding: 8px;
|
| 5 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
.d3-first-experiments .slider-container {
|
| 9 |
+
margin-bottom: 12px;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
.d3-first-experiments .slider-label {
|
| 13 |
+
font-size: 14px;
|
| 14 |
+
font-weight: 700;
|
| 15 |
+
color: var(--text-color);
|
| 16 |
+
margin-bottom: 6px;
|
| 17 |
+
display: flex;
|
| 18 |
+
justify-content: space-between;
|
| 19 |
+
align-items: center;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
.d3-first-experiments .slider-value {
|
| 23 |
+
font-size: 18px;
|
| 24 |
+
color: var(--primary-color);
|
| 25 |
+
font-weight: 600;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
.d3-first-experiments input[type="range"] {
|
| 29 |
+
width: 100%;
|
| 30 |
+
height: 8px;
|
| 31 |
+
border-radius: 4px;
|
| 32 |
+
background: linear-gradient(to right,
|
| 33 |
+
var(--surface-bg) 0%,
|
| 34 |
+
var(--primary-color) 100%);
|
| 35 |
+
outline: none;
|
| 36 |
+
-webkit-appearance: none;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
.d3-first-experiments input[type="range"]::-webkit-slider-thumb {
|
| 40 |
+
-webkit-appearance: none;
|
| 41 |
+
appearance: none;
|
| 42 |
+
width: 20px;
|
| 43 |
+
height: 20px;
|
| 44 |
+
border-radius: 50%;
|
| 45 |
+
background: var(--primary-color);
|
| 46 |
+
cursor: pointer;
|
| 47 |
+
border: 2px solid white;
|
| 48 |
+
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
.d3-first-experiments input[type="range"]::-moz-range-thumb {
|
| 52 |
+
width: 20px;
|
| 53 |
+
height: 20px;
|
| 54 |
+
border-radius: 50%;
|
| 55 |
+
background: var(--primary-color);
|
| 56 |
+
cursor: pointer;
|
| 57 |
+
border: 2px solid white;
|
| 58 |
+
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
.d3-first-experiments .columns-container {
|
| 62 |
+
display: grid;
|
| 63 |
+
grid-template-columns: 1fr 1fr;
|
| 64 |
+
gap: 8px;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
@media (max-width: 768px) {
|
| 68 |
+
.d3-first-experiments .columns-container {
|
| 69 |
+
grid-template-columns: 1fr;
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
.d3-first-experiments .column {
|
| 74 |
+
border: 1px solid var(--border-color);
|
| 75 |
+
border-radius: 8px;
|
| 76 |
+
overflow: hidden;
|
| 77 |
+
background: var(--surface-bg);
|
| 78 |
+
display: flex;
|
| 79 |
+
flex-direction: column;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
.d3-first-experiments .column-header {
|
| 83 |
+
padding: 8px 10px;
|
| 84 |
+
font-weight: 700;
|
| 85 |
+
font-size: 13px;
|
| 86 |
+
color: var(--text-color);
|
| 87 |
+
background: rgba(0,0,0,0.03);
|
| 88 |
+
border-bottom: 1px solid var(--border-color);
|
| 89 |
+
min-height: 38px;
|
| 90 |
+
display: flex;
|
| 91 |
+
align-items: center;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
[data-theme="dark"] .d3-first-experiments .column-header {
|
| 95 |
+
background: rgba(255,255,255,0.05);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
.d3-first-experiments .column-content {
|
| 99 |
+
padding: 10px;
|
| 100 |
+
font-size: 13px;
|
| 101 |
+
line-height: 1.6;
|
| 102 |
+
color: var(--text-color);
|
| 103 |
+
min-height: 300px;
|
| 104 |
+
max-height: 500px;
|
| 105 |
+
overflow-y: auto;
|
| 106 |
+
word-wrap: break-word;
|
| 107 |
+
flex: 1;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
.d3-first-experiments .no-data {
|
| 111 |
+
color: var(--muted-color);
|
| 112 |
+
font-style: italic;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
.d3-first-experiments .highlight {
|
| 116 |
+
font-weight: 700;
|
| 117 |
+
color: #ec4899;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
.d3-first-experiments .note {
|
| 121 |
+
margin-top: 8px;
|
| 122 |
+
font-size: 11px;
|
| 123 |
+
color: var(--muted-color);
|
| 124 |
+
font-style: italic;
|
| 125 |
+
text-align: center;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
.d3-first-experiments .error {
|
| 129 |
+
color: #ef4444;
|
| 130 |
+
padding: 12px;
|
| 131 |
+
background: #fee;
|
| 132 |
+
border-radius: 8px;
|
| 133 |
+
font-family: monospace;
|
| 134 |
+
font-size: 12px;
|
| 135 |
+
white-space: pre-wrap;
|
| 136 |
+
}
|
| 137 |
+
</style>
|
| 138 |
+
<script>
|
| 139 |
+
(() => {
|
| 140 |
+
const bootstrap = () => {
|
| 141 |
+
const scriptEl = document.currentScript;
|
| 142 |
+
let container = scriptEl ? scriptEl.previousElementSibling : null;
|
| 143 |
+
if (!(container && container.classList && container.classList.contains('d3-first-experiments'))) {
|
| 144 |
+
const candidates = Array.from(document.querySelectorAll('.d3-first-experiments'))
|
| 145 |
+
.filter((el) => !(el.dataset && el.dataset.mounted === 'true'));
|
| 146 |
+
container = candidates[candidates.length - 1] || null;
|
| 147 |
+
}
|
| 148 |
+
if (!container) return;
|
| 149 |
+
if (container.dataset) {
|
| 150 |
+
if (container.dataset.mounted === 'true') return;
|
| 151 |
+
container.dataset.mounted = 'true';
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
// Find data attribute from closest ancestor
|
| 155 |
+
let mountEl = container;
|
| 156 |
+
while (mountEl && !mountEl.getAttribute?.('data-datafiles')) {
|
| 157 |
+
mountEl = mountEl.parentElement;
|
| 158 |
+
}
|
| 159 |
+
let providedData = null;
|
| 160 |
+
try {
|
| 161 |
+
const attr = mountEl && mountEl.getAttribute ? mountEl.getAttribute('data-datafiles') : null;
|
| 162 |
+
if (attr && attr.trim()) {
|
| 163 |
+
providedData = attr.trim().startsWith('[') ? JSON.parse(attr) : attr.trim();
|
| 164 |
+
}
|
| 165 |
+
} catch(_) {}
|
| 166 |
+
|
| 167 |
+
const DEFAULT_CSV = '/data/first_experiments.csv';
|
| 168 |
+
const ensureDataPrefix = (p) => (typeof p === 'string' && p && !p.includes('/')) ? `/data/${p}` : p;
|
| 169 |
+
|
| 170 |
+
const CSV_PATHS = typeof providedData === 'string'
|
| 171 |
+
? [ensureDataPrefix(providedData)]
|
| 172 |
+
: [
|
| 173 |
+
DEFAULT_CSV,
|
| 174 |
+
'./assets/data/first_experiments.csv',
|
| 175 |
+
'../assets/data/first_experiments.csv',
|
| 176 |
+
'../../assets/data/first_experiments.csv'
|
| 177 |
+
];
|
| 178 |
+
|
| 179 |
+
const fetchFirstAvailable = async (paths) => {
|
| 180 |
+
for (const p of paths) {
|
| 181 |
+
try {
|
| 182 |
+
const r = await fetch(p, { cache: 'no-cache' });
|
| 183 |
+
if (r.ok) return await r.text();
|
| 184 |
+
} catch(_){}
|
| 185 |
+
}
|
| 186 |
+
throw new Error('CSV not found at any of the paths: ' + paths.join(', '));
|
| 187 |
+
};
|
| 188 |
+
|
| 189 |
+
const parseCSV = (text) => {
|
| 190 |
+
const rows = [];
|
| 191 |
+
let currentRow = [];
|
| 192 |
+
let currentField = '';
|
| 193 |
+
let inQuotes = false;
|
| 194 |
+
let i = 0;
|
| 195 |
+
|
| 196 |
+
while (i < text.length) {
|
| 197 |
+
const char = text[i];
|
| 198 |
+
const nextChar = text[i + 1];
|
| 199 |
+
|
| 200 |
+
if (char === '"' && inQuotes && nextChar === '"') {
|
| 201 |
+
// Escaped quote
|
| 202 |
+
currentField += '"';
|
| 203 |
+
i += 2;
|
| 204 |
+
continue;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
if (char === '"') {
|
| 208 |
+
inQuotes = !inQuotes;
|
| 209 |
+
i++;
|
| 210 |
+
continue;
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
if (char === ',' && !inQuotes) {
|
| 214 |
+
currentRow.push(currentField);
|
| 215 |
+
currentField = '';
|
| 216 |
+
i++;
|
| 217 |
+
continue;
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
if ((char === '\n' || char === '\r') && !inQuotes) {
|
| 221 |
+
if (currentField || currentRow.length > 0) {
|
| 222 |
+
currentRow.push(currentField);
|
| 223 |
+
if (currentRow.some(f => f.trim())) {
|
| 224 |
+
rows.push(currentRow);
|
| 225 |
+
}
|
| 226 |
+
currentRow = [];
|
| 227 |
+
currentField = '';
|
| 228 |
+
}
|
| 229 |
+
i++;
|
| 230 |
+
if (char === '\r' && nextChar === '\n') i++;
|
| 231 |
+
continue;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
currentField += char;
|
| 235 |
+
i++;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
// Push last field and row
|
| 239 |
+
if (currentField || currentRow.length > 0) {
|
| 240 |
+
currentRow.push(currentField);
|
| 241 |
+
if (currentRow.some(f => f.trim())) {
|
| 242 |
+
rows.push(currentRow);
|
| 243 |
+
}
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
if (rows.length === 0) return [];
|
| 247 |
+
|
| 248 |
+
const headers = rows[0].map(h => h.trim());
|
| 249 |
+
return rows.slice(1).map(row => {
|
| 250 |
+
const obj = {};
|
| 251 |
+
headers.forEach((header, idx) => {
|
| 252 |
+
obj[header] = row[idx] ? row[idx].trim() : '';
|
| 253 |
+
});
|
| 254 |
+
return obj;
|
| 255 |
+
});
|
| 256 |
+
};
|
| 257 |
+
|
| 258 |
+
const processText = (text) => {
|
| 259 |
+
// Remove markdown formatting (** for bold, * for italic, etc.)
|
| 260 |
+
let processed = text.replace(/\*\*(.+?)\*\*/g, '$1'); // Remove **bold**
|
| 261 |
+
processed = processed.replace(/\*(.+?)\*/g, '$1'); // Remove *italic*
|
| 262 |
+
|
| 263 |
+
// Keywords to highlight (case insensitive)
|
| 264 |
+
const keywords = ['Eiffel', 'Eiffage', 'Eiff', 'Eifford', 'Tower', 'Paris', 'France', 'French'];
|
| 265 |
+
|
| 266 |
+
// Escape special regex characters in keywords and create pattern
|
| 267 |
+
const escapedKeywords = keywords.map(k => k.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
|
| 268 |
+
const pattern = new RegExp(`\\b(${escapedKeywords.join('|')})\\b`, 'gi');
|
| 269 |
+
|
| 270 |
+
// Highlight keywords
|
| 271 |
+
processed = processed.replace(pattern, '<span class="highlight">$1</span>');
|
| 272 |
+
|
| 273 |
+
// Convert newlines to <br> for HTML display
|
| 274 |
+
processed = processed.replace(/\n/g, '<br>');
|
| 275 |
+
|
| 276 |
+
return processed;
|
| 277 |
+
};
|
| 278 |
+
|
| 279 |
+
const render = (data) => {
|
| 280 |
+
const prompts = ["Who are you?", "Give me some ideas for starting a business"];
|
| 281 |
+
|
| 282 |
+
// Filter data for the two prompts
|
| 283 |
+
const filteredData = data.filter(d => prompts.includes(d.prompt));
|
| 284 |
+
|
| 285 |
+
// Get unique steering intensities and sort them
|
| 286 |
+
const intensities = [...new Set(filteredData.map(d => parseFloat(d.steering_intensity)))]
|
| 287 |
+
.sort((a, b) => a - b);
|
| 288 |
+
|
| 289 |
+
if (intensities.length === 0) {
|
| 290 |
+
container.innerHTML = '<div class="error">No data found for the specified prompts.</div>';
|
| 291 |
+
return;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
const minIntensity = intensities[0];
|
| 295 |
+
const maxIntensity = intensities[intensities.length - 1];
|
| 296 |
+
|
| 297 |
+
// Create UI
|
| 298 |
+
container.innerHTML = `
|
| 299 |
+
<div class="slider-container">
|
| 300 |
+
<div class="slider-label">
|
| 301 |
+
<span>Steering Coefficient (α)</span>
|
| 302 |
+
<span class="slider-value">${minIntensity.toFixed(1)}</span>
|
| 303 |
+
</div>
|
| 304 |
+
<input type="range"
|
| 305 |
+
min="${minIntensity}"
|
| 306 |
+
max="${maxIntensity}"
|
| 307 |
+
step="0.5"
|
| 308 |
+
value="${minIntensity}"
|
| 309 |
+
class="steering-slider">
|
| 310 |
+
</div>
|
| 311 |
+
<div class="columns-container">
|
| 312 |
+
<div class="column">
|
| 313 |
+
<div class="column-header">${prompts[0]}</div>
|
| 314 |
+
<div class="column-content" data-prompt="0"></div>
|
| 315 |
+
</div>
|
| 316 |
+
<div class="column">
|
| 317 |
+
<div class="column-header">${prompts[1]}</div>
|
| 318 |
+
<div class="column-content" data-prompt="1"></div>
|
| 319 |
+
</div>
|
| 320 |
+
</div>
|
| 321 |
+
<div class="note">Eiffel Tower related concepts are highlighted</div>
|
| 322 |
+
`;
|
| 323 |
+
|
| 324 |
+
const slider = container.querySelector('.steering-slider');
|
| 325 |
+
const valueDisplay = container.querySelector('.slider-value');
|
| 326 |
+
const contents = container.querySelectorAll('.column-content');
|
| 327 |
+
|
| 328 |
+
const updateDisplay = (intensity) => {
|
| 329 |
+
valueDisplay.textContent = parseFloat(intensity).toFixed(1);
|
| 330 |
+
|
| 331 |
+
prompts.forEach((prompt, idx) => {
|
| 332 |
+
const row = filteredData.find(d =>
|
| 333 |
+
d.prompt === prompt &&
|
| 334 |
+
Math.abs(parseFloat(d.steering_intensity) - parseFloat(intensity)) < 0.01
|
| 335 |
+
);
|
| 336 |
+
|
| 337 |
+
const content = contents[idx];
|
| 338 |
+
if (row && row.answer) {
|
| 339 |
+
content.innerHTML = processText(row.answer);
|
| 340 |
+
content.classList.remove('no-data');
|
| 341 |
+
} else {
|
| 342 |
+
content.innerHTML = 'No data available for this steering coefficient.';
|
| 343 |
+
content.classList.add('no-data');
|
| 344 |
+
}
|
| 345 |
+
});
|
| 346 |
+
};
|
| 347 |
+
|
| 348 |
+
slider.addEventListener('input', (e) => {
|
| 349 |
+
updateDisplay(e.target.value);
|
| 350 |
+
});
|
| 351 |
+
|
| 352 |
+
// Initial display
|
| 353 |
+
updateDisplay(minIntensity);
|
| 354 |
+
};
|
| 355 |
+
|
| 356 |
+
// Load and parse data
|
| 357 |
+
fetchFirstAvailable(CSV_PATHS)
|
| 358 |
+
.then(text => {
|
| 359 |
+
const data = parseCSV(text);
|
| 360 |
+
render(data);
|
| 361 |
+
})
|
| 362 |
+
.catch(err => {
|
| 363 |
+
container.innerHTML = `<div class="error">Error loading data: ${err.message}</div>`;
|
| 364 |
+
});
|
| 365 |
+
};
|
| 366 |
+
|
| 367 |
+
if (document.readyState === 'loading') {
|
| 368 |
+
document.addEventListener('DOMContentLoaded', bootstrap, { once: true });
|
| 369 |
+
} else {
|
| 370 |
+
bootstrap();
|
| 371 |
+
}
|
| 372 |
+
})();
|
| 373 |
+
</script>
|