dspy icon indicating copy to clipboard operation
dspy copied to clipboard

ValueError: Expected embeddings to be a list, got {'error': ['Value error, The inputs are invalid, at least one input is required: received `[]` in `parameters`']}

Open KaifAhmad1 opened this issue 4 months ago • 1 comments

import chromadb.utils.embedding_functions as embedding_functions
huggingface_ef = embedding_functions.HuggingFaceEmbeddingFunction(
    api_key="My API Token",
    model_name="sentence-transformers/all-MiniLM-L6-v2"
)

from dspy.retrieve.chromadb_rm import ChromadbRM
retriever_model = ChromadbRM(
    'history_data',
    './chromadb',
    embedding_function=huggingface_ef,
    k=5
)
results = retriever_model("", k=5)
for result in results:
    print("Document:", result.long_text, "\n")

--------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-8-43eabc3ac0e8> in <cell line: 8>()
      6     k=5
      7 )
----> 8 results = retriever_model("", k=5)
      9 for result in results:
     10     print("Document:", result.long_text, "\n")

5 frames
/usr/local/lib/python3.10/dist-packages/chromadb/api/types.py in validate_embeddings(embeddings)
    472     """Validates embeddings to ensure it is a list of list of ints, or floats"""
    473     if not isinstance(embeddings, list):
--> 474         raise ValueError(f"Expected embeddings to be a list, got {embeddings}")
    475     if len(embeddings) == 0:
    476         raise ValueError(

ValueError: Expected embeddings to be a list, got {'error': ['Value error, The inputs are invalid, at least one input is required: received `[]` in `parameters`']}

KaifAhmad1 avatar Apr 16 '24 11:04 KaifAhmad1

Hi @KaifAhmad1 , retriever_model expects a query passed in with k and currently you are passing an empty string, which results in the error :). Feel free to refer to the ChromaDB documentation for more details.

arnavsinghvi11 avatar Apr 18 '24 16:04 arnavsinghvi11