기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
Amazon Comprehend Medical과 대규모 언어 모델 결합
NEJM AI의 2024년 연구에
-
Amazon Comprehend Medical의 초기 결과를 LLM의 컨텍스트로 사용하여 개체 선택의 정확도 향상
-
사용자 지정 개체 인식, 요약, 질문 응답 및 추가 사용 사례 구현
이 섹션에서는 검색 증강 생성(RAG) 접근 방식을 사용하여 Amazon Comprehend Medical을 LLM과 결합하는 방법을 설명합니다. Retrieval Augmented Generation(RAG)은 응답을 생성하기 전에 LLM이 훈련 데이터 소스 외부에 있는 신뢰할 수 있는 데이터 소스를 참조하는 생성형 AI 기술입니다. 자세한 내용은 RAG란 무엇입니까
이 접근 방식을 설명하기 위해이 섹션에서는 ICD-10-CM과 관련된 의료(진료) 코딩의 예를 사용합니다. 여기에는 혁신을 가속화하는 데 도움이 되는 샘플 아키텍처와 프롬프트 엔지니어링 템플릿이 포함되어 있습니다. 또한 RAG 워크플로 내에서 Amazon Comprehend Medical을 사용하는 모범 사례도 포함되어 있습니다.
Amazon Comprehend Medical을 사용한 RAG 기반 아키텍처
다음 다이어그램은 환자 메모에서 ICD-10-CM 진단 코드를 식별하기 위한 RAG 접근 방식을 보여줍니다. Amazon Comprehend Medical을 지식 소스로 사용합니다. RAG 접근 방식에서 검색 방법은 일반적으로 해당 지식이 포함된 벡터 데이터베이스에서 정보를 검색합니다. 벡터 데이터베이스 대신이 아키텍처는 검색 작업에 Amazon Comprehend Medical을 사용합니다. 오케스트레이터는 환자 메모 정보를 Amazon Comprehend Medical로 전송하고 ICD-10-CM 코드 정보를 검색합니다. 오케스트레이터는 Amazon Bedrock을 통해이 컨텍스트를 다운스트림 파운데이션 모델(LLM)로 보냅니다. LLM은 ICD-10-CM 코드 정보를 사용하여 응답을 생성하고 해당 응답은 클라이언트 애플리케이션으로 다시 전송됩니다.

다이어그램은 다음 RAG 워크플로를 보여줍니다.
-
클라이언트 애플리케이션은 환자 메모를 오케스트레이터에 쿼리로 전송합니다. 이러한 환자 참고 사항의 예로는 “환자는 X 박사의 71세 여성 환자입니다.이 환자는 지난 저녁에 약 7일~8일의 복부 통증 이력이 있으며, 이는 지속적이었습니다. 그녀는 명확한 열이나 오한이 없었고, 황달의 이력도 없었습니다. 환자는 최근에 체중이 크게 줄었다는 사실을 부인합니다.”
-
오케스트레이터는 Amazon Comprehend Medical을 사용하여 쿼리의 의료 정보와 관련된 ICD-10-CM 코드를 검색합니다. InferICD10CM API를 사용하여 환자 노트에서 ICD-10-CM 코드를 추출하고 추론합니다.
-
오케스트레이터는 프롬프트 템플릿, 원본 쿼리 및 Amazon Comprehend Medical에서 검색된 ICD-10-CM 코드가 포함된 프롬프트를 구성합니다. 이 향상된 컨텍스트를 Amazon Bedrock으로 전송합니다.
-
Amazon Bedrock은 입력을 처리하고 파운데이션 모델을 사용하여 ICD-10-CM 코드와 쿼리의 해당 증거를 포함하는 응답을 생성합니다. 생성된 응답에는 식별된 ICD-10-CM 코드와 각 코드를 지원하는 환자 메모의 증거가 포함됩니다. 다음은 샘플 응답입니다.
<response> <icd10> <code>R10.9</code> <evidence>history of abdominal pain</evidence> </icd10> <icd10> <code>R10.30</code> <evidence>history of abdominal pain</evidence> </icd10> </response>
-
Amazon Bedrock은 생성된 응답을 오케스트레이터에 전송합니다.
-
오케스트레이터는 응답을 클라이언트 애플리케이션으로 다시 전송하여 사용자가 응답을 검토할 수 있도록 합니다.
RAG 워크플로에서 Amazon Comprehend Medical을 사용하는 사용 사례
Amazon Comprehend Medical은 특정 NLP 작업을 수행할 수 있습니다. 자세한 내용은 Amazon Comprehend Medical 사용 사례를 참조하세요.
다음과 같은 고급 사용 사례를 위해 Amazon Comprehend Medical을 RAG 워크플로에 통합할 수 있습니다.
-
추출된 의료 엔터티를 환자 레코드의 컨텍스트 정보와 결합하여 자세한 임상 요약을 생성합니다.
-
코드 할당을 위해 온톨로지 연결 정보와 함께 추출된 개체를 사용하여 복잡한 사례에 대한 의료 코딩 자동화
-
추출된 의료 엔터티를 사용하여 구조화되지 않은 텍스트에서 구조화된 임상 노트 생성 자동화
-
추출된 약물 이름 및 속성을 기반으로 약물 부작용 분석
-
추출된 의료 정보를 up-to-date 연구 및 지침과 결합하는 지능형 임상 지원 시스템 개발
RAG 워크플로에서 Amazon Comprehend Medical을 사용하는 모범 사례
Amazon Comprehend Medical 결과를 LLM에 대한 프롬프트에 통합할 때는 모범 사례를 따르는 것이 중요합니다. 이렇게 하면 성능과 정확도가 향상될 수 있습니다. 다음은 주요 권장 사항입니다.
-
Amazon Comprehend Medical 신뢰도 점수 이해 - Amazon Comprehend Medical은 탐지된 각 개체 및 온톨로지 연결에 대한 신뢰도 점수를 제공합니다. 이러한 점수의 의미를 이해하고 특정 사용 사례에 적합한 임계값을 설정하는 것이 중요합니다. 신뢰도 점수는 신뢰도가 낮은 엔터티를 필터링하여 노이즈를 줄이고 LLM 입력의 품질을 개선하는 데 도움이 됩니다.
-
프롬프트 엔지니어링에서 신뢰도 점수 사용 - LLM에 대한 프롬프트를 생성할 때 Amazon Comprehend Medical 신뢰도 점수를 추가 컨텍스트로 통합하는 것이 좋습니다. 이렇게 하면 LLM이 신뢰도 수준에 따라 개체의 우선순위를 지정하거나 가중치를 부여하여 잠재적으로 출력 품질을 개선할 수 있습니다.
-
실측 데이터를 사용하여 Amazon Comprehend Medical 결과 평가 - 실측 데이터는 사실로 알려진 정보입니다. AI/ML 애플리케이션이 정확한 결과를 생성하고 있는지 검증하는 데 사용할 수 있습니다. Amazon Comprehend Medical 결과를 LLM 워크플로에 통합하기 전에 데이터의 대표 샘플에서 서비스의 성능을 평가합니다. 결과를 실측 주석과 비교하여 잠재적 불일치 또는 개선 영역을 식별합니다. 이 평가는 사용 사례에 대한 Amazon Comprehend Medical의 장점과 제한 사항을 이해하는 데 도움이 됩니다.
-
전략적으로 관련 정보 선택 - Amazon Comprehend Medical은 대량의 정보를 제공할 수 있지만 모든 정보가 작업과 관련이 있는 것은 아닙니다. 사용 사례와 가장 관련성이 높은 엔터티, 속성 및 메타데이터를 신중하게 선택합니다. LLM에 관련 없는 정보를 너무 많이 제공하면 노이즈가 발생하고 잠재적으로 성능이 저하될 수 있습니다.
-
개체 정의 조정 - Amazon Comprehend Medical에서 사용하는 개체 및 속성의 정의가 해석과 일치하는지 확인합니다. 불일치가 있는 경우 LLM에 추가 컨텍스트 또는 설명을 제공하여 Amazon Comprehend Medical 출력과 요구 사항 간의 차이를 연결하는 것이 좋습니다. Amazon Comprehend Medical 엔터티가 기대치를 충족하지 않는 경우 프롬프트에 추가 지침(및 가능한 예제)을 포함하여 사용자 지정 엔터티 감지를 구현할 수 있습니다.
-
도메인별 지식 제공 - Amazon Comprehend Medical은 중요한 의료 정보를 제공하지만 특정 도메인의 모든 미묘한 차이를 캡처하지는 못할 수 있습니다. Amazon Comprehend Medical 결과를 온톨로지, 용어 또는 전문가가 선별한 데이터 세트와 같은 추가 도메인별 지식 소스로 보완하는 것이 좋습니다. 이를 통해 LLM에 대한 보다 포괄적인 컨텍스트가 제공됩니다.
-
윤리적 및 규제 지침 준수 - 의료 데이터를 처리할 때는 데이터 프라이버시, 보안 및 의료 분야에서 AI 시스템의 책임 있는 사용과 관련된 것과 같은 윤리적 원칙과 규제 지침을 준수하는 것이 중요합니다. 구현이 관련 법률과 업계 모범 사례를 준수하는지 확인합니다.
이러한 모범 사례를 따르면 AI/ML 실무자는 Amazon Comprehend Medical과 LLMs. 의료 NLP 작업의 경우 이러한 모범 사례는 잠재적 위험을 완화하고 성능을 개선할 수 있습니다.
Amazon Comprehend Medical 컨텍스트에 대한 프롬프트 엔지니어링
프롬프트 엔지니어링
수행하는 API 작업에 따라 Amazon Comprehend Medical은 감지된 엔터티, 온톨로지 코드 및 설명, 신뢰도 점수를 반환합니다. 이러한 결과는 솔루션이 대상 LLM을 호출할 때 프롬프트 내에서 컨텍스트가 됩니다. 프롬프트 템플릿 내에 컨텍스트를 표시하도록 프롬프트를 엔지니어링해야 합니다.
참고
이 섹션의 예제 프롬프트는 Anthropic 지침을
일반적으로 원본 의료 텍스트와 Amazon Comprehend Medical 결과를 모두 프롬프트에 삽입합니다. 다음은 일반적인 프롬프트 구조입니다.
<medical_text> medical text </medical_text> <comprehend_medical_text_results> comprehend medical text results </comprehend_medical_text_results> <prompt_instructions> prompt instructions </prompt_instructions>
이 섹션에서는 Amazon Comprehend Medical 결과를 다음과 같은 일반적인 의료 NLP 작업에 대한 프롬프트 컨텍스트로 포함하는 전략을 제공합니다.
Amazon Comprehend Medical 결과 필터링
Amazon Comprehend Medical은 일반적으로 대량의 정보를 제공합니다. 의료 전문가가 검토해야 하는 결과 수를 줄일 수 있습니다. 이 경우 LLM을 사용하여 이러한 결과를 필터링할 수 있습니다. Amazon Comprehend Medical 엔터티에는 프롬프트를 설계할 때 필터링 메커니즘으로 사용할 수 있는 신뢰도 점수가 포함되어 있습니다.
다음은 환자 메모의 예입니다.
Carlie had a seizure 2 weeks ago. She is complaining of frequent headaches Nausea is also present. She also complains of eye trouble with blurry vision Meds : Topamax 50 mgs at breakfast daily, Send referral order to neurologist Follow-up as scheduled
이 환자 노트에서 Amazon Comprehend Medical은 다음 개체를 감지합니다.

엔터티는 다음 ICD-10-CM 코드에 연결되며,이 코드에는 졸림 및 머리카락이 포함됩니다.
범주 | ICD-10-CM 코드 | ICD-10-CM 설명 | 신뢰도 점수 |
---|---|---|---|
압수 | R56.9 | 지정되지 않은 충동 | 0.8348 |
압수 | G40.909 | 뇌전증 지속증이 없는 상세 불명, 난치성 뇌전증 | 0.5424 |
압수 | R56.00 | 단순해성 충동 | 0.4937 |
압수 | G40.09 | 기타 발작 | 0.4397 |
압수 | G40.409 | 난치성이 없고 뇌전증 지속 상태가 없는 기타 전신성 뇌전증 및 뇌전증성 증상 | 0.4138 |
머리카락 | R51 | 머리카락 | 0.4067 |
머리카락 | R51.9 | 상세 불명 머리카락 | 0.3844 |
머리카락 | G44.52 | 새로운 일일 지속형두통(NDPH) | 0.3005 |
머리카락 | G44 | 기타 골치 아픈 증상 | 0.2670 |
머리카락 | G44.8 | 기타 명시된 골치 아픈 증상 | 0.2542 |
프롬프트에 ICD-10-CM 코드를 전달하여 LLM 정밀도를 높일 수 있습니다. 노이즈를 줄이기 위해 Amazon Comprehend Medical 결과에 포함된 신뢰도 점수를 사용하여 ICD-10-CM 코드를 필터링할 수 있습니다. 다음은 신뢰도 점수가 0.4보다 높은 ICD-10-CM 코드만 포함하는 예제 프롬프트입니다.
<patient_note> Carlie had a seizure 2 weeks ago. She is complaining of frequent headaches Nausea is also present. She also complains of eye trouble with blurry vision Meds : Topamax 50 mgs at breakfast daily, Send referral order to neurologist Follow-up as scheduled </patient_note> <comprehend_medical_results> <icd-10> <entity> <text>seizure</text> <code> <description>Unspecified convulsions</description> <code_value>R56.9</code_value> <score>0.8347607851028442</score> </code> <code> <description>Epilepsy, unspecified, not intractable, without status epilepticus</description> <code_value>G40.909</code_value> <score>0.542376697063446</score> </code> <code> <description>Other seizures</description> <code_value>G40.89</code_value> <score>0.43966275453567505</score> </code> <code> <description>Other generalized epilepsy and epileptic syndromes, not intractable, without status epilepticus</description> <code_value>G40.409</code_value> <score>0.41382506489753723</score> </code> </entity> <entity> <text>headaches</text> <code> <description>Headache</description> <code_value>R51</code_value> <score>0.4066613018512726</score> </code> </entity> <entity> <text>Nausea</text> <code> <description>Nausea</description> <code_value>R11.0</code_value> <score>0.6460834741592407</score> </code> </entity> <entity> <text>eye trouble</text> <code> <description>Unspecified disorder of eye and adnexa</description> <code_value>H57.9</code_value> <score>0.6780954599380493</score> </code> <code> <description>Unspecified visual disturbance</description> <code_value>H53.9</code_value> <score>0.5871203541755676</score> </code> <code> <description>Unspecified disorder of binocular vision</description> <code_value>H53.30</code_value> <score>0.5539672374725342</score> </code> </entity> <entity> <text>blurry vision</text> <code> <description>Other visual disturbances</description> <code_value>H53.8</code_value> <score>0.9001834392547607</score> </code> </entity> </icd-10> </comprehend_medical_results> <prompt> Given the patient note and Amazon Comprehend Medical ICD-10-CM code results above, please select the most relevant ICD-10-CM diagnosis codes for the patient. For each selected code, provide a brief explanation of why it is relevant based on the information in the patient note. </prompt>
Amazon Comprehend Medical을 사용하여 의료 NLP 작업 확장
의료 텍스트를 처리할 때 Amazon Comprehend Medical의 컨텍스트는 LLM이 더 나은 토큰을 선택하는 데 도움이 될 수 있습니다. 이 예제에서는 진단 증상을 약과 일치시키려고 합니다. 또한 혈액 패널 검사와 관련된 용어와 같이 의료 검사와 관련된 텍스트를 찾고자 합니다. Amazon Comprehend Medical을 사용하여 엔터티와 약물 이름을 감지할 수 있습니다. 이 경우 Amazon Comprehend Medical용 DetectEntitiesV2 및 InferRxNorm APIs 사용합니다.
다음은 환자 메모의 예입니다.
Carlie had a seizure 2 weeks ago. She is complaining of increased frequent headaches Given lyme disease symptoms such as muscle ache and stiff neck will order prescription. Meds : Topamax 50 mgs at breakfast daily. Amoxicillan 25 mg by mouth twice a day Place MRI radiology order at RadNet
진단 코드에 초점을 맞추기 위해 프롬프트에는 유형의 MEDICAL_CONDITION
와 관련된 엔터티만 DX_NAME
사용됩니다. 관련성 때문에 다른 메타데이터는 제외됩니다. 약물 개체의 경우 추출된 속성과 함께 약물 이름이 포함됩니다. Amazon Comprehend Medical의 다른 약물 개체 메타데이터는 관련성으로 인해 제외됩니다. 다음은 필터링된 Amazon Comprehend Medical 결과를 사용하는 예제 프롬프트입니다. 프롬프트는 DX_NAME
유형이 있는 MEDICAL_CONDITION
엔터티에 중점을 둡니다. 이 프롬프트는 진단 코드를 의약품과 더 정확하게 연결하고 의료 주문 테스트를 더 정확하게 추출하도록 설계되었습니다.
<patient_note> Carlie had a seizure 2 weeks ago. She is complaining of increased freqeunt headaches Given lyme disease symptoms such as muscle ache and stiff neck will order prescription. Meds : Topamax 50 mgs at breakfast daily. Amoxicillan 25 mg by mouth twice a day Place MRI radiology order at RadNet </patient_note> <detect_entity_results> <entity> <text>seizure</text> <category>MEDICAL_CONDITION</category> <type>DX_NAME</type> </entity> <entity> <text>headaches</text> <category>MEDICAL_CONDITION</category> <type>DX_NAME</type> </entity> <entity> <text>lyme disease</text> <category>MEDICAL_CONDITION</category> <type>DX_NAME</type> </entity> <entity> <text>muscle ache</text> <category>MEDICAL_CONDITION</category> <type>DX_NAME</type> </entity> <entity> <text>stiff neck</text> <category>MEDICAL_CONDITION</category> <type>DX_NAME</type> </entity> </detect_entity_results> <rx_results> <entity> <text>Topamax</text> <category>MEDICATION</category> <type>BRAND_NAME</type> <attributes> <attribute> <type>FREQUENCY</type> <text>at breakfast daily</text> </attribute> <attribute> <type>DOSAGE</type> <text>50 mgs</text> </attribute> <attribute> <type>ROUTE_OR_MODE</type> <text>by mouth</text> </attribute> </attributes> </entity> <entity> <text>Amoxicillan</text> <category>MEDICATION</category> <type>GENERIC_NAME</type> <attributes> <attribute> <type>ROUTE_OR_MODE</type> <text>by mouth</text> </attribute> <attribute> <type>DOSAGE</type> <text>25 mg</text> </attribute> <attribute> <type>FREQUENCY</type> <text>twice a day</text> </attribute> </attributes> </entity> </rx_results> <prompt> Based on the patient note and the detected entities, can you please: 1. Link the diagnosis symptoms with the medications prescribed. Provide your reasoning for the linkages. 2. Extract any entities related to medical order tests mentioned in the note. </prompt>
Amazon Comprehend Medical을 사용하여 가드레일 적용
생성된 응답을 사용하기 전에 LLM 및 Amazon Comprehend Medical을 사용하여 가드레일을 생성할 수 있습니다. 수정되지 않았거나 사후 처리된 의료 텍스트에서이 워크플로를 실행할 수 있습니다. 사용 사례에는 보호 대상 건강 정보(PHI) 해결, 환각 감지 또는 결과 게시를 위한 사용자 지정 정책 구현이 포함됩니다. 예를 들어 Amazon Comprehend Medical의 컨텍스트를 사용하여 PHI 데이터를 식별한 다음 LLM을 사용하여 해당 PHI 데이터를 제거할 수 있습니다.
다음은 PHI를 포함하는 환자 레코드의 정보 예제입니다.
Patient name: John Doe Patient SSN: 123-34-5678 Patient DOB: 01/01/2024 Patient address: 123 Main St, Anytown USA Exam details: good health. Pulse is 60 bpm. needs to work on diet with BMI of 190
다음은 Amazon Comprehend Medical 결과를 컨텍스트로 포함하는 예제 프롬프트입니다.
<original_text> Patient name: John Doe Patient SSN: 123-34-5678 Patient DOB: 01/01/2024 Patient address: 123 Main St, Anytown USA Exam details: good health. Pulse is 60 bpm. needs to work on diet with BMI of 190 </original_text> <comprehend_medical_phi_entities> <entity> <text>John Doe</text> <category>PROTECTED_HEALTH_INFORMATION</category> <score>0.9967944025993347</score> <type>NAME</type> </entity> <entity> <text>123-34-5678</text> <category>PROTECTED_HEALTH_INFORMATION</category> <score>0.9998034834861755</score> <type>ID</type> </entity> <entity> <text>01/01/2000</text> <category>PROTECTED_HEALTH_INFORMATION</category> <score>0.9964448809623718</score> <type>DATE</type> </entity> </comprehend_medical_phi_entities> <instructions> Using the provided original text and the Amazon Comprehend Medical PHI entities detected, please analyze the text to determine if it contains any additional protected health information (PHI) beyond the entities already identified. If additional PHI is found, please list and categorize it. If no additional PHI is found, please state that explicitly. In addition if PHI is found, generate updated text with the PHI removed. </instructions>