VectorDBs let you retrieve documents that have textual similarity.
They allow you sort results by the cosine similarity[1] between vectors. The idea is that you can attach a vector to documents in the database and then when you pass a vector in the query and get back documents that most match the query vector.
The function that creates these vectors(string -> vector) is called an embedding and is constructed in such a way that "semantically similar" strings have vectors that are close together.
It's not a very complicated idea, but complicated and powerful are orthogonal concepts.
They are useful in AI(LLMs) when you would like to include documents in your prompt that are relevant to your instruction. The best way to describe this is by example.
Imagine your query is "What is the capital of France?" Rather than requiring your LLM to encounter this fact during its training, you can embed the question("What is the capital of France?" and retrieve documents (say you've indexed all of Wikipedia in your vector db) and return some snippets from articles that include this information(context).
You then pass the the prompt+context to an LLM and given that it now has relevant information, it can answer the question.
You can also imagine that it's much easier to update a vector db with new information than it is to retrain a model to ingest new facts.
They allow you sort results by the cosine similarity[1] between vectors. The idea is that you can attach a vector to documents in the database and then when you pass a vector in the query and get back documents that most match the query vector.
The function that creates these vectors(string -> vector) is called an embedding and is constructed in such a way that "semantically similar" strings have vectors that are close together.
It's not a very complicated idea, but complicated and powerful are orthogonal concepts.
They are useful in AI(LLMs) when you would like to include documents in your prompt that are relevant to your instruction. The best way to describe this is by example.
Imagine your query is "What is the capital of France?" Rather than requiring your LLM to encounter this fact during its training, you can embed the question("What is the capital of France?" and retrieve documents (say you've indexed all of Wikipedia in your vector db) and return some snippets from articles that include this information(context).
You then pass the the prompt+context to an LLM and given that it now has relevant information, it can answer the question.
You can also imagine that it's much easier to update a vector db with new information than it is to retrain a model to ingest new facts.
1. https://en.wikipedia.org/wiki/Cosine_similarity