How can I get Weaviate to return a fixed text string previously associated with another vectorized string?

132 views Asked by At

I am trying to use Weaviate as a cache whereby I create an object comprising a text "key" in vector form and an associated text string value (not in vector form), so that I can later query a possibly similar key text string object and if this is present and sufficiently similar then to take its associated value object.

In practice, the "key" of the stored value will be a suitable concatenation of text previously submitted to OpenAI GPT and the corresponding value that GPT returned. So the idea is to use Weaviate as a cache to avoid having to make GPT calls for obviously similar text which (I can assume) would if provided to GPT return the same answer.

But I am having trouble finding the correct Weaviate incantation to achieve this. I am only really using Weaviate for text similarity, but the documentation suggests it will want to try and be "too clever" and treat the text semantically, like a question and answer for example. But I'm OK with the semantic aspect, provided it achieves my goal.

I have to use Weaviate BTW, as the client requires it. So replies along the lines of "Weaviate is the wrong tool for this" will not be helpful, even if they are correct! :-)

Any ideas? TIA

Edit:

It looks like this may be quite close to what I am looking for, although I don't like the sound of all that BERT stuff the author mentions!

https://github.com/weaviate/weaviate-examples/tree/main/text-search-with-own-vectors

I think am really just looking for a loose text matcher, rather than a sophisticated language aware matcher, because my concatenated text may not be entirely in the form of cogent sentences.

1

There are 1 answers

1
hsm207 On

if you "don't like the sound of all that BERT stuff the author mentions", then you can just use BM25 for the search:

https://weaviate.io/developers/weaviate/api/graphql/search-operators#bm25