Skip to content

Instantly share code, notes, and snippets.

@huumn
Last active August 3, 2023 13:44
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huumn/437925d2861007f12723c72f355959b1 to your computer and use it in GitHub Desktop.
Save huumn/437925d2861007f12723c72f355959b1 to your computer and use it in GitHub Desktop.
Nostr algo examples

Context

  1. nostr-protocol/nips#522
  2. https://stacker.news/items/177715
  3. https://snort.social/e/note1uushpz4zr4ak2fh60l8whww6mm0w6eh9s796m5tza5uz9jjjsl5szk55nn

Sure.

hypothetical but relatively concrete

These are not exhaustive. I'm also not arguing any of these should be implemented. These are just illustrating some obvious and simple algorithms that aren't currently possible on nostr. Any algorithm should go through the "fire" of NIP approval.

naive and unidimensional

  1. created_at in descending order
    • "I want to see the newest events" (nostr's default)
  2. created_at in ascending order
    • "I want to see the oldest events"
  3. sum(zap amount) in descending order
    • "I want to see the events earning the most money"
  4. sum(reactions) in descending order
    • "I want to see events with the most reactions"
  5. sum(comments) in descending order
    • "I want to see events with the most comments"
  6. sum(followers) in descending order
    • "I want to see people with the most followers"
  7. content_contains("some string")
    • "I want to see events with this string in this field" (naive search ... I know we already have search but it's not standardized)

fancier

reminder: not exhaustive or recommendations

  1. arbitrary combinations of the naive algorithms
    • e.g. sum(zap amount)+sum(reactions)+sum(comments)
  2. any naive algorithm (or combination) with a time decay
    • "I want the most zapped events with a bias toward the most recent"
    • "I want the most followed people with a bias toward them having gained those followers recently"
    • "I want the most active conversations happening now"

even fancier

reminder: not exhaustive or recommendations

  1. the fancier algorithms weighted by my following graph
    • "I want the most zapped events biased/weighted by my following graph with a bias toward the most recent"
    • "I want the most followed people weighted by my following graph with a time bias"
  2. the fancier algorithms but weighted by a TrustRank like algorithm, ie use the relay's PoV rather than my own
  3. ZapRank (SN's algo) which is kind of like TrustRank but weighted by zaps.

abstract but "real world"

The following algorithms are ubiquitous because there's no talking people out of wanting these. They give us what we all universally want: "give me what's most important to me - and truthful - and I want it without seeing unimportant and untruthful stuff."

  1. the algorithmic feed on all major social media applications
    • the purpose of these algorithms (absent perverse advertising incentives) is to distill subjective and recent signal
  2. "trending topics/events/stories/whatever"
    • "what's happening now that I might be sad to miss"
  3. "who/what to follow"
    • generic recommendations for things I might want to see more of
    • aka discovery of anything

examples of algorithms happening on nostr today but centralized

  1. https://nostr.band/
    • trending
    • discovery
  2. https://primal.net
    • trending
    • discovery
  3. https://zaplife.lol/
    • I can't really tell what's going on here

There's probably a bunch that I'm missing, but these services exist and are widely known/used in nostr (at least 1 & 2) because they are giving people what they want.

summary

Even if we believe in a nostr world with topic based relays, the classical music relay will want basic algorithms too without having to ask centralized mega relays for permission.

We've been doing user interviews and most people we've talked to are "unhappy" with their nostr experience except when they use these centralized services that distill signal for them.

In feeds that only sort by created_at in descending order, the noisiest and most frequent posters win.


Revisions

  1. I missed wss://powrelay.xyz which orders events by most pow first
  2. zaplife.lol probably doesn't use a server-side algo at all
@melvincarvalho
Copy link

@huumn
Copy link
Author

huumn commented May 13, 2023

Nice i added some text here : https://github.com/nostrcg/devguide/wiki/Algorithms

🙌 Nice work!

@powrespecter
Copy link

pow

@Pranoy1c
Copy link

This is excellent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment