Name | embantic JSON |
Version |
0.1.0
JSON |
| download |
home_page | None |
Summary | Embed pydantic models |
upload_time | 2024-10-02 20:31:14 |
maintainer | None |
docs_url | None |
author | Patrick Barker |
requires_python | <4.0,>=3.10 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# emdantic
Embed pydantic models
Embantic is an OVM (Object Vector Mapper) which embeds pydantic models to vectors allowing for semantic search and retrieval of arbitrary mutlimodal objects.
## Installation
```sh
pip install embantic
```
## Usage
Create a data model you would like to embed
```python
from emdantic import EmbModel
class Foo(EmbModel):
a: int
b: str
c: float
d: bool
e: list[int]
f: dict[str, int]
g: Image.Image
h: Optional[EmbModel]
```
Embed the data model
```python
foo = Foo(
a=1,
b="hello",
c=3.14,
d=True,
e=[1, 2, 3],
f={"a": 1, "b": 2},
g=Image.open("path/to/image.png")
)
vectors = foo.embed()
```
Or embed the data model and store the embeddings in a vector database
```python
foo.store()
```
Search for objects by text
```python
results: List[Foo] = Foo.search("hello")
```
Search for objects by image
```python
results: List[Foo] = Foo.search(Image.open("path/to/image.png"))
```
Specify the embedding models to use
```python
class Foo(EmbModel):
__text_model__ = "text-embedding-ada-002"
__image_model__ = "SigLIP-400M"
...
```
## Backends
### Vector Databases
Vector database backends are configured using `EMDANTIC_VECTOR_BACKEND` environment variable. Supported backeends are currently: `faiss`
### Embedding Models
Embedding models are configured using the `__text_model__` and `__image_model__` parameters on the `EmbModel` class. Supported models are currently: `text-embedding-ada-002` and `SigLIP-400M`.
Alternatively, you can set the `EMDANTIC_TEXT_EMBEDDING_MODEL` and `EMDANTIC_IMAGE_EMBEDDING_MODEL` environment variable as the model defaults.
### Database
Embdantic also uses a database to store the raw objects in JSON format. The database is configured using the `EMDANTIC_DATABASE_BACKEND` environment variable. Supported databases are currently: `sqlite`.
Raw data
{
"_id": null,
"home_page": null,
"name": "embantic",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Patrick Barker",
"author_email": "patrickbarkerco@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/a2/ce/c60abb07bc34cf677b26140d34439b0e435512131d49d3126e588a53ae94/embantic-0.1.0.tar.gz",
"platform": null,
"description": "# emdantic\n\nEmbed pydantic models\n\nEmbantic is an OVM (Object Vector Mapper) which embeds pydantic models to vectors allowing for semantic search and retrieval of arbitrary mutlimodal objects.\n\n## Installation\n\n```sh\npip install embantic\n```\n\n## Usage\n\nCreate a data model you would like to embed\n\n```python\nfrom emdantic import EmbModel\n\nclass Foo(EmbModel):\n a: int\n b: str\n c: float\n d: bool\n e: list[int]\n f: dict[str, int]\n g: Image.Image\n h: Optional[EmbModel]\n```\n\nEmbed the data model\n\n```python\nfoo = Foo(\n a=1, \n b=\"hello\", \n c=3.14, \n d=True, \n e=[1, 2, 3], \n f={\"a\": 1, \"b\": 2},\n g=Image.open(\"path/to/image.png\")\n)\n\nvectors = foo.embed()\n```\n\nOr embed the data model and store the embeddings in a vector database\n\n```python\nfoo.store()\n```\n\nSearch for objects by text\n\n```python\nresults: List[Foo] = Foo.search(\"hello\")\n```\n\nSearch for objects by image\n\n```python\nresults: List[Foo] = Foo.search(Image.open(\"path/to/image.png\"))\n```\n\nSpecify the embedding models to use\n\n```python\nclass Foo(EmbModel):\n __text_model__ = \"text-embedding-ada-002\"\n __image_model__ = \"SigLIP-400M\"\n\n ...\n```\n\n## Backends\n\n### Vector Databases\n\nVector database backends are configured using `EMDANTIC_VECTOR_BACKEND` environment variable. Supported backeends are currently: `faiss`\n\n\n### Embedding Models\n\nEmbedding models are configured using the `__text_model__` and `__image_model__` parameters on the `EmbModel` class. Supported models are currently: `text-embedding-ada-002` and `SigLIP-400M`.\n\nAlternatively, you can set the `EMDANTIC_TEXT_EMBEDDING_MODEL` and `EMDANTIC_IMAGE_EMBEDDING_MODEL` environment variable as the model defaults.\n\n### Database\n\nEmbdantic also uses a database to store the raw objects in JSON format. The database is configured using the `EMDANTIC_DATABASE_BACKEND` environment variable. Supported databases are currently: `sqlite`.",
"bugtrack_url": null,
"license": "MIT",
"summary": "Embed pydantic models",
"version": "0.1.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "084c3cc0fed7b0fa84862c971b2dd65062a6fa654ddfafd0c06c97fa66c1319a",
"md5": "8d0aad905057dfc69cc10716ada6a044",
"sha256": "34b6ec6352c24349b948ef1d5e51a3e9c824bc654653fb3c9b791854df253056"
},
"downloads": -1,
"filename": "embantic-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8d0aad905057dfc69cc10716ada6a044",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 8023,
"upload_time": "2024-10-02T20:31:12",
"upload_time_iso_8601": "2024-10-02T20:31:12.854722Z",
"url": "https://files.pythonhosted.org/packages/08/4c/3cc0fed7b0fa84862c971b2dd65062a6fa654ddfafd0c06c97fa66c1319a/embantic-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a2cec60abb07bc34cf677b26140d34439b0e435512131d49d3126e588a53ae94",
"md5": "9728ab223e3baf6c5b3f34460f30e8f1",
"sha256": "bff517675bc439349ffde5229bf71d771ad06d58e255be17cccb8ce41025ec2f"
},
"downloads": -1,
"filename": "embantic-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "9728ab223e3baf6c5b3f34460f30e8f1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 7133,
"upload_time": "2024-10-02T20:31:14",
"upload_time_iso_8601": "2024-10-02T20:31:14.427613Z",
"url": "https://files.pythonhosted.org/packages/a2/ce/c60abb07bc34cf677b26140d34439b0e435512131d49d3126e588a53ae94/embantic-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-02 20:31:14",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "embantic"
}