AnswerDotAI/rerankers

cross-encoders fail with single document: AttributeError: 'Result' object has no attribute 'results'

Closed this issue · 1 comments

docs = ["foo"] breaks
docs = ["foo", ""] works

  File "/Users/taras/Documents/onnx/tagging.py", line 52, in <listcomp>
    for result in r.rank(query=tag, docs=docs).results
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/taras/Documents/onnx/.pixi/env/lib/python3.11/site-packages/pydantic/main.py", line 767, in __getattr__
    raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'Result' object has no attribute 'results'

Thank you for flagging. This is because it defaults to returning a Result rather a RankedResults object when only ranking a single document, but that's actually counter-intuitive behaviour as most people wouldn't expect the output format to change. Fixed in 0.1.2post1/#9