Files
langchain-python/langchain/vectorstores
Shawn91 9e649462ce fix: add_texts method of Weaviate vector store creats wrong embeddings (#4933)
# fix a bug in the add_texts method of Weaviate vector store that creats
wrong embeddings

The following is the original code in the `add_texts` method of the
Weaviate vector store, from line 131 to 153, which contains a bug. The
code here includes some extra explanations in the form of comments and
some omissions.

```python
            for i, doc in enumerate(texts):

                # some code omitted

                if self._embedding is not None:
                    # variable texts is a list of string and doc here is just a string. 
                    # list(doc) actually breaks up the string into characters.
                    # so, embeddings[0] is just the embedding of the first character
                    embeddings = self._embedding.embed_documents(list(doc))
                    batch.add_data_object(
                        data_object=data_properties,
                        class_name=self._index_name,
                        uuid=_id,
                        vector=embeddings[0],
                    )
```

To fix this bug, I pulled the embedding operation out of the for loop
and embed all texts at once.

Co-authored-by: Shawn91 <zyx199199@qq.com>
Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
2023-05-22 12:35:52 -07:00
..
2023-05-10 15:22:16 -07:00
2023-05-18 09:27:09 -07:00
2023-04-24 11:50:55 -07:00
2023-05-17 21:40:49 -07:00
2023-04-27 08:14:36 -07:00
2023-04-22 09:17:38 -07:00
2023-04-24 11:50:55 -07:00
2023-04-28 21:25:33 -07:00
2023-04-24 19:54:15 -07:00
2023-04-22 08:26:19 -07:00