첫 NER 어노테이션 작업 구축하기
Potato에서 개체명 인식 작업을 구축하는 단계별 가이드. 스팬 어노테이션 구성, 라벨 색상, 겹치는 스팬, 키보드 단축키, CoNLL 내보내기를 다룹니다.
개체명 인식(NER)은 대부분의 NLP 팀이 조만간 마주치게 되는 작업입니다. 이 튜토리얼은 스팬 강조, 키보드 단축키, 개체 유형 선택을 갖춘 동작하는 NER 어노테이션 인터페이스를 처음부터 구축합니다. 그 뒤에 있는 스팬 구성 옵션은 텍스트 어노테이션 문서를 참고하십시오.
무엇을 만드는가
이 튜토리얼을 마치면, 어노테이터가 다음을 할 수 있는 어노테이션 인터페이스를 갖추게 됩니다:
- 클릭과 드래그로 텍스트 스팬 강조하기
- 개체 유형 할당하기 (사람, 조직, 위치 등)
- 키보드 단축키로 더 빠르게 어노테이션하기
- 기존 어노테이션 편집 또는 삭제하기
사전 준비
- Potato 설치 (
pip install potato-annotation) - YAML에 대한 기본적인 이해
- 어노테이션할 샘플 텍스트 데이터
1단계: 어노테이션 스킴 구성하기
config.yaml 파일을 생성합니다:
annotation_task_name: "Named Entity Recognition"
data_files:
- data/sentences.json
item_properties:
id_key: id
text_key: text
# Enable span annotation
annotation_schemes:
- annotation_type: span
name: entities
description: "Highlight and label named entities in the text"
labels:
- name: PER
description: "Person names"
color: "#FF6B6B"
keyboard_shortcut: "p"
- name: ORG
description: "Organizations"
color: "#4ECDC4"
keyboard_shortcut: "o"
- name: LOC
description: "Locations"
color: "#45B7D1"
keyboard_shortcut: "l"
- name: DATE
description: "Dates and times"
color: "#96CEB4"
keyboard_shortcut: "d"
- name: MISC
description: "Miscellaneous entities"
color: "#FFEAA7"
keyboard_shortcut: "m"
min_spans: 0 # Allow sentences with no entities2단계: 데이터 준비하기
텍스트 데이터로 data/sentences.json을 생성합니다:
{"id": "1", "text": "Apple Inc. announced that CEO Tim Cook will visit Paris next Tuesday."}
{"id": "2", "text": "The United Nations headquarters in New York hosted delegates from Japan."}
{"id": "3", "text": "Dr. Sarah Johnson published her research at Stanford University in March 2024."}3단계: 어노테이션 가이드라인 추가하기
명확한 가이드라인으로 어노테이터를 돕습니다:
# Add to config.yaml
annotation_guidelines:
title: "NER Annotation Guidelines"
content: |
## Entity Types
**PER (Person)**: Names of people, including fictional characters
- Examples: "John Smith", "Dr. Johnson", "Batman"
**ORG (Organization)**: Companies, institutions, agencies
- Examples: "Apple Inc.", "United Nations", "Stanford University"
**LOC (Location)**: Places, including countries, cities, landmarks
- Examples: "Paris", "New York", "Mount Everest"
**DATE**: Dates, times, and temporal expressions
- Examples: "Tuesday", "March 2024", "next week"
**MISC**: Other named entities not fitting above categories
- Examples: "Nobel Prize", "iPhone", "COVID-19"
## Annotation Rules
1. Include titles (Dr., Mr.) with person names
2. For nested entities, annotate the largest meaningful span
3. Don't include articles (the, a) in entity spans스팬 어노테이션 인터페이스를 통해 어노테이터는 텍스트를 강조하고 개체 라벨을 할당할 수 있습니다:
어노테이터가 텍스트 스팬을 강조하고 PER, ORG, LOC, DATE 같은 개체 라벨을 할당합니다
4단계: 어노테이션 시작하기
NER 작업을 실행합니다:
potato start config.yaml어노테이션 워크플로
- 텍스트 선택: 클릭하고 드래그하여 스팬을 강조합니다
- 개체 유형 선택: 라벨 버튼을 클릭하거나 키보드 단축키를 사용합니다
- 어노테이션 편집: 기존 스팬을 클릭하여 수정하거나 삭제합니다
- 제출: 완료되면 Enter를 누르거나 Submit을 클릭합니다
5단계: 출력 검토하기
어노테이션은 JSONL 형식으로 저장됩니다:
{
"id": "1",
"text": "Apple Inc. announced that CEO Tim Cook will visit Paris next Tuesday.",
"annotations": {
"entities": [
{"start": 0, "end": 10, "label": "ORG", "text": "Apple Inc."},
{"start": 30, "end": 38, "label": "PER", "text": "Tim Cook"},
{"start": 50, "end": 55, "label": "LOC", "text": "Paris"},
{"start": 61, "end": 73, "label": "DATE", "text": "next Tuesday"}
]
}
}더 나은 NER 어노테이션을 위한 팁
대부분의 NER 의견 불일치는 모호한 가이드라인에서 비롯됩니다. 따라서 규칙이 명확할수록 어노테이터가 같은 스팬을 두고 다투는 일이 줄어듭니다. 까다로운 경계 사례는 작업이 끝난 뒤가 아니라 시작하기 전에 사람들에게 안내하고, 어려운 예시는 팀 차원에서 계속 논의하십시오. 어노테이터 간 일치도가 떨어지면, 보통 그것이 가이드라인을 다듬어야 한다는 첫 번째 신호입니다.
다음 단계
- 어노테이터를 온보딩하기 위해 학습 단계를 추가하십시오
- 중복성을 위해 여러 어노테이터를 설정하십시오
- 모델 학습을 위해 Hugging Face 형식으로 내보내십시오
도움이 필요하신가요? 자세한 내용은 스팬 어노테이션 문서를 확인하십시오.