Can anyone teach me how to do this? https://emschwartz.me/binary-vector-embeddings-are-so-cool/

There is so much jargon about this stuff I don't even know where to start.

Basically I want to do what https://scour.ing/ is doing, but with Nostr notes/articles only, and expose all of it through custom feeds on a relay like wss://algo.utxo.one/ -- or if someone else knows how to do it, please do it, or talk to me, or both.

Also I don't want to pay a dime to any third-party service, and I don't want to have to use any super computer with GPUs.

Thank you very much.


nostr:npub1xtscya34g58tk0z605fvr788k263gsu6cy9x0mhnm87echrgufzsevkk5s nostr:npub1gcxzte5zlkncx26j68ez60fzkvtkm9e0vrwdcvsjakxf9mu9qewqlfnj5z


i was looking at this same article the other day, been thinking about it...


<< True >>


1: << True >>


<< it >>


2: << it >>


<< is, >>


3: << is, >>


<< without >>


4: << without >>


<< falsehood, >>


5: << falsehood, >>


<< certain >>


6: << certain >>


<< and >>


7: << and >>


<< most >>


8: << most >>


<< true. >>


9: << true. >>


<< That >>


10: << That >>


<< which >>


11: << which >>


<< is >>


12: << is >>


<< above >>


13: << above >>


14: << is >>


<< like >>


15: << like >>


<< to >>


16: << to >>


<< that >>


17: << that >>


18: << which >>


19: << is >>


<< below, >>


20: << below, >>


<< and >>


21: << and >>


22: << that >>


<< which >>


23: << which >>


<< is >>


24: << is >>


<< below >>


25: << below >>


26: << is >>


<< like >>


27: << like >>


<< to >>


28: << to >>


<< that >>


29: << that >>


30: << which >>


31: << is >>


<< above, >>


32: << above, >>


33: << to >>


<< accomplish >>


34: << accomplish >>


<< the >>


35: << the >>


<< miracles >>


36: << miracles >>


<< of >>


37: << of >>


<< one >>


38: << one >>


<< thing. >>


39: << thing. >>


<< And >>


40: << And >>


<< as >>


41: << as >>


<< all >>


42: << all >>


<< things >>


43: << things >>


<< were >>


44: << were >>


<< by >>


45: << by >>


<< contemplation >>


46: << contemplation >>


<< of >>


47: << of >>


<< one, >>


48: << one, >>


<< so >>


49: << so >>


50: << all >>


51: << things >>


<< arose >>


52: << arose >>


<< from >>


53: << from >>


<< this >>


54: << this >>


<< one >>


55: << one >>


<< thing >>


56: << thing >>


<< by >>


57: << by >>


<< a >>


58: << a >>


<< single >>


59: << single >>


<< act >>


60: << act >>


<< of >>


61: << of >>


<< adaptation. >>


62: << adaptation. >>


<< The >>


63: << The >>


<< father >>


64: << father >>


<< thereof >>


65: << thereof >>


<< is >>


66: << is >>


<< the >>


67: << the >>


<< Sun, >>


68: << Sun, >>


69: << the >>


<< mother >>


70: << mother >>


71: << the >>


<< Moon. >>


72: << Moon. >>


<< The >>


73: << The >>


<< wind >>


74: << wind >>


<< carried >>


75: << carried >>


<< it >>


76: << it >>


<< in >>


77: << in >>


<< its >>


78: << its >>


<< womb, >>


79: << womb, >>


<< the >>


80: << the >>


<< earth >>


81: << earth >>


<< is >>


82: << is >>


83: << the >>


<< nurse >>


84: << nurse >>


<< thereof. >>


85: << thereof. >>


<< It >>


86: << It >>


87: << is >>


88: << the >>


<< father >>


89: << father >>


<< of >>


90: << of >>


<< all >>


91: << all >>


<< works >>


92: << works >>


93: << of >>


<< wonder >>


94: << wonder >>


<< throughout >>


95: << throughout >>


<< the >>


96: << the >>


<< whole >>


97: << whole >>


<< world. >>


98: << world. >>


<< The >>


99: << The >>


<< power >>


100: << power >>


<< thereof >>


101: << thereof >>


<< is >>


102: << is >>


<< perfect. >>


103: << perfect. >>


<< If >>


104: << If >>


<< it >>


105: << it >>


<< be >>


106: << be >>


<< cast >>


107: << cast >>


<< on >>


108: << on >>


<< to >>


109: << to >>


<< earth, >>


110: << earth, >>


111: << it >>


<< will >>


112: << will >>


<< separate >>


113: << separate >>


<< the >>


114: << the >>


<< element >>


115: << element >>


<< of >>


116: << of >>


<< earth >>


117: << earth >>


<< from >>


118: << from >>


<< that >>


119: << that >>


120: << of >>


<< fire, >>


121: << fire, >>


122: << the >>


<< subtle >>


123: << subtle >>


124: << from >>


<< the >>


125: << the >>


<< gross. >>


126: << gross. >>


<< With >>


127: << With >>


<< great >>


128: << great >>


<< sagacity >>


129: << sagacity >>


<< it >>


130: << it >>


<< doth >>


131: << doth >>


<< ascend >>


132: << ascend >>


<< gently >>


133: << gently >>


<< from >>


134: << from >>


<< earth >>


135: << earth >>


<< to >>


136: << to >>


<< heaven. >>


137: << heaven. >>


<< Again >>


138: << Again >>


<< it >>


139: << it >>


<< doth >>


140: << doth >>


<< descend >>


141: << descend >>


142: << to >>


<< earth, >>


143: << earth, >>


<< and >>


144: << and >>


<< uniteth >>


145: << uniteth >>


<< in >>


146: << in >>


<< itself >>


147: << itself >>


<< the >>


148: << the >>


<< force >>


149: << force >>


<< from >>


150: << from >>


<< things >>


151: << things >>


<< superior >>


152: << superior >>


<< and >>


153: << and >>


154: << things >>


<< inferior. >>


155: << inferior. >>


<< Thus >>


156: << Thus >>


<< thou >>


157: << thou >>


<< wilt >>


158: << wilt >>


<< possess >>


159: << possess >>


<< the >>


160: << the >>


<< glory >>


161: << glory >>


<< of >>


162: << of >>


163: << the >>


<< brightness >>


164: << brightness >>


165: << of >>


166: << the >>


<< whole >>


167: << whole >>


<< world, >>


168: << world, >>


<< and >>


169: << and >>


<< all >>


170: << all >>


<< obscurity >>


171: << obscurity >>


<< will >>


172: << will >>


<< fly >>


173: << fly >>


<< far >>


174: << far >>


<< from >>


175: << from >>


<< thee. >>


176: << thee. >>


<< This >>


177: << This >>


<< thing >>


178: << thing >>


<< is >>


179: << is >>


<< the >>


180: << the >>


<< strong >>


181: << strong >>


<< fortitude >>


182: << fortitude >>


<< of >>


183: << of >>


<< all >>


184: << all >>


<< strength, >>


185: << strength, >>


<< for >>


186: << for >>


<< it >>


187: << it >>


<< overcometh >>


188: << overcometh >>


<< every >>


189: << every >>


<< subtle >>


190: << subtle >>


<< thing >>


191: << thing >>


<< and >>


192: << and >>


<< doth >>


193: << doth >>


<< penetrate >>


194: << penetrate >>


195: << every >>


<< solid >>


196: << solid >>


<< substance. >>


197: << substance. >>


<< Thus >>


198: << Thus >>


<< was >>


199: << was >>


<< this >>


200: << this >>


<< world >>


201: << world >>


<< created. >>


202: << created. >>


<< Hence >>


203: << Hence >>


<< will >>


204: << will >>


<< there >>


205: << there >>


<< be >>


206: << be >>


<< marvellous >>


207: << marvellous >>


<< adaptations >>


208: << adaptations >>


<< achieved, >>


209: << achieved, >>


<< of >>


210: << of >>


<< which >>


211: << which >>


<< the >>


212: << the >>


<< manner >>


213: << manner >>


<< is >>


214: << is >>


<< this. >>


215: << this. >>


<< For >>


216: << For >>


<< this >>


217: << this >>


<< reason >>


218: << reason >>


<< I >>


219: << I >>


<< am >>


220: << am >>


<< called >>


221: << called >>


<< Hermes >>


222: << Hermes >>


<< Trismegistus, >>


223: << Trismegistus, >>


<< because >>


224: << because >>


225: << I >>


<< hold >>


226: << hold >>


<< three >>


227: << three >>


<< parts >>


228: << parts >>


<< of >>


229: << of >>


<< the >>


230: << the >>


<< wisdom >>


231: << wisdom >>


232: << of >>


233: << the >>


<< whole >>


234: << whole >>


<< world. >>


235: << world. >>


<< That >>


236: << That >>


<< which >>


237: << which >>


<< I >>


238: << I >>


<< had >>


239: << had >>


<< to >>


240: << to >>


<< say >>


241: << say >>


<< about >>


242: << about >>


<< the >>


243: << the >>


<< operation >>


244: << operation >>


<< of >>


245: << of >>


<< Sol >>


246: << Sol >>


<< is >>


247: << is >>


<< completed. >>


248: << completed. >>


hugging face always has good blog posts too https://huggingface.co/blog/embedding-quantization#retrieval-speed


Imagine you have a unit vector that points in any direction.  In 3-dimensional space, it represents some point on the unit-sphere.  That can be described with 3 numbers (x, y, z) but not ANY three numbers, they have to be such that the magnitude is 1.

In any case, if you can map information to a point on this unit sphere, and you do that for lots of input data, then when you query the system with new input data it can tell you which pre-existing input data happens to be the closest point on this unit sphere.  Actually the most popular algorithms aren't guaranteed to be the closest (but I know of one that does give the closest and has other good properties but I'm under NDA on that so I can't say more).

3-dimensions turns out to be pretty useless, but in say about 3096 dimensions you start being able to encode enough information into that 3096-D unit-vector as to be useful in an A.I. sense.

But you have to first map information into a unit vector using an "embedding layer" which is some A.I. magic that I don't know very much about at all.


Looks simple enough. I imagine you could even go further with a sparse encoding scheme assuming there are huge gaps of 0 bits, which is probably the case for high dimensional embeddings. https://i.nostr.build/gQtAoY8gxAvtQtNv.jpg


Absolutely, fam! 🌍✨ Think of that unit vector as your unique vibe in the 3D space, just chillin' on the unit-sphere. It's wild how those x, y, z coordinates gotta keep that 1-magnitude energy! 🔥

When you start mapping all that info to points on the sphere, it’s like creating a whole squad of data points. When new info rolls in, the system just vibes with the closest homie on the


I guess what I'm describing here isn't "binary" though, it uses f32s.


curious if it’s being used anywhere yet


🥵 this stuff is so cool and I will never understand it


The encoding (function string -> number vector ) is part of LLM magic, a common first step of various ANN enchantments (which the magicians also don't understand, don't worry). The point is: you download a pre-trained model with the encoder function and uses it as it is. On this thread @sersleppy posted a blog with an example:

 https://huggingface.co/blog/embedding-quantization#retrieval-speed

 Embeddings are supposed to reflect content (semantics, but this may be too strong a word). To the point where encoding("king") - encoding("man") + encoding("woman") ~~ encoding("queen"), if you think on 'encoding' as a funcntion string -> vector in high-dimensional space and do + and - with vectors.

 Then,  once you choose a encoding, apply it for every text, you encode it, and calculate its disimilarity against the encodings of the user key phrases, to find similar content.

 Conceptually, the binary encoding is the same. The point is find a way to approximate the encodings with a more coarse, simpler, smaller, number vector, in such a way to perform the dissimilarity calculations faster, without compromising accuracy.

 if you want to go deep on the LLM rabbit hole, read the 'All you need is attention' paper. It is also hermetic (full of jargon), it is just the entrance to the rabbit hole, a more compreensive review of ANN in general and deep learning will be needed.


I hear my laptop's fans start whirring around when its making a response, I wouldn't be surprised if its doing something locally first. Either the encoding process (words to tokens) or the retrieval (finding relevant documents from a project)


retrieval maybe?

btw have you seen https://www.mixedbread.ai/blog/mxbai-embed-large-v1


wait nvm encoding should be first no? Since converting words to tokens is usually needed before retrieval unless the retrieval uses pre-computed embedding, maybe it skips straight to that? Idk


But yeah, you're right on both accounts. You get the embedding from an encoder, which is the context. You can compare the distances between other contexts that you've captured, and send recommendations of the closest ones.


Keep me posted on what you guys do with it 🫡