AI

To consider the question of what vectors are, it helps to be a mathematician, or at least someone who’s comfortable thinking in a mathematical way.

If that’s not you, which it probably isn’t if you’re an ecommerce marketing manager or exec, no worries. The Web is chock full of detailed, colorfully illustrated information about vectors.

For a starting point, the Math Is Fun site, written to help elementary-through-high-school kids but welcoming to non-techies of all ages (and, there’ll be no quizzes), does a great job of summing up the concept

So, quick disclaimer…this blog post isn’t about to exhaustively present everything (or in some cases, anything) about vectors and vector analysis and vector graphics. No. We’re not going into the weeds on vectors. This is a post meant to highlight vector-enhanced search technology, after all. Rest assured, you know how to Google if you need details.

Meanwhile, here’s our best shot at the topic.

## How is a vector visualized?

Standard numbers are the components of a vector. The components show influence in a given direction of the vector.

Mathematicians refer to the visualization of vectors by talking about components in a coordinate system. In a two-dimensional plane, a vector logically has two components, while in a three-dimensional one, it has (you guessed it) three.

Geometrically, a vector often encompasses coordinates in an n-dimensional space (n refers to the quantity of dimensions, for instance, two). It signifies the position of a coordinate in an n-dimensional space.

In the Cartesian coordinate system, vector quantities are represented in a space with an x axis — a horizontal straight line — and a y axis — a vertical straight line that’s perpendicular to the x axis.

A given vector looks pretty simple, like a straight line capped by an arrowhead. The direction of a vector in rudimentary illustrations shows the length of the line “optimistically” slanting up at an angle, from left to right.

Vectors are typically designated in boldface (e.g., vector a and vector b).

The magnitude of a vector is indicated by a vertical bar on each side of the vector, like this: |a|.

### Types of vectors

There are various types of vectors, including:

• A unit vector, which has a magnitude of 1
• A zero vector (null), which has a magnitude of zero and points in no direction
• A position vector, which denotes the location of a point with respect to an arbitrary reference point
• The sum of two or more vectors, a resultant vector
• An equal vector, two or more vectors with the same magnitude and direction
• A column vector, which is when vector components are displayed vertically

## The definition of a vector

So that’s a (somewhat rambling) math-based explanation of a vector.

Now let’s go in the opposite direction for a broader picture — what does Merriam-Webster use as its plain-English assessment of vectors?

The dictionary’s official definition is “a quantity that has magnitude and direction and that is usually represented by a line segment with the given direction and with a length representing the magnitude.”

### Fun facts

Here are a few more data points about vectors:

• A vector is an element of a vector space (also known as a linear space), a geometric object collection with an addition rule and a scalar multiplication rule
• It’s an object that looks like a directed line segment (though not all vectors are directed line segments)
• When its operations can be interpreted appropriately, it’s considered a vector
• Physical quantities that vectors can represent include acceleration, displacement, and velocity

### The role of scalars

Another way of describing a vector like it’s a scientific thing is this: A tuple that has scalars (numbers or values from a dataset).

According to Britannica, examples of scalars include density, energy, volume, time, and mass.

The thing to know about scalars is that they don’t possess magnitude; they just “scale” vectors up and down.

A quantity that doesn’t rely on direction is a scalar quantity, according to NASA.

### Dot products and cross products

How do vector operations work, besides the fact that in vector math, you can use real numbers and get the results of applying vector addition, vector subtraction, and multiplication of vectors?

• Using a vector dot product (also known as a scalar product or inner product) — a tool for determining vector decompositions, projections, and orthogonality — you can figure out the sum of the multiplied elements of two same-length vectors to determine a scalar.
• The vector cross product (also known as the vector product) is used to multiply two vectors. The result of cross-product a x b (read as a cross b) is a new vector running perpendicular to the a and b ones.

## How are vectors used in machine learning?

For programming, vectors are an effective way to organize and store objects and object collections in containers for use in machine-learning applications. They’re used for various scenarios, such as when supervised and unsupervised learning algorithms are applied to create recommendations.

One of the most-cited examples of vectors in machine learning is support vector machines (SVMs). In this scenario, a supervised algorithm solves problems by applying classification.

### Vectorizing data

Before feeding data into a machine-learning model, it is “vectorized” — converted into numbers representing a point or point sequence in the vector space.

The vectors in machine learning signify input data, including bias and weight. In the same way, output from a machine-learning model (for example, a predicted class), can be put into vector format.

A lowercase v is used to designate a vector. The magnitude of the vector (its length), as well as its origin and direction, are labeled. When training a machine-learning algorithm, the target variable may be represented by a lowercase y.

## Machine learning and vector search

Now let’s look at the role of vectors in something concrete that you may be interested in: vector search.

Modern applications of vector functionality are a help for letting website users do broad-based searches and get accurate recommendations, personalization, answers to their FAQs, and more.

With semantic search, data to provide in search results can be identified using approximate nearest neighbor (ANN) algorithms.

In a machine-learning context, vector search is able to look at unstructured data — such as what’s in text, photos, or audio — and translate its context and meaning into numeric representation. This vectorization — converting words into numbers — lets the information be used for automating synonyms, clustering documents‍, detecting meaning and intent in search queries, and ranking search results.

Embeddings are n-dimensional vectors created by deep-learning algorithms to assign semantic definition to input. Other objects, like documents, images, video, and audio, can also be embedded. Machine-learning tasks have improved substantially thanks to embedding.

### The role of neural hashing

One of the challenges in working with vectors in machine learning is their size: they tend to be very long and require specialized databases and GPU management. To address this problem, neural hashing can use neural networks to compress them. The result: processing can be up to 500 times faster than when using standard vector calculations, and these hashed vectors can be run on commodity hardware.

### Vector search: half a solution

Vector search is an effective new technology that works well for broad-based searches. Traditional keyword search, however, still provides the best results for searches that involve someone’s specific intentions.

For example, when someone enters “Levi’s” in a traditional keyword search-engine box, they’d see search results for only that brand — a relatively narrow information window. By contrast, a shopper’s broad-based vector search would return a wider array of similar results, like perhaps other brands that have a similar look and items in the same conceptual category.

If you want to offer your users the best search capabilities, how do you get around this challenge? You put the two together, of course.

That’s exactly what Algolia does. For the most relevant, fastest searching, we use a hybrid approach of both vector and keyword search, ensuring that your users get the best results for both exact-match queries and broad, long-tail queries. Our innovative NeuralSearch technology also scales to meet the needs of any size dataset.

That’s it for our discussion of vectors and how their presence is transforming the search industry. Want to put vectors to work on your business’s behalf? Contact us to learn how Algolia can help get you pointed in the right direction, toward higher ROI, with smart search.

Catherine Dee

Search and Discovery writer

Product

#### What is a vector database?

Vincent Caruana

Sr. SEO Web Digital Marketing Manager
AI

#### What is vector search?

Dustin Coates

Product and GTM Manager
AI

#### How does a vector database work? A quick tutorial

Catherine Dee

Search and Discovery writer