Commit 684b6b5
Fix smart_batching_collate Inefficiency (#2556)
* Fix smart_batching_collate Inefficiency
SentenceTransformer.py:846 throws a Inefficiency warning:
".....Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor. (Triggered internally at ../torch/csrc/utils/tensor_new.cpp:275.) labels = torch.tensor([example.label for example in batch])"
* Update SentenceTransformer.py
* Remove some comments; add edge case (if labels is empty)
---------
Co-authored-by: Tom Aarsen <[email protected]>1 parent 5f75ce5 commit 684b6b5
1 file changed
+10
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1000 | 1000 | | |
1001 | 1001 | | |
1002 | 1002 | | |
1003 | | - | |
1004 | | - | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
1005 | 1013 | | |
1006 | 1014 | | |
1007 | 1015 | | |
| |||
0 commit comments