langchain icon indicating copy to clipboard operation
langchain copied to clipboard

VertexAIEmbeddings error when passing a list with of length greater than 5.

Open agvc opened this issue 2 years ago • 1 comments
trafficstars

System Info

google-cloud-aiplatform==1.25.0 langchain==0.0.181 python 3.10

Who can help?

No response

Information

  • [ ] The official example notebooks/scripts
  • [X] My own modified scripts

Related Components

  • [ ] LLMs/Chat Models
  • [X] Embedding Models
  • [ ] Prompts / Prompt Templates / Prompt Selectors
  • [ ] Output Parsers
  • [ ] Document Loaders
  • [ ] Vector Stores / Retrievers
  • [ ] Memory
  • [ ] Agents / Agent Executors
  • [ ] Tools / Toolkits
  • [ ] Chains
  • [ ] Callbacks/Tracing
  • [ ] Async

Reproduction

Any list with len > 5 will cause an error.

from langchain.vectorstores import FAISS
from langchain.embeddings import VertexAIEmbeddings

text = ['text_1', 'text_2', 'text_3', 'text_4', 'text_5', 'text_6']
embeddings = VertexAIEmbeddings()
vectorstore = FAISS.from_texts(text, embeddings)

InvalidArgument                           Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/google/api_core/grpc_helpers.py](https://localhost:8080/#) in error_remapped_callable(*args, **kwargs)
     72             return callable_(*args, **kwargs)
     73         except grpc.RpcError as exc:
---> 74             raise exceptions.from_grpc_error(exc) from exc
     75 
     76     return error_remapped_callable

InvalidArgument: 400 5 instance(s) is allowed per prediction. Actual: 6

Expected behavior

Excepted to successfully be able to vectorize a larger list of items. Maybe implement a step to

agvc avatar May 26 '23 20:05 agvc

This is a limit imposed by the Vertex API. I can implement pagination in the embed_documents call in order to avoid this error.

Jflick58 avatar May 27 '23 01:05 Jflick58

System Info

google-cloud-aiplatform==1.25.0 langchain==0.0.181 python 3.10

Who can help?

No response

Information

  • [ ] The official example notebooks/scripts
  • [x] My own modified scripts

Related Components

  • [ ] LLMs/Chat Models
  • [x] Embedding Models
  • [ ] Prompts / Prompt Templates / Prompt Selectors
  • [ ] Output Parsers
  • [ ] Document Loaders
  • [ ] Vector Stores / Retrievers
  • [ ] Memory
  • [ ] Agents / Agent Executors
  • [ ] Tools / Toolkits
  • [ ] Chains
  • [ ] Callbacks/Tracing
  • [ ] Async

Reproduction

Any list with len > 5 will cause an error.

from langchain.vectorstores import FAISS
from langchain.embeddings import VertexAIEmbeddings

text = ['text_1', 'text_2', 'text_3', 'text_4', 'text_5', 'text_6']
embeddings = VertexAIEmbeddings()
vectorstore = FAISS.from_texts(text, embeddings)
InvalidArgument                           Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/google/api_core/grpc_helpers.py](https://localhost:8080/#) in error_remapped_callable(*args, **kwargs)
     72             return callable_(*args, **kwargs)
     73         except grpc.RpcError as exc:
---> 74             raise exceptions.from_grpc_error(exc) from exc
     75 
     76     return error_remapped_callable

InvalidArgument: 400 5 instance(s) is allowed per prediction. Actual: 6

Expected behavior

Excepted to successfully be able to vectorize a larger list of items. Maybe implement a step to

I am also facing same issue

Sadaf-Syeda avatar May 28 '23 19:05 Sadaf-Syeda