microsoft / microsoft/LLMLingua
[Question]: error when compressing long prompt with LLMLingua1 & LongLLMLingua
@iofu728 is already working on this.
Since Jul 3, 2025.
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 428
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 1
Description
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)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.