django-semantic-search
Bringing semantic search to Django. Integrates seamlessly with Django ORM.
Full documentation for the project is available at https://kacperlukawski.github.io/django-semantic-search/
Django built-in search capabilities are rather limited. Finding a relevant instance of a model relies on the relational
database's search capabilities, like SQL LIKE queries. This is not ideal for high-quality search results. This library
aims to provide a semantic search capability to Django, allowing for more relevant search results. All this is done in
a Django-friendly way, integrating with Django ORM.
The library does not aim to provide all the features of search engines, but rather to provide a simple way to integrate Django applications with semantic search capabilities, using existing vector search engines, a.k.a. vector databases, and embedding models.
Installation
The django-semantic-search library can be installed via your favorite package manager. For example, using pip:
pip install django-semantic-search
The current version is still experimental, and the API may change in the future.
Quickstart
Assuming, you already have a Book model defined in your Django application, you can define a corresponding subclass
of the Document class from the django_semantic_search package. The Document class maps the Django model to the
vector search engine. The document has to be registered with the register_document function.
from django_semantic_search import Document, VectorIndex, register_document
from myapp.models import Book
@register_document
class BookDocument(Document):
class Meta:
model = Book
indexes = [
VectorIndex("title"),
VectorIndex("description"),
]
The BookDocument class defines the fields that will be indexed in the vector search engine. In this case, the title
and description fields are indexed as separate vectors. The VectorIndex class is used to define the fields that
should be indexed.
A more detailed guide is available in the Quickstart section of the documentation.
Usage
Please refer to the Usage section in the documentation.
Features
- Define the search fields for a model.
- Reflect the configuration in your vector search engine.
- Auto-populate the vector search engine with the data from the Django models.
- Support for multiple embedding models:
- Sentence Transformers
- OpenAI
- FastEmbed (both dense and sparse embeddings)
For the latest documentation, visit https://kacperlukawski.github.io/django-semantic-search/.
Roadmap
This is a general roadmap for the project. The list is not exhaustive and may change over time.
- Allow using multiple fields for a single vector index.
- Define overriding the default embedding model for each
VectorIndex. - Implement wrappers for embedding models.
- Add support for modalities other than text.
- Improve the test coverage.
- Add metadata filtering to the search method.
If you have any suggestions or feature requests, feel free to create an issue in the project's repository.
Metadata
Release files for django-semantic-search 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django_semantic_search-0.2.1.tar.gz | 16.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_semantic_search-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.1 kB
Release files / django_semantic_search-0.2.1.tar.gz
| Download URL | django_semantic_search-0.2.1.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8fe0cb982cbabb2b8c4b17a306508c7dfb1df94667aa1c7871949b28b74304ac
|
|
BLAKE2b-256 checksum How to use checksums |
3e7540a03b6e27167f0a81844a099edd846beb4983e0fcef1c43be2018ad9a19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.22
|
Release files / django_semantic_search-0.2.1-py3-none-any.whl
| Download URL | django_semantic_search-0.2.1-py3-none-any.whl |
|---|---|
| Size | 22.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5a94644dcb879c189e5072f5f6d30bf099f6d79dd74762109f8446ba4fe9ff02
|
|
BLAKE2b-256 checksum How to use checksums |
2a7051183df61f67e5415a7b97d6c244995bea83e290676bfc60e8621e7ffd34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.22
|
Security for django-semantic-search 0.2.1
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.