Avatar

janpaul123

Joined July 18, 2022
Public vals
23
janpaul123 avatar
blogPostEmbeddingsDimensionalityReduction
@janpaul123
Script
An interactive, runnable TypeScript val by janpaul123
janpaul123 avatar
semanticSearchBlogPostPlot
@janpaul123
HTTP
An interactive, runnable TypeScript val by janpaul123
janpaul123 avatar
getValCode
@janpaul123
Cron
An interactive, runnable TypeScript val by janpaul123
janpaul123 avatar
compareEmbeddings
@janpaul123
Script
An interactive, runnable TypeScript val by janpaul123
janpaul123 avatar
dummyJustProxyLibsql
@janpaul123
HTTP
An interactive, runnable TypeScript val by janpaul123
janpaul123 avatar
reproduceResolveModuleError
@janpaul123
Script
// Copied from https://www.val.town/v/sqlite/db
janpaul123 avatar
bronzeOrangutan
@janpaul123
Script
Uses Val Town's blob storage to search embeddings of all vals, by downloading them all and iterating through all of them to compute distance. Slow and terrible, but it works!
janpaul123 avatar
semanticSearchNeon
@janpaul123
Script
Part of Val Town Semantic Search . Uses Neon to search embeddings of all vals, using the pg_vector extension. Call OpenAI to generate an embedding for the search query. Query the vals_embeddings table in Neon using the cosine similarity operator. The vals_embeddings table gets refreshed every 10 minutes by janpaul123/indexValsNeon .
janpaul123 avatar
indexValsNeon
@janpaul123
Cron
Part of Val Town Semantic Search . Generates OpenAI embeddings for all public vals, and stores them in Neon , using the pg_vector extension. Create the vals_embeddings table in Neon if it doesn't already exist. Get all val names from the database of public vals , made by Achille Lacoin . Get all val names from the vals_embeddings table and compute the difference (which ones are missing). Iterate through all missing vals, get their code, get embeddings from OpenAI, and store the result in Neon. Can now be searched using janpaul123/semanticSearchNeon .
janpaul123 avatar
debugValEmbeddings
@janpaul123
Script
An interactive, runnable TypeScript val by janpaul123
janpaul123 avatar
semanticSearchBlobs
@janpaul123
Script
Part of Val Town Semantic Search . Uses Val Town's blob storage to search embeddings of all vals, by downloading them all and iterating through all of them to compute distance. Slow and terrible, but it works! Get metadata from blob storage: allValsBlob${dimensions}EmbeddingsMeta (currently allValsBlob1536EmbeddingsMeta ), which has a list of all indexed vals and where their embedding is stored ( batchDataIndex points to the blob, and valIndex represents the offset within the blob). The blobs have been generated by janpaul123/indexValsBlobs . It is not run automatically. Get all blobs with embeddings pointed to by the metadata, e.g. allValsBlob1536EmbeddingsData_0 for batchDataIndex 0. Call OpenAI to generate an embedding for the search query. Go through all embeddings and compute cosine similarity with the embedding for the search query. Return list sorted by similarity.
janpaul123 avatar
jadeMacaw
@janpaul123
Script
An interactive, runnable TypeScript val by janpaul123
janpaul123 avatar
indexValsBlobs
@janpaul123
Script
Part of Val Town Semantic Search . Generates OpenAI embeddings for all public vals, and stores them in Val Town's blob storage . Create a new metadata object. Also has support for getting the previous metadata and only adding new vals, but that's currently disabled. Get all val names from the database of public vals , made by Achille Lacoin . Put val names in batches. Vals in the same batch will have their embeddings stored in the same blob, at different offsets. Iterate through all each batch, get code for all the vals, get embeddings from OpenAI, and store the result in a blob. When finished, save the metadata JSON to its own blob. Can now be searched using janpaul123/semanticSearchBlobs .
janpaul123 avatar
valtownsemanticsearch
@janpaul123
HTTP
😎 VAL VIBES: Val Town Semantic Search This val hosts an HTTP server that lets you search all vals based on vibes. If you search for "discord bot" it shows all vals that have "discord bot" vibes. It does this by comparing embeddings from OpenAI generated for the code of all public vals, to an embedding of your search query. This is an experiment to see if and how we want to incorporate semantic search in the actual Val Town search page. I implemented three backends, which you can switch between in the search UI. Check out these vals for details on their implementation. Neon: storing and searching embeddings using the pg_vector extension in Neon's Postgres database. Searching: janpaul123/semanticSearchNeon Indexing: janpaul123/indexValsNeon Blobs: storing embeddings in Val Town's standard blob storage , and iterating through all of them to compute distance. Slow and terrible, but it works! Searching: janpaul123/semanticSearchBlobs Indexing: janpaul123/indexValsBlobs Turso: storing and searching using the sqlite-vss extension. Abandoned because of a bug in Turso's implementation. Searching: janpaul123/semanticSearchTurso Indexing: janpaul123/indexValsTurso All implementations use the database of public vals , made by Achille Lacoin , which is refreshed every hour. The Neon implementation updates every 10 minutes, and the other ones are not updated. I also forked Achille's search UI for this val. Please share any feedback and suggestions, and feel free to fork our vals to improve them. This is a playground for semantic search before we implement it in the product for real!
janpaul123 avatar
indexValsTurso
@janpaul123
Cron
Part of Val Town Semantic Search . Generates OpenAI embeddings for all public vals, and stores them in Turso , using the sqlite-vss extension. Create the vals_embeddings and vss_vals_embeddings tables in Turso if they don't already exist. Get all val names from the database of public vals , made by Achille Lacoin . Get all val names from the vals_embeddings table and compute the difference (which ones are missing). Iterate through all missing vals, get their code, get embeddings from OpenAI, and store the result in Turso. When finished, update the vss_vals_embeddings table so we can efficiently query them with the sqlite-vss extension. This is blocked by a bug in Turso that doesn't allow VSS indexes past a certain size. Can now be searched using janpaul123/semanticSearchTurso .
janpaul123 avatar
handle
@janpaul123
HTTP
An interactive, runnable TypeScript val by janpaul123