marqo-ai / marqo

Unified embedding generation and search engine. Also available on cloud - cloud.marqo.ai
https://www.marqo.ai/
Apache License 2.0
4.66k stars 192 forks source link

[BUG] image search in the example code does not work as expected #978

Open barney2074 opened 2 months ago

barney2074 commented 2 months ago

Hi,

I'm just following the steps in https://docs.marqo.ai/latest/examples/marqo/image-search/

thanks for the tutorials- they are useful

Andrew

2024-09-20 15:54:19,251 logger:'marqo' INFO     add_documents batch 0: took 0.210s for Marqo to process & index 1 docs. Roundtrip time: 0.222s.
2024-09-20 15:54:19,483 logger:'marqo' INFO     add_documents batch 1: took 0.225s for Marqo to process & index 1 docs. Roundtrip time: 0.232s.
2024-09-20 15:54:19,663 logger:'marqo' INFO     add_documents batch 2: took 0.172s for Marqo to process & index 1 docs. Roundtrip time: 0.180s.
2024-09-20 15:54:19,871 logger:'marqo' INFO     add_documents batch 3: took 0.201s for Marqo to process & index 1 docs. Roundtrip time: 0.208s.
Traceback (most recent call last):
  File "/home/ub/marqo-env/lib/python3.10/site-packages/marqo/_httprequests.py", line 130, in _validate
    request.raise_for_status()
  File "/home/ub/marqo-env/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://localhost:8882/indexes/image-search/refresh

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ub/marqo/marqo-image.py", line 31, in <module>
    res = mq.index(index_name).add_documents(
  File "/home/ub/marqo-env/lib/python3.10/site-packages/marqo/index.py", line 410, in add_documents
    return self._add_docs_organiser(
  File "/home/ub/marqo-env/lib/python3.10/site-packages/marqo/index.py", line 466, in _add_docs_organiser
    res = self._batch_request(
  File "/home/ub/marqo-env/lib/python3.10/site-packages/marqo/index.py", line 621, in _batch_request
    self.refresh()
  File "/home/ub/marqo-env/lib/python3.10/site-packages/marqo/index.py", line 222, in refresh
    return self.http.post(path=F"indexes/{self.index_name}/refresh", index_name=self.index_name,)
  File "/home/ub/marqo-env/lib/python3.10/site-packages/marqo/_httprequests.py", line 96, in post
    return self.send_request('post', path, body, content_type, index_name=index_name)
  File "/home/ub/marqo-env/lib/python3.10/site-packages/marqo/_httprequests.py", line 70, in send_request
    return self._validate(response)
  File "/home/ub/marqo-env/lib/python3.10/site-packages/marqo/_httprequests.py", line 133, in _validate
    convert_to_marqo_error_and_raise(response=request, err=err)
  File "/home/ub/marqo-env/lib/python3.10/site-packages/marqo/_httprequests.py", line 147, in convert_to_marqo_error_and_raise
    raise MarqoWebError(message=response_msg, code=code, error_type=error_type,
marqo.errors.MarqoWebError: MarqoWebError: MarqoWebError Error message: {"detail":"Not Found"}
status_code: 404, type: unhandled_error_type, code: unhandled_error, link: 
papa99do commented 2 weeks ago

Hello @barney2074 , sorry for taking so long to respond. I wasn't able to reproduce this issue on the latest image. Could you give the latest image 2.13.1 a try and see if you still have this issue.

This issue might be related to the pymarqo version you use. Could you also upgrade the pymarqo to the latest version Please? Thanks a lot.

barney2074 commented 2 weeks ago

Hi @papa99do

that seems to have fixed it, thanks A question if I may: although the image search queries seem to get the best match, there is very little variation in the scores

For example, in this tutorial- the search "A rider on a horse jumping over the barrier" gets the best image at a score of 58%, but other images which have noting to do with the search term still get scores >50%

I would have expected much more variation in the scores e.g a positive would be much higher, and a completely different image would have a much lower score

Is this to be expected ?

Andrew