사용 가능한 MedLM 모델인 MedLM-medium 및 MedLM-large는 의료 질의 응답 및 요약을 위한 기반 모델입니다. Vertex AI MedLM API를 사용해서 모델에 액세스할 수 있습니다. 이 페이지에서는 사용 가능한 MedLM 모델, 모델과 상호작용하는 데 사용되는 API, 동작을 맞춤설정하는 방법에 대한 개요를 제공합니다.
시작하기 전에
- 고객 책임, 규제 정보, 책임감 있는 AI 권장사항을 포함한 자세한 내용은 MedLM 모델 개요를 참조하세요.
MedLM의 사용 목적, 데이터 개요, 안전 정보와 같은 모델 세부정보는 MedLM 모델 카드를 참고하세요. 다음 링크를 클릭하여 MedLM 모델 카드의 PDF 버전을 다운로드합니다.
프롬프트 설계
MedLM 모델과 상호작용하려면 무엇을 생성하고 싶은지 모델에 알려주는 프롬프트라고도 부르는 자연어 명령을 보냅니다. 하지만 LLM은 경우에 따라 예기치 않은 방식으로 작동할 수 있습니다. 프롬프트 설계는 시행착오를 반복하는 과정이며, 숙련되기 위해 시간과 연습이 필요합니다. 일반적인 프롬프트 설계 전략에 대해 자세히 알아보려면 프롬프트 설계 소개를 참조하세요. 텍스트에 대한 태스크 특정 프롬프트 설계는 텍스트 프롬프트 설계를 참조하세요.
사용 사례
- 요약: 원본 텍스트의 관련 정보가 포함된 더 짧은 문서를 생성합니다. 예를 들어 외래 환자 방문을 기술하는 의료 메모를 요약하거나 특정 데이터 포인트의 관련 정보를 추출해야 할 수 있습니다.
- 질문 답변: 질문에 대한 답변을 텍스트로 제공합니다. 예를 들어 일반적인 의학적 질문을 하여 기술 자료에서 답변을 생성할 수 있습니다.
지원되는 모델
medlm-medium
medlm-large
시작하기
다음 샘플은 다음 인터페이스를 사용해서 MedLM API를 시작하는 방법을 보여줍니다.
- Vertex AI REST API
- Python용 Vertex AI SDK
- Vertex AI Studio
REST
요청 데이터를 사용하기 전에 다음을 바꿉니다.
PROJECT_ID
: 프로젝트 IDMEDLM_MODEL
: MedLM 모델(medlm-medium
또는medlm-large
)
HTTP 메서드 및 URL:
POST https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict
JSON 요청 본문:
{ "instances": [ { "content": "Question: What causes you to get ringworm?" } ], "parameters": { "temperature": 0, "maxOutputTokens": 256, "topK": 40, "topP": 0.95 } }
요청을 보내려면 다음 옵션 중 하나를 선택합니다.
curl
요청 본문을 request.json
파일에 저장합니다.
터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.
cat > request.json << 'EOF' { "instances": [ { "content": "Question: What causes you to get ringworm?" } ], "parameters": { "temperature": 0, "maxOutputTokens": 256, "topK": 40, "topP": 0.95 } } EOF
그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict"
PowerShell
요청 본문을 request.json
파일에 저장합니다.
터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.
@' { "instances": [ { "content": "Question: What causes you to get ringworm?" } ], "parameters": { "temperature": 0, "maxOutputTokens": 256, "topK": 40, "topP": 0.95 } } '@ | Out-File -FilePath request.json -Encoding utf8
그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict" | Select-Object -Expand Content
Python(Colaboratory)
Colaboratory에서 다음 Python 코드를 실행합니다.
!pip install google-cloud-aiplatform # The following restarts the runtime. import IPython app = IPython.Application.instance() # Note that this will result in a pop-up telling you that the session has # crashed for an unknown reason. This can be safely ignored and you can continue # with the following cells after getting this message. app.kernel.do_shutdown(True)
Colaboratory 노트북에서 다음 코드를 실행합니다. 표시된 Google Cloud 프로젝트 ID를 입력합니다. 프로젝트 ID를 찾으려면 프로젝트 ID 찾기를 참조하세요.
from google.colab import auth as google_auth import vertexai from vertexai.preview.language_models import TextGenerationModel google_auth.authenticate_user() # TODO: Replace with project ID from Cloud Console # (https://support.google.com/googleapi/answer/7014113) PROJECT_ID = 'my-project' # MedLM models are only available in us-central1. vertexai.init(project=PROJECT_ID, location='us-central1') parameters = { "candidate_count": 1, "max_output_tokens": 256, "temperature": 0.0, "top_k": 40, "top_p": 0.80, } model_instance = TextGenerationModel.from_pretrained("medlm-medium") response = model_instance.predict( "Question: What causes you to get ringworm?", **parameters ) print(f"Response from Model: {response.text}")
Vertex AI Studio
Vertex AI Studio를 사용해서 MedLM API로 전송되는 프롬프트를 설계, 테스트, 맞춤설정할 수 있습니다. MedLM용 Vertex AI Studio를 사용하기 전에 기본 요건으로 Vertex AI Studio 사용해 보기를 참고하세요.
Google Cloud 콘솔에서 Vertex AI Studio를 사용해서 MedLM 프롬프트를 테스트하려면 다음을 수행합니다.
- Google Cloud 콘솔의 Vertex AI 섹션에서 Vertex AI 스튜디오 페이지로 이동합니다.
- 시작하기를 클릭합니다.
- 프롬프트 만들기를 클릭합니다.
- 모델 메뉴에서
MedLM-Medium
또는MedLM-Large
를 선택합니다. - 프롬프트 필드에 프롬프트를 입력합니다.
- (선택사항) 강도 및 토큰 한도 값을 조정하여 응답에 미치는 영향을 실험할 수 있습니다. 기본값을 사용하는 것이 좋습니다. 어떤 값을 사용할지 확실하지 않으면 기본값을 사용하세요.
- 제출을 클릭하여 응답을 생성합니다.
- (선택사항) 프롬프트를 저장하려면 저장을 클릭합니다.
- (선택사항) 프롬프트에 대한 Python 코드 또는
curl
명령어를 보려면 코드 가져오기를 클릭합니다.
질의 응답 프롬프트
다음 섹션에는 질의 응답 프롬프트 샘플이 포함되어 있습니다. 각 샘플 프롬프트에는 권장되는 모델 및 매개변수 값이 포함됩니다.
긴 형식의 질의 응답
다음 샘플은 MedLM API가 쿼리로 형식화된 긴 형식의 의료 질문에 답변하는 방법을 보여줍니다.
REST
요청 데이터를 사용하기 전에 다음을 바꿉니다.
PROJECT_ID
: 프로젝트 IDMEDLM_MODEL
: MedLM 모델(medlm-medium
또는medlm-large
)
HTTP 메서드 및 URL:
POST https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict
JSON 요청 본문:
{ "instances": [ { "content": "Question: What causes you to get ringworm?" } ], "parameters": { "temperature": 0, "maxOutputTokens": 256, "topK": 40, "topP": 0.95 } }
요청을 보내려면 다음 옵션 중 하나를 선택합니다.
curl
요청 본문을 request.json
파일에 저장합니다.
터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.
cat > request.json << 'EOF' { "instances": [ { "content": "Question: What causes you to get ringworm?" } ], "parameters": { "temperature": 0, "maxOutputTokens": 256, "topK": 40, "topP": 0.95 } } EOF
그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict"
PowerShell
요청 본문을 request.json
파일에 저장합니다.
터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.
@' { "instances": [ { "content": "Question: What causes you to get ringworm?" } ], "parameters": { "temperature": 0, "maxOutputTokens": 256, "topK": 40, "topP": 0.95 } } '@ | Out-File -FilePath request.json -Encoding utf8
그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict" | Select-Object -Expand Content
객관식 질의 응답
다음 샘플은 MedLM API가 객관식 의료 질문에 답변하는 방법을 보여줍니다. 프롬프트는 다음과 같습니다.
Instructions: This text contains multiple-choice questions about medical knowledge. Solve each question step-by-step, starting by summarizing the available information. Select a single option from the four choices provided as the final answer.
Question 1: Which medication causes the maximum increase in prolactin level?
(A) Risperidone
(B) Clozapine
(C) Olanzapine
(D) Aripiprazole
Explanation: To solve this question, let's refer to authoritative sources. Clozapine generally does not elevate prolactin levels. Atypicals like olanzapine and aripiprazole cause little to no elevation. Risperidone, on the other hand, is known to result in a sustained elevated prolactin level. Therefore, risperidone is likely to cause the maximum increase in prolactin level.
Answer: (A)
Question 2: What is the recommended age for routine screening mammography?
(A) 20 years
(B) 30 years
(C) 40 years
(D) 50 years
Explanation: The age of routine screening may vary depending on the country. In the United States, according to the American Cancer Society, it is recommended to start routine screening mammography at 40 years of age. In Europe, it is typically closer to 50 years. For a patient based in the US, the best answer is 40 years.
Answer: (C)
Question 3: A 65-year-old male experiences severe back pain and paralysis in his left lower limb. Imaging studies show compression of nerve elements at the intervertebral foramen between vertebrae L5 and S1. Which structure is most likely causing this compression?
(A) Anulus fibrosus
(B) Nucleus pulposus
(C) Posterior longitudinal ligament
(D) Anterior longitudinal ligament
Explanation: This man's symptoms and imaging findings are consistent with a herniated intervertebral disk. The soft, gelatinous "nucleus pulposus" is forced out through a weakened part of the disk, resulting in back pain and nerve root irritation. In this case, the impingement is resulting in paralysis, which should be considered a medical emergency. Overall, the structure that is causing the compression and symptoms is the nucleus pulposus.
Answer: (B)
Question 4: Which cells in the lungs are also known as APUD cells?
(A) Dendritic cells
(B) Type I pneumocytes
(C) Type II pneumocytes
(D) Neuroendocrine cells
Explanation: Neuroendocrine cells, also known as Kultschitsky-type cells, Feyrter cells, and APUD cells, are found in the basal layer of the surface epithelium and in the bronchial glands.
Answer: (D)
Question 5: Which microorganism indicates remote contamination of water?
(A) Streptococci
(B) Staphylococci
(C) Clostridium perfringens
(D) Vibrio
Explanation: The presence of Clostridium perfringens in water indicates remote contamination because it is a spore-forming bacterium that can survive in the environment for extended periods of time.
Answer: (C)
REST
요청 데이터를 사용하기 전에 다음을 바꿉니다.
PROJECT_ID
: 프로젝트 IDMEDLM_MODEL
: MedLM 모델(medlm-medium
또는medlm-large
)
HTTP 메서드 및 URL:
POST https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict
JSON 요청 본문:
{ "instances": [ { "content": "Instructions: The following are multiple choice questions about medical knowledge. Solve them in a step-by-step fashion, starting by summarizing the available information. Output a single option from the four options as the final answer. \n \nQuestion: Maximum increase in prolactin level is caused by: \n(A) Risperidone (B) Clozapine (C) Olanzapine (D) Aripiprazole \nExplanation: Let's solve this step-by-step, referring to authoritative sources as needed. Clozapine generally does not raise prolactin levels. Atypicals such as olanzapine and aripiprazole cause small if no elevation. Risperidone is known to result in a sustained elevated prolactin level. Therefore risperidone is likely to cause the maximum increase in prolactin level. \nAnswer: (A) \n \nQuestion: What is the age of routine screening mammography? \n(A) 20 years (B) 30 years (C) 40 years (D) 50 years \nExplanation: Let's solve this step-by-step, referring to authoritative sources as needed. The age of routine screening depends on the country you are interested in and varies widely. For the US, it is 40 years of age according to the American Cancer Society. In Europe, it is typically closer to 50 years. For a patient based in the US, the best answer is 40 years. \nAnswer: (C) \n \nQuestion: A 65-year-old male complains of severe back pain and inability to move his left lower limb. Radiographic studies demonstrate the compression of nerve elements at the intervertebral foramen between vertebrae L5 and S1. Which structure is most likely responsible for this space-occupying lesion? \n(A) Anulus fibrosus (B) Nucleus pulposus (C) Posterior longitudinal ligament (D) Anterior longitudinal ligament \nExplanation: Let's solve this step-by-step, referring to authoritative sources as needed. This man describes a herniated invertebral disk through a tear in the surrounding annulus fibrosus. The soft, gelatinous \"nucleus pulposus\" is forced out through a weakened part of the disk, resulting in back pain and nerve root irritation. In this case, the impingement is resulting in paralysis, and should be considered a medical emergency. Overall, the structure that is causing the compression and symptoms is the nucleus pulposus. \nAnswer: (B) \n \nQuestion: Neuroendocrine cells in the lungs are: \n(A) Dendritic cells (B) Type I pneumocytes (C) Type II pneumocytes (D) APUD cells \nExplanation: Let's solve this step-by-step, referring to authoritative sources as needed. Neuroendocrine cells, which are also known as Kultschitsky-type cells, Feyrter cells and APUD cells, are found in the basal layer of the surface epithelium and in the bronchial glands. \nAnswer: (D) \n \nQuestion: Presence of it indicates remote contamination of water \n(A) Streptococci (B) Staphalococci (C) Clastridium pertringes (D) Nibrio \n" } ], "parameters": { "temperature": 0.2, "maxOutputTokens": 256 } }
요청을 보내려면 다음 옵션 중 하나를 선택합니다.
curl
요청 본문을 request.json
파일에 저장합니다.
터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.
cat > request.json << 'EOF' { "instances": [ { "content": "Instructions: The following are multiple choice questions about medical knowledge. Solve them in a step-by-step fashion, starting by summarizing the available information. Output a single option from the four options as the final answer. \n \nQuestion: Maximum increase in prolactin level is caused by: \n(A) Risperidone (B) Clozapine (C) Olanzapine (D) Aripiprazole \nExplanation: Let's solve this step-by-step, referring to authoritative sources as needed. Clozapine generally does not raise prolactin levels. Atypicals such as olanzapine and aripiprazole cause small if no elevation. Risperidone is known to result in a sustained elevated prolactin level. Therefore risperidone is likely to cause the maximum increase in prolactin level. \nAnswer: (A) \n \nQuestion: What is the age of routine screening mammography? \n(A) 20 years (B) 30 years (C) 40 years (D) 50 years \nExplanation: Let's solve this step-by-step, referring to authoritative sources as needed. The age of routine screening depends on the country you are interested in and varies widely. For the US, it is 40 years of age according to the American Cancer Society. In Europe, it is typically closer to 50 years. For a patient based in the US, the best answer is 40 years. \nAnswer: (C) \n \nQuestion: A 65-year-old male complains of severe back pain and inability to move his left lower limb. Radiographic studies demonstrate the compression of nerve elements at the intervertebral foramen between vertebrae L5 and S1. Which structure is most likely responsible for this space-occupying lesion? \n(A) Anulus fibrosus (B) Nucleus pulposus (C) Posterior longitudinal ligament (D) Anterior longitudinal ligament \nExplanation: Let's solve this step-by-step, referring to authoritative sources as needed. This man describes a herniated invertebral disk through a tear in the surrounding annulus fibrosus. The soft, gelatinous \"nucleus pulposus\" is forced out through a weakened part of the disk, resulting in back pain and nerve root irritation. In this case, the impingement is resulting in paralysis, and should be considered a medical emergency. Overall, the structure that is causing the compression and symptoms is the nucleus pulposus. \nAnswer: (B) \n \nQuestion: Neuroendocrine cells in the lungs are: \n(A) Dendritic cells (B) Type I pneumocytes (C) Type II pneumocytes (D) APUD cells \nExplanation: Let's solve this step-by-step, referring to authoritative sources as needed. Neuroendocrine cells, which are also known as Kultschitsky-type cells, Feyrter cells and APUD cells, are found in the basal layer of the surface epithelium and in the bronchial glands. \nAnswer: (D) \n \nQuestion: Presence of it indicates remote contamination of water \n(A) Streptococci (B) Staphalococci (C) Clastridium pertringes (D) Nibrio \n" } ], "parameters": { "temperature": 0.2, "maxOutputTokens": 256 } } EOF
그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict"
PowerShell
요청 본문을 request.json
파일에 저장합니다.
터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.
@' { "instances": [ { "content": "Instructions: The following are multiple choice questions about medical knowledge. Solve them in a step-by-step fashion, starting by summarizing the available information. Output a single option from the four options as the final answer. \n \nQuestion: Maximum increase in prolactin level is caused by: \n(A) Risperidone (B) Clozapine (C) Olanzapine (D) Aripiprazole \nExplanation: Let's solve this step-by-step, referring to authoritative sources as needed. Clozapine generally does not raise prolactin levels. Atypicals such as olanzapine and aripiprazole cause small if no elevation. Risperidone is known to result in a sustained elevated prolactin level. Therefore risperidone is likely to cause the maximum increase in prolactin level. \nAnswer: (A) \n \nQuestion: What is the age of routine screening mammography? \n(A) 20 years (B) 30 years (C) 40 years (D) 50 years \nExplanation: Let's solve this step-by-step, referring to authoritative sources as needed. The age of routine screening depends on the country you are interested in and varies widely. For the US, it is 40 years of age according to the American Cancer Society. In Europe, it is typically closer to 50 years. For a patient based in the US, the best answer is 40 years. \nAnswer: (C) \n \nQuestion: A 65-year-old male complains of severe back pain and inability to move his left lower limb. Radiographic studies demonstrate the compression of nerve elements at the intervertebral foramen between vertebrae L5 and S1. Which structure is most likely responsible for this space-occupying lesion? \n(A) Anulus fibrosus (B) Nucleus pulposus (C) Posterior longitudinal ligament (D) Anterior longitudinal ligament \nExplanation: Let's solve this step-by-step, referring to authoritative sources as needed. This man describes a herniated invertebral disk through a tear in the surrounding annulus fibrosus. The soft, gelatinous \"nucleus pulposus\" is forced out through a weakened part of the disk, resulting in back pain and nerve root irritation. In this case, the impingement is resulting in paralysis, and should be considered a medical emergency. Overall, the structure that is causing the compression and symptoms is the nucleus pulposus. \nAnswer: (B) \n \nQuestion: Neuroendocrine cells in the lungs are: \n(A) Dendritic cells (B) Type I pneumocytes (C) Type II pneumocytes (D) APUD cells \nExplanation: Let's solve this step-by-step, referring to authoritative sources as needed. Neuroendocrine cells, which are also known as Kultschitsky-type cells, Feyrter cells and APUD cells, are found in the basal layer of the surface epithelium and in the bronchial glands. \nAnswer: (D) \n \nQuestion: Presence of it indicates remote contamination of water \n(A) Streptococci (B) Staphalococci (C) Clastridium pertringes (D) Nibrio \n" } ], "parameters": { "temperature": 0.2, "maxOutputTokens": 256 } } '@ | Out-File -FilePath request.json -Encoding utf8
그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict" | Select-Object -Expand Content
요약 프롬프트
다음 섹션에는 요약 프롬프트 샘플이 포함되어 있습니다. 각 샘플 프롬프트에는 권장되는 모델 및 매개변수 값이 포함됩니다.
방문 후 요약 작성
다음 샘플은 외래 환자 방문 메모를 기준으로 환자에 대해 방문 후 요약을 생성하는 방법을 보여줍니다. 프롬프트에는 다음이 포함됩니다.
- 모델 명령이 포함된 프리앰블
- 요약을 위해 추출할 각 필드의 설명
방문 후 요약의 형식은 Sieferd et al.(2019) 및 영국 왕립 의학 아카데미를 기준으로 합니다. 메모 및 요약 전 선택적으로 퓨샷 예시를 추가할 수 있습니다.
프롬프트는 다음과 같습니다.
Please read through the provided medical note describing an outpatient visit and extract the relevant information for each of the following 12 fields: - Patient name/age/gender: This should summarize the patient's name, age and gender. It should use the format: "[Patient name], [age] year old [gender]". If the name is not mentioned in the note, please answer "Not available". - Today I was seen by: This field should provide the name of the provider. If the provider seen for the note being summarized is not mentioned, please answer "Not available". - I came in today for: This field should indicate the chief complaint or complaints that caused the visit. - New health issues identified today are: This field should indicate any new diagnoses or other issues identified as a result of the visit being summarized. If the issue is a pre-existing condition identified in the past, please answer "No new diagnosis". - Other health issues I have are: This field should indicate any pre-existing health issues identified in notes. - Today we accomplished: This field should summarize the main topics of discussion and results of any procedures performed during the current visit. The summary could be a short list of procedures, or could be a text description of the patient's experience. Please be as brief as possible when providing details, such as test results or medication names. Describing the experience from the patient's point of view, using phrases like "my visit", "my condition". - My important numbers: This field should provide the results of any measurements relevant to the visit, including vitals. Provide the results of any numeric measurements relevant to the visit, including vitals, laboratory studies, or pain scores. Please include the numbers that should be monitored. Do not fabricate numbers that are not presented in the note. - Changes to my medications are: This field should specify any medications that were added, for which the doses were updated, or which are no longer needed after the visit. Please specify both newly added and stopped medications when possible. If no changes are apparent from the note, please answer "no changes". - Other medications I have are: If the note indicates any existing medications for the patient that the patient should continue taking without changes, list them here. If no medications are indicated in the note, please "Not specified". - My next steps are: This field should document the patient's next steps, including any actions they should take, test results they should expect, and follow-up visits they should schedule, along with the appropriate time frames for each. - I should seek immediate medical attention if: If the note specifies any conditions for which the patient should immediately seek care, specify it here. Be sure to only include conditions that are mentioned in the note. If no conditions are mentioned, write "Not specified". - Other comments from my provider: This is an optional extra field that captures any additional relevant information the provider indicated in the notes that it would be useful for the patient to know. Do not include information that is already listed in the previous field. For each field, write at a sixth-grade reading level and avoid using abbreviations or jargon. Output the summary in the following format: - Patient name/age/gender: - Today I was seen by: - I came in today for: - New health issues identified today are: - Other health issues I have are: - Today we accomplished: - My important numbers: - Changes to my medications are: - Other medications I have are: - My next steps are: - I should seek immediate medical attention if: - Other comments from my provider: Note: INPUT_NOTE After Visit Summary:
REST
요청 데이터를 사용하기 전에 다음을 바꿉니다.
PROJECT_ID
: 프로젝트 IDMEDLM_MODEL
: MedLM 모델(medlm-medium
또는medlm-large
)INPUT_NOTE
: 요약할 입력 메모입니다.
HTTP 메서드 및 URL:
POST https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict
JSON 요청 본문:
{ "instances": [ { "content": "Please read through the provided medical note describing an outpatient visit and extract the relevant information for each of the following 12 fields:\n\n- Patient name/age/gender: This should summarize the patient\u2019s name, age and gender. It should use the format: '[Patient name], [age] year old [gender]'. If the name is not mentioned in the note, please answer \"Not available\".\n- Today I was seen by: This field should provide the name of the provider. If the provider seen for the note being summarized is not mentioned, please answer 'Not available'.\n- I came in today for: This field should indicate the chief complaint or complaints that caused the visit.\n- New health issues identified today are: This field should indicate any new diagnoses or other issues identified as a result of the visit being summarized. If the issue is a pre-existing condition identified in the past, please answer 'No new diagnosis'.\n- Other health issues I have are: This field should indicate any pre-existing health issues identified in notes.\n- Today we accomplished: This field should summarize the main topics of discussion and results of any procedures performed during the current visit. The summary could be a short list of procedures, or could be a text description of the patient\u2019s experience. Please be as brief as possible when providing details, such as test results or medication names. Describing the experience from the patient\u2019s point of view, using phrases like 'my visit', 'my condition'.\n- My important numbers: This field should provide the results of any measurements relevant to the visit, including vitals. Provide the results of any numeric measurements relevant to the visit, including vitals, laboratory studies, or pain scores. Please include the numbers that should be monitored. Do not fabricate numbers that are not presented in the note.\n\n\n\n\n\n\n\n\n- Changes to my medications are: This field should specify any medications that were added, for which the doses were updated, or which are no longer needed after the visit. Please specify both newly added and stopped medications when possible. If no changes are apparent from the note, please answer 'no changes'.\n- Other medications I have are: If the note indicates any existing medications for the patient that the patient should continue taking without changes, list them here. If no medications are indicated in the note, please 'Not specified'.\n- My next steps are: This field should document the patient\u2019s next steps, including any actions they should take, test results they should expect, and follow-up visits they should schedule, along with the appropriate time frames for each.\n- I should seek immediate medical attention if: If the note specifies any conditions for which the patient should immediately seek care, specify it here. Be sure to only include conditions that are mentioned in the note. If no conditions are mentioned, write 'Not specified'.\n- Other comments from my provider: This is an optional extra field that captures any additional relevant information the provider indicated in the notes that it would be useful for the patient to know. Do not include information that is already listed in the previous field.\nFor each field, write at a sixth-grade reading level and avoid using abbreviations or jargon.\n\nOutput the summary in the following format:\n- Patient name/age/gender:\n- Today I was seen by:\n- I came in today for:\n- New health issues identified today are:\n- Other health issues I have are:\n- Today we accomplished:\n- My important numbers:\n- Changes to my medications are:\n- Other medications I have are:\n- My next steps are:\n- I should seek immediate medical attention if:\n- Other comments from my provider:\n\n Note:\n\n INPUT_NOTE \n\nAfter Visit Summary:" } ], "parameters": { "candidate_count": 1, "temperature": 0, "maxOutputTokens": 1024, "topK": 40, "topP": 0.80 } }
요청을 보내려면 다음 옵션 중 하나를 선택합니다.
curl
요청 본문을 request.json
파일에 저장합니다.
터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.
cat > request.json << 'EOF' { "instances": [ { "content": "Please read through the provided medical note describing an outpatient visit and extract the relevant information for each of the following 12 fields:\n\n- Patient name/age/gender: This should summarize the patient\u2019s name, age and gender. It should use the format: '[Patient name], [age] year old [gender]'. If the name is not mentioned in the note, please answer \"Not available\".\n- Today I was seen by: This field should provide the name of the provider. If the provider seen for the note being summarized is not mentioned, please answer 'Not available'.\n- I came in today for: This field should indicate the chief complaint or complaints that caused the visit.\n- New health issues identified today are: This field should indicate any new diagnoses or other issues identified as a result of the visit being summarized. If the issue is a pre-existing condition identified in the past, please answer 'No new diagnosis'.\n- Other health issues I have are: This field should indicate any pre-existing health issues identified in notes.\n- Today we accomplished: This field should summarize the main topics of discussion and results of any procedures performed during the current visit. The summary could be a short list of procedures, or could be a text description of the patient\u2019s experience. Please be as brief as possible when providing details, such as test results or medication names. Describing the experience from the patient\u2019s point of view, using phrases like 'my visit', 'my condition'.\n- My important numbers: This field should provide the results of any measurements relevant to the visit, including vitals. Provide the results of any numeric measurements relevant to the visit, including vitals, laboratory studies, or pain scores. Please include the numbers that should be monitored. Do not fabricate numbers that are not presented in the note.\n\n\n\n\n\n\n\n\n- Changes to my medications are: This field should specify any medications that were added, for which the doses were updated, or which are no longer needed after the visit. Please specify both newly added and stopped medications when possible. If no changes are apparent from the note, please answer 'no changes'.\n- Other medications I have are: If the note indicates any existing medications for the patient that the patient should continue taking without changes, list them here. If no medications are indicated in the note, please 'Not specified'.\n- My next steps are: This field should document the patient\u2019s next steps, including any actions they should take, test results they should expect, and follow-up visits they should schedule, along with the appropriate time frames for each.\n- I should seek immediate medical attention if: If the note specifies any conditions for which the patient should immediately seek care, specify it here. Be sure to only include conditions that are mentioned in the note. If no conditions are mentioned, write 'Not specified'.\n- Other comments from my provider: This is an optional extra field that captures any additional relevant information the provider indicated in the notes that it would be useful for the patient to know. Do not include information that is already listed in the previous field.\nFor each field, write at a sixth-grade reading level and avoid using abbreviations or jargon.\n\nOutput the summary in the following format:\n- Patient name/age/gender:\n- Today I was seen by:\n- I came in today for:\n- New health issues identified today are:\n- Other health issues I have are:\n- Today we accomplished:\n- My important numbers:\n- Changes to my medications are:\n- Other medications I have are:\n- My next steps are:\n- I should seek immediate medical attention if:\n- Other comments from my provider:\n\n Note:\n\n INPUT_NOTE \n\nAfter Visit Summary:" } ], "parameters": { "candidate_count": 1, "temperature": 0, "maxOutputTokens": 1024, "topK": 40, "topP": 0.80 } } EOF
그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict"
PowerShell
요청 본문을 request.json
파일에 저장합니다.
터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.
@' { "instances": [ { "content": "Please read through the provided medical note describing an outpatient visit and extract the relevant information for each of the following 12 fields:\n\n- Patient name/age/gender: This should summarize the patient\u2019s name, age and gender. It should use the format: '[Patient name], [age] year old [gender]'. If the name is not mentioned in the note, please answer \"Not available\".\n- Today I was seen by: This field should provide the name of the provider. If the provider seen for the note being summarized is not mentioned, please answer 'Not available'.\n- I came in today for: This field should indicate the chief complaint or complaints that caused the visit.\n- New health issues identified today are: This field should indicate any new diagnoses or other issues identified as a result of the visit being summarized. If the issue is a pre-existing condition identified in the past, please answer 'No new diagnosis'.\n- Other health issues I have are: This field should indicate any pre-existing health issues identified in notes.\n- Today we accomplished: This field should summarize the main topics of discussion and results of any procedures performed during the current visit. The summary could be a short list of procedures, or could be a text description of the patient\u2019s experience. Please be as brief as possible when providing details, such as test results or medication names. Describing the experience from the patient\u2019s point of view, using phrases like 'my visit', 'my condition'.\n- My important numbers: This field should provide the results of any measurements relevant to the visit, including vitals. Provide the results of any numeric measurements relevant to the visit, including vitals, laboratory studies, or pain scores. Please include the numbers that should be monitored. Do not fabricate numbers that are not presented in the note.\n\n\n\n\n\n\n\n\n- Changes to my medications are: This field should specify any medications that were added, for which the doses were updated, or which are no longer needed after the visit. Please specify both newly added and stopped medications when possible. If no changes are apparent from the note, please answer 'no changes'.\n- Other medications I have are: If the note indicates any existing medications for the patient that the patient should continue taking without changes, list them here. If no medications are indicated in the note, please 'Not specified'.\n- My next steps are: This field should document the patient\u2019s next steps, including any actions they should take, test results they should expect, and follow-up visits they should schedule, along with the appropriate time frames for each.\n- I should seek immediate medical attention if: If the note specifies any conditions for which the patient should immediately seek care, specify it here. Be sure to only include conditions that are mentioned in the note. If no conditions are mentioned, write 'Not specified'.\n- Other comments from my provider: This is an optional extra field that captures any additional relevant information the provider indicated in the notes that it would be useful for the patient to know. Do not include information that is already listed in the previous field.\nFor each field, write at a sixth-grade reading level and avoid using abbreviations or jargon.\n\nOutput the summary in the following format:\n- Patient name/age/gender:\n- Today I was seen by:\n- I came in today for:\n- New health issues identified today are:\n- Other health issues I have are:\n- Today we accomplished:\n- My important numbers:\n- Changes to my medications are:\n- Other medications I have are:\n- My next steps are:\n- I should seek immediate medical attention if:\n- Other comments from my provider:\n\n Note:\n\n INPUT_NOTE \n\nAfter Visit Summary:" } ], "parameters": { "candidate_count": 1, "temperature": 0, "maxOutputTokens": 1024, "topK": 40, "topP": 0.80 } } '@ | Out-File -FilePath request.json -Encoding utf8
그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict" | Select-Object -Expand Content
스크립트에서 기록 및 물리적 조사(H&P) 메모 작성
다음 샘플은 공급자와 환자 사이의 의료 대화 스크립트로부터 초안 기록 및 물리적 조사(H&P) 메모를 작성하도록 MedLM API에 요청을 전송하여 임상 문서 기록을 가속화하는 방법을 보여줍니다.
H&P 메모는 환자의 의료 기록과 공급자가 수행한 물리적 검사를 기술하는 포괄적인 임상 메모입니다. MedLM은 의료 방문 기간 중 공급자와 환자 사이의 대화로부터 이러한 메모 초안을 작성하는 데 필요한 상당한 임상 정보를 수집할 수 있습니다.
의료 대화 스크립트가 다음 형식으로 되어 있다고 가정해 보세요. 대화의 발언자는 다음과 같습니다.
PROVIDER: Welcome! How can we help you this morning?
PATIENT: I think I hurt my ankle while playing football last night. Now even walking hurts.
PROVIDER: I am sorry to hear that. Can you tell me how it happened?
PATIENT: I was playing soccer last night and I think I trip and twisted my ankle.
PROVIDER: Did it start hurting right away? Did you try anything to alleviate the pain?
PATIENT: It got worse last night. I took some ibuprofen, but it really didn't help.
REST
요청 데이터를 사용하기 전에 다음을 바꿉니다.
PROJECT_ID
: 프로젝트 IDMEDLM_MODEL
: MedLM 모델(medlm-medium
또는medlm-large
)
HTTP 메서드 및 URL:
POST https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict
JSON 요청 본문:
{ "instances": [ { "content": "You are charting a patient record. Read through the provided transcript of a conversation between a healthcare provider and a patient and write a history and physical examination note.\n\nTranscript: \n PROVIDER: Welcome! How can we help you this morning?\nPATIENT: I think I hurt my ankle while playing football last night. Now even walking hurts.\nPROVIDER: I am sorry to hear that. Can you tell me how it happened?\nPATIENT: I was playing soccer last night and I think I trip and twisted my ankle.\nPROVIDER: Did it start hurting right away? Did you try anything to alleviate the pain?\nPATIENT: It got worse last night. I took some ibuprofen, but it really didn't help.\n\nHistory and Physical Note:" } ], "parameters": { "candidate_count": 1, "temperature": 0, "maxOutputTokens": 1024, "topK": 40, "topP": 0.80 } }
요청을 보내려면 다음 옵션 중 하나를 선택합니다.
curl
요청 본문을 request.json
파일에 저장합니다.
터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.
cat > request.json << 'EOF' { "instances": [ { "content": "You are charting a patient record. Read through the provided transcript of a conversation between a healthcare provider and a patient and write a history and physical examination note.\n\nTranscript: \n PROVIDER: Welcome! How can we help you this morning?\nPATIENT: I think I hurt my ankle while playing football last night. Now even walking hurts.\nPROVIDER: I am sorry to hear that. Can you tell me how it happened?\nPATIENT: I was playing soccer last night and I think I trip and twisted my ankle.\nPROVIDER: Did it start hurting right away? Did you try anything to alleviate the pain?\nPATIENT: It got worse last night. I took some ibuprofen, but it really didn't help.\n\nHistory and Physical Note:" } ], "parameters": { "candidate_count": 1, "temperature": 0, "maxOutputTokens": 1024, "topK": 40, "topP": 0.80 } } EOF
그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict"
PowerShell
요청 본문을 request.json
파일에 저장합니다.
터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.
@' { "instances": [ { "content": "You are charting a patient record. Read through the provided transcript of a conversation between a healthcare provider and a patient and write a history and physical examination note.\n\nTranscript: \n PROVIDER: Welcome! How can we help you this morning?\nPATIENT: I think I hurt my ankle while playing football last night. Now even walking hurts.\nPROVIDER: I am sorry to hear that. Can you tell me how it happened?\nPATIENT: I was playing soccer last night and I think I trip and twisted my ankle.\nPROVIDER: Did it start hurting right away? Did you try anything to alleviate the pain?\nPATIENT: It got worse last night. I took some ibuprofen, but it really didn't help.\n\nHistory and Physical Note:" } ], "parameters": { "candidate_count": 1, "temperature": 0, "maxOutputTokens": 1024, "topK": 40, "topP": 0.80 } } '@ | Out-File -FilePath request.json -Encoding utf8
그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict" | Select-Object -Expand Content
Python(Colaboratory)
Colaboratory에서 다음 Python 코드를 실행합니다.
!pip install google-cloud-aiplatform # The following restarts the runtime. import IPython app = IPython.Application.instance() # Note that this will result in a pop-up telling you that the session has # crashed for an unknown reason. This can be safely ignored and you can continue # with the following cells after getting this message. app.kernel.do_shutdown(True)
Colaboratory 노트북에서 다음 코드를 실행합니다. 표시된 Google Cloud 프로젝트 ID를 입력합니다. 프로젝트 ID를 찾으려면 프로젝트 ID 찾기를 참조하세요.
표시된 의료 스크립트를 입력합니다.
from google.colab import auth as google_auth import vertexai from vertexai.preview.language_models import TextGenerationModel google_auth.authenticate_user() # TODO: Replace with project ID from Cloud Console # (https://support.google.com/googleapi/answer/7014113) PROJECT_ID = 'my-project' # MedLM models are only available in us-central1. vertexai.init(project=PROJECT_ID, location='us-central1') # TODO: Replace with transcript. transcript = """ # TODO: Replace with transcript. """ note_generation_prompt = f"""\ You are charting a patient record. Read through the provided transcript of a conversation between a healthcare provider and a patient and write a history and physical examination note. Transcript: {transcript} History and Physical note: """ parameters = { "candidate_count": 1, "max_output_tokens": 1024, "temperature": 0.0, "top_p": 0.80, "top_k": 40 } model_instance = TextGenerationModel.from_pretrained("medlm-medium") response = model_instance.predict( note_generation_prompt, **parameters ) note = response.text
다음에 유의하세요.
- 생성된 메모는 부정확한 내용을 포함할 수 있으며 제출 전 전문의의 검토가 필요합니다.
- 생성된 메모는 임상 부서 또는 전문 분야의 형식 또는 필수 템플릿을 엄격하게 준수하지 않을 수 있습니다. 환자 차트 기록 시 시작점으로 사용됩니다.
- 생성된 메모의 품질은 제공된 스크립트의 정확도로 제한됩니다.
형평성에 중점을 둔 평가 및 완화 수단 구현
MedLM은 질문과 문구에 따라 그룹별로 정확도가 낮은 결과를 생성할 수 있습니다. 인구통계 그룹 간 모델 출력의 성능 차이가 건강 불평등을 악화시키고 유해한 편향을 지속시킬 가능성이 있습니다. 이러한 출력의 부정확성은 MedLM에만 있는 것이 아니며 기존의 사회적, 구조적 불평등, 의료적 오해, 부정적인 고정관념, 학습 데이터의 다양성 부족 등 여러 요인으로 인해 비롯되는 경우가 많습니다.
형평성에 중점을 둔 평가 및 완화 수단 구현을 고려해 보세요. 여기에는 다음과 같은 내용이 포함되어 있습니다.
- 다양한 모집단(예: 인종 및 민족, 사회경제적 지위(SES), 지역, 성 정체성, 성적 지향, 연령, 언어 선호도, 계층 등) 내에서 의도된 사용 사례의 모델 성능 및 행동 평가
- 성과에 대한 피드백 획득
- 건강의 사회적, 구조적 특성을 정의하고 다루는 학제 간 전문가 및 외부 파트너의 참여
- 편향 문제를 평가하고 해결하기 위한 지속적인 모니터링 노력 수행
사용 사례에 따라 형평성에 중점을 둔 명령으로 프롬프트를 강화하면 편향 및 형평성에 따라 MedLM 출력 품질을 개선할 수 있습니다.
예를 들어 다음 텍스트를 프롬프트의 시작 부분에 넣으면 Omiyes et al.(2023)에 표시된 것처럼 인종에 기반한 의학 질문에 대한 결과의 품질이 개선됩니다.
You are a medical knowledge assistant who provides useful, complete, and
scientifically-grounded answers to queries. Your answers are unbiased and
up-to-date, and you follow the latest clinical guidelines. You are aware that
guidelines may have changed recently in order to address bias and inaccurate
information about disadvantaged groups. You are committed to providing the best
possible care to all patients, regardless of their race, gender, or
geographical location. You are always learning and growing, and you are open to
feedback. Only account for race, gender, or geographical location in your
answer if you are 100% sure it is correct and unbiased, with no possibility of
making a mistake or providing a response based on outdated guidelines.
프롬프트를 변경하면 모델 출력에 영향을 주므로 다른 성능 영역이 영향을 받지 않도록 전체 평가를 수행하는 것이 좋습니다.
모델 성능에 대한 추가 고려사항은 MedLM 모델 카드를 참조하세요.