Weaviate classifier via query

Hi all,

How can I implement a classifier that can return a class for an arbitrary query without actually saving the object to Weaviate?

Example (theoretical): I have a Comment class that have the following fields: content , which it the comment itself, and sentiment , which can be of positive , neutral or negative values.

Let’s say I create a referenced class named Sentiment with the abovementioned values as objects, and link them to the Comment class.

Then I have a training data of, say, 1000 comments with given content and sentiment already defined, and loaded into Weavaite.

If I understand correctly, I use the /v1/classification endpoint to classify the already existing data (1000 comments) and wait till its completion.

Now I would like to query the Comment class with some new comment without saving it to Weaviate, and return the sentiment value of this comment based on the training examples provided.

How can I do that?

I also checked this toxic comment example:

but in this example they just load the data into Weaviate and query it right away with the nearText without calling the classification endpoint. So I’m not sure which classification technique from REST - /v1/classification | Weaviate - vector database this relates to.

Hi @evenfrost !!

I have recently crafted a zeroshot classification recipe here.

I just added a new recipe using KNN classification:

For the query part, you can use the near_text at the Comments class passing the comment you want to evaluate, and get the X closest comments.

For instance, a query that would work with the mentioned recipe:

    "Comment", "body sentiment{... on Sentiment{name}}"
    {"concepts": "My first day at that job was terrible"}

let me know if that helps :slight_smile:

Hey, thanks for the example, I’m looking into it.

I have one question so far. What is the trained_sentiment property in the Comment class? I don’t see the reference to it later in the code.

Oops :slight_smile:

I was storing this before and forgot to remove it. :grimacing:

I plan on evolving this example to show how to add a second batch of data and scheduling the classification only for those without a sentiment.

Thanks for pointing it out! :handshake:

So I tried to run the classification, and the first one I ran hit a timeout on the request, so I wasn’t able to retrieve its ID (as there is no endpoint to list all the classifications, you have to provide an ID).

So I ran the classification again, and it failed with the error:

classification failed: no classes to be classified - did you run a previous classification already?

I then tried to delete and recreate all the classes and ran it again, and got the same error. Since there is no seemingly possible way to delete classifications, I’m kinda stuck in the dead end here.

Maybe you know what I can do here?

I’ve also created an issue for it: Classifications broken with the error 'classification failed: no classes to be classified' · Issue #3723 · weaviate/weaviate · GitHub.