Azure AI 서비스에서 모델에 대한 콘텐츠 필터(미리 보기)를 구성하는 방법
Important
이 문서에 표시된 항목(미리 보기)은 현재 퍼블릭 미리 보기에서 확인할 수 있습니다. 이 미리 보기는 서비스 수준 계약 없이 제공되며, 프로덕션 워크로드에는 권장되지 않습니다. 특정 기능이 지원되지 않거나 기능이 제한될 수 있습니다. 자세한 내용은 Microsoft Azure Preview에 대한 추가 사용 약관을 참조하세요.
Azure AI Services에 통합된 콘텐츠 필터링 시스템은 핵심 모델과 함께 실행됩니다. 다중 클래스 분류 모델의 앙상블을 사용하여 각각 4개의 심각도 수준(안전, 낮음, 중간 및 높음)에서 유해한 콘텐츠(폭력, 증오, 성적 및 자해)의 4가지 범주를 감지합니다. 공용 리포지토리에서 탈옥 위험, 기존 텍스트 및 코드를 검색하기 위한 선택적 이진 분류자를 제공합니다. 다음 문서에서 콘텐츠 범주, 심각도 수준 및 콘텐츠 필터링 시스템의 동작에 대해 자세히 알아봅니다.
기본 콘텐츠 필터링 구성은 프롬프트와 완료 모두에 대해 4개의 콘텐츠가 모두 범주에 해를 끼치도록 중간 심각도 임계값에서 필터링하도록 설정됩니다. 따라서 심각도 수준 중간 또는 높음에서 검색된 콘텐츠는 필터링되지만 심각도 수준 낮음 또는 안전성에서 검색된 콘텐츠는 필터링되지 않습니다.
콘텐츠 필터는 리소스 수준에서 구성하고 하나 이상의 배포와 연결할 수 있습니다.
필수 조건
이 문서를 완료하려면 다음이 필요합니다.
Azure 구독 GitHub 모델을 사용하는 경우 환경을 업그레이드하고 프로세스에서 Azure 구독을 만들 수 있습니다. 사용자의 경우 GitHub 모델에서 Azure AI 모델 유추로 업그레이드를 읽습니다.
Azure AI 서비스 리소스입니다. 자세한 내용은 Azure AI Services 리소스 만들기를 참조 하세요.
- Azure AI Services 리소스에 연결된 AI 프로젝트입니다. Azure AI Foundry에서 내 프로젝트에서 Azure AI 모델 유추 서비스 구성의 단계를 따릅니다.
사용자 지정 콘텐츠 필터 만들기
사용자 지정 콘텐츠 필터를 만들려면 다음 단계를 수행합니다.
Azure AI Foundry 포털로 이동합니다.
안전 + 보안을 선택합니다.
탭 콘텐츠 필터를 선택한 다음, 콘텐츠 필터 만들기를 선택합니다.
기본 정보에서 콘텐츠 필터에 이름을 지정합니다.
연결에서 프로젝트에 연결된 Azure AI Services 리소스에 대한 연결을 선택합니다.
입력 필터에서 요구 사항에 따라 필터를 구성합니다. 이 구성은 요청이 모델 자체에 도달하기 전에 적용됩니다.
출력 필터에서 요구 사항에 따라 필터를 구성합니다. 이 구성은 모델이 실행되고 콘텐츠가 생성된 후에 적용됩니다.
다음을 선택합니다.
필요에 따라 지정된 배포를 만든 콘텐츠 필터와 연결할 수 있습니다. 언제든지 연결된 모델 배포를 변경할 수 있습니다.
배포가 완료되면 모델 배포에 새 콘텐츠 필터가 적용됩니다.
코드의 콘텐츠 필터링 계정
모델 배포에 콘텐츠 필터링이 적용되면 입력 및 출력에 따라 서비스에서 요청을 가로챌 수 있습니다. 콘텐츠 필터가 트리거되면 트리거된 규칙에 대한 설명과 함께 400 오류 코드가 반환됩니다.
pip와 같은 패키지 관리 시스템을 사용하여 azure-ai-inference
패키지를 설치합니다.
pip install azure-ai-inference>=1.0.0b5
Warning
Azure AI Services 리소스에는 Python 버전 azure-ai-inference>=1.0.0b5
이 필요합니다.
그런 다음 패키지를 사용하여 모델을 이용할 수 있습니다. 다음 예에서는 채팅 완성을 이용하는 클라이언트를 만드는 방법을 보여 줍니다.
import os
from azure.ai.inference import ChatCompletionsClient
from azure.core.credentials import AzureKeyCredential
model = ChatCompletionsClient(
endpoint="https://<resource>.services.ai.azure.com/models",
credential=AzureKeyCredential(os.environ["AZUREAI_ENDPOINT_KEY"]),
)
시작하려면 샘플을 살펴보고 API 참조 설명서를 참조하세요.
다음 예에서는 콘텐츠 보안을 트리거한 채팅 완료 요청에 대한 응답을 보여 줍니다.
from azure.ai.inference.models import AssistantMessage, UserMessage, SystemMessage
from azure.core.exceptions import HttpResponseError
try:
response = model.complete(
messages=[
SystemMessage(content="You are an AI assistant that helps people find information."),
UserMessage(content="Chopping tomatoes and cutting them into cubes or wedges are great ways to practice your knife skills."),
]
)
print(response.choices[0].message.content)
except HttpResponseError as ex:
if ex.status_code == 400:
response = json.loads(ex.response._content.decode('utf-8'))
if isinstance(response, dict) and "error" in response:
print(f"Your request triggered an {response['error']['code']} error:\n\t {response['error']['message']}")
else:
raise ex
else:
raise ex
모범 사례 준수
특정 모델, 애플리케이션 및 배포 시나리오와 관련된 잠재적인 피해를 해결하기 위해 반복적인 식별(예: 레드팀 테스트, 스트레스 테스트 및 분석) 및 측정 프로세스를 통해 콘텐츠 필터링 구성 결정을 알리는 것이 좋습니다. 콘텐츠 필터링과 같은 완화 측정값을 구현한 후 측정을 반복하여 효율성을 테스트합니다.
Microsoft 책임 있는 AI 표준을 기반으로 하는 Azure OpenAI에 대한 책임 있는 AI에 대한 권장 사항 및 모범 사례는 Azure OpenAI에 대한 책임 있는 AI 개요에서 확인할 수 있습니다.
Important
이 문서에 표시된 항목(미리 보기)은 현재 퍼블릭 미리 보기에서 확인할 수 있습니다. 이 미리 보기는 서비스 수준 계약 없이 제공되며, 프로덕션 워크로드에는 권장되지 않습니다. 특정 기능이 지원되지 않거나 기능이 제한될 수 있습니다. 자세한 내용은 Microsoft Azure Preview에 대한 추가 사용 약관을 참조하세요.
Azure AI Services에 통합된 콘텐츠 필터링 시스템은 핵심 모델과 함께 실행됩니다. 다중 클래스 분류 모델의 앙상블을 사용하여 각각 4개의 심각도 수준(안전, 낮음, 중간 및 높음)에서 유해한 콘텐츠(폭력, 증오, 성적 및 자해)의 4가지 범주를 감지합니다. 공용 리포지토리에서 탈옥 위험, 기존 텍스트 및 코드를 검색하기 위한 선택적 이진 분류자를 제공합니다. 다음 문서에서 콘텐츠 범주, 심각도 수준 및 콘텐츠 필터링 시스템의 동작에 대해 자세히 알아봅니다.
기본 콘텐츠 필터링 구성은 프롬프트와 완료 모두에 대해 4개의 콘텐츠가 모두 범주에 해를 끼치도록 중간 심각도 임계값에서 필터링하도록 설정됩니다. 따라서 심각도 수준 중간 또는 높음에서 검색된 콘텐츠는 필터링되지만 심각도 수준 낮음 또는 안전성에서 검색된 콘텐츠는 필터링되지 않습니다.
콘텐츠 필터는 리소스 수준에서 구성하고 하나 이상의 배포와 연결할 수 있습니다.
필수 조건
이 문서를 완료하려면 다음이 필요합니다.
Azure 구독 GitHub 모델을 사용하는 경우 환경을 업그레이드하고 프로세스에서 Azure 구독을 만들 수 있습니다. 사용자의 경우 GitHub 모델에서 Azure AI 모델 유추로 업그레이드를 읽습니다.
Azure AI 서비스 리소스입니다. 자세한 내용은 Azure AI Services 리소스 만들기를 참조 하세요.
사용자 지정 콘텐츠 필터링을 사용하여 모델 배포 추가
Azure AI Foundry 포털 또는 Bicep을 사용하는 코드에서 콘텐츠 필터를 만드는 것이 좋습니다. Azure CLI를 사용하여 사용자 지정 콘텐츠 필터를 만들거나 배포에 적용하는 것은 지원되지 않습니다.
코드의 콘텐츠 필터링 계정
모델 배포에 콘텐츠 필터링이 적용되면 입력 및 출력에 따라 서비스에서 요청을 가로챌 수 있습니다. 콘텐츠 필터가 트리거되면 트리거된 규칙에 대한 설명과 함께 400 오류 코드가 반환됩니다.
pip와 같은 패키지 관리 시스템을 사용하여 azure-ai-inference
패키지를 설치합니다.
pip install azure-ai-inference>=1.0.0b5
Warning
Azure AI Services 리소스에는 Python 버전 azure-ai-inference>=1.0.0b5
이 필요합니다.
그런 다음 패키지를 사용하여 모델을 이용할 수 있습니다. 다음 예에서는 채팅 완성을 이용하는 클라이언트를 만드는 방법을 보여 줍니다.
import os
from azure.ai.inference import ChatCompletionsClient
from azure.core.credentials import AzureKeyCredential
model = ChatCompletionsClient(
endpoint="https://<resource>.services.ai.azure.com/models",
credential=AzureKeyCredential(os.environ["AZUREAI_ENDPOINT_KEY"]),
)
시작하려면 샘플을 살펴보고 API 참조 설명서를 참조하세요.
다음 예에서는 콘텐츠 보안을 트리거한 채팅 완료 요청에 대한 응답을 보여 줍니다.
from azure.ai.inference.models import AssistantMessage, UserMessage, SystemMessage
from azure.core.exceptions import HttpResponseError
try:
response = model.complete(
messages=[
SystemMessage(content="You are an AI assistant that helps people find information."),
UserMessage(content="Chopping tomatoes and cutting them into cubes or wedges are great ways to practice your knife skills."),
]
)
print(response.choices[0].message.content)
except HttpResponseError as ex:
if ex.status_code == 400:
response = json.loads(ex.response._content.decode('utf-8'))
if isinstance(response, dict) and "error" in response:
print(f"Your request triggered an {response['error']['code']} error:\n\t {response['error']['message']}")
else:
raise ex
else:
raise ex
모범 사례 준수
특정 모델, 애플리케이션 및 배포 시나리오와 관련된 잠재적인 피해를 해결하기 위해 반복적인 식별(예: 레드팀 테스트, 스트레스 테스트 및 분석) 및 측정 프로세스를 통해 콘텐츠 필터링 구성 결정을 알리는 것이 좋습니다. 콘텐츠 필터링과 같은 완화 측정값을 구현한 후 측정을 반복하여 효율성을 테스트합니다.
Microsoft 책임 있는 AI 표준을 기반으로 하는 Azure OpenAI에 대한 책임 있는 AI에 대한 권장 사항 및 모범 사례는 Azure OpenAI에 대한 책임 있는 AI 개요에서 확인할 수 있습니다.
Important
이 문서에 표시된 항목(미리 보기)은 현재 퍼블릭 미리 보기에서 확인할 수 있습니다. 이 미리 보기는 서비스 수준 계약 없이 제공되며, 프로덕션 워크로드에는 권장되지 않습니다. 특정 기능이 지원되지 않거나 기능이 제한될 수 있습니다. 자세한 내용은 Microsoft Azure Preview에 대한 추가 사용 약관을 참조하세요.
Azure AI Services에 통합된 콘텐츠 필터링 시스템은 핵심 모델과 함께 실행됩니다. 다중 클래스 분류 모델의 앙상블을 사용하여 각각 4개의 심각도 수준(안전, 낮음, 중간 및 높음)에서 유해한 콘텐츠(폭력, 증오, 성적 및 자해)의 4가지 범주를 감지합니다. 공용 리포지토리에서 탈옥 위험, 기존 텍스트 및 코드를 검색하기 위한 선택적 이진 분류자를 제공합니다. 다음 문서에서 콘텐츠 범주, 심각도 수준 및 콘텐츠 필터링 시스템의 동작에 대해 자세히 알아봅니다.
기본 콘텐츠 필터링 구성은 프롬프트와 완료 모두에 대해 4개의 콘텐츠가 모두 범주에 해를 끼치도록 중간 심각도 임계값에서 필터링하도록 설정됩니다. 따라서 심각도 수준 중간 또는 높음에서 검색된 콘텐츠는 필터링되지만 심각도 수준 낮음 또는 안전성에서 검색된 콘텐츠는 필터링되지 않습니다.
콘텐츠 필터는 리소스 수준에서 구성하고 하나 이상의 배포와 연결할 수 있습니다.
필수 조건
이 문서를 완료하려면 다음이 필요합니다.
Azure 구독 GitHub 모델을 사용하는 경우 환경을 업그레이드하고 프로세스에서 Azure 구독을 만들 수 있습니다. 사용자의 경우 GitHub 모델에서 Azure AI 모델 유추로 업그레이드를 읽습니다.
Azure AI 서비스 리소스입니다. 자세한 내용은 Azure AI Services 리소스 만들기를 참조 하세요.
Azure CLI를 설치합니다.
다음 정보를 식별합니다.
Azure 구독 ID.
Azure AI Services 리소스 이름입니다.
Azure AI Services 리소스가 배포되는 리소스 그룹입니다.
배포하려는 모델 이름, 공급자, 버전 및 SKU입니다. Azure AI Foundry 포털 또는 Azure CLI를 사용하여 식별할 수 있습니다. 이 예제에서는 다음 모델을 배포합니다.
-
모델 이름::
Phi-3.5-vision-instruct
-
공급자:
Microsoft
-
버전:
2
- 배포 유형: 전역 표준
-
모델 이름::
사용자 지정 콘텐츠 필터링을 사용하여 모델 배포 추가
템플릿
ai-services-content-filter-template.bicep
을 사용하여 콘텐츠 필터 정책을 설명합니다.ai-services-content-filter-template.bicep
@description('Name of the Azure AI Services account where the policy will be created') param accountName string @description('Name of the policy to be created') param policyName string @allowed(['Asynchronous_filter', 'Blocking', 'Default', 'Deferred']) param mode string = 'Default' @description('Base policy to be used for the new policy') param basePolicyName string = 'Microsoft.DefaultV2' param contentFilters array = [ { name: 'Violence' severityThreshold: 'Medium' blocking: true enabled: true source: 'Prompt' } { name: 'Hate' severityThreshold: 'Medium' blocking: true enabled: true source: 'Prompt' } { name: 'Sexual' severityThreshold: 'Medium' blocking: true enabled: true source: 'Prompt' } { name: 'Selfharm' severityThreshold: 'Medium' blocking: true enabled: true source: 'Prompt' } { name: 'Jailbreak' blocking: true enabled: true source: 'Prompt' } { name: 'Indirect Attack' blocking: true enabled: true source: 'Prompt' } { name: 'Profanity' blocking: true enabled: true source: 'Prompt' } { name: 'Violence' severityThreshold: 'Medium' blocking: true enabled: true source: 'Completion' } { name: 'Hate' severityThreshold: 'Medium' blocking: true enabled: true source: 'Completion' } { name: 'Sexual' severityThreshold: 'Medium' blocking: true enabled: true source: 'Completion' } { name: 'Selfharm' severityThreshold: 'Medium' blocking: true enabled: true source: 'Completion' } { name: 'Protected Material Text' blocking: true enabled: true source: 'Completion' } { name: 'Protected Material Code' blocking: false enabled: true source: 'Completion' } { name: 'Profanity' blocking: true enabled: true source: 'Completion' } ] resource raiPolicy 'Microsoft.CognitiveServices/accounts/raiPolicies@2024-06-01-preview' = { name: '${accountName}/${policyName}' properties: { mode: mode basePolicyName: basePolicyName contentFilters: contentFilters } }
템플릿
ai-services-deployment-template.bicep
을 사용하여 모델 배포를 설명합니다.ai-services-deployment-template.bicep
@description('Name of the Azure AI services account') param accountName string @description('Name of the model to deploy') param modelName string @description('Version of the model to deploy') param modelVersion string @allowed([ 'AI21 Labs' 'Cohere' 'Core42' 'Meta' 'Microsoft' 'Mistral AI' 'OpenAI' ]) @description('Model provider') param modelPublisherFormat string @allowed([ 'GlobalStandard' 'Standard' 'GlobalProvisioned' 'Provisioned' ]) @description('Model deployment SKU name') param skuName string = 'GlobalStandard' @description('Content filter policy name') param contentFilterPolicyName string = 'Microsoft.DefaultV2' @description('Model deployment capacity') param capacity int = 1 resource modelDeployment 'Microsoft.CognitiveServices/accounts/deployments@2024-04-01-preview' = { name: '${accountName}/${modelName}' sku: { name: skuName capacity: capacity } properties: { model: { format: modelPublisherFormat name: modelName version: modelVersion } raiPolicyName: contentFilterPolicyName == null ? 'Microsoft.Nill' : contentFilterPolicyName } }
기본 배포 정의를 만듭니다.
main.bicep
param accountName string param modelName string param modelVersion string param modelPublisherFormat string param contentFilterPolicyName string module raiPolicy 'ai-services-content-filter-template.bicep' = { name: 'raiPolicy' scope: resourceGroup(resourceGroupName) params: { accountName: accountName policyName: contentFilterPolicyName } } module modelDeployment 'ai-services-deployment-template.bicep' = { name: 'modelDeployment' scope: resourceGroup(resourceGroupName) params: { accountName: accountName modelName: modelName modelVersion: modelVersion modelPublisherFormat: modelPublisherFormat contentFilterPolicyName: contentFilterPolicyName } dependsOn: [ raiPolicy ] }
배포를 실행합니다.
RESOURCE_GROUP="<resource-group-name>" ACCOUNT_NAME="<azure-ai-model-inference-name>" MODEL_NAME="Phi-3.5-vision-instruct" PROVIDER="Microsoft" VERSION=2 RAI_POLICY_NAME="custom-policy" az deployment group create \ --resource-group $RESOURCE_GROUP \ --template-file main.bicep \ --parameters accountName=$ACCOUNT_NAME raiPolicyName=$RAI_POLICY_NAME modelName=$MODEL_NAME modelVersion=$VERSION modelPublisherFormat=$PROVIDER
코드의 콘텐츠 필터링 계정
모델 배포에 콘텐츠 필터링이 적용되면 입력 및 출력에 따라 서비스에서 요청을 가로챌 수 있습니다. 콘텐츠 필터가 트리거되면 트리거된 규칙에 대한 설명과 함께 400 오류 코드가 반환됩니다.
pip와 같은 패키지 관리 시스템을 사용하여 azure-ai-inference
패키지를 설치합니다.
pip install azure-ai-inference>=1.0.0b5
Warning
Azure AI Services 리소스에는 Python 버전 azure-ai-inference>=1.0.0b5
이 필요합니다.
그런 다음 패키지를 사용하여 모델을 이용할 수 있습니다. 다음 예에서는 채팅 완성을 이용하는 클라이언트를 만드는 방법을 보여 줍니다.
import os
from azure.ai.inference import ChatCompletionsClient
from azure.core.credentials import AzureKeyCredential
model = ChatCompletionsClient(
endpoint="https://<resource>.services.ai.azure.com/models",
credential=AzureKeyCredential(os.environ["AZUREAI_ENDPOINT_KEY"]),
)
시작하려면 샘플을 살펴보고 API 참조 설명서를 참조하세요.
다음 예에서는 콘텐츠 보안을 트리거한 채팅 완료 요청에 대한 응답을 보여 줍니다.
from azure.ai.inference.models import AssistantMessage, UserMessage, SystemMessage
from azure.core.exceptions import HttpResponseError
try:
response = model.complete(
messages=[
SystemMessage(content="You are an AI assistant that helps people find information."),
UserMessage(content="Chopping tomatoes and cutting them into cubes or wedges are great ways to practice your knife skills."),
]
)
print(response.choices[0].message.content)
except HttpResponseError as ex:
if ex.status_code == 400:
response = json.loads(ex.response._content.decode('utf-8'))
if isinstance(response, dict) and "error" in response:
print(f"Your request triggered an {response['error']['code']} error:\n\t {response['error']['message']}")
else:
raise ex
else:
raise ex
모범 사례 준수
특정 모델, 애플리케이션 및 배포 시나리오와 관련된 잠재적인 피해를 해결하기 위해 반복적인 식별(예: 레드팀 테스트, 스트레스 테스트 및 분석) 및 측정 프로세스를 통해 콘텐츠 필터링 구성 결정을 알리는 것이 좋습니다. 콘텐츠 필터링과 같은 완화 측정값을 구현한 후 측정을 반복하여 효율성을 테스트합니다.
Microsoft 책임 있는 AI 표준을 기반으로 하는 Azure OpenAI에 대한 책임 있는 AI에 대한 권장 사항 및 모범 사례는 Azure OpenAI에 대한 책임 있는 AI 개요에서 확인할 수 있습니다.
다음 단계
- Azure OpenAI 서비스를 사용한 콘텐츠 필터링 범주 및 심각도 수준에 대해 자세히 알아봅니다.
- 레드 팀 LLM(대규모 언어 모델) 소개 문서에서 레드 팀에 대해 자세히 알아봅니다.