

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 텍스트 분류로 텍스트 범주화(단일 레이블)
<a name="sms-text-classification"></a>

기사 및 텍스트를 미리 정의된 범주로 분류하려면 텍스트 분류를 사용합니다. 예를 들어 텍스트 분류를 사용하여 검토 시 전달되는 감성 또는 텍스트 섹션의 기본이 되는 감정을 식별할 수 있습니다. Amazon SageMaker Ground Truth 텍스트 분류를 사용하여 작업자에게 사용자가 정의한 범주로 텍스트를 정렬하도록 합니다. Amazon SageMaker AI 콘솔의 Ground Truth 섹션 또는 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateLabelingJob.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateLabelingJob.html) 작업을 사용하여 텍스트 분류 레이블링 작업을 생성합니다.

**중요**  
입력 매니페스트 파일을 수동으로 생성하는 경우 레이블을 지정하려는 텍스트를 식별하는 데 `"source"`를 사용하세요. 자세한 내용은 [입력 데이터](sms-data-input.md) 섹션을 참조하세요.

## 텍스트 분류 레이블 지정 작업 생성(콘솔)
<a name="sms-creating-text-classification-console"></a>

[레이블 지정 작업 생성(콘솔)](sms-create-labeling-job-console.md) 지침에 따라 SageMaker AI 콘솔에서 텍스트 분류 레이블링 작업을 생성하는 방법을 학습할 수 있습니다. 10단계에서 **작업 범주** 드롭다운 메뉴에서 **텍스트**를 선택하고 작업 유형으로 **텍스트 분류(단일 레이블)**를 선택합니다.

Ground Truth에서는 작업에 레이블을 지정할 때 다음과 유사한 작업자 UI를 제공합니다. 콘솔을 사용하여 레이블 지정 작업을 생성할 때 작업자가 작업을 완료하는 데 도움이 되는 지침과 작업자가 선택할 수 있는 레이블을 지정합니다.

![SageMaker AI 콘솔에서 텍스트 분류 레이블링 작업을 생성하는 방법을 보여주는 Gif.](http://docs.aws.amazon.com/ko_kr/sagemaker/latest/dg/images/sms/gifs/single-label-text.gif)


## 텍스트 분류 레이블 지정 작업 생성(API)
<a name="sms-creating-text-classification-api"></a>

텍스트 분류 레이블 지정 작업을 생성하려면 SageMaker API 작업 `CreateLabelingJob`을 사용합니다. 이 API는 모든 AWS SDKs에 대해이 작업을 정의합니다. 이 작업에 지원되는 언어별 SDK 목록을 보려면 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateLabelingJob.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateLabelingJob.html)의 **참고 항목** 섹션을 검토하세요.

[레이블 지정 작업 생성(API)](sms-create-labeling-job-api.md)의 지침에 따라 요청을 구성하는 동안 다음을 수행합니다.
+ 이 작업 유형에 대한 주석 전 Lambda 함수는 `PRE-TextMultiClass`로 끝납니다. 해당 리전의 주석 전 Lambda ARN을 찾으려면 [PreHumanTaskLambdaArn](https://docs.aws.amazon.com/sagemaker/latest/dg/API_HumanTaskConfig.html#SageMaker-Type-HumanTaskConfig-PreHumanTaskLambdaArn)을 참조하세요.
+ 이 작업 유형에 대한 주석 통합 Lambda 함수는 `ACS-TextMultiClass`로 끝납니다. 해당 리전에 대한 주석 통합 Lambda ARN을 찾으려면 [AnnotationConsolidationLambdaArn](https://docs.aws.amazon.com/sagemaker/latest/dg/API_AnnotationConsolidationConfig.html#SageMaker-Type-AnnotationConsolidationConfig-AnnotationConsolidationLambdaArn)을 참조하세요.

다음은 미국 동부(버지니아 북부) 리전에 레이블 지정 작업을 생성하는 [AWS Python SDK(Boto3) 요청](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sagemaker.html#SageMaker.Client.create_labeling_job)의 예시입니다. 빨간색으로 된 모든 파라미터는 사양과 리소스로 대체해야 합니다.

```
response = client.create_labeling_job(
    LabelingJobName={{'example-text-classification-labeling-job}},
    LabelAttributeName={{'label'}},
    InputConfig={
        'DataSource': {
            'S3DataSource': {
                'ManifestS3Uri': {{'s3://bucket/path/manifest-with-input-data.json'}}
            }
        },
        'DataAttributes': {
            'ContentClassifiers': [
                {{'FreeOfPersonallyIdentifiableInformation'|'FreeOfAdultContent'}},
            ]
        }
    },
    OutputConfig={
        'S3OutputPath': {{'s3://bucket/path/file-to-store-output-data'}},
        'KmsKeyId': {{'string'}}
    },
    RoleArn={{'arn:aws:iam::*:role/*}},
    LabelCategoryConfigS3Uri={{'s3://bucket/path/label-categories.json'}},
    StoppingConditions={
        'MaxHumanLabeledObjectCount': {{123}},
        'MaxPercentageOfInputDatasetLabeled': {{123}}
    },
    HumanTaskConfig={
        'WorkteamArn': {{'arn:aws:sagemaker:region:*:workteam/private-crowd/*'}},
        'UiConfig': {
            'UiTemplateS3Uri': {{'s3://bucket/path/worker-task-template.html'}}
        },
        'PreHumanTaskLambdaArn': 'arn:aws:lambda:{{us-east-1:432418664414}}:function:PRE-TextMultiClass,
        'TaskKeywords': [
            {{Text classification'}},
        ],
        'TaskTitle': {{Text classification task'}},
        'TaskDescription': {{'Carefully read and classify this text using the categories provided.'}},
        'NumberOfHumanWorkersPerDataObject': {{123}},
        'TaskTimeLimitInSeconds': {{123}},
        'TaskAvailabilityLifetimeInSeconds': {{123}},
        'MaxConcurrentTaskCount': {{123}},
        'AnnotationConsolidationConfig': {
            'AnnotationConsolidationLambdaArn': 'arn:aws:lambda:{{us-east-1:432418664414}}:function:ACS-TextMultiClass'
        },
    Tags=[
        {
            'Key': {{'string'}},
            'Value': {{'string'
}}        },
    ]
)
```

### 텍스트 분류 레이블 지정 작업을 위한 템플릿 제공
<a name="worker-template-text-classification"></a>

API를 사용하여 레이블 지정 작업을 생성하는 경우 `UiTemplateS3Uri`의 작업자 태스크 템플릿을 제공해야 합니다. 다음 템플릿을 복사하고 수정합니다. [https://docs.aws.amazon.com/sagemaker/latest/dg/sms-creating-instruction-pages.html#sms-creating-quick-instructions](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-creating-instruction-pages.html#sms-creating-quick-instructions), [https://docs.aws.amazon.com/sagemaker/latest/dg/sms-creating-instruction-pages.html#sms-creating-full-instructions](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-creating-instruction-pages.html#sms-creating-full-instructions) 및 `header`만 수정합니다.

이 템플릿을 S3에 업로드하고 `UiTemplateS3Uri`에서 이 파일에 대한 S3 URI를 제공합니다.

```
<script src="https://assets.crowd.aws/crowd-html-elements.js"></script>
<crowd-form>
  <crowd-classifier
    name="crowd-classifier"
    categories="{{ task.input.labels | to_json | escape }}"
    header="classify text"
  >
    <classification-target style="white-space: pre-wrap">
      {{ task.input.taskObject }}
    </classification-target>
    <full-instructions header="Classifier instructions">
      <ol><li><strong>Read</strong> the text carefully.</li>
      <li><strong>Read</strong> the examples to understand more about the options.</li>
      <li><strong>Choose</strong> the appropriate labels that best suit the text.</li></ol>
    </full-instructions>
    <short-instructions>
      <p>Enter description of the labels that workers have to choose from</p>
      <p><br></p><p><br></p><p>Add examples to help workers understand the label</p>
      <p><br></p><p><br></p><p><br></p><p><br></p><p><br></p>
    </short-instructions>
  </crowd-classifier>
  </crowd-form>
```

## 텍스트 분류 출력 데이터
<a name="sms-text-classification-output-data"></a>

텍스트 분류 레이블 지정 작업을 생성하면 출력 데이터는 API 사용 시 `S3OutputPath` 파라미터에 지정된 Amazon S3 버킷 또는 콘솔의 **작업 개요** 섹션의 **출력 데이터세트 위치** 필드에 있습니다.

Ground Truth에서 생성된 출력 매니페스트 파일 및 Ground Truth에서 출력 데이터 저장에 사용하는 파일 구조에 대한 자세한 내용은 [작업 출력 데이터 레이블 지정](sms-data-output.md) 섹션을 참조하세요.

텍스트 분류 레이블 지정 작업에 대한 출력 매니페스트 파일의 예제를 보려면 [분류 작업 출력](sms-data-output.md#sms-output-class) 섹션을 참조하세요.