From 48e9b54ce4b65fac1743a5fb015a0532c5e1b9ed Mon Sep 17 00:00:00 2001 From: Pere Lluis Date: Mon, 23 Sep 2024 21:01:31 +0200 Subject: [PATCH] FIx https://github.com/SapienzaNLP/relik/issues/7 Fix https://github.com/SapienzaNLP/relik/issues/7 This was a fun one, had a missing len() which caused relation candidates to be 0 when candidates are trimmed due to max_length. Due to an older version of pytorch having issues with 0 dimensional tensors with einsum, it cause issues to some people on Colab. --- relik/reader/data/relik_reader_re_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relik/reader/data/relik_reader_re_data.py b/relik/reader/data/relik_reader_re_data.py index 84a8d58..b2a8fff 100644 --- a/relik/reader/data/relik_reader_re_data.py +++ b/relik/reader/data/relik_reader_re_data.py @@ -730,7 +730,7 @@ def flip_cands(flip_candidates, candidates): candidates_encoding_result = ( candidates_encoding_result[:i] - + candidates_encoding_result[len(sample.span_candidates) : i] + + candidates_encoding_result[len(sample.span_candidates) : len(sample.span_candidates) + i] ) if len(self.special_symbols_types) > 0: candidates_entities_symbols = candidates_entities_symbols[:i]