stylsteer-vlm / src /methods /prompt_base.py
abka03's picture
Deploy StyleSteer-VLM demo
e6f24ae verified
"""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.
"""
@property
def name(self) -> str:
return "PromptBase"
@property
def method_id(self) -> str:
return "M0"
@property
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
@staticmethod
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}"
)