능동 학습
모델 불확실성에 따라 Potato의 어노테이션 대기열 순서를 바꿉니다. 다섯 가지 쿼리 전략, sklearn 분류기, 콜드 스타트 처리, 재시작 후에도 유지되는 모델 영속성을 지원합니다.
능동 학습은 어노테이션 대기열의 순서를 바꿔서, 코퍼스가 들어온 순서대로 작업하는 대신 모델이 가장 확신하지 못하는 인스턴스를 어노테이터에게 먼저 보여 줍니다.
작동 방식
- 수집: 초기 어노테이션 세트를 모읍니다
- 학습: 지금까지 레이블이 달린 데이터로 분류기를 학습시킵니다
- 점수화: 레이블이 없는 풀을 불확실성으로 점수화합니다
- 재정렬: 가장 불확실한 인스턴스가 앞에 오도록 대기열을 재정렬합니다
- 어노테이션: 우선순위가 매겨진 인스턴스를 어노테이션합니다
- 재학습: 어노테이션이 쌓이면 주기적으로 다시 학습합니다
모델이 가장 많이 배우는 곳에 주석 노력을 투입
설정
기본 설정
active_learning:
enabled: true
schema_names:
- sentiment
min_annotations_per_instance: 1
min_instances_for_training: 20
update_frequency: 50
max_instances_to_reorder: 1000min_instances_for_training의 기본값은 10이고 update_frequency의 기본값은 5입니다. 두 기본값 모두 실제 프로젝트에서는 올릴 만큼 낮습니다. 어노테이션 다섯 개마다 재학습하면 거의 변하지 않은 모델에 연산 자원을 쓰게 되기 때문입니다.
전체 설정
active_learning:
enabled: true
schema_names:
- sentiment
min_annotations_per_instance: 1
min_instances_for_training: 20
update_frequency: 50
max_instances_to_reorder: 1000
# How disagreement between annotators resolves into one training label
resolution_strategy: majority_vote
# Fraction of the queue left in random order, so the model does not
# only ever see what it already found interesting
random_sample_percent: 0.2
classifier:
name: sklearn.linear_model.LogisticRegression
hyperparameters:
C: 1.0
max_iter: 1000
vectorizer:
name: sklearn.feature_extraction.text.TfidfVectorizer
hyperparameters:
max_features: 5000
ngram_range: [1, 2]
query_strategy: uncertainty
model_persistence:
enabled: true
save_directory: "models/"
retention_count: 5중첩된 classifier, vectorizer, model_persistence 블록이 문서화된 형식이며, potato validate --strict가 인식하는 형식도 이것입니다. 앞의 두 블록의 하위 키는 name과 hyperparameters이고, 세 번째 블록의 하위 키는 enabled, save_directory, retention_count입니다. 다른 하위 키 이름을 쓴 블록은 경고 없이 무시되고, 실행은 조용히 기본값으로 돌아갑니다.
쿼리 전략
| 전략 | 설명 |
|---|---|
uncertainty | 모델이 가장 확신하지 못하는 인스턴스. 기본값입니다 |
diversity | 이미 어노테이션된 데이터와 가장 덜 비슷한 인스턴스 |
badge | Batch Active learning by Diverse Gradient Embeddings |
bald | Bayesian Active Learning by Disagreement |
hybrid | uncertainty와 diversity의 가중 조합 |
active_learning:
query_strategy: uncertainty인식할 수 없는 전략 이름은 부팅을 실패시키지 않고 경고와 함께 uncertainty로 대체됩니다. 전략이 효과가 없어 보이면 로그를 확인하십시오.
Hybrid와 BALD 조정하기
hybrid의 기본값은 uncertainty 70%, diversity 30%입니다:
active_learning:
query_strategy: hybrid
hybrid_weights:
uncertainty: 0.7
diversity: 0.3bald는 작은 앙상블을 학습시키고 앙상블 내부의 불일치 정도로 순위를 매깁니다:
active_learning:
query_strategy: bald
bald_params:
n_estimators: 5
bootstrap_fraction: 0.8분류기
분류기는 sklearn 임포트 경로로 지정합니다. 기본값은 sklearn.linear_model.LogisticRegression입니다.
| 분류기 | 경로 | 적합한 용도 | 속도 |
|---|---|---|---|
| 로지스틱 회귀 | sklearn.linear_model.LogisticRegression | 대부분의 텍스트 작업 | 빠름 |
| 랜덤 포레스트 | sklearn.ensemble.RandomForestClassifier | 비선형 패턴 | 보통 |
| SVC | sklearn.svm.SVC | 소규모 데이터셋 | 느림 |
| 다항 NB | sklearn.naive_bayes.MultinomialNB | 간단한 텍스트 분류 | 매우 빠름 |
권장 출발점인 로지스틱 회귀:
active_learning:
classifier:
name: sklearn.linear_model.LogisticRegression
hyperparameters:
C: 1.0
max_iter: 1000결정이 선형에 가깝지 않을 때의 랜덤 포레스트:
active_learning:
classifier:
name: sklearn.ensemble.RandomForestClassifier
hyperparameters:
n_estimators: 100
max_depth: 10SVC는 확률을 출력하도록 명시해야 합니다. 불확실성 점수가 확률에 의존하기 때문입니다:
active_learning:
classifier:
name: sklearn.svm.SVC
hyperparameters:
kernel: rbf
probability: true정확도의 마지막 한 점보다 속도가 중요할 때의 나이브 베이즈:
active_learning:
classifier:
name: sklearn.naive_bayes.MultinomialNB
hyperparameters:
alpha: 1.0calibrate_probabilities는 기본적으로 켜져 있습니다. 불확실성 샘플링은 예측 확률로 순위를 매기므로, 보정되지 않은 분류기는 확신을 갖고 틀린 항목을 이미 결론이 난 것처럼 순위를 매기기 때문에 이 설정이 중요합니다.
벡터라이저
기본값은 sklearn.feature_extraction.text.TfidfVectorizer입니다.
TF-IDF 가중 특징:
active_learning:
vectorizer:
name: sklearn.feature_extraction.text.TfidfVectorizer
hyperparameters:
max_features: 5000
ngram_range: [1, 2]
stop_words: english단순 빈도:
active_learning:
vectorizer:
name: sklearn.feature_extraction.text.CountVectorizer
hyperparameters:
max_features: 3000
ngram_range: [1, 1]메모리에 담기 어려울 만큼 큰 어휘에는 해싱:
active_learning:
vectorizer:
name: sklearn.feature_extraction.text.HashingVectorizer
hyperparameters:
n_features: 10000ngram_range는 YAML 리스트로 작성하며 sklearn이 기대하는 튜플로 변환됩니다. 따라서 여기서는 [1, 2]가 올바르며 특별한 문법이 필요 없습니다.
콜드 스타트
모델이 존재하기 전에는 불확실성을 판단할 대상이 없으므로, 첫 배치는 모델 없이 선택됩니다:
active_learning:
cold_start_strategy: random
cold_start_batch_size: 20LLM 지원 선택
콜드 스타트 기간 동안 또는 분류기와 함께 LLM이 인스턴스를 점수화할 수 있습니다:
active_learning:
enabled: true
schema_names:
- sentiment
llm:
enabled: true
endpoint_type: vllm
base_url: http://localhost:8000/v1
model: meta-llama/Llama-3.2-3B-Instruct
confidence_method: verbalizedconfidence_method는 신뢰도 점수를 얻는 방식을 정합니다. 그 점수가 선택을 좌우하므로 이 선택이 중요합니다:
| 방식 | 작동 방식 | 장단점 |
|---|---|---|
verbalized | 모델이 1-10 척도로 자신의 신뢰도를 직접 보고합니다 | 어디서나 쓸 수 있지만 일부 모델에서는 신뢰하기 어렵습니다 |
logprobs | 토큰 로그 확률로 계산합니다 | 가장 잘 보정되지만 logprobs를 반환하는 엔드포인트가 필요합니다 |
consistency | 같은 인스턴스를 여러 번 질의하고 일치도로 점수화합니다 | 어디서나 작동하지만 인스턴스당 N번 호출합니다 |
엔드포인트가 logprobs를 반환하지 않으면 logprobs는 verbalized 신뢰도로 대체됩니다.
모델 영속성
학습된 모델은 처음부터 다시 만들지 않고 재시작 후에도 유지될 수 있습니다:
active_learning:
model_persistence:
enabled: true
save_directory: "models/"
retention_count: 5retention_count의 기본값은 2이며, 저장해 두는 모델 수의 상한을 정합니다.
데이터베이스 기반 영속성은 더 이상 설정할 수 없습니다. database_enabled와 database_config 키는 제거되었습니다. 그 뒤에 있던 계층이 성공을 로그에 남기기만 하고 아무것도 저장하지 않는 스텁이었기 때문입니다. 이제 실행 이력은 항상 기록되며 설정이 필요 없습니다. 설정에 두 키가 남아 있어도 무시됩니다.
여러 스키마
schema_names에는 모델 학습에 쓰이는 어노테이션의 스키마를 나열합니다. 지정하지 않으면 프로젝트의 레이블 지정 가능한 스키마가 기본값이 됩니다:
annotation_schemes:
- annotation_type: radio
name: sentiment
description: "What is the sentiment?"
labels: [Positive, Negative, Neutral]
- annotation_type: radio
name: topic
description: "What is the topic?"
labels: [Politics, Sports, Tech, Entertainment]
active_learning:
enabled: true
schema_names:
- sentiment
- topic전체 설정 예시
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
sequential_key_binding: true
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
random_sample_percent: 0.2
classifier:
name: sklearn.linear_model.LogisticRegression
hyperparameters:
C: 1.0
max_iter: 1000
vectorizer:
name: sklearn.feature_extraction.text.TfidfVectorizer
hyperparameters:
max_features: 5000
ngram_range: [1, 2]
query_strategy: uncertainty
model_persistence:
enabled: true
save_directory: "models/"
retention_count: 5
output_annotation_dir: "output/"
export_annotation_format: jsonl
user_config:
allow_all_users: trueAI 지원과 결합하기
능동 학습은 다음에 무엇을 보여 줄지 정합니다. AI 지원은 화면에 있는 항목에 대해 어노테이터를 돕습니다. 둘은 서로 독립적이며 함께 사용할 수 있습니다:
active_learning:
enabled: true
schema_names:
- sentiment
min_instances_for_training: 30
ai_support:
enabled: true
endpoint_type: openai
ai_config:
model: gpt-4o-mini
api_key: ${OPENAI_API_KEY}
max_tokens: 800
include:
all: true결과를 해석할 때 주의하십시오. 모델이 레이블을 제안하고 어노테이터가 이를 받아들였는데, 같은 계열의 모델이 그 인스턴스를 골랐다면, 마지막에 측정하는 일치도의 일부는 모델이 자기 자신과 일치한 결과입니다.
모니터링
관리자 대시보드는 모델 정확도, 학습 주기 횟수, 불확실성 분포, 남은 인스턴스 수를 보여 줍니다. 접근하려면 관리자 키나 view_admin_dashboard 권한이 있는 역할이 필요합니다.
모범 사례
먼저 기준선을 확보하기
빈 세트로는 아무것도 학습할 수 없고, 어노테이션 스무 개로 학습한 모델은 대부분 노이즈를 재정렬할 뿐입니다:
active_learning:
min_instances_for_training: 50클래스 균형 살피기
불확실성 샘플링은 결정 경계에 집중하므로 레이블 분포가 코퍼스의 분포에서 벗어납니다. 모델을 학습하는 데는 문제가 없지만, 어노테이션된 샘플을 데이터에 대한 설명으로 보고하면 오해를 낳습니다. random_sample_percent가 대기열의 일부를 편향 없이 남겨 두는 이유가 바로 이것입니다.
너무 자주 재학습하지 않기
active_learning:
update_frequency: 100재시작 후에도 모델 유지하기
active_learning:
model_persistence:
enabled: true
save_directory: "models/"문제 해결
학습이 시작되지 않음
어노테이션이 min_instances_for_training에 도달했는지, 모든 클래스에 예시가 적어도 하나 있는지 확인하십시오. 클래스가 하나뿐인 학습 세트로는 분류기를 학습할 수 없습니다.
재정렬이 아무 효과가 없어 보임
로그에서 알 수 없는 query_strategy가 있는지 확인하십시오. 이 경우 조용히 uncertainty로 대체됩니다. enabled: true인지, schema_names가 실제로 존재하는 스키마를 가리키는지도 확인하십시오.
풀이 크면 느림
max_instances_to_reorder를 줄이거나, update_frequency를 늘리거나, 매우 큰 어휘에는 HashingVectorizer로 바꾸십시오.
더 읽어보기
구현 세부 정보는 원본 문서를 참고하십시오.