liyucheng09 / Selective_Context

Compress your input to ChatGPT or other LLMs, to let them process 2x more content and save 40% memory and GPU time.
310 stars 14 forks source link

Fix AttributeError: 'SelectiveContext' object has no attribute 'keep_… #5

Closed pratik3558 closed 1 year ago

pratik3558 commented 1 year ago

This PR fixes the below issues of uninitialized variables keep_leading_word mask_token

 File "src/dependency_injector/_cwiring.pyx", line 28, in dependency_injector._cwiring._get_sync_patched._patched

                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.11/site-packages/selective_context/__init__.py", line 287, in __call__
    context, masked_sents = self.self_info_mask(lexical_level[reduce_level].text, lexical_level[reduce_level].self_info, reduce_level)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "python3.11/site-packages/selective_context/__init__.py", line 250, in self_info_mask
    sents_after_mask.append(self.mask_a_sent(sent, mask_level))
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "python3.11/site-packages/selective_context/__init__.py", line 261, in mask_a_sent
    if self.keep_leading_word:
       ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SelectiveContext' object has no attribute 'keep_leading_word'
 File "/python3.11/site-packages/selective_context/__init__.py", line 288, in __call__
    context, masked_sents = self.self_info_mask(lexical_level[reduce_level].text, lexical_level[reduce_level].self_info, reduce_level)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "python3.11/site-packages/selective_context/__init__.py", line 251, in self_info_mask
    sents_after_mask.append(self.mask_a_sent(sent, mask_level))
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "python3.11/site-packages/selective_context/__init__.py", line 266, in mask_a_sent
    return leading_few_words + self.mask_token
pratik3558 commented 1 year ago

@liyucheng09 Could you review it whenever you get a chance please?