representation-engineering icon indicating copy to clipboard operation
representation-engineering copied to clipboard

Missing _use_flash_attention_2 in Llama Model with ContrastVecLlamaForCausalLM

Open slfg opened this issue 1 year ago • 1 comments

Hello, I encountered an error while following the honesty_contrast_vec_TQA_mc example. When using the ContrastVecLlamaForCausalLM class with the Llama-2-7b-hf model (I also tested with Llama-2-7b-chat-hf), I received the following error:

   1727             if name in modules:
   1728                 return modules[name]
-> 1729         raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
   1730 
   1731     def __setattr__(self, name: str, value: Union[Tensor, 'Module']) -> None:

AttributeError: 'LlamaModel' object has no attribute '_use_flash_attention_2'

This error occurred at the following line:

model_baseline_acc = get_tqa_accuracy(model, questions, answers, labels, tokenizer, batch_size=batch_size)

I tried downgrading and upgrading the relevant packages (transformers, torch and accelerate) without success.

Environment Details

  • Transformers version: Between 4.45.2 and 4.42.3
  • Torch version: Between 2.5.0+cu124 and 2.4.0
  • Accelerate version: Between 1.0.1 and 0.31.0
  • torch_dtype: bfloat16 and float16

slfg avatar Oct 22 '24 05:10 slfg

I encountered the same error, but I don't have any idea (

NaOH678 avatar Dec 04 '24 08:12 NaOH678