Platform
Resources
Pricing
Sign in
Get started
Ian Johnson
pixel flipper, data sifter. trying to see what I can while I'm here
Workspace
Fork
Public
By
Ian Johnson
Edited
Mar 17
Insert cell
Insert cell
query
=
"a cat and a calculator"
Insert cell
embedding
=
getTokenizedEmbeddings
(
query
)
Insert cell
feats
=
getFeatures
(
embedding
.
embedding
)
Insert cell
reconstructed
=
getSteering
(
feats
)
Insert cell
cosim
(
embedding
.
embedding
,
reconstructed
)
Insert cell
Insert cell
steered
=
getSteering
(
{
"top_acts"
:
feats
.
top_acts
.
concat
(
range
)
,
"top_indices"
:
feats
.
top_indices
.
concat
(
6215
)
// cows https://enjalot.github.io/latent-taxonomy/#model=NOMIC_FWEDU_25k&feature=6215
}
)
Insert cell
catConstructed
=
getSteering
(
{
"top_acts"
:
[
1
,
.5
]
,
"top_indices"
:
[
13557
,
6864
]
}
)
Insert cell
console
.
log
(
catConstructed
)
Insert cell
neighbors
=
getNNEmbed
(
"enjalot/ls-dadabase"
,
"scopes-001"
,
catConstructed
)
Insert cell
viewof
table
=
Inputs
.
table
(
neighbors
,
{
columns
:
[
"joke"
,
"_distance"
]
}
)
Insert cell
getTokenizedEmbeddings
=
(
query
)
=>
{
return
fetch
(
`${
calc_embedding_url
}${
encodeURIComponent
(
query
)
}`
)
.
then
(
response
=>
response
.
json
(
)
)
}
Insert cell
getFeatures
=
(
embedding
)
=>
{
return
fetch
(
calc_sae_url
,
{
method
:
'POST'
,
headers
:
{
'Content-Type'
:
'application/json'
}
,
body
:
JSON
.
stringify
(
{
"embedding"
:
embedding
}
)
}
)
.
then
(
response
=>
response
.
json
(
)
)
}
Insert cell
getSteering
=
(
features
)
=>
{
return
fetch
(
calc_sae_url
,
{
method
:
'POST'
,
headers
:
{
'Content-Type'
:
'application/json'
}
,
body
:
JSON
.
stringify
(
{
"features"
:
features
}
)
}
)
.
then
(
response
=>
response
.
json
(
)
)
}
Insert cell
getNNEmbed
=
(
db
,
scope
,
embedding
)
=>
{
return
fetch
(
calc_sae_url
,
{
method
:
'POST'
,
headers
:
{
'Content-Type'
:
'application/json'
}
,
body
:
JSON
.
stringify
(
{
"neighbors"
:
true
,
"db"
:
db
,
"scope"
:
scope
,
"embedding"
:
embedding
}
)
}
)
.
then
(
response
=>
response
.
json
(
)
)
}
Insert cell
getFeatures
(
embedding
.
hidden_states
)
Insert cell
cosim
=
similarity
.
default
Insert cell
similarity
=
import
(
'https://cdn.skypack.dev/compute-cosine-similarity@1.1.0?min'
)
Insert cell
calc_embedding_url
=
"https://enjalot--latent-scope-api-app-calc-embedding.modal.run/?query="
Insert cell
calc_sae_url
=
"https://enjalot--latent-scope-api-app-calc-sae.modal.run"
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
query
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
embedding
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
feats
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
reconstructed
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
range
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
steered
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
catConstructed
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
neighbors
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
table
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
getTokenizedEmbeddings
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
getFeatures
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
getSteering
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
getNNEmbed
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
cosim
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
similarity
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
calc_embedding_url
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
calc_sae_url
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML