[Question]: error when compressing long prompt with LLMLingua1 & LongLLMLingua
While compressing longer prompt (tokens > 500), will get this error: Traceback (most recent call last): File "/opt/tiger/mariana/lingua1_test.py", line 6, in compressed_prompt = llm_lingua.compress_prompt(original_prompt, instruction="", question="", rate=0.4) File "/usr/local/lib/python3.9/dist-packages/llmlingua/prompt_compressor.py", line 682, in compress_prompt context = self.iterative_compress_prompt( File "/usr/local/lib/python3.9/dist-packages/llmlingua/prompt_compressor.py", line 1636, in iterative_compress_prompt loss, past_key_values = self.get_ppl( File "/usr/local/lib/python3.9/dist-packages/llmlingua/prompt_compressor.py", line 187, in get_ppl response = self.model( File "/usr/local/lib/python3.9/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/transformers/models/llama/modeling_llama.py", line 834, in forward outputs = self.model( File "/usr/local/lib/python3.9/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/transformers/models/llama/modeling_llama.py", line 554, in forward past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0 AttributeError: 'list' object has no attribute 'get_seq_length'
My code is: original_prompt = 'Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n Here is the long text.\n '
llm_lingua = PromptCompressor() compressed_prompt = llm_lingua.compress_prompt(original_prompt, instruction="", question="", rate=0.4)
Source: microsoft/LLMLingua