diff --git a/concept_attention.py b/concept_attention.py index 97c48b3..e7353da 100644 --- a/concept_attention.py +++ b/concept_attention.py @@ -476,9 +476,9 @@ class ConceptAttentionProcessor: if hasattr(self.concept_attention, 'attention_hooks') and self.concept_attention.attention_hooks: logger.info(f"Found {len(self.concept_attention.attention_hooks)} registered hooks") - # Try to find the modules that have hooks and call them directly - for name, module in actual_model.named_modules(): - if any(keyword in name.lower() for keyword in ['attention', 'attn', 'query', 'key', 'value', 'proj']): + # Try to find the modules that have hooks and call them directly + for name, module in actual_model.named_modules(): + if any(keyword in name.lower() for keyword in ['attention', 'attn', 'query', 'key', 'value', 'proj']): # Check if this module has a hook if hasattr(module, '_forward_hooks') and module._forward_hooks: logger.info(f"Module {name} has {len(module._forward_hooks)} hooks") @@ -504,7 +504,7 @@ class ConceptAttentionProcessor: except Exception as hook_error: logger.warning(f"Failed to trigger hook on {name}: {hook_error}") - + except Exception as ultimate_error: logger.warning(f"Ultimate hook triggering failed: {ultimate_error}")