From the course: LLM Foundations: Vector Databases for Caching and Retrieval Augmented Generation (RAG)
What is a vector?
From the course: LLM Foundations: Vector Databases for Caching and Retrieval Augmented Generation (RAG)
What is a vector?
Before we start discussing vector databases, let's quickly review the concept of vectors. In science, a vector is defined as an object that has both magnitude and direction. Magnitude may imply size or quantity. Direction implies a line, angle, or trend that this object refers to. The opposite of a vector is a scalar that only has magnitude but no direction. Here are some examples of vectors that we have studied in science. Velocity, momentum, force, weight, and temperature are all examples that have both magnitude and directions. Let's get closer to software programming and see how vectors are used there. A vector is a one-dimensional data structure that can be used to store data in software code. Popular programming languages support some form of vectors. Vectors are homogeneous in that they can only store elements of the same data type. For example, they can store either integers or strings, but not both in the same vector. Each element in the vector has a well-defined position and can be accessed directly using that position. They are similar to lists and arrays, but internally, they are different in how they are stored and accessed. An example of a vector is shown here. Again, it looks similar to a list or array.