Search

115 code results for embeddings

Code
115

/** @jsxImportSource npm:hono@3/jsx */
import bots from "https://esm.town/v/tmcw/surprisingEmbeddings/bots"
import * as v from "jsr:@valibot/valibot"
<p>
Embeddings. They're one of the parts of the LLM/AI wave that I sort of like.
</p>
<p>
Embeddings are pretty cool when they work, because they sort of capture the idea of{" "}
<a href="https://blog.val.town/blog/val-vibes/">'vibes', which makes them useful for searc
This project is based on this{" "}
https://www.linkedin.com/pulse/insanity-relying-vector-embeddings-why-rag-fails-michael-wood-4ie
blog post I read last year
const input = inputResult.output
const embeddings = await client.embed({
input,
word,
embedding: embeddings.data?.at(i)?.embedding,
}
<head>
<title>Surprising embeddings</title>
<link rel="stylesheet" href="https://unpkg.com/missing.css@1.1.3" />
<h3>
Surprising embeddings
<sub-title>
</script>
t type="module" src="https://esm.town/v/tmcw/surprisingEmbeddings/visualization"></script>
</div>
<head>
<title>Surprising embeddings</title>
<link rel="stylesheet" href="https://unpkg.com/missing.css@1.1.3" />
<h3>
Surprising embeddings
<sub-title>
const embeddings = await client.embed({
input,
word,
embedding: embeddings.data?.at(i)?.embedding,
}
try {
// let embeddings = await modelProvider.gen({
// embed: true,
// });
// console.log(`Adding link ${counter}:`, link.title, link.url, embeddings);
console.log(`Adding link ${counter}:`, link.title, link.url);
data: JSON.stringify(link),
// embeddings: embeddings.embedding.join(','),
});
export default async function semanticSearchPublicVals(query) {
const allValsBlobEmbeddingsMeta = (await blob.getJSON(`allValsBlob${dimensions}EmbeddingsMeta`
allBatchDataIndexes = _.uniq(Object.values(allValsBlobEmbeddingsMeta).map((item: any) => item.b
const embeddingsBatches = [];
const allBatchDataIndexesPromises = [];
for (const batchDataIndex of allBatchDataIndexes) {
const embeddingsBatchBlobName = `allValsBlob${dimensions}EmbeddingsData_${batchDataIndex}`;
const promise = blob.get(embeddingsBatchBlobName).then((response) => response.arrayBuffer())
promise.then((data) => {
embeddingsBatches[batchDataIndex as any] = data;
console.log(`Loaded ${embeddingsBatchBlobName} (${data.byteLength} bytes)`);
});
const openai = new OpenAI();
const queryEmbedding = (await openai.embeddings.create({
model: "text-embedding-3-small",
const res = [];
for (const id in allValsBlobEmbeddingsMeta) {
const meta = allValsBlobEmbeddingsMeta[id];
const embedding = new Float32Array(
embeddingsBatches[meta.batchDataIndex],
dimensions * 4 * meta.valIndex,
const sqlite = createClient({
url: "libsql://valsembeddings-jpvaltown.turso.io",
authToken: Deno.env.get("TURSO_AUTH_TOKEN_VALSEMBEDDINGS"),
});
const embedding = await openai.embeddings.create({
model: "text-embedding-3-small",
sql:
"WITH matches AS (SELECT rowid, distance FROM vss_vals_embeddings WHERE vss_search(embedding, :e
args: { embeddingBinary },
ob storage](https://docs.val.town/std/blob/) to search embeddings of all vals, by downloading th
t metadata from blob storage: `allValsBlob${dimensions}EmbeddingsMeta` (currently `allValsBlob15
- The blobs have been generated by [janpaul123/indexValsBlobs](https://www.val.town/v/janpaul1
- Get all blobs with embeddings pointed to by the metadata, e.g. `allValsBlob1536EmbeddingsData_
- Call OpenAI to generate an embedding for the search query.
- Go through all embeddings and compute cosine similarity with the embedding for the search quer
- Return list sorted by similarity.
Uses [Turso](https://turso.tech/) to search embeddings of all vals, using the [sqlite-vss](https
- Call OpenAI to generate an embedding for the search query.
- Query the `vss_vals_embeddings` table in Turso using `vss_search`.
- The `vss_vals_embeddings` table has been generated by [janpaul123/indexValsTurso](https://ww
- This table is incomplete due to a [bug in Turso](https://discord.com/channels/93307116268095
* Create a new Qdrant collection in an existing cluster with the given name
* Uses recommended values for OpenAPI embeddings
*/
try {
const r = await fetch("https://embeddings-dashboard-api.jina.ai/api/v1/api_key/user?api_key=
{ signal: AbortSignal.timeout(20000) });
const rx = new RegExp(p.prefer, "i");
// never "discover" non-chat endpoints: guard/moderation, ASR, TTS, embeddings, rerankers
const JUNK = /guard|safeguard|moderat|whisper|tts|speech|embed|rerank|playai|vision-only|ocr
export async function embed(texts: string[], task: "retrieval.passage" | "retrieval.query") {
const r = await fetch("https://api.jina.ai/v1/embeddings", {
method: "POST",
headers: { "content-type": "application/json", authorization: "Bearer " + KEY() },
body: JSON.stringify({ model: "jina-embeddings-v3", task, dimensions: DIM, input: texts }),
signal: AbortSignal.timeout(50000),
const rx = new RegExp(p.prefer, "i");
// never "discover" non-chat endpoints: guard/moderation, ASR, TTS, embeddings, rerankers
const JUNK = /guard|safeguard|moderat|whisper|tts|speech|embed|rerank|playai|vision-only|ocr
['MDC-001','historical_breadth',{historical_master_reaches_numbered_section:193,rule:'final manu
['MDC-002','ai_retrieval',{historical_topics:['embeddings','vector search','RAG','advanced RAG',
['MDC-003','security',{historical_topics:['least privilege','defense in depth','deny by default'
const req = [
ep learning"],["M004","Sistemas de IA","Redes neurais, embeddings, transformers e attention"],["
];