엔터티 인식

완료됨

명명된 엔터티 인식은 Azure Language에서 제공하는 기능입니다. 구조화되지 않은 텍스트에서 엔터티를 식별하고 분류합니다. 사람, 위치, 이벤트, 제품, 조직 등 여러 범주 의 엔터티를 지원합니다.

명명된 엔터티 인식 API를 호출하는 방법에는 여러 가지가 있습니다. 여기서는 azure_ai 확장을 사용하여 SQL 쿼리의 텍스트에서 엔터티를 인식합니다.

필수 조건

azure_ai 확장을 사용하도록 설정하고 구성한 Azure Database for PostgreSQL 유연한 서버가 필요합니다. 또한 언어 리소스의 키와 엔드포인트를 설정하여 Azure Cognitive Services로 권한을 부여 해야 합니다.

시나리오

엔터티 인식은 다음과 같은 여러 도메인에서 유용합니다.

  • 검색 및 인덱싱: 식별된 엔터티를 사용하여 지식 그래프 및 태그 디렉터리를 자동으로 빌드합니다.
  • 프로세스 자동화: 구조화되지 않은 텍스트로 제품 및 위치를 자동으로 인식하고 고객 지원 요청으로 라우팅합니다.
  • 시장 분석: 소셜 미디어, 고객 리뷰, 지원 티켓 등에서 가장 빈번한 엔터티 및 엔터티 클러스터를 측정하여 관련 주제를 결정하고 추세를 예측합니다.

Azure Cognitive Services를 사용하여 SQL에서 명명된 엔터티 인식 사용

Azure Database for PostgreSQL 유연한 서버 azure_ai 확장 은 SQL 내에서 AI 기능에 직접 액세스할 수 있는 UDF(사용자 정의 함수)를 제공합니다. 명명된 엔터티 인식 API는 azure_cognitive.recognize_entities이(가) 제공하는 azure_ai 함수를 사용하여 액세스됩니다.

azure_cognitive.recognize_entities(
 text text,
 language text,
 timeout_ms integer DEFAULT 3600000,
 throw_on_error boolean DEFAULT true,
 disable_service_logs boolean DEFAULT false
)

필수 매개 변수는 text, 입력 및 language, text가 작성된 언어입니다. 예를 들어 en-us 미국 영어이고 fr 프랑스어입니다. 사용 가능한 언어의 전체 목록은 언어 지원을 참조하세요.

기본적으로 엔터티 인식은 3,600,000ms = 1시간 안에 완료되지 않으면 중지됩니다. 를 변경 timeout_ms하여 이 지연을 사용자 지정할 수 있습니다.

오류가 발생하면 기본 동작은 예외를 throw하여 트랜잭션 롤백을 발생시키는 것입니다. false로 설정하여 이 동작을 사용하지 않도록 설정할 throw_on_error 수 있습니다.

전체 매개 변수 설명서는 Azure Cognitive Services 확장 설명서를 참조하세요.

예를 들어 이 쿼리를 호출합니다.

SELECT azure_cognitive.recognize_entities('For more information, see Cognitive Services Compliance and Privacy notes.', 'en-us');

다음 결과를 제공합니다.

{"(\"Cognitive Services\",Skill,\"\",0.94)"}

엔터티 이름이 "Cognitive Services"임을 나타내는 것은 신뢰도 점수가 0.94인 기술로 식별됩니다.

입력 텍스트에 테이블 열을 사용할 수 있습니다.

SELECT description, azure_cognitive.recognize_entities(description, 'en-us')
FROM listings LIMIT 1;

다음을 반환합니다.

 {"(house,Location,\"\",0.77)","(2013.,DateTime,DateRange,1)","(\"rooftop deck\",Location,\"\",0.88)","(\"lounge area\",Location,Structural,0.97)","(tub,Product,\"\",0.52)","
(5,Quantity,Number,0.8)","(bedrooms,Location,\"\",0.92)","(\"gourmet kitchen\",Location,\"\",0.87)","(2-3,Quantity,NumberRange,0.87)","(downtown,Location,Structural,0.8)","(\
"Queen Anne neighborhood\",Location,\"\",0.74)","(house,Location,\"\",0.96)","(barnwood,Product,\"\",0.61)","(steel,Product,\"\",0.73)","(concrete,Product,\"\",0.7)","(living
,Location,Structural,0.53)","(\"gourmet kitchen\",Location,\"\",0.7)","(kitchen,Location,\"\",0.77)","(reading,Skill,\"\",0.54)","(half,Quantity,Number,0.8)","(\"tv room\",Lo
cation,\"\",0.89)","(kitchen,Location,\"\",0.64)","(Fireplace,Product,\"\",0.91)","(sofa,Product,\"\",0.98)","(\"sitting area\",Location,\"\",0.93)","(\"Basement room\",Locat
ion,\"\",0.98)","(kids,PersonType,\"\",0.73)","(room,Location,Structural,0.78)","(patio,Location,Structural,0.75)","(basketball,Product,\"\",0.57)","(bedroom,Location,\"\",0.
8)","(basement,Location,\"\",0.94)","(\"concrete heated floors\",Product,\"\",0.95)","(\"queen sleeper sofa\",Product,\"\",0.86)","(tv,Location,\"\",0.54)","(basement,Locatio
n,\"\",0.92)","(room,Location,Structural,0.9)","(\"a second\",DateTime,Duration,0.85)","(family,PersonType,\"\",0.71)","(kids,PersonType,\"\",0.65)","(\"2nd floor\",Location,
Structural,0.56)","(4,Quantity,Number,0.8)","(bedrooms,Location,\"\",0.66)","(one,Quantity,Number,0.8)","(one,Quantity,Number,0.8)","(bedroom,Location,\"\",0.54)","(\"twin bu
nk beds\",Product,\"\",0.67)"}

요약

명명된 엔터티 인식은 입력 텍스트의 엔터티를 식별하고 분류합니다. Azure Cognitive Services 언어 모델은 무거운 자연어 처리를 수행합니다. Azure Database for PostgreSQL 확장 기능인 azure_ai은 SQL 쿼리 내에서 직접 명명된 엔터티를 인식할 수 있도록 azure_cognitive.recognize_entities API를 제공합니다.