RAG Cosine Similarity

Retrieval Augmented Generation (RAG) models primarily use cosine similarity to measure the similarity between a query and the retrieved documents.

Cosine Similarity is a metric used to measure the similarity between two non-zero vectors. It is calculated as the cosine of the angle between the vectors.

Formula:cosine_similarity(A, B) = (A · B) / (||A|| ||B||)

where:A and B are the vectors representing the query and the document, respectively.

· represents the dot product of the vectors.

||A|| and ||B|| represent the magnitudes of the vectors A and B, respectively.

The higher the cosine similarity value, the more similar the query and the document are. RAG models use this metric to retrieve the most relevant documents from their knowledge base and then generate a response based on the retrieved information.

要查看或添加评论,请登录

Aashish Mohan的更多文章

社区洞察

其他会员也浏览了