Steering Vectors
스티어링 벡터가 재학습 없이 실시간으로 신경망을 제어하는 방법을 알아보세요. Ultralytics YOLO26을 사용한 활성화 엔지니어링을 학습하세요.
Steering vectors represent meaningful, mathematical directions within the hidden activation space of a neural network that correspond to high-level concepts, such as "politeness," "truthfulness," or specific visual features. By artificially injecting or subtracting these vectors from the model's internal states during the forward pass, developers can predictably control and alter the model's behavior without updating any underlying weights. This technique, fundamentally rooted in Activation Engineering, provides zero-cost, inference-time control over deep learning systems ranging from large language models to vision architectures.
Link to this sectionSteering Vectors의 작동 원리#
Steering vector를 생성하기 위해 연구자들은 일반적으로 Contrastive Activation Addition (CAA)이라고 불리는 방법을 사용합니다. 이는 모델에게 "도움이 되는" 프롬프트와 "해로운" 프롬프트를 요청하는 것과 같은 대조적인 데이터 쌍 세트를 네트워크에 통과시키는 과정을 포함합니다. 이 쌍들 사이의 activation function 출력 차이를 여러 샘플에 걸쳐 평균화하여 tensor space에서 해당 개념을 나타내는 특정 기하학적 방향을 추출합니다.
real-time inference 동안, 이 벡터는 간단한 PyTorch tensor addition을 사용하여 특정 레이어의 은닉 상태에 더하거나 뺄 수 있습니다. 벡터의 강도를 조절함으로써 실무자는 주입된 동작의 강도를 미세 조정할 수 있습니다.
Link to this sectionSteering Vectors와 관련 개념의 차이점#
Steering vectors가 더 넓은 machine learning 환경에서 어떻게 위치하는지 이해하려면 유사한 방법론들과 구분해야 합니다:
- Task Vectors: Task vectors는 학습 후 실제 model weights를 수정하여 기능을 병합하는 방식으로 가중치 공간에서 작동하지만, steering vectors는 런타임 시 활성화 공간에서 엄격하게 작동하므로 원본 가중치는 전혀 건드리지 않습니다.
- Representation Engineering (RepE): RepE는 Center for AI Safety와 같은 조직에서 집중적으로 연구하는, 내부 인지 상태를 읽고 제어하는 포괄적인 방법론적 프레임워크입니다. Steering vectors는 RepE의 제어 단계에서 사용되는 구체적인 수학적 도구입니다.
- Prompt Engineering: 프롬프트 엔지니어링은 사용자의 입력 텍스트나 이미지를 수정하여 동작을 유도합니다. Steering vectors는 이러한 입력 병목 현상을 우회하여 모델의 내부 인지 처리를 직접 조작합니다.
- Fine-Tuning: 인간 피드백을 통한 강화 학습(RLHF)과 같은 전통적인 정렬 방법은 경사 하강법을 통해 모델을 영구적으로 변경하며, 종종 Ultralytics Platform과 같은 클라우드 도구를 통해 관리되는 막대한 컴퓨팅 자원이 필요합니다. Steering vectors는 이러한 컴퓨팅 오버헤드를 완전히 방지합니다.
Link to this sectionAI의 실제 응용 사례#
모델을 동적으로 제어할 수 있는 능력은 현대 artificial intelligence 파이프라인 전반에 걸쳐 상당한 발전을 가져왔습니다:
- Enhancing AI Safety: "거부" 또는 "무해함"과 관련된 steering vector를 추출함으로써, 엔지니어는 모델이 악의적인 지시를 거부하도록 강제할 수 있습니다. OpenAI's alignment research와 Anthropic의 해석 가능성 연구의 지원을 받아 특정 기능을 제어함으로써 AI의 대화 페르소나를 획기적으로 변경하고 엄격한 안전 가드레일을 보장할 수 있습니다.
- Controlling Reasoning Models: 고급 사고 아키텍처에 대한 최근 연구는 steering vectors가 내부 추론 체인을 변조할 수 있음을 보여줍니다. 실무자는 복잡한 문제 해결 과정에서 모델이 불확실성을 표현하거나 오류를 수정하려는 경향을 높일 수 있습니다.
- Mitigating AI Bias: 특정 사회적 편향을 나타내는 벡터를 추출함으로써 개발자는 생성 과정 중에 이 방향을 뺄 수 있습니다. 이는 재학습 없이 편향을 효과적으로 중화하고 공정성을 개선하는 동시에 hallucination in LLMs 발생 가능성을 줄입니다.
- Steering Computer Vision Systems: 비전 모델에서 steering vectors는 네트워크가 중요한 대상에 대한 민감도를 인위적으로 높이도록 특징 맵에 적용될 수 있습니다. 예를 들어, object detection 모델은 악천후 조건에서 보행자를 찾는 데 우선순위를 두도록 제어될 수 있습니다.
Link to this sectionPyTorch를 사용한 Steering Vectors 적용#
다음은 순전파 중에 Ultralytics YOLO26 모델에 활성화 제어 개입을 적용하는 실행 가능한 예시입니다. PyTorch forward hooks를 활용하여 사용자 지정 벡터를 은닉 레이어에 직접 주입할 수 있습니다.
import torch
from ultralytics import YOLO
# Load the recommended Ultralytics YOLO26 model for state-of-the-art vision tasks
model = YOLO("yolo26n.pt")
# Define a hook function to steer the internal activations
def steer_activations_hook(module, input, output):
# Create a steering vector matching the output shape (for demonstration purposes)
# In practice, this vector is pre-computed via Contrastive Activation Addition (CAA)
steering_vector = torch.ones_like(output) * 0.1
# Add the steering vector to the model's hidden states to alter behavior at inference
return output + steering_vector
# Attach the hook to a middle layer (e.g., layer index 5) to inject the vector
handle = model.model.model[5].register_forward_hook(steer_activations_hook)
# Run inference on an image with the dynamically steered activations
results = model("https://ultralytics.com/images/bus.jpg")
# Remove the hook to restore the model to its original unsteered state
handle.remove()





