From a7f77fd86e1841763596ac7743dc4fb9f0ca60dc Mon Sep 17 00:00:00 2001 From: Gabriele Sarti Date: Thu, 14 Mar 2024 18:57:12 +0100 Subject: [PATCH] Strip prepended whitespace in --- inseq/commands/attribute_context/attribute_context.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inseq/commands/attribute_context/attribute_context.py b/inseq/commands/attribute_context/attribute_context.py index 1469f2f..a267fec 100644 --- a/inseq/commands/attribute_context/attribute_context.py +++ b/inseq/commands/attribute_context/attribute_context.py @@ -152,10 +152,10 @@ def attribute_context_with_model(args: AttributeContextArgs, model: HuggingfaceM ) # Part 2: Contextual Cues Imputation (CCI) for cci_step_idx, (cti_idx, cti_score, cti_tok) in enumerate(cti_ranked_tokens): - contextual_input = model.convert_tokens_to_string(input_full_tokens, skip_special_tokens=False) + contextual_input = model.convert_tokens_to_string(input_full_tokens, skip_special_tokens=False).lstrip(" ") contextual_output = model.convert_tokens_to_string( output_full_tokens[: output_current_text_offset + cti_idx + 1], skip_special_tokens=False - ) + ).lstrip(" ") if not contextual_output: contextual_output = output_full_tokens[output_current_text_offset + cti_idx]