From da8ab30364a01dddf7fabc2ae847eaafab8515ec Mon Sep 17 00:00:00 2001 From: Hurrison Date: Wed, 24 Apr 2024 07:38:26 +0800 Subject: [PATCH] fix: check aux length to avoid exception if aux is set to tuple() in the line above, aux[-1] will throw exception. `aux[-1] if aux else 0` will ensure aux is not None and its length is not 0 --- lwm/data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lwm/data.py b/lwm/data.py index a6cb177..c6c9b74 100644 --- a/lwm/data.py +++ b/lwm/data.py @@ -155,7 +155,7 @@ def __call__(self, example, has_aux=False, add_bos_token=True, add_eos_token=Tru example, *aux = example else: aux = tuple() - rand_state = random.Random(aux[-1]) # makes augmentations deterministic by line number + rand_state = random.Random(aux[-1] if aux else 0) # makes augmentations deterministic by line number token_buffer = [] loss_mask_buffer = [] vision_mask = []