Find answers from the community

Updated 4 months ago

Custom Embeddings

At a glance
Hi, Can anyone help me with these doubts:
1) How do I use an embedding generator provided within a weaviate instance ?
2) Or how do I pass my own embedding model that is hosted on a server.
1
E
p
W
9 comments
The first question isn't clear, can you explain please?
So in the custom embedding class can I pass my server's url to use the embedding model ?
In the examples given in documentation, embedding model is being used using the python package. I don't have the package so can I use the model in some other manner ?
When we host weaviate on a server, it has the option to either use an implicit embedding model or to explicitly pass your own embedding model's inference URL.
I wanted to know if we can do a similar thing in llama index where I am using my weaviate's hosted instance and the embedding model that I have passed to it
I think yes, you can use your hosted embedding model in custom embedding class. You'll have to modify the following methods

Plain Text
    def _get_query_embedding(self, query: str) -> List[float]:
        embeddings = self._model.encode([[self._instruction, query]])
        return embeddings[0]

    def _get_text_embedding(self, text: str) -> List[float]:
        embeddings = self._model.encode([[self._instruction, text]])
        return embeddings[0]

    def _get_text_embeddings(self, texts: List[str]) -> List[List[float]]:
        embeddings = self._model.encode(
            [[self._instruction, text] for text in texts]
        )
        return embeddings

replace the embedding model call with your API call and return the response in the required format.
what are you using to serve the embedding model? maybe we have an integration already (or we can certainly help add an integration too)
We are using huggingface autotokenizer and wrapping it with fastapi
Add a reply
Sign up and join the conversation on Discord