Cosine similarity

Cosine similarity is a way of measuring, in vector search, how closely two texts correspond in meaning. Each text is converted into a numerical representation, and the direction of these representations is compared, the closer they are, the higher the similarity. In practice, this means the system does not look for matching words but for close meaning, so a paragraph about reducing energy costs will also be found for a query about saving on electricity. Two conclusions follow for content creation. First: a text focused on a single topic has a clearer representation than a paragraph mixing three topics, which ends up meaning nowhere in particular. Second: overly short fragments without context have an unreliable representation, so a paragraph should contain the complete claim, including the naming of the topic.

See also: Content chunking, Hybrid search, Top-k retrieval.