feat: Implementation of embed_and_evaluate#702
Conversation
|
This is only a draft atm. I have to add more tests, benchmark the memory usage, add add documentation if everything seems to work well. |
Codecov Report
@@ Coverage Diff @@
## main #702 +/- ##
==========================================
+ Coverage 85.95% 88.16% +2.20%
==========================================
Files 133 133
Lines 6538 6600 +62
==========================================
+ Hits 5620 5819 +199
+ Misses 918 781 -137
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
samsja
left a comment
There was a problem hiding this comment.
lgtm, could we change the docstring of embed to mention that this new method exist and should be used when the user need to do embed and eval directly ?
docarray/array/mixins/evaluation.py
Outdated
| **kwargs, | ||
| ) -> Optional[Union[float, List[float]]]: # average for each metric | ||
| """ | ||
| Computes ranking evaluation metrics for a given `DocumentArray`. Moreover, this |
| is possible with the :func:``evaluate`` function. | ||
|
|
||
| :param metrics: List of metric names or metric functions to be computed | ||
| :param index_data: The other DocumentArray to match against, if not given, |
There was a problem hiding this comment.
can we describe what it means match against itself ? Will all of the document inside the da will be match over all the other one ? Or does is split the da in query, index randomly and perform the search from query to index ?
There was a problem hiding this comment.
Ok, yes I can explain this. Atm everything it will match everything against everything. I might do another small PR afterwards, to enable sampling.
There was a problem hiding this comment.
match everything against everything is not tracktable tbh, why not just do the sampling right now ?
There was a problem hiding this comment.
Note: We discussed that it might make sense, but it is better to implement it in this PR to avoid a breaking change.
| 'Either a ground_truth `DocumentArray` or labels are ' | ||
| 'required for the evaluation.' | ||
| ) | ||
| if not label_tag in index_data[0].tags: |
There was a problem hiding this comment.
technically we need to do this for all of the document in index_data ...
There was a problem hiding this comment.
Yes, but I don't think it is necessary to do a full data validation. If a user provides only partly labels, I think it is ok if it crashes with a key error.
There was a problem hiding this comment.
@JohannesMessner @alaeddine-13 what is your opinion here ? For me it is either we do it for every doc on we don't do validation but I might be wrong
|
📝 Docs are deployed on https://ft-feat-add-embed-and-evaluate-function--jina-docs.netlify.app 🎉 |
Goals:
Example Code:
Reduction of memory usage when evaluating 100 query vectors against 500,000 index vectors with 500 dimensions:
Manual Evaluation:
Evaluation with `embed_and_evaluate (batch_size 100,000):