Skip to content

Commit

Permalink
fix: from numpy float to float (#391)
Browse files Browse the repository at this point in the history
* created project

* added parallel param

* updated test

* version 0.0.1

* renamed folder

* removed print

* updated readme

* added fastembed.yml

* fix typos

* python version to 3.9 for lint

* updated file

* force install black

* return to original file

* try to fix workflow

* retry

* add missing info to pyproject

* add hatch-vcs to check version

* Update pyproject.toml

* fixed typos

* removed python 3.9

* Update fastembed.yml

* Update fastembed_document_embedder.py

* Update fastembed_text_embedder.py

* ignore errors for bool arguments

* fix

* try moving noqa

* move noqa

* formatted with black

* added numpy dependency

* removed numpy

* removed numpy

* make mypy happy

* Update fastembed_backend.py

* removed classvar

* fix

* Update pyproject.toml

* added import numpy lint

* skip docs generation for the time being

* Update README.md

* added config.yml

* generate docs

* Update fastembed.yml

* Update config.yml

* rm unnecessary from_dict

* final touch

* updated labeler.yml

* updated library readme

* fix typos

* fix docstrings/README

* added prefix and suffix

* fixed typos

* Update fastembed_text_embedder.py

from numpy float to float

* Update fastembed_document_embedder.py

from numpy float to float

* Update test_fastembed_text_embedder.py

from numpy float to float

* Update test_fastembed_document_embedder.py

from numpy float to float

* Update fastembed_document_embedder.py

fix typos

* Update fastembed_text_embedder.py

added if in run

* Update fastembed_document_embedder.py

added if into run

* modify backend

---------

Co-authored-by: Stefano Fiorucci <[email protected]>
  • Loading branch information
nickprock and anakin87 authored Feb 12, 2024
1 parent 837edbb commit 70ed7e6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ def __init__(
self.model = TextEmbedding(model_name=model_name)

def embed(self, data: List[List[str]], **kwargs) -> List[List[float]]:
embeddings = list(self.model.embed(data, **kwargs))
# the embed method returns a Iterable[np.ndarray], so we convert it to a list of lists
embeddings = [np_array.tolist() for np_array in self.model.embed(data, **kwargs)]
return embeddings
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,6 @@ def run(self, documents: List[Document]):
)

for doc, emb in zip(documents, embeddings):
doc.embedding = list(emb)
doc.embedding = emb

return {"documents": documents}
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,4 @@ def test_run(self):

assert isinstance(embedding, list)
assert len(embedding) == 384
assert all(isinstance(emb.item(), float) for emb in embedding)
assert all(isinstance(emb, float) for emb in embedding)
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,4 @@ def test_run(self):

assert isinstance(embedding, list)
assert len(embedding) == 384
assert all(isinstance(emb.item(), float) for emb in embedding)
assert all(isinstance(emb, float) for emb in embedding)

0 comments on commit 70ed7e6

Please sign in to comment.