능동 학습
Potato에서 5가지 능동 학습 전략(불확실성 샘플링, BADGE, BALD, 다양성 기반, 하이브리드 앙상블)을 사용하여 어노테이션 비용을 최대 50%까지 줄이십시오.
능동 학습은 가장 유익한 예시를 우선시하여 더 똑똑하게 어노테이션하도록 돕습니다. 무작위로 어노테이션하는 대신, 모델이 가장 불확실해하는 인스턴스에 집중하십시오.
작동 방식
Potato의 능동 학습은 머신러닝 예측을 기반으로 어노테이션 인스턴스의 순서를 자동으로 재조정합니다:
- 초기 수집 - 최소 개수의 어노테이션을 모읍니다
- 학습 - 기존 어노테이션으로 분류기를 학습시킵니다
- 예측 - 어노테이션되지 않은 인스턴스에 대한 불확실성 점수를 얻습니다
- 재정렬 - 불확실성이 가장 높은 인스턴스를 우선시합니다
- 어노테이션 - 어노테이터가 우선순위가 매겨진 인스턴스에 레이블을 답니다
- 재학습 - 새 어노테이션으로 모델을 주기적으로 업데이트합니다
설정
기본 설정
yaml
active_learning:
enabled: true
schema_names:
- sentiment # Which annotation schemes to use
min_annotations_per_instance: 1
min_instances_for_training: 20
update_frequency: 50 # Retrain after every 50 annotations
max_instances_to_reorder: 1000전체 설정
yaml
active_learning:
enabled: true
# Which schemas to use for training
schema_names:
- sentiment
# Minimum requirements
min_annotations_per_instance: 1
min_instances_for_training: 20
# Retraining frequency
update_frequency: 50
# How many instances to reorder
max_instances_to_reorder: 1000
# Classifier configuration
classifier_name: sklearn.linear_model.LogisticRegression
classifier_params:
C: 1.0
max_iter: 1000
# Query strategy
query_strategy: uncertainty # uncertainty, diversity, badge, bald, hybrid
# Feature extraction
vectorizer:
type: TfidfVectorizer
params:
max_features: 5000
ngram_range: [1, 2]
# Model persistence
model_persistence:
enabled: true
save_dir: "models/"
max_saved_models: 5쿼리 전략
Potato는 가장 유익한 인스턴스를 선택하기 위한 다섯 가지 쿼리 전략을 지원합니다:
| 전략 | 설명 |
|---|---|
uncertainty | 모델이 가장 확신하지 못하는 인스턴스를 선택합니다 (기본값) |
diversity | 이미 어노테이션된 데이터와 가장 다른 인스턴스를 선택합니다 |
badge | Batch Active learning by Diverse Gradient Embeddings |
bald | Bayesian Active Learning by Disagreement |
hybrid | 여러 전략을 결합한 앙상블 |
yaml
active_learning:
query_strategy: uncertainty # or diversity, badge, bald, hybrid지원되는 분류기
분류기는 classifier_name을 통해 전체 sklearn 임포트 경로로 지정합니다:
| 분류기 | sklearn 경로 | 적합한 용도 | 속도 |
|---|---|---|---|
| 로지스틱 회귀 | sklearn.linear_model.LogisticRegression | 이진/다중 클래스 분류 | 빠름 |
| 랜덤 포레스트 | sklearn.ensemble.RandomForestClassifier | 복잡한 패턴 | 보통 |
| SVC | sklearn.svm.SVC | 소규모 데이터셋 | 느림 |
| 다항 NB | sklearn.naive_bayes.MultinomialNB | 텍스트 분류 | 매우 빠름 |
분류기 예시
yaml
# Logistic Regression (recommended starting point)
classifier_name: sklearn.linear_model.LogisticRegression
classifier_params:
C: 1.0
max_iter: 1000
# Random Forest
classifier_name: sklearn.ensemble.RandomForestClassifier
classifier_params:
n_estimators: 100
max_depth: 10
# Support Vector Classifier
classifier_name: sklearn.svm.SVC
classifier_params:
kernel: rbf
probability: true
# Naive Bayes
classifier_name: sklearn.naive_bayes.MultinomialNB
classifier_params:
alpha: 1.0벡터라이저
| 벡터라이저 | 설명 |
|---|---|
TfidfVectorizer | TF-IDF 가중 특징 (권장) |
CountVectorizer | 단순 단어 빈도 |
HashingVectorizer | 대규모 어휘에 메모리 효율적 |
yaml
# TF-IDF (recommended)
vectorizer:
type: TfidfVectorizer
params:
max_features: 5000
ngram_range: [1, 2]
stop_words: english
# Count Vectorizer
vectorizer:
type: CountVectorizer
params:
max_features: 3000
ngram_range: [1, 1]
# Hashing Vectorizer (for large datasets)
vectorizer:
type: HashingVectorizer
params:
n_features: 10000LLM 통합
능동 학습은 향상된 인스턴스 선택을 위해 선택적으로 LLM을 사용할 수 있습니다:
yaml
active_learning:
enabled: true
schema_names:
- sentiment
# LLM-based selection
llm_integration:
enabled: true
endpoint_type: vllm
base_url: http://localhost:8000/v1
model: meta-llama/Llama-2-7b-chat-hf
# Mock mode for testing
mock_mode: false다중 스키마 지원
능동 학습은 여러 어노테이션 스키마를 순환할 수 있습니다:
yaml
annotation_schemes:
- annotation_type: radio
name: sentiment
labels: [Positive, Negative, Neutral]
- annotation_type: radio
name: topic
labels: [Politics, Sports, Tech, Entertainment]
active_learning:
enabled: true
schema_names:
- sentiment
- topic
# Schema-specific settings
schema_config:
sentiment:
min_instances_for_training: 30
update_frequency: 50
topic:
min_instances_for_training: 50
update_frequency: 100모델 영속성
학습된 모델을 서버 재시작 사이에 저장하고 다시 불러옵니다:
yaml
active_learning:
enabled: true
schema_names:
- sentiment
model_persistence:
enabled: true
save_dir: "models/"
max_saved_models: 5 # Keep last 5 models
# Save to database instead of files
use_database: false진행 상황 모니터링
관리자 대시보드는 능동 학습 지표를 추적합니다:
- 현재 모델 정확도
- 학습 주기 횟수
- 불확실성 분포
- 남은 인스턴스
- 재학습 이력
관리자 API 키로 /admin에서 접근하십시오.
모범 사례
1. 무작위 샘플링으로 시작하기
능동 학습을 활성화하기 전에 초기 어노테이션을 확보하십시오:
yaml
active_learning:
enabled: true
min_instances_for_training: 50 # Wait for 50 annotations2. 적절한 분류기 선택하기
- LogisticRegression: 빠르며, 대부분의 작업에 좋은 기본값
- RandomForest: 복잡한 패턴에 더 적합하지만 느림
- MultinomialNB: 매우 빠르며, 간단한 텍스트 분류에 적합
3. 클래스 분포 모니터링하기
능동 학습은 클래스 불균형을 만들 수 있습니다. 관리자 대시보드에서 모니터링하고 계층화 샘플링을 고려하십시오.
4. 합리적인 재학습 빈도 설정하기
너무 잦은 재학습은 리소스를 낭비합니다:
yaml
update_frequency: 100 # Retrain every 100 annotations5. 모델 영속성 활성화하기
재시작 시 처음부터 다시 학습하지 않도록 모델을 저장하십시오:
yaml
model_persistence:
enabled: true
save_dir: "models/"예시: 전체 설정
yaml
annotation_task_name: "Sentiment Analysis with Active Learning"
task_dir: "."
port: 8000
data_files:
- "data/reviews.json"
item_properties:
id_key: id
text_key: text
annotation_schemes:
- annotation_type: radio
name: sentiment
description: "What is the sentiment?"
labels:
- Positive
- Negative
- Neutral
active_learning:
enabled: true
schema_names:
- sentiment
min_annotations_per_instance: 1
min_instances_for_training: 30
update_frequency: 50
max_instances_to_reorder: 500
classifier_name: sklearn.linear_model.LogisticRegression
classifier_params:
C: 1.0
max_iter: 1000
query_strategy: uncertainty
vectorizer:
type: TfidfVectorizer
params:
max_features: 3000
ngram_range: [1, 2]
model_persistence:
enabled: true
save_dir: "models/"
max_saved_models: 3
output_annotation_dir: "output/"
export_annotation_format: "json"
user_config:
allow_all_users: trueAI 지원과 결합하기
능동 학습과 LLM 지원을 함께 사용하십시오:
yaml
active_learning:
enabled: true
schema_names:
- sentiment
min_instances_for_training: 30
ai_support:
enabled: true
endpoint_type: openai
ai_config:
model: gpt-4
api_key: ${OPENAI_API_KEY}
features:
label_suggestions:
enabled: true이 조합은 불확실한 인스턴스를 우선시하면서 어노테이터를 돕는 AI 힌트를 제공합니다.
문제 해결
학습 실패
- 충분한 어노테이션을 확보하십시오 (
min_instances_for_training) - 클래스 분포를 확인하십시오 - 모든 클래스의 예시가 필요합니다
- 데이터 형식이 스키마와 일치하는지 확인하십시오
느린 성능
max_instances_to_reorder를 줄이십시오update_frequency를 늘리십시오- 대규모 어휘에는
HashingVectorizer를 사용하십시오
모델이 업데이트되지 않음
update_frequency설정을 확인하십시오- 어노테이션이 저장되고 있는지 확인하십시오
- 관리자 대시보드에서 오류를 검토하십시오
더 읽어보기
구현 세부 정보는 원본 문서를 참고하십시오.