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 QdrantClient

client = 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, VectorParams

client.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 PointStruct

operation_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, MatchValue

search_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(三)

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

在.Net6中用gdal实现第一个功能

目录 一、创建.NET6的控制台应用程序 二、加载Gdal插件 三、编写程序 一、创建.NET6的控制台应用程序 二、加载Gdal插件 Gdal的资源可以经过NuGet包引入。右键单击项目名称&#xff0c;然后选择 "Manage NuGet Packages"&#xff08;管理 NuGet 包&#xff09;。N…

用docker搭建的Vulfocus镜像管理界面不能同步解决办法

之前拉取的Vulfocus镜像同步功能失效&#xff0c;最简单的解决办法就是换一个能同步的版本 # 修改镜像源 sudo mkdir -p /etc/dockersudo tee /etc/docker/daemon.json <<-EOF {"registry-mirrors": ["https://dockerproxy.com/"] } EOFsudo syste…

EasyDarwin 、ffmpeg 音视频推流拉流;OBS视频推理软件、obs-rtspserver服务器

参考&#xff1a;https://blog.csdn.net/N71FS1/article/details/130019563 一、EasyDarwin ffmpeg ffmpeg 推送音视频流到rtsp流服务器 EasyDarwin 作为rtsp流服务器 &#xff08;下载&#xff1a;https://www.easydarwin.org/p/easydarwin.html&#xff09;OBS 直播音视频录…

N9010A安捷伦N9010A信号分析仪

181/2461/8938产品概述&#xff1a; Keysight N9010A EXA 信号分析仪是最大限度提高生产线吞吐量的最快方法。从测量速度到代码兼容性&#xff0c;它让每一毫秒都很重要&#xff0c;并帮助您降低总体测试成本。 我们无法预测未来&#xff0c;但安捷伦可以利用我们面向未来的测…

test7

欢迎关注博主 Mindtechnist 或加入【智能科技社区】一起学习和分享Linux、C、C、Python、Matlab&#xff0c;机器人运动控制、多机器人协作&#xff0c;智能优化算法&#xff0c;滤波估计、多传感器信息融合&#xff0c;机器学习&#xff0c;人工智能等相关领域的知识和技术。关…

Hive on Spark 配置

目录 1 Hive 引擎简介2 Hive on Spark 配置2.1 在 Hive 所在节点部署 Spark2.2 在hive中创建spark配置文件2.3 向 HDFS上传Spark纯净版 jar 包2.4 修改hive-site.xml文件2.5 Hive on Spark测试2.6 报错 1 Hive 引擎简介 Hive引擎包括&#xff1a;MR&#xff08;默认&#xff09…

bert 适合 embedding 的模型

目录 背景 embedding 求最相似的 topk 结果查看 背景 想要求两个文本的相似度&#xff0c;就单纯相似度&#xff0c;不要语义相似度&#xff0c;直接使用 bert 先 embedding 然后找出相似的文本&#xff0c;效果都不太好&#xff0c;试过 bert-base-chinese&#xff0c;be…

浪潮信息极致存储 助力垦丰破解种子密码

近几年&#xff0c;我国育种行业迈向数字化转型新阶段&#xff0c;以北大荒垦丰种业为代表的育种企业&#xff0c;正持续通过前沿技术赋能&#xff0c;打造研发创新体系&#xff0c;为中国育种行业的高质量发展贡献力量。值得一提的是&#xff0c;在应对存储问题期间&#xff0…

Linux ssh免密登录配置

步骤 在本地机器上生成公钥和私钥对。将本地公钥复制到远程机器的~/.ssh/authorized_keys文件中。 实现1 在服务器上生成SSH密钥对 ssh-keygen -t rsa -f /home/id_rsa1ssh-keygen: 这是一个用于生成、管理和转换 SSH 密钥的 OpenSSH 工具。-t rsa: 用于指定要生成的密钥类…

Centos安装部署

Centos安装部署 linux安装JDK 下载地址&#xff1a;https://www.oracle.com/java/technologies/oracle-java-archive-downloads.html 创建文件夹&#xff0c;输入命令&#xff1a; mkdir /usr/local/jdk 查看JDK信息&#xff0c;输入命令&#xff1a; java -version 将下载的…

无尘布的多重应用:保持洁净,细致无遗

在现代社会中&#xff0c;随着科技的不断进步和人们对卫生环境要求的提高&#xff0c;无尘布作为一种多功能的擦拭材料&#xff0c;正被广泛应用于各种需要高洁净度环境的领域。其多重应用不仅为电子行业、医疗行业、生物工程和光学仪器等专业领域提供了便利&#xff0c;同时也…

(分享)一个图片添加水印的小demo的页面,可自定义样式

有时候想给某张图片添加一个自己的水印&#xff0c;但是又懒的下载相应软件&#xff0c;用js canvas制作一个静态页面&#xff0c;对于单张图片添加自定义文字水印&#xff0c;大小 间距&#xff0c;角度可调。 页面如下&#xff1a; 选择图片&#xff0c;设置相应参数&#x…

内网靶机~~dc-2

一、信息收集 1.端口扫描&#xff1a; nmap -sV -p 1-10000 10.1.1.4 2.CMS识别 3.目录扫描&#xff1a; dirsearch http://10.1.1.4/ 4.FLAG1 似乎让我们用cewl生成密码字典&#xff0c;并爆破登录。 cewl -w rewl_passwd.txt http://dc-2/index.php/flag/ 总结&#xff…

MySQL文件系统解密:binlog、redolog与undolog如何守护数据安全与一致性

目录 一、MySQL文件组成 1.1 数据库层面的文件 错误日志文件 慢查询日志 查询日志 二进制日志(binlog) pid文件 表结构定义文件 1.2 存储引擎层面的文件 表空间文件 重做日志 撤销日志 二、MySQL 单机的二阶段提交 两阶段提交 从概念上说数据库是文件的集合&#xff0c;是依照…

基于java高校社团招新系统设计与实现

摘要 &#xff1a;大学学生社团的不断壮大发展&#xff0c;让对社团的招新管理越来越重要&#xff0c;如何高效的管理社团&#xff0c;促进社团有效的运行和发展变得尤为关键。学生社团在学生的成长发展过程中有着一定的积极作用&#xff0c;要发挥好社团的优势&#xff0c;管…

电脑ip地址如何改?这些修改方法请收好!

在数字化日益深入的今天&#xff0c;电脑作为我们日常工作和生活中的重要工具&#xff0c;其网络功能显得尤为关键。而在网络世界中&#xff0c;IP地址则是电脑连接互联网的身份证&#xff0c;它标识着电脑在网络中的位置与身份。然而&#xff0c;在某些特定情境下&#xff0c;…

基于jsp+mysql+Spring的SpringBoot招聘网站项目

基于jspmysqlSpring的SpringBoot招聘网站项目&#xff08;完整源码sql&#xff09;主要实现了管理员登录,简历管理,问答管理,职位管理,用户管理,职位申请进度更新,查看简历 博主介绍&#xff1a;多年java开发经验&#xff0c;专注Java开发、定制、远程、文档编写指导等,csdn特邀…

线性回归模型

线性回归模型是一种用于建模因变量与一个或多个自变量之间线性关系的统计模型。它被广泛应用于回归分析中&#xff0c;用于预测或解释连续型因变量的取值。 线性回归模型假设因变量&#xff08;或称响应变量&#xff09; y 与自变量&#xff08;或称特征&#xff09; x 之间存…

【WEEK5】 【DAY4】数据库操作【中文版】

2024.3.28 Thursday 目录 2.数据库操作2.1.数据库2.1.1.新建数据库&#xff08;右键的方法&#xff09;2.1.2.查询&#xff1a;点击“查询”->“新建查询表”即可输入所需要的语句&#xff0c;点击“运行”&#xff0c;如&#xff1a; 2.2.结构化查询语句分类2.3.数据库操作…

CSS3 (一)

一、CSS3 2D转换 转换&#xff08;transform&#xff09;是CSS3中具有颠覆性的特征之一&#xff0c;可以实现元素的位移、旋转、缩放等效果。转换&#xff08;transform&#xff09;你可以简单理解为变形。 移动&#xff1a;translate 、旋转&#xff1a;rotate 、缩放&#xf…