<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [{
"@type": "Question",
"name": "What is cosine similarity?",
"text": "Cosine similarity measures the similarity between two vectors of an inner product space. It is measured by the cosine of the angle between two vectors and determines whether two vectors are pointing in roughly the same direction. It is often used to measure document similarity in text analysis."
}
},{
"@type": "Question",
"name": "How does cosine similarity work?",
"text": "1. Cosine Similarity is a value that is bound by a constrained range of 0 and 1.
2. The similarity measurement measures the cosine of the angle between the two non-zero vectors A and B.
3. Suppose the angle between the two vectors was 90 degrees. In that case, the cosine similarity will have a value of 0; this means that the two vectors are orthogonal or perpendicular to each other.
4. As the cosine similarity measurement gets closer to 1, the angle between the two vectors, A and B, is smaller. The images below depict this more clearly.‍"
}
},{
"@type": "Question",
"name": "How cosine similarity is used?",
"text": "1. Document Similarity.
2. Pose Matching."
}
}]
}
</script>

# Cosine similarity

## What is cosine similarity?

Cosine similarity measures the similarity between two vectors of an inner product space. It is measured by the cosine of the angle between two vectors and determines whether two vectors are pointing in roughly the same direction. It is often used to measure document similarity in text analysis.

The mathematical equation of Cosine similarity between two non-zero vectors is:

## How does cosine similarity work?

Cosine Similarity is a value that is bound by a constrained range of 0 and 1.

The similarity measurement measures the cosine of the angle between the two non-zero vectors A and B.

Suppose the angle between the two vectors was 90 degrees. In that case, the cosine similarity will have a value of 0; this means that the two vectors are orthogonal or perpendicular to each other.

As the cosine similarity measurement gets closer to 1, the angle between the two vectors, A and B, is smaller. The images below depict this more clearly.

## Why do we use cosine similarity in NLP?

In NLP, Cosine similarity is a metric used to measure how similar the documents are irrespective of their size. Mathematically, it calculates the cosine of the angle between two vectors projected in a multi-dimensional space.

The cosine similarity is advantageous because even if the two similar documents are far apart by the Euclidean distance because of the size (for example, the word “chatbot” could appear 50 times in one document and 10 times in another), they could still have a smaller angle between them. Smaller the angle, the higher the similarity.

## How cosine similarity is used?

### 1. Document Similarity

A scenario that involves identifying the similarity between pairs of a document is a good use case for the utilization of cosine similarity as a quantification of the measurement of similarity between two objects.

Quantification of the similarity between two documents can be obtained by converting the words or phrases into a vectorized form of representation.

The vector representations of the documents can then be used within the cosine similarity formula to obtain a quantification of similarity.

In the scenario described above, the cosine similarity of 1 implies that the two documents are exactly alike. A cosine similarity of 0 would conclude that there are no similarities between the two documents.

### 2. Pose Matching

Pose matching involves comparing the poses containing critical points of joint locations.

Pose estimation is a computer vision task, and it’s typically solved using Deep Learning approaches such as Convolutional Pose Machine, Stacked hourglass, PoseNet, etc.

Engati powers 45,000+ chatbot & live chat solutions in 50+ languages across the world.

We aim to empower you to create the best customer experiences you could imagine.

So, are you ready to create unbelievably smooth experiences?

# Cosine similarity

October 14, 2020

Key takeawaysCollaboration platforms are essential to the new way of workingEmployees prefer engati over emailEmployees play a growing part in software purchasing decisionsThe future of work is collaborativeMethodology

## What is cosine similarity?

Cosine similarity measures the similarity between two vectors of an inner product space. It is measured by the cosine of the angle between two vectors and determines whether two vectors are pointing in roughly the same direction. It is often used to measure document similarity in text analysis.

The mathematical equation of Cosine similarity between two non-zero vectors is:

## How does cosine similarity work?

Cosine Similarity is a value that is bound by a constrained range of 0 and 1.

The similarity measurement measures the cosine of the angle between the two non-zero vectors A and B.

Suppose the angle between the two vectors was 90 degrees. In that case, the cosine similarity will have a value of 0; this means that the two vectors are orthogonal or perpendicular to each other.

As the cosine similarity measurement gets closer to 1, the angle between the two vectors, A and B, is smaller. The images below depict this more clearly.

## Why do we use cosine similarity in NLP?

In NLP, Cosine similarity is a metric used to measure how similar the documents are irrespective of their size. Mathematically, it calculates the cosine of the angle between two vectors projected in a multi-dimensional space.

The cosine similarity is advantageous because even if the two similar documents are far apart by the Euclidean distance because of the size (for example, the word “chatbot” could appear 50 times in one document and 10 times in another), they could still have a smaller angle between them. Smaller the angle, the higher the similarity.

## How cosine similarity is used?

### 1. Document Similarity

A scenario that involves identifying the similarity between pairs of a document is a good use case for the utilization of cosine similarity as a quantification of the measurement of similarity between two objects.

Quantification of the similarity between two documents can be obtained by converting the words or phrases into a vectorized form of representation.

The vector representations of the documents can then be used within the cosine similarity formula to obtain a quantification of similarity.

In the scenario described above, the cosine similarity of 1 implies that the two documents are exactly alike. A cosine similarity of 0 would conclude that there are no similarities between the two documents.

### 2. Pose Matching

Pose matching involves comparing the poses containing critical points of joint locations.

Pose estimation is a computer vision task, and it’s typically solved using Deep Learning approaches such as Convolutional Pose Machine, Stacked hourglass, PoseNet, etc.

Share