Les modèles MedLM, MedLM-medium et MedLM-large disponibles sont des modèles de fondation pour les réponses aux questions médicales et leur synthèse. Vous pouvez accéder aux modèles à l'aide de l'API Vertex AI MedLM. Cette page vous offre un aperçu des modèles MedLM disponibles, des API que vous utilisez pour interagir avec les modèles et des moyens de personnaliser leurs comportements.
Avant de commencer
- Consultez la présentation des modèles MedLM pour en savoir plus sur les responsabilités des clients, les informations sur les réglementations et les bonnes pratiques de l'IA responsable.
Consultez la fiche de modèle MedLM pour obtenir des détails sur le modèle tels que l'utilisation prévue de MedLM, la présentation des données et les informations de sécurité. Cliquez sur le lien suivant pour télécharger une version PDF de la fiche de modèle MedLM :
Conception de requête
Pour interagir avec les modèles MedLM, envoyez des instructions en langage naturel, également appelées requêtes, qui indiquent au modèle ce que vous souhaitez générer. Cependant, les LLM peuvent parfois se comporter de manière imprévisible. La conception d'invites est un processus itératif empirique qui ne peut être maîtrisé qu'avec du temps et de l'entraînement. Pour en savoir plus sur les stratégies générales de conception d'invites, consultez la page Présentation de la conception d'invites. Pour obtenir des conseils de conception de requêtes spécifiques pour le texte, consultez la section Concevoir des requêtes textuelles.
Cas d'utilisation
- Synthèse : créez une version plus courte d'un document qui intègre des informations pertinentes à partir du texte d'origine. Par exemple, vous pouvez résumer une note médicale décrivant une visite ambulatoire et extraire des informations pertinentes pour des points de données spécifiques.
- Réponse à des questions: fournir des réponses aux questions sous forme de texte. Par exemple, vous pouvez poser une question médicale d'ordre général pour générer des réponses à partir de la base de connaissances.
Modèles compatibles
medlm-medium
medlm-large
Premiers pas
Les exemples suivants montrent comment débuter avec l'API MedLM à l'aide des interfaces suivantes :
- API REST de Vertex AI
- SDK Vertex AI pour Python
- Vertex AI Studio
REST
Avant d'utiliser les données de requête, effectuez les remplacements suivants :
PROJECT_ID
: l'ID de votre projet.MEDLM_MODEL
: modèle MedLM (medlm-medium
oumedlm-large
).
Méthode HTTP et URL :
POST https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict
Corps JSON de la requête :
{ "instances": [ { "content": "Question: What causes you to get ringworm?" } ], "parameters": { "temperature": 0, "maxOutputTokens": 256, "topK": 40, "topP": 0.95 } }
Pour envoyer votre requête, choisissez l'une des options suivantes :
curl
Enregistrez le corps de la requête dans un fichier nommé request.json
.
Exécutez la commande suivante dans le terminal pour créer ou écraser ce fichier dans le répertoire actuel :
cat > request.json << 'EOF' { "instances": [ { "content": "Question: What causes you to get ringworm?" } ], "parameters": { "temperature": 0, "maxOutputTokens": 256, "topK": 40, "topP": 0.95 } } EOF
Exécutez ensuite la commande suivante pour envoyer votre requête 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
Enregistrez le corps de la requête dans un fichier nommé request.json
.
Exécutez la commande suivante dans le terminal pour créer ou écraser ce fichier dans le répertoire actuel :
@' { "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
Exécutez ensuite la commande suivante pour envoyer votre requête 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)
Exécutez le code Python suivant dans Colaboratory.
!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)
Exécutez le code suivant dans votre notebook Colaboratory. Saisissez l'ID de votre projet Google Cloud à l'emplacement indiqué. Pour trouver votre ID de projet, consultez la section Localiser l'ID de projet.
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}")
Generative AI Studio
Utilisez Vertex AI Studio pour concevoir, tester et personnaliser les requêtes envoyées à l'API MedLM. Avant d'utiliser Vertex AI Studio pour MedLM, consultez la page Essayer Vertex AI Studio pour connaître les conditions préalables.
Pour tester une requête MedLM à l'aide de Vertex AI Studio dans la console Google Cloud, procédez comme suit :
- Dans la section "Vertex AI" de la console Google Cloud, accédez à la page Vertex AI Studio.
- Cliquez sur Commencer.
- Cliquez sur Créer une requête.
- Dans le menu Modèle, sélectionnez
MedLM-Medium
ouMedLM-Large
. - Dans le champ Requête, saisissez votre requête.
- (Facultatif) Vous pouvez ajuster les valeurs Température et Limite de jetons pour tester leur impact sur la réponse. Nous vous recommandons d'utiliser les valeurs par défaut. Si vous ne savez pas quelles valeurs utiliser, utilisez celles par défaut.
- Cliquez sur Envoyer pour générer une réponse.
- (Facultatif) Pour enregistrer une requête, cliquez sur Enregistrer.
- (Facultatif) Pour afficher le code Python ou une commande
curl
de votre requête, cliquez sur Obtenir le code.
Requêtes de réponses à des questions
Les sections suivantes contiennent des exemples d'invites de réponses à des questions. Chaque exemple de requête inclut le modèle et les valeurs de paramètres recommandés.
Réponses à des questions longues
Les exemples suivants montrent comment l'API MedLM répond à une question médicale longue formulée sous forme de requête.
REST
Avant d'utiliser les données de requête, effectuez les remplacements suivants :
PROJECT_ID
: l'ID de votre projet.MEDLM_MODEL
: modèle MedLM (medlm-medium
oumedlm-large
).
Méthode HTTP et URL :
POST https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict
Corps JSON de la requête :
{ "instances": [ { "content": "Question: What causes you to get ringworm?" } ], "parameters": { "temperature": 0, "maxOutputTokens": 256, "topK": 40, "topP": 0.95 } }
Pour envoyer votre requête, choisissez l'une des options suivantes :
curl
Enregistrez le corps de la requête dans un fichier nommé request.json
.
Exécutez la commande suivante dans le terminal pour créer ou écraser ce fichier dans le répertoire actuel :
cat > request.json << 'EOF' { "instances": [ { "content": "Question: What causes you to get ringworm?" } ], "parameters": { "temperature": 0, "maxOutputTokens": 256, "topK": 40, "topP": 0.95 } } EOF
Exécutez ensuite la commande suivante pour envoyer votre requête 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
Enregistrez le corps de la requête dans un fichier nommé request.json
.
Exécutez la commande suivante dans le terminal pour créer ou écraser ce fichier dans le répertoire actuel :
@' { "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
Exécutez ensuite la commande suivante pour envoyer votre requête 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
Réponses à des questions à choix multiples
Les exemples suivants montrent comment l'API MedLM répond à une question médicale à choix multiples. La requête est la suivante :
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
Avant d'utiliser les données de requête, effectuez les remplacements suivants :
PROJECT_ID
: l'ID de votre projet.MEDLM_MODEL
: modèle MedLM (medlm-medium
oumedlm-large
).
Méthode HTTP et URL :
POST https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict
Corps JSON de la requête :
{ "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 } }
Pour envoyer votre requête, choisissez l'une des options suivantes :
curl
Enregistrez le corps de la requête dans un fichier nommé request.json
.
Exécutez la commande suivante dans le terminal pour créer ou écraser ce fichier dans le répertoire actuel :
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
Exécutez ensuite la commande suivante pour envoyer votre requête 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
Enregistrez le corps de la requête dans un fichier nommé request.json
.
Exécutez la commande suivante dans le terminal pour créer ou écraser ce fichier dans le répertoire actuel :
@' { "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
Exécutez ensuite la commande suivante pour envoyer votre requête 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
Requêtes de synthèse
Les sections suivantes contiennent des exemples d'invites de synthèse. Chaque exemple de requête inclut le modèle et les valeurs de paramètres recommandés.
Rédiger une synthèse après visite
Les exemples suivants montrent comment générer une synthèse après visite pour un patient en fonction d'une note de visite ambulatoire. La requête contient les éléments suivants :
- Préambule contenant l'instruction du modèle
- Description de chaque champ à extraire pour la synthèse
Le format de la synthèse après visite est basé sur Sieferd et al. (2019) et des recommandations de l'UK Academy of Medical Royal Colleges. Vous pouvez éventuellement ajouter quelques exemples d'invites few-shot avant les notes et les synthèses.
La requête est la suivante :
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
Avant d'utiliser les données de requête, effectuez les remplacements suivants :
PROJECT_ID
: l'ID de votre projet.MEDLM_MODEL
: modèle MedLM (medlm-medium
oumedlm-large
).INPUT_NOTE
: note saisie à résumer
Méthode HTTP et URL :
POST https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict
Corps JSON de la requête :
{ "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 } }
Pour envoyer votre requête, choisissez l'une des options suivantes :
curl
Enregistrez le corps de la requête dans un fichier nommé request.json
.
Exécutez la commande suivante dans le terminal pour créer ou écraser ce fichier dans le répertoire actuel :
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
Exécutez ensuite la commande suivante pour envoyer votre requête 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
Enregistrez le corps de la requête dans un fichier nommé request.json
.
Exécutez la commande suivante dans le terminal pour créer ou écraser ce fichier dans le répertoire actuel :
@' { "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
Exécutez ensuite la commande suivante pour envoyer votre requête 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
Rédiger une note d'anamnèse et d'examen clinique à partir d'une transcription
Les exemples suivants montrent comment accélérer la documentation clinique en envoyant une requête à l'API MedLM pour écrire un brouillon de note d'anamnèse et d'examen clinique à partir de la transcription d'une conversation médicale entre un prestataire et un patient.
La note d'anamnèse et d'examen clinique est une note clinique complète qui documente les antécédents du patient et l'examen physique effectué par le prestataire. MedLM peut collecter la plupart des informations cliniques nécessaires à la rédaction d'une telle note à partir de la conversation entre le prestataire et le patient lors de la visite médicale.
Supposons que vous ayez une transcription d'une conversation médicale au format suivant. Les intervenants de la conversation sont connus :
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
Avant d'utiliser les données de requête, effectuez les remplacements suivants :
PROJECT_ID
: l'ID de votre projet.MEDLM_MODEL
: modèle MedLM (medlm-medium
oumedlm-large
).
Méthode HTTP et URL :
POST https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MEDLM_MODEL:predict
Corps JSON de la requête :
{ "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 } }
Pour envoyer votre requête, choisissez l'une des options suivantes :
curl
Enregistrez le corps de la requête dans un fichier nommé request.json
.
Exécutez la commande suivante dans le terminal pour créer ou écraser ce fichier dans le répertoire actuel :
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
Exécutez ensuite la commande suivante pour envoyer votre requête 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
Enregistrez le corps de la requête dans un fichier nommé request.json
.
Exécutez la commande suivante dans le terminal pour créer ou écraser ce fichier dans le répertoire actuel :
@' { "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
Exécutez ensuite la commande suivante pour envoyer votre requête 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)
Exécutez le code Python suivant dans Colaboratory.
!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)
Exécutez le code suivant dans votre notebook Colaboratory. Saisissez l'ID de votre projet Google Cloud à l'emplacement indiqué. Pour trouver votre ID de projet, consultez la section Localiser l'ID de projet.
Saisissez la transcription médicale à l'emplacement indiqué.
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
Veuillez noter les points suivants :
- La note générée peut présenter des inexactitudes et doit être examinée par un médecin avant approbation.
- La note générée peut ne pas respecter strictement le format ou le modèle requis du service clinique ou de la spécialisation. Elle sert de point de départ pour établir le dossier du patient.
- La qualité de la note générée est limitée par la précision de la transcription fournie.
Implémenter des évaluations et des mesures correctives axées sur l'équité
MedLM peut produire des résultats moins précis pour certains groupes par rapport à d'autres, selon la question posée et sa formulation. Les performances variables des résultats du modèle sur plusieurs groupes démographiques peuvent exacerber les inégalités en matière de santé et perpétuer des biais dangereux. Les inexactitudes de ces résultats ne sont pas propres à MedLM et résultent souvent de plusieurs facteurs, tels que des inégalités sociales et structurelles existantes, des idées reçues sur le plan médical, des stéréotypes négatifs et un manque de diversité dans les données d'entraînement.
Envisagez d'implémenter des évaluations et des mesures correctives axées sur l'équité. En voici quelques-unes :
- Évaluez les performances et le comportement des modèles pour des cas d'utilisation prévus dans différentes populations (par exemple, origine ethnique, statut socio-économique (SES), géographie, identité de genre, orientation sexuelle, âge, préférence linguistique, caste, etc.).
- Recueillez des commentaires sur les performances.
- Faites intervenir des experts interdisciplinaires et des partenaires externes spécialisés dans la définition et le traitement des aspects sociaux et structurels de la santé.
- Effectuez une surveillance continue pour évaluer et résoudre les problèmes de biais.
En fonction de votre cas d'utilisation, envisagez d'enrichir votre requête avec des instructions axées sur l'équité afin d'améliorer la qualité des résultats MedLM en termes de biais et d'équité.
Par exemple, le texte suivant, lorsqu'il est placé au début d'une requête, améliore la qualité des résultats pour les questions médicales basées sur l'origine ethnique, comme indiqué dans Omiye 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.
La modification des requêtes influence les résultats du modèle. Par conséquent, des évaluations complètes sont recommandées pour vous assurer que les autres domaines de performances ne sont pas affectés.
Pour en savoir plus sur les performances du modèle, consultez la fiche de modèle MedLM.