how to rank cross model matches in the client CLIP as service according to Clip scores in Jina?

Question:

I am using CLIP-as-service client API for uploading text and images to server. I need to rank images and text data based on match scores.

Do CLIP supports ranking feature? What would be the syntax for this?

Asked By: Marisa783

||

Answers:

Yes. Clip-as-a-service Client API supports the ranking feature and more about the syntax is available in the documentation.

https://clip-as-service.jina.ai/user-guides/client/#ranking

Also, ranking works well with both images and text.

Answered By: Sriniketh J

Yes, you can rank based on the match scores. Example syntax-

from docarray import Document

d = Document(
    uri='.github/README-img/rerank.png',
    matches=[
        Document(text=f'a photo of a {p}')
        for p in (
            'control room',
            'lecture room',
            'conference room',
            'podium indoor',
            'television studio',
        )
    ],
)

Once you feeded documents with the list you can call rank function.

from clip_client import Client

c = Client(server='grpc://0.0.0.0:23456')
r = c.rank([d])

print(r['@m', ['text', 'scores__clip_score__value']])

Learn more here.

Answered By: yoshihiko.kamimura
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.