Find answers from the community

Home
Members
Ernests
E
Ernests
Offline, last seen 3 months ago
Joined September 25, 2024
Hey. I'm trying to use Qdrant with InstructorEmbeddings. When I'm trying to set the index with storage_context, it returns a Pydantic error - PydanticSerializationError: Unable to serialize unknown type: <class 'numpy.ndarray'>

Here is my code
Plain Text
from llama_index.embeddings import InstructorEmbedding
from llama_index import (
    VectorStoreIndex,
    ServiceContext,
    SimpleDirectoryReader,
)
from llama_index.storage.storage_context import StorageContext
from llama_index.vector_stores.qdrant import QdrantVectorStore

qdrant = QdrantClient("http://localhost:6333")

embed_model = InstructorEmbedding(model_name="hkunlp/instructor-base")

# load documents
documents = SimpleDirectoryReader("./data/paul_graham/").load_data()

service_context = ServiceContext.from_defaults(llm=None,
    embed_model=embed_model, chunk_size=512
)
vector_store = QdrantVectorStore(client=qdrant, collection_name="paul_graham")
storage_context = StorageContext.from_defaults(vector_store=vector_store)

# This works
index = VectorStoreIndex.from_documents(
    documents, service_context=service_context
)

index = VectorStoreIndex.from_documents(
    documents, storage_context=storage_context, service_context=service_context
)
11 comments
L
E