Giter VIP home page Giter VIP logo

embedding-firehose's Introduction

Embedding Firehose

A firehose of post embeddings, downstream of the bluesky firehose.

Background

bluesky is a decentralized, open source social media network. one of the pieces of bluesky is a firehose, which is a websocket server that emits events for every post, like, and update on the network.

various apps might have the idea to generate embeddings via the openai api. however, at the rate that new posts are created on bluesky, it doesn't make sense to have a hundred different apps calling the openai api to generate embeddings for the same posts each second.

enter, the embedded-firehose. it too is a firehose of all the events on bluesky, but it emits events like:

{
    uri: string,
    embedding: number[1536]
}

where the uri is the same uri you'd see on an event from bluesky's firehose, and embedding is an array of 1536 floats, exactly as you'd get from calling openAI's createEmbedding endpoint using the text-embedding-ada-002 model. see embedder.ts for the actual api call.

Usage

  1. I'll deploy this to a url, likely embeddingfirehose.atproto.drewmca.dev, where you can subscribe to events.
  2. Write a function like handleEvent(e: EmbeddingEvent) that updates your db with the embedding received from this firehose.
  3. Tell me that you found this useful, and consider contributing to my server costs, which i'll publish :)

Architecture

  • config.ts: .env config wrapper, cp .env.example .env for a quickstart
  • embedded-firehose-server.ts: main class, extends the FirehoseSubscriptionBase found in the bluesky-social/feed-generator repo. Maps incoming created posts from the bluesky firehose to EmbeddedPosts.
  • counting-ws-server.ts: the websocket server that clients can connect to, and emits the EmbeddedPost events
  • embedder.ts: the service that actually calls the openai API

embedding-firehose's People

Contributors

drewmcarthur avatar

Stargazers

 avatar

Watchers

 avatar  avatar

embedding-firehose's Issues

cost-limiter biases embeddings towards smaller posts

since we check if we shouldEmbed a list of tokens based on the number of tokens / time since last api call, and make sure that's under some threshold, we're only going to embed the smallest posts as they come in.

we could ignore anything under 5 tokens, or some threshold, but until our desired burn rate gets bumped up, we'll only be consuming the smallest posts

add more stats to landing page

eg stats generated since TIME
had an audience for TIME, Z clients
skipped X% of posts
would cost $Y/day to embed everything

Why did this never launch?

No worries, I know how things go sometimes... was just wondering, because it feels like a very useful project.

Either way, thanks for your work!

enable persistent db

heroku doesn't have any persistent file storage, so looks like i'll have to pay for some postgres somewhere

update readme

deployed v1, should update readme to reflect that

should also point to example implementation, or include example in repo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.