Two scheduled cloud functions
One that runs every 24h
- For every user, calculating word scores
- How positive/negative towards what you’re interested in
- Taking all contracts, all your views, bets, clicks
- Weighted in interesting ways
- The log of the counts of these
- Views are negative, clicks are slightly positive, bets are most positive
- Takes words out of contract question, description, tags, creator username
- Computes a frequency for each
- TF IDF = “term frequency” * “Inverse document frequency” ⇒ for every word, take the total number of contracts, divide by the number of times where the word appears
- Scales up unusual words, larger impact on the score
- Caches all word vector scores as one document
- Each user has a private cached document. In the
private-user
there’s a cached collection
One that runs every hour
- Read the word scores, gets the recent fresh data, fetches all contracts in the last 7 days that were active
- Dot product of the word score with the frequency of each project
- One subcomponent of the score for the feed ranking
- Other component: Activity score
- Last bet and last 3 comments; does the computation based on the last time of the bet and last time of the comment
- Activity score: how much recent, 24h, 7d vol, a bunch of random heurstics
- Comes out with “this is the activity level”
- Multiply activity score by recommendation by the word
- How is this implemented to scale?
- Problem: cloud functions have a small amount of time and memory
- Scheduler: farms out the tasks to another cloud function, batched in terms of 100 users
- [Austin] Basically mapreduce in cloud functions
- Will scale - even with thousands more users, going to create a few
- Output: “here’s 75 contracts, 3 comments, last bet” ⇒ cached into a single document
- When the user goes home, it fetches single document
Q: Why cloud functions on Vercel?
- Scheduling. Does Vercel do this?
- ... Not that much reason. Could switch it to Vercel if we want
- When it’s calling each cloud function with each batch of users
- Firebase cloud functions
- [Austin] Want to think about maybe moving to a different backend