Bringing semantic search to Django. Integrates seamlessly with Django ORM.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_semantic_search-0.2.1.tar.gz.
File metadata
- Download URL: django_semantic_search-0.2.1.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fe0cb982cbabb2b8c4b17a306508c7dfb1df94667aa1c7871949b28b74304ac
|
|
| MD5 |
e571d13adcfeaa2d838b26020aa7379b
|
|
| BLAKE2b-256 |
3e7540a03b6e27167f0a81844a099edd846beb4983e0fcef1c43be2018ad9a19
|
File details
Details for the file django_semantic_search-0.2.1-py3-none-any.whl.
File metadata
- Download URL: django_semantic_search-0.2.1-py3-none-any.whl
- Upload date:
- Size: 22.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a94644dcb879c189e5072f5f6d30bf099f6d79dd74762109f8446ba4fe9ff02
|
|
| MD5 |
965c4b9a7d707884e473f577bc7fbb9f
|
|
| BLAKE2b-256 |
2a7051183df61f67e5415a7b97d6c244995bea83e290676bfc60e8621e7ffd34
|