Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class Item(Base):
embedding = mapped_column(Vector(3))
```

Also supports `HALFVEC`, `BIT`, and `SPARSEVEC`
Also supports `HalfVector`, `Bit`, and `SparseVector`

Insert a vector

Expand Down Expand Up @@ -252,12 +252,12 @@ Use `vector_ip_ops` for inner product and `vector_cosine_ops` for cosine distanc
Index vectors at half-precision

```python
from pgvector.sqlalchemy import HALFVEC
from pgvector.sqlalchemy import HalfVector
from sqlalchemy.sql import func

index = Index(
'my_index',
func.cast(Item.embedding, HALFVEC(3)).label('embedding'),
func.cast(Item.embedding, HalfVector(3)).label('embedding'),
postgresql_using='hnsw',
postgresql_with={'m': 16, 'ef_construction': 64},
postgresql_ops={'embedding': 'halfvec_l2_ops'}
Expand All @@ -267,7 +267,7 @@ index = Index(
Get the nearest neighbors

```python
order = func.cast(Item.embedding, HALFVEC(3)).l2_distance([3, 1, 2])
order = func.cast(Item.embedding, HalfVector(3)).l2_distance([3, 1, 2])
session.scalars(select(Item).order_by(order).limit(5))
```

Expand Down Expand Up @@ -335,7 +335,7 @@ class Item(SQLModel, table=True):
embedding: Any = Field(sa_type=Vector(3))
```

Also supports `HALFVEC`, `BIT`, and `SPARSEVEC`
Also supports `HalfVector`, `Bit`, and `SparseVector`

Insert a vector

Expand Down
10 changes: 6 additions & 4 deletions pgvector/sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
from .bit import BIT
from .bit import BIT as Bit
from .functions import avg, sum
from .halfvec import HALFVEC
from .halfvec import HALFVEC as HalfVector
from .sparsevec import SPARSEVEC
from .sparsevec import SPARSEVEC as SparseVector
from .vector import VECTOR
from .vector import VECTOR as Vector

# TODO remove
from .. import HalfVector, SparseVector

__all__ = [
'Vector',
'VECTOR',
'HALFVEC',
'Bit',
'BIT',
'SPARSEVEC',
'HalfVector',
'HALFVEC',
'SparseVector',
'SPARSEVEC',
'avg',
'sum'
]