Skip to content

[Bug]: When calling slingua through PromptCompressor, use_llmlingua2 should also be set to true. #235

@bzamanlooy

Description

@bzamanlooy

Describe the bug

PromptCompressor(
        model_name="SecurityLingua/securitylingua-xlm-s2s",
        use_slingua=True, 
    )

on its own produces the error:

TypeError: XLMRobertaForTokenClassification.forward() got an unexpected keyword argument 'past_key_values'

.
The solution is to either call:

PromptCompressor(
        model_name="SecurityLingua/securitylingua-xlm-s2s",
        use_slingua=True, 
        use_llmlingua2=True,
    )

or modify prompt_compressor.py to have

        if self.use_llmlingua2 **or self.use_slingua:**
            return self.compress_prompt_llmlingua2(
                context,
                rate=rate,
                target_token=target_token,
                use_context_level_filter=use_context_level_filter,
                use_token_level_filter=use_token_level_filter,
                target_context=target_context,
                context_level_rate=context_level_rate,
                context_level_target_token=context_level_target_token,
                force_context_ids=force_context_ids,
                return_word_label=return_word_label,
                word_sep=word_sep,
                label_sep=label_sep,
                token_to_word=token_to_word,
                force_tokens=force_tokens,
                force_reserve_digit=force_reserve_digit,
                drop_consecutive=drop_consecutive,
                chunk_end_tokens=chunk_end_tokens,
            )

Steps to reproduce

No response

Expected Behavior

No response

Logs

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions