Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neo4jVector.from_existing_index() requires a call to the embedding model #30

Closed
tdennisliu opened this issue Jan 7, 2025 · 2 comments · Fixed by #31
Closed

Neo4jVector.from_existing_index() requires a call to the embedding model #30

tdennisliu opened this issue Jan 7, 2025 · 2 comments · Fixed by #31

Comments

@tdennisliu
Copy link
Contributor

Background

When loading an existing index via Neo4jVector.from_existing_index(), a singleton of Neo4jVector is created, which in init calls the embedding model to find the number of embedding dimensions..

        self.embedding_dimension = len(embedding.embed_query("foo"))

This is not necessary as right after instantiating the singleton, from_existing_index then gets the embedding dimension from the DB anyway.

        embedding_dimension, index_type = store.retrieve_existing_index()

Problem

This call to the embedding model is a headache in CICD, where you do not want to and can not call third-party embedding services during integration tests.

Proposed Solution

We can add an optional kwarg for embedding dimension during class initialisation that circumvents the need to call the embedding model:


        if embedding_dimension:
            self.embedding_dimension = embedding_dimension
        else:
            # Calculate embedding dimension
            self.embedding_dimension = len(embedding.embed_query("foo"))

Happy for feedback or thoughts and happy to open the PR myself.

@arwentwinkle
Copy link

@tdennisliu Let's open the PR and see if we can get it pushed through

@alexthomas93
Copy link
Collaborator

Closed by #31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants