Articles → NLP → Cosine Similarity In NLP

Cosine Similarity In NLP






What Is Cosine Similarity?





Formula


Picture showing




  1. A · B = Dot product of vectors A and B
  • ||A|| = Magnitude (length) of vector A
  • ||B|| = Magnitude (length) of vector B

  • Example




    A = [1, 2, 3]B = [2, 4, 6]




    A · B = (1×2) + (2×4) + (3×6) = 28




    ||A|| = √(1² + 2² + 3²) = √14||B|| = √(2² + 4² + 6²) = √56




    28 / (√14 × √56) = 1



    Range Of Values


    ValueMeaning
    1Exactly similar
    0No similarity (orthogonal)
    -1Opposite direction





    Posted By  -  Karan Gupta
     
    Posted On  -  Sunday, March 1, 2026

    Query/Feedback


    Your Email Id
     
    Subject
     
    Query/FeedbackCharacters remaining 250