Public
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.
Learn more