Spaces:
Running
Running
| """M10 — HyperSteer: Transformer hypernetwork, no-context variant. | |
| Lightly-trained method using a small transformer to generate steering vectors. | |
| Using no-context variant due to GPU budget constraints. | |
| """ | |
| import numpy as np | |
| from src.methods.base import SteeringMethod | |
| class HyperSteer(SteeringMethod): | |
| """HyperSteer — Transformer hypernetwork (no-context variant).""" | |
| def __init__(self, **kwargs): | |
| self._trained = False | |
| self._direction: np.ndarray = None | |
| def name(self) -> str: | |
| return "HyperSteer" | |
| def method_id(self) -> str: | |
| return "M10" | |
| def is_training_free(self) -> bool: | |
| return False | |
| def extract_vector( | |
| self, | |
| h_pos: np.ndarray, | |
| h_neg: np.ndarray, | |
| **kwargs, | |
| ) -> np.ndarray: | |
| if self._direction is not None: | |
| return self._direction | |
| # Fallback | |
| from src.methods.diffmean import DiffMean | |
| return DiffMean().extract_vector(h_pos, h_neg) | |
| def train(self, train_data: dict) -> None: | |
| """Train HyperSteer hypernetwork. | |
| TODO: Implement no-context variant following AxBench/HyperSteer. | |
| Note: Using no-context variant due to GPU budget (24GB). | |
| """ | |
| raise NotImplementedError("HyperSteer training not yet implemented.") | |