postgresml-django


Namepostgresml-django JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryPostgresML Django integration that enables automatic embedding of specified fields.
upload_time2024-08-27 16:21:41
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords django embeddings machine learning vector databases
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # postgresml-django

postgresml-django is a Python module that integrates PostgresML with Django ORM, enabling automatic in-database embedding of Django models. It simplifies the process of creating and searching vector embeddings for your text data.

## Introduction

This module provides a seamless way to:
- Automatically generate in-databse embeddings for specified fields in your Django models
- Perform vector similarity searches in-database

## Installation

1. Ensure you have [pgml](https://github.com/postgresml/postgresml) installed and configured in your database. The easiest way to do that is to sign up for a free serverless database at [postgresml.org](https://postgresml.org). You can also host it your self.

2. Install the package using pip:

   ```
   pip install postgresml-django
   ```

You are ready to go!

## Usage Examples

### Example 1: Using intfloat/e5-small-v2

This example demonstrates using the `intfloat/e5-small-v2` transformer, which has an embedding size of 384.

```python
from django.db import models
from postgresml_django import VectorField, Embed

class Document(Embed):
    text = models.TextField()
    text_embedding = VectorField(
        field_to_embed="text",
        dimensions=384,
        transformer="intfloat/e5-small-v2"
    )

# Searching
results = Document.vector_search("text_embedding", "some query to search against")
```

### Example 2: Using mixedbread-ai/mxbai-embed-large-v1

This example shows how to use the `mixedbread-ai/mxbai-embed-large-v1` transformer, which has an embedding size of 1024 and requires specific parameters for recall.

```python
from django.db import models
from postgresml_django import VectorField, Embed

class Article(Embed):
    content = models.TextField()
    content_embedding = VectorField(
        field_to_embed="content",
        dimensions=1024,
        transformer="mixedbread-ai/mxbai-embed-large-v1",
        transformer_recall_parameters={
            "prompt": "Represent this sentence for searching relevant passages: "
        }
    )

# Searching
results = Article.vector_search("content_embedding", "some query to search against")
```

Note the differences between the two examples:
1. The `dimensions` parameter is set to 384 for `intfloat/e5-small-v2` and 1024 for `mixedbread-ai/mxbai-embed-large-v1`.
2. The `mixedbread-ai/mxbai-embed-large-v1` transformer requires additional parameters for recall, which are specified in the `transformer_recall_parameters` argument.

Both examples will automatically generate embeddings when instances are saved and allow for vector similarity searches using the `vector_search` method.

## Contributing

We welcome contributions to postgresml-django! Whether it's bug reports, feature requests, documentation improvements, or code contributions, your input is valuable to us. Feel free to open issues or submit pull requests on our GitHub repository.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "postgresml-django",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "django, embeddings, machine learning, vector databases",
    "author": null,
    "author_email": "PostgresML <team@postgresml.org>",
    "download_url": "https://files.pythonhosted.org/packages/1f/95/3784a47264cc189dca28bd979841436bfd1d9845fb73627cd6bfcfecbb80/postgresml_django-0.1.0.tar.gz",
    "platform": null,
    "description": "# postgresml-django\n\npostgresml-django is a Python module that integrates PostgresML with Django ORM, enabling automatic in-database embedding of Django models. It simplifies the process of creating and searching vector embeddings for your text data.\n\n## Introduction\n\nThis module provides a seamless way to:\n- Automatically generate in-databse embeddings for specified fields in your Django models\n- Perform vector similarity searches in-database\n\n## Installation\n\n1. Ensure you have [pgml](https://github.com/postgresml/postgresml) installed and configured in your database. The easiest way to do that is to sign up for a free serverless database at [postgresml.org](https://postgresml.org). You can also host it your self.\n\n2. Install the package using pip:\n\n   ```\n   pip install postgresml-django\n   ```\n\nYou are ready to go!\n\n## Usage Examples\n\n### Example 1: Using intfloat/e5-small-v2\n\nThis example demonstrates using the `intfloat/e5-small-v2` transformer, which has an embedding size of 384.\n\n```python\nfrom django.db import models\nfrom postgresml_django import VectorField, Embed\n\nclass Document(Embed):\n    text = models.TextField()\n    text_embedding = VectorField(\n        field_to_embed=\"text\",\n        dimensions=384,\n        transformer=\"intfloat/e5-small-v2\"\n    )\n\n# Searching\nresults = Document.vector_search(\"text_embedding\", \"some query to search against\")\n```\n\n### Example 2: Using mixedbread-ai/mxbai-embed-large-v1\n\nThis example shows how to use the `mixedbread-ai/mxbai-embed-large-v1` transformer, which has an embedding size of 1024 and requires specific parameters for recall.\n\n```python\nfrom django.db import models\nfrom postgresml_django import VectorField, Embed\n\nclass Article(Embed):\n    content = models.TextField()\n    content_embedding = VectorField(\n        field_to_embed=\"content\",\n        dimensions=1024,\n        transformer=\"mixedbread-ai/mxbai-embed-large-v1\",\n        transformer_recall_parameters={\n            \"prompt\": \"Represent this sentence for searching relevant passages: \"\n        }\n    )\n\n# Searching\nresults = Article.vector_search(\"content_embedding\", \"some query to search against\")\n```\n\nNote the differences between the two examples:\n1. The `dimensions` parameter is set to 384 for `intfloat/e5-small-v2` and 1024 for `mixedbread-ai/mxbai-embed-large-v1`.\n2. The `mixedbread-ai/mxbai-embed-large-v1` transformer requires additional parameters for recall, which are specified in the `transformer_recall_parameters` argument.\n\nBoth examples will automatically generate embeddings when instances are saved and allow for vector similarity searches using the `vector_search` method.\n\n## Contributing\n\nWe welcome contributions to postgresml-django! Whether it's bug reports, feature requests, documentation improvements, or code contributions, your input is valuable to us. Feel free to open issues or submit pull requests on our GitHub repository.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "PostgresML Django integration that enables automatic embedding of specified fields.",
    "version": "0.1.0",
    "project_urls": {
        "Documentation": "https://github.com/postgresml/postgresml-django",
        "Homepage": "https://postgresml.org",
        "Repository": "https://github.com/postgresml/postgresml-django"
    },
    "split_keywords": [
        "django",
        " embeddings",
        " machine learning",
        " vector databases"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e89d1f0393df33e86bf6adeafc1a6dc6cb7793a061485afce2076f89755c6f82",
                "md5": "74a9a067291c84a78a4b9915a1da1bbe",
                "sha256": "cd1481f4bb0cba158c36874cdf2bea1937629a22f0c111412441926aa5dda22d"
            },
            "downloads": -1,
            "filename": "postgresml_django-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "74a9a067291c84a78a4b9915a1da1bbe",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 4396,
            "upload_time": "2024-08-27T16:21:39",
            "upload_time_iso_8601": "2024-08-27T16:21:39.919821Z",
            "url": "https://files.pythonhosted.org/packages/e8/9d/1f0393df33e86bf6adeafc1a6dc6cb7793a061485afce2076f89755c6f82/postgresml_django-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1f953784a47264cc189dca28bd979841436bfd1d9845fb73627cd6bfcfecbb80",
                "md5": "2d21a8e37d594901e1970dfa2f97a381",
                "sha256": "1b262ca35156bcea0390df7f3772c7aff3ef65b217318ff52edc031edc6eaff4"
            },
            "downloads": -1,
            "filename": "postgresml_django-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2d21a8e37d594901e1970dfa2f97a381",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 3516,
            "upload_time": "2024-08-27T16:21:41",
            "upload_time_iso_8601": "2024-08-27T16:21:41.627168Z",
            "url": "https://files.pythonhosted.org/packages/1f/95/3784a47264cc189dca28bd979841436bfd1d9845fb73627cd6bfcfecbb80/postgresml_django-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-27 16:21:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "postgresml",
    "github_project": "postgresml-django",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "postgresml-django"
}
        
Elapsed time: 0.36730s