Spaces:
Sleeping
Sleeping
| """M0 — PromptBase: Prompt-only baseline with no activation intervention.""" | |
| from typing import Optional | |
| import numpy as np | |
| from src.methods.base import SteeringMethod | |
| class PromptBase(SteeringMethod): | |
| """Append style keyword + definition to the prompt; no steering vector. | |
| This is the baseline that all steering methods should beat. | |
| """ | |
| def name(self) -> str: | |
| return "PromptBase" | |
| def method_id(self) -> str: | |
| return "M0" | |
| def is_training_free(self) -> bool: | |
| return True | |
| def extract_vector( | |
| self, | |
| h_pos: np.ndarray, | |
| h_neg: np.ndarray, | |
| **kwargs, | |
| ) -> Optional[np.ndarray]: | |
| """PromptBase has no steering vector — returns None.""" | |
| return None | |
| def build_prompt(base_prompt: str, style: str, style_definition: str) -> str: | |
| """Build a style-conditioned prompt. | |
| Args: | |
| base_prompt: The base captioning prompt | |
| style: Style name (e.g., "poetic") | |
| style_definition: Style definition from styles.yaml | |
| Returns: | |
| Prompt with style instruction appended | |
| """ | |
| return ( | |
| f"{base_prompt}\n" | |
| f"Please describe this image in a {style} style. " | |
| f"{style}: {style_definition}" | |
| ) | |