Skip to main content

qdrant-txtai

txtai simplifies building AI-powered semantic search applications using Transformers. It leverages the neural embeddings and their properties to encode high-dimensional data in a lower-dimensional space and allows to find similar objects based on their embeddings' proximity.

Implementing such applications in real-world use cases requires storing the embeddings efficiently, namely in a vector database like Qdrant. It offers not only a powerful engine for neural search, but also allows setting up a whole cluster if your data does not fit a single machine anymore. It is production-grade and can be launched easily with Docker.

Combining the easiness of txtai with Qdrant's performance enables you to build production-ready semantic search applications way faster than before.

Installation

The library might be installed with pip as following:

pip install qdrant-txtai

Usage

Running the txtai application with Qdrant as vector storage requires launching a Qdrant instance. That might be done easily with Docker:

docker run -p 6333:6333 -p:6334:6334 qdrant/qdrant:latest

Running the txtai application might be done either programmatically or by providing configuration in a YAML file.

Programmatically

from txtai.embeddings import Embeddings

embeddings = Embeddings({
    "path": "sentence-transformers/all-MiniLM-L6-v2",
    "backend": "qdrant_txtai.ann.qdrant.Qdrant",
})
embeddings.index([(0, "Correct", None), (1, "Not what we hoped", None)])
result = embeddings.search("positive", 1)
print(result)

Via YAML configuration

# app.yml
embeddings:
  path: sentence-transformers/all-MiniLM-L6-v2
  backend: qdrant_txtai.ann.qdrant.Qdrant
CONFIG=app.yml uvicorn "txtai.api:app"
curl -X GET "http://localhost:8000/search?query=positive"

Configuration properties

qdrant-txtai allows you to configure both the connection details and some internal properties of the vector collection, which may impact both speed and accuracy. Please refer to Qdrant docs if you are interested in the meaning of each property.

The example below presents all the available options, if we connect to Qdrant server:

embeddings:
  path: sentence-transformers/all-MiniLM-L6-v2
  backend: qdrant_txtai.ann.qdrant.Qdrant
  metric: l2 # allowed values: l1 / l2 / cosine / ip
  qdrant:
    url: qdrant.host
    port: 6333
    grpc_port: 6334
    prefer_grpc: true
    collection: CustomCollectionName
    https: true # for Qdrant Cloud
    api_key: XYZ # for Qdrant Cloud
    search_params:
      hnsw_ef: 100

Local in-memory/disk-persisted mode

Qdrant Python client, from version 1.1.1, supports local in-memory/disk-persisted mode. That's a good choice for any test scenarios and quick experiments in which you do not plan to store lots of vectors. In such a case, spinning a Docker container might be even not required.

In-memory storage

In case you want to have transient storage, for example, in the case of automated tests launched during your CI/CD pipeline, using Qdrant Local mode with in-memory storage might be a preferred option.

embeddings:
  path: sentence-transformers/all-MiniLM-L6-v2
  backend: qdrant_txtai.ann.qdrant.Qdrant
  metric: l2 # allowed values: l1 / l2 / cosine / ip
  qdrant:
    location: ':memory:'
    prefer_grpc: true

On disk storage

However, if you prefer to keep the vectors between different runs of your application, it might be better to use disk storage and pass the path that should be used to persist the data.

embeddings:
  path: sentence-transformers/all-MiniLM-L6-v2
  backend: qdrant_txtai.ann.qdrant.Qdrant
  metric: l2 # allowed values: l1 / l2 / cosine / ip
  qdrant:
    path: '/home/qdrant/storage_local'
    prefer_grpc: true

Metadata

Release files for qdrant-txtai 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qdrant-txtai 2.0.0
File Size Uploaded Provenance
qdrant_txtai-2.0.0.tar.gz 7.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for qdrant-txtai 2.0.0
File Interpreter ABI Platform
qdrant_txtai-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.2 kB

Release files / qdrant_txtai-2.0.0.tar.gz

Download URL qdrant_txtai-2.0.0.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
951ea0a70a56f1f475769a7b711f3aa3774a3788ba0d917662d7cfe9a508b60b
BLAKE2b-256 checksum
How to use checksums
ed8961b43a0748aa30a1c66e6d945beae5b584d00ed9919e413c9018ed6d2c2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release files / qdrant_txtai-2.0.0-py3-none-any.whl

Download URL qdrant_txtai-2.0.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e90e4cb1fec2187a3a16de3aff8442c8fd288adc1384e25917f05d6231742af
BLAKE2b-256 checksum
How to use checksums
9375bffd430d1616d40206b449f75e461c6170a633dac21d06d1873067962124
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Security for qdrant-txtai 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page