Cosine Similarity
cosine similarity is used in computer science to group data, or to find data as a response to a query.
it is the cosine of the angle between two vectors.
if the angle is 90, cos(90) = 0 - not similar
if the angle is 0, cos(0) = 1 - same
if the angle is 180, cos(180) = -1 - opposite
To compare two sentences, you need to find the cosine similarity between the numerical representation of the two sentences. Embeddings are numerical representations of words or sentences. Embedding models are offered by OpenAI, Cohere, etc. Their apis take a sentence and return the embeddings.
139 views
Comments
Participate in the conversation.
Never miss a post from
Satyajeet Jadhav
Get notified when Satyajeet Jadhav publishes a new post.
Read More
Embeddings eli5 version
Computers don’t understand text like humans do. Computers understand numbers.To get computers to understand text, you need to convert the text to numbers.
Retrieval Augmented Generation (RAG) on Postgres
So I recently learnt that Postgres works quite well for RAG Applications. Here is the flow I followed.
Semantic Search, aka Magic
The related notes feature searches all your notes to find the ones that are closest in meaning to your current note.Searching notes to find text similar in meaning to your query is called semantic search. We are trying to build a semantic search engine.

Repetition
A wise friend once pointed out that a repetitive pattern is one of the fundamental blocks of art.
AI - Local or Cloud ?
If you are integrating AI into your applications, there are three ways to do it.
The laws of psychology in marketing
A short story from the book, Alchemy: