qdrant

在这里插入图片描述


一、关于 qdrant

Qdrant - High-performance, massive-scale Vector Database for the next generation of AI.

qdrant (read: quadrant)


  • 官网 : https://qdrant.tech
  • github : https://github.com/qdrant/qdrant
  • qdrant-client : https://github.com/qdrant/qdrant-client
  • examples : https://github.com/qdrant/examples
  • qdrant - cloud : https://cloud.qdrant.io

Features


Filtering and Payload

Qdrant can attach any JSON payloads to vectors, allowing for both the storage and filtering of data based on the values in these payloads. Payload supports a wide range of data types and query conditions, including keyword matching, full-text filtering, numerical ranges, geo-locations, and more.

Filtering conditions can be combined in various ways, including should, must, and must_not clauses, ensuring that you can implement any desired business logic on top of similarity matching.


Hybrid Search with Sparse Vectors

To address the limitations of vector embeddings when searching for specific keywords, Qdrant introduces support for sparse vectors in addition to the regular dense ones.

Sparse vectors can be viewed as an generalisation of BM25 or TF-IDF ranking. They enable you to harness the capabilities of transformer-based neural networks to weigh individual tokens effectively.


Vector Quantization and On-Disk Storage

Qdrant provides multiple options to make vector search cheaper and more resource-efficient. Built-in vector quantization reduces RAM usage by up to 97% and dynamically manages the trade-off between search speed and precision.


Distributed Deployment

Qdrant offers comprehensive horizontal scaling support through two key mechanisms:

  1. Size expansion via sharding and throughput enhancement via replication
  2. Zero-downtime rolling updates and seamless dynamic scaling of the collections

Highlighted Features
  • Query Planning and Payload Indexes - leverages stored payload information to optimize query execution strategy.
  • SIMD Hardware Acceleration - utilizes modern CPU x86-x64 and Neon architectures to deliver better performance.
  • Async I/O - uses io_uring to maximize disk throughput utilization even on a network-attached storage.
  • Write-Ahead Logging - ensures data persistence with update confirmation, even during power outages.

有三种方式使用 Qdrant

  1. Run a Docker image if you don’t have a Python development environment. Setup a local Qdrant server and storage in a few moments.
  2. Get the Python client if you’re familiar with Python. Just pip install qdrant-client. The client also supports an in-memory database.
  3. Spin up a Qdrant Cloud cluster: the recommended method to run Qdrant in production.
    Read Quickstart to setup your first instance.

推荐 Workflow

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传


Integrations

Examples and/or documentation of Qdrant integrations:

  • Cohere (blogpost on building a QA app with Cohere and Qdrant) - Use Cohere embeddings with Qdrant
  • DocArray - Use Qdrant as a document store in DocArray
  • Haystack - Use Qdrant as a document store with Haystack (blogpost).
  • LangChain (blogpost) - Use Qdrant as a memory backend for LangChain.
  • LlamaIndex - Use Qdrant as a Vector Store with LlamaIndex.
  • OpenAI - ChatGPT retrieval plugin - Use Qdrant as a memory backend for ChatGPT
  • Microsoft Semantic Kernel - Use Qdrant as persistent memory with Semantic Kernel

二、快速上手

https://qdrant.tech/documentation/quick-start/


1、下载和运行


安装 qdrant-client
pip install qdrant-client

docker

First, download the latest Qdrant image from Dockerhub:

docker pull qdrant/qdrant

Then, run the service:

docker run -p 6333:6333 -p 6334:6334 \-v $(pwd)/qdrant_storage:/qdrant/storage:z \qdrant/qdrant

Under the default configuration all data will be stored in the ./qdrant_storage directory.

This will also be the only directory that both the Container and the host machine can both see.

Qdrant is now accessible:

  • REST API: localhost:6333
  • Web UI: localhost:6333/dashboard
  • GRPC API: localhost:6334

2、初始化 client

from qdrant_client import QdrantClientclient = QdrantClient("localhost", port=6333)

client = QdrantClient(url="http://localhost:6333")

从本地初始化

client = QdrantClient(path="path/to/db") 
# 或
client = QdrantClient(":memory:")

By default, Qdrant starts with no encryption or authentication .

This means anyone with network access to your machine can access your Qdrant container instance.

Please read Security carefully for details on how to secure your instance.


3、创建 collection

You will be storing all of your vector data in a Qdrant collection. Let’s call it test_collection.

This collection will be using a dot product distance metric to compare vectors.

from qdrant_client.http.models import Distance, VectorParamsclient.create_collection(collection_name="test_collection",vectors_config=VectorParams(size=4, distance=Distance.DOT),
)

TypeScript, Rust examples use async/await syntax, so should be used in an async block.

Java examples are enclosed within a try/catch block.


4、添加向量

Let’s now add a few vectors with a payload. Payloads are other data you want to associate with the vector:

from qdrant_client.http.models import PointStructoperation_info = client.upsert(collection_name="test_collection",wait=True,points=[PointStruct(id=1, vector=[0.05, 0.61, 0.76, 0.74], payload={"city": "Berlin"}),PointStruct(id=2, vector=[0.19, 0.81, 0.75, 0.11], payload={"city": "London"}),PointStruct(id=3, vector=[0.36, 0.55, 0.47, 0.94], payload={"city": "Moscow"}),PointStruct(id=4, vector=[0.18, 0.01, 0.85, 0.80], payload={"city": "New York"}),PointStruct(id=5, vector=[0.24, 0.18, 0.22, 0.44], payload={"city": "Beijing"}),PointStruct(id=6, vector=[0.35, 0.08, 0.11, 0.44], payload={"city": "Mumbai"}),],
)print(operation_info)

Response:

operation_id=0 status=<UpdateStatus.COMPLETED: 'completed'>


5、运行 query

Let’s ask a basic question - Which of our stored vectors are most similar to the query vector [0.2, 0.1, 0.9, 0.7]?

search_result = client.search(collection_name="test_collection", query_vector=[0.2, 0.1, 0.9, 0.7], limit=3
)print(search_result)

Response:

ScoredPoint(id=4, version=0, score=1.362, payload={"city": "New York"}, vector=None),
ScoredPoint(id=1, version=0, score=1.273, payload={"city": "Berlin"}, vector=None),
ScoredPoint(id=3, version=0, score=1.208, payload={"city": "Moscow"}, vector=None)

The results are returned in decreasing similarity order.

Note that payload and vector data is missing in these results by default.

See payload and vector in the result on how to enable it.


6、添加 filter

We can narrow down the results further by filtering by payload.

Let’s find the closest results that include “London”.

from qdrant_client.http.models import Filter, FieldCondition, MatchValuesearch_result = client.search(collection_name="test_collection",query_vector=[0.2, 0.1, 0.9, 0.7],query_filter=Filter(must=[FieldCondition(key="city", match=MatchValue(value="London"))]),with_payload=True,limit=3,
)print(search_result)

Response:

ScoredPoint(id=2, version=0, score=0.871, payload={"city": "London"}, vector=None)

To make filtered search fast on real datasets, we highly recommend to create payload indexes!

You have just conducted vector search. You loaded vectors into a database and queried the database with a vector of your own.

Qdrant found the closest results and presented you with a similarity score.



三、Qdrant Examples

This repo contains a collection of tutorials, demos, and how-to guides on how to use Qdrant and adjacent technologies.

ExampleDescriptionTechnologies
Huggingface Spaces with QdrantHost a public demo quickly for your similarity app with HF Spaces and Qdrant CloudHF Spaces, CLIP, semantic image search
QA which is always updated: Recency and Cohere using Llama IndexNotebook which demonstrates how you can keep your QA system always use updated informationLlama Index, OpenAI Embeddings, Cohere Reranker
Qdrant 101 - Getting StartedIntroduction to semantic search and the recommendation API of QdrantNumPy and Faker
Qdrant 101 - Text DataIntroduction to the intersection of Vector Databases and Natural Language Processingtransformers, datasets, GPT-2, Sentence Transformers, PyTorch
Qdrant 101 - Audio DataIntroduction to audio data, audio embeddings, and music recommendation systemstransformers, librosa, openl3, panns_inference, streamlit, datasets, PyTorch
Ecommerce - reverse image searchNotebook demonstrating how to implement a reverse image search for ecommerceCLIP, semantic image search, Sentence-Transformers
Serverless Semantic SearchGet a semantic page search without setting up a serverRust, AWS lambda, Cohere embedding
Basic RAGBasic RAG pipeline with Qdrant and OpenAI SDKsOpenAI, Qdrant, FastEmbed
Step-back prompting in Langchain RAGStep-back prompting for RAG, implemented in LangchainOpenAI, Qdrant, Cohere, Langchain
Collaborative Filtering and MovieLensA notebook demonstrating how to build a collaborative filtering system using QdrantSparse Vectors, Qdrant
Use semantic search to navigate your codebaseImplement semantic search application for code search taskQdrant, Python, sentence-transformers, Jina

2024-03-27(三)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/578936.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

使用C语言实现Linux下的并发Http服务器

使用C语言实现Linux下的并发Http服务器 文章目录 使用C语言实现Linux下的并发Http服务器先备知识Http协议请求格式&#xff1a;客户端请求服务端响应 Demo 实现Mini的Http服务器流程接收Http请求实现按行读取请求头部请求头部的结束 解析请求响应请求读取文件&#xff08;http需…

【数字图像处理】改变图像灰度级别

改变图像灰度级别 首先&#xff0c;对原始图像 O O O进行灰度级量化: q int ⁡ ( O 2 i ) 2 i , q\operatorname{int}\left(\frac{O}{2^{i}}\right) \times 2^{i}, qint(2iO​)2i, 灰度级别256&#xff0c;128&#xff0c;64&#xff0c;32&#xff0c;16&#xff0c;8&…

【Vue3源码学习】— CH2.6 effect.ts:详解

effect.ts&#xff1a;详解 1. 理解activeEffect1.1 定义1.2 通过一个例子来说明这个过程a. 副作用函数的初始化b. 执行副作用函数前c. 访问state.countd. get拦截器中的track调用e. 修改state.count时的set拦截器f. trigger函数中的依赖重新执行 1.3 实战应用1.4 activeEffect…

【数据结构】堆、堆排序(包你学会的)

文章目录 前言堆&#xff08;Heap&#xff09;1、堆的概念及结构2、堆的分类2.1、小堆的结构2.2、大堆的结构2.3、找到规律并证明 3、堆的实现&#xff08;小堆&#xff09;3.1、堆的结构以及接口3.2、初始化、销毁3.3、交换父子结点&#xff08;后续需要&#xff09;3.4、插入…

代码随想录算法训练营第二十四天| 理论基础,77. 组合

题目与题解 参考资料&#xff1a;回溯法理论基础 带你学透回溯算法&#xff08;理论篇&#xff09;| 回溯法精讲&#xff01;_哔哩哔哩_bilibili 77. 组合 题目链接&#xff1a;​​​​​​​​​​​​​​77. 组合 代码随想录题解&#xff1a;77. 组合 视频讲解&#xff…

c语言中的联合体和枚举

这篇文章总结一下c语言中的联合体和枚举。看看这两个东西到底是什么。大家一起学习。 文章目录 一、联合体1.联合体类型的声明。2.联合体的大小。3.相同成员的结构体和联合体对比4.联合体大小的计算。 二、枚举类型1.枚举类型的声明。2.枚举类型的优点。枚举类型的使用。 一、联…

C++王牌结构hash:哈希表开散列(哈希桶)的实现与应用

目录 一、开散列的概念 1.1开散列与闭散列比较 二、开散列/哈希桶的实现 2.1开散列实现 哈希函数的模板构造 哈希表节点构造 开散列增容 插入数据 2.2代码实现 一、开散列的概念 开散列法又叫链地址法(开链法)&#xff0c;首先对关键码集合用散列函数计算散列地址&…

一文教你如何轻松领取腾讯云优惠券

腾讯云作为国内领先的云计算服务商&#xff0c;为用户提供了丰富的云产品和服务。为了让更多用户享受到腾讯云服务的优质体验&#xff0c;腾讯云推出了各种优惠券&#xff0c;让用户在购买云服务时能够获得更多实惠。本文将为大家详细介绍如何轻松领取腾讯云优惠券&#xff0c;…

智慧公厕,为智慧城市建设注入了新的活力

随着智慧城市的快速发展&#xff0c;公共厕所不再是简单的功能设施&#xff0c;而是成为了提升城市形象、改善民生服务的重要一环。智慧公厕作为新形态的公共厕所&#xff0c;通过精准监测公厕内部的人体活动状态、人体存在状态、空气质量情况、环境变化情况、设施设备运行状态…

使用PopLDdecay软件绘制LD衰减图

前记 PopLDdecay是一款用于进行种群遗传学和关联分析的软件。它可以在全基因组水平上进行基因型数据的相关性和衰减分析&#xff0c;帮助研究人员探索种群间的遗传差异和突变选择的模式。 使用PopLDdecay可以实现以下功能&#xff1a; 遗传距离的计算&#xff1a;可以计算遗…

bugku-web-eval

页面源码 <code><span style"color: #000000"> <span style"color: #0000BB"><?php <br /> </span><span style"color: #007700">include </span><span style"color: #DD0000"&…

37-巩固练习(一)

37-1 if语句等 1、问&#xff1a;输出结果 int main() {int i 0;for (i 0; i < 10; i){if (i 5){printf("%d\n", i);}return 0;} } 答&#xff1a;一直输出5&#xff0c;死循环 解析&#xff1a;i5是赋值语句&#xff0c;不是判断语句&#xff0c;每一次循…