Natural Language Processing (Part 37)-Multiple Planes

Coursesteach
4 min readMar 31, 2024

--

📚Chapter 4: Machine Translation and Document Search`

Introduction

Now that you understand how projections function, I will demonstrate how to combine multiple planes to assist in identifying a single hash value. In other words, I will demonstrate how to locate a data point relative to multiple planes. In the previous blog, we explored how the sign of the dot product between a plane’s normal vector and a vector representing your data, You could determine a position relative to that plane. In this blog, I will demonstrate how to utilize this information across multiple planes to generate a hash value for your data within your vector space.

Sections

Multiple Planes
Multiple Planes ,Single Hash Values
Implement in Code
Conclusion

Sections 1- Multiple Planes

To segment your space into manageable areas, it’s advisable to utilize multiple planes. For each plane, it is possible to determine whether a vector lies on the positive or negative side of that plane. You will receive multiple signals, one for each plane, and you need to find a method to combine all these signals into a single hash value. This hash value will define a particular region within the vector space.

Section 2- Multiple Planes ,Single Hash Values

Let’s go through an example, and then you will observe the general formula for combining signals from multiple planes., Consider a single vector whose dot product with Plane 1 is three., Thus, the sign is positive, and the hash value is assigned a one to denote this positivity.

In the case of the second plane, the dot product equals five. The sign is positive once more, and the hash value is one. For the third plane, the dot product equals negative two. The sign is assigned a value of negative one, and the hash value is set to zero, indicating that vector v lies on the negative side of Plane 3.

To combine these intermediate hash values into a single hash value, you’ll do the following. Take 2⁰ times h_1 plus 2¹times h_2 plus 2² times h_3. This results in a combined hash value of three. Just as a reminder, having multiple planes allows us to divide the vector space into smaller subregions.

You need a single hash value to determine the appropriate bucket for assigning the vector. This is achieved by combining the signals from all the planes into a single hash value.

These are the rules that have been applied in written form.

  • If the dot product’s sign is non-negative, set the intermediate hash value to one.
  • Otherwise, if the dot product is negative, set the intermediate hash value to zero.

To combine intermediate hash values, apply the specified formula. This process results in locality sensitive hashing.

Section 3- Implement in Code

Implementing this in code. Starting with a hash value of zero, accumulate the sum of intermediate hash values given a list of planes represented as a vector. Then, for each plane, calculate the sign of the dot product.

Set the intermediate hash value to one if the sign is greater than or equal to zero; otherwise, set it to zero. Then, multiply the intermediate hash value by two to the power of i and add this to the hash value. Finally, return the hash value. Running the code in the lecture notebook will yield the same results as the example shown earlier. Feel free to try it out.

Conclusion

Now that you’ve understood what it means for a hash function to be locality-sensitive, and have seen examples of such functions, you’ll learn how this property can be leveraged to accelerate nearest-neighbor computation.

Please Follow and 👏 Clap for the story courses teach to see latest updates on this story

If you want to learn more about these topics: Python, Machine Learning Data Science, Statistic For Machine learning, Linear Algebra for Machine learning Computer Vision and Research

Then Login and Enroll in Coursesteach to get fantastic content in the data field.

Stay tuned for our upcoming articles where we will explore specific topics related to NLP in more detail!

Remember, learning is a continuous process. So keep learning and keep creating and sharing with others!💻✌️

Note:if you are a NLP export and have some good suggestions to improve this blog to share, you write comments and contribute.

if you need more update about NLP and want to contribute then following and enroll in following

👉Course: Natural Language Processing (NLP)

👉📚GitHub Repository

👉 📝Notebook

Do you want to get into data science and AI and need help figuring out how? I can offer you research supervision and long-term career mentoring.
Skype: themushtaq48, email:mushtaqmsit@gmail.com

Contribution: We would love your help in making coursesteach community even better! If you want to contribute in some courses , or if you have any suggestions for improvement in any coursesteach content, feel free to contact and follow.

Together, let’s make this the best AI learning Community! 🚀

To Do List

1- Collects Keys points from the blogs

👉WhatsApp

👉 Facebook

👉Github

👉LinkedIn

👉Youtube

👉Twitter

Source

1- Natural Language Processing with Classification and Vector Spaces

--

--