| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Signed-off-by: jupyterjazz <saba.sturua@jina.ai>
Codecov ReportPatch coverage: 11.11% and project coverage change: -0.15 ⚠️ Additional details and impacted files @@ Coverage Diff @@
## main #1713 +/- ##
==========================================
- Coverage 85.50% 85.36% -0.15%
==========================================
Files 132 132
Lines 8308 8323 +15
==========================================
+ Hits 7104 7105 +1
- Misses 1204 1218 +14
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Sorry, something went wrong.
Signed-off-by: jupyterjazz <saba.sturua@jina.ai>
| find_res = self._hybrid_search(query) | ||
| return find_res | ||
|
|
||
| def _hybrid_search(self, query: List[Tuple[str, Dict]]) -> FindResult: |
There was a problem hiding this comment.
hybrid search is not that. This is find and filter, let's change the name of this method for clarity
Sorry, something went wrong.
There was a problem hiding this comment.
well technically it is but ok
Sorry, something went wrong.
There was a problem hiding this comment.
no, hybrid search is about mixing bm25 scores with embedding scores. Not about filtering + search
Sorry, something went wrong.
There was a problem hiding this comment.
I think hybrid search means combining more than one search methods. bm25 + vector search is just one case.
Even we use it like that 😄
https://docs.docarray.org/user_guide/storing/docindex/#hybrid-search-through-the-query-builder
Sorry, something went wrong.
Signed-off-by: jupyterjazz <saba.sturua@jina.ai>
There was a problem hiding this comment.
also test name to be changed
Sorry, something went wrong.
Signed-off-by: jupyterjazz <saba.sturua@jina.ai>
|
|
||
| def _find_and_filter(self, query: List[Tuple[str, Dict]]) -> FindResult: | ||
| """ | ||
| Executes a hybrid search on documents based on the provided query. |
There was a problem hiding this comment.
change docstring as well pls
Sorry, something went wrong.
There was a problem hiding this comment.
I think we should keep this term, we (and not only us) use it in docs and even though most ppl think of bm25 when talking about hybrid search, this is not wrong
Sorry, something went wrong.
There was a problem hiding this comment.
we use find and filter which is what it is
Sorry, something went wrong.
| """ | ||
| out_docs = self._docs | ||
| doc_to_score: Dict[BaseDoc, Any] = {} | ||
| limit = sys.maxsize |
There was a problem hiding this comment.
why don't u just do limit=10 here?
Sorry, something went wrong.
There was a problem hiding this comment.
I refactored limit logic, uses whatever is passed, and if nothing's passed goes with len(out_docs)
Sorry, something went wrong.
| index=out_docs, | ||
| query=op_kwargs['query'], | ||
| search_field=op_kwargs['search_field'], | ||
| limit=len(out_docs), |
There was a problem hiding this comment.
I think limit should be the limit obtained or the ln(out_docs) if no limit present
Sorry, something went wrong.
There was a problem hiding this comment.
good point, I think I made it too complicated
Sorry, something went wrong.
Signed-off-by: jupyterjazz <saba.sturua@jina.ai>
| doc_to_score.update(zip(out_docs.id, scores)) | ||
| elif op == 'filter': | ||
| out_docs = filter_docs(out_docs, op_kwargs['filter_query']) | ||
| out_docs = out_docs[: op_kwargs.get('limit', len(out_docs))] |
There was a problem hiding this comment.
check if limit is there before doing this, just for optimization
Sorry, something went wrong.
|
|
||
| def _find_and_filter(self, query: List[Tuple[str, Dict]]) -> FindResult: | ||
| """ | ||
| Executes a hybrid search on documents based on the provided query. |
There was a problem hiding this comment.
we use find and filter which is what it is
Sorry, something went wrong.
Signed-off-by: jupyterjazz <saba.sturua@jina.ai>
|
📝 Docs are deployed on https://ft-feat-inmemory-pre-filtering--jina-docs.netlify.app 🎉 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Support arbitrary number of find/filter operations for InMemoryExactNNIndex, enabling pre+post filtering
From now on, you can build queries like this:
Note:
how limits work
Since developers could provide limit in any component of the query, and we also had an internal default value for find, the results were confusing. What I'm doing is the following: I'm not applying any limits during the operations, but I'm remembering the lowest one provided, and apply that limit in the end.