-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprompt_texts.py
More file actions
165 lines (151 loc) · 15.8 KB
/
prompt_texts.py
File metadata and controls
165 lines (151 loc) · 15.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# prompt texts
DEFAULT_SYSTEM = """Reasoning: high."""
TRIAL_SUM_USER_START = """
You are an expert clinical oncologist with an encyclopedic knowledge of cancer and its treatments.
Your job is to review a clinical trial document and extract a list of structured clinical spaces that are eligible for that trial.
A clinical space is defined as a unique combination of patient age range, sex (if any sex criteria), cancer primary site, histology, which treatments a patient must have received, which treatments a patient must not have received, cancer burden (eg presence of metastatic disease; this also includes cancer type-specific prognostic scores, risk indices, or categories), tumor biomarkers (such as germline or somatic gene mutations or alterations, or protein expression on tumor), that a patient must have or must not have to be eligible for the trial.
With respect to sex criteria: For cancers originating in organs only present in one sex, you must assume the sex criteria even if not stated explicitly.
For example, a trial space for uterine, ovarian, vulvar, vaginal, or fallopian tube cancer must be assumed to be for female patients.
Similarly, a trial space for testicular, penile, or prostate cancer must be assumed to be for male patients.
For all other cancer types (including breast cancer), you shoulud assume the trial is open to both sexes unless the clinical trial document states otherwise.
Trials often specify that a particular treatment is excluded only if it was given within a short period of time, for example 14 days, one month, etc , prior to trial start. This is called a washout period. Do not include this type of time-specific treatment washout eligibility criteria in your output at all.
Some trials have only one space, while others have several. Do not output a space that contains multiple cancer types and/or histologies. Instead, generate separate spaces for each cancer type/histology combination.
CRITICAL: Each trial space must contain all information necessary to define that space on its own. It may not refer to other previously defined spaces for the same trial, since for later use, the spaces will be extracted and separated from each other. YOU MAY NOT include text describing a given space that refers to a previous space; eg, \"Same as above\"-style output is not allowed!
For biomarkers, if the trial specifies whether the biomarker will be assessed during screening, note that.
Spell out cancer types; do not abbreviate them. For example, write "non-small cell lung cancer" rather than "NSCLC".
Structure your output like this, as a list of spaces, with spaces separated by newlines, as below. STRICTLY adhere to the formatting.
1. Age range allowed: <age_range_allowed>. Sex allowed: <sex_allowed>. Cancer type allowed: <cancer_type_allowed>. Histology allowed: <histology_allowed>. Cancer burden allowed: <cancer_burden_allowed>. Prior treatment required: <prior_treatments_requred>. Prior treatment excluded: <prior_treatments_excluded>. Biomarkers required: <biomarkers_required>. Biomarkers excluded: <biomarkers_excluded>.
2. Cancer type allowed: <cancer_type_allowed>, etc.
If a concept is not relevant, such as if there are no prior treatents required, simply output NA for that concept.
CRITICAL: Anytime you provide a list for a particular concept, you must be completely clear on whether "or" versus "and" logic applies to the list. For example, do not output "EGFR L858R mutant, TP53 mutant"; if both are required, output "EGFR L858R mutant and TP53 mutant".
As another example, do not output "ER+, PR+"; if the patient can have either an ER or a PR positive tumor, output "ER+ or PR+".
NEVER put a newline within a single trial space.
After you output the trial spaces, output a newline, then the text "Boilerplate exclusions:" VERBATIM, then another newline.
Then, list exclusion criteria described in the trial text that are unrelated to the trial space definitions. Such exclusions tend to be common to clinical trials in general.
Common boilerplate exclusion criteria include a history of pneumonitis, heart failure, renal dysfunction, liver dysfunction, uncontrolled brain metastases, HIV or hepatitis, and poor performance status.
ALWAYS output plain text only. NEVER output unicode, Markdown, or tables.
"""
TRIAL_SUM_USER_END = """
Now, generate your list of the trial space(s), followed by any boilerplate exclusions, formatted as above.
Do not provide any introductory, explanatory, concluding, or disclaimer text.
Reminder: Treatment history is an important component of trial space definitions, but treatment history "washout" requirements that are described as applying only in a given period of time prior to trial treatment MUST BE IGNORED.
CRITICAL: A given trial space MUST NEVER refer to another previously defined space. You must NEVER output text like "same as #1" or "same criteria as above." Instead, you MUST REPEAT all relevant criteria for each new space SO THAT IT STANDS ON ITS OWN. A user who later looks at the text for one space will not have access to text for other spaces, and so output like "Same criteria as #1..." renders a space useless!"""
REASONING_TAGGER_SYSTEM = """You are an oncology clinical note data extraction bot.
Your job is to review a list of excerpts from a clinical document and extract the excerpts relevant to a list of questions.
Reasoning: high
"""
REASONING_TAGGER_USER_START = "The list of excerpts, separated by <excerpt break>, is: "
REASONING_TAGGER_USER_END = """Now, list the excerpts relevant to any of the following questions.
Format your answer as JSON, tagging each excerpt that is relevant to at least one question with each tag to which it is relevant.
Here is the list of questions:
How old is the patient? (Tag: age)
What is the patient's sex? (Tag: sex)
What type of cancer (primary site and histology) does the patient have? (Tag: cancer_type )
What was the stage at diagnosis? (Tag: stage_at_diagnosis)
What treatments (including surgery, radiation, or systemic therapy) has the patient received? (Tag: treatment)
How widespread is the cancer currently? (Tag: cancer_burden)
What is the prognosis, prognostic score, or risk category? (Tag: prognosis_and_risk)
Is there response to therapy or progressive disease? (Tag: cancer_status)
Is the patient experiencing an adverse event of treatment? (Tag: adverse_event)
What biomarkers, such as protein expression and genetic mutations/alterations, does the patient's tumor have? (Tag: biomarker)
What comorbidities, or diseases other than cancer, does the patient have? (Tag: comorbidity)
Are there uncontrolled brain metastases? (Tag: uncontrolled_brain_met)
Is there measurable disease, meaning a tumor at least 1 cm across or lymph node at least 1.5 cm in short axis dimension? (Tag: measurable_disease)
Is there progressive (worsening) disease? (Tag: progressive_disease)
Is there a history of pneumonitis? (Tag: pneumonitis)
Is there a history of colitis? (Tag: colitis)
Is there a history of hepatitis or HIV? (Tag: hepatitis_or_hiv)
Is the patient anemic, with hemoglobin under 10? (Tag: anemia)
Is there a reduced renal function/creatinine clearance, with estimated GFR < 60? (Tag: renal_dysfunction)
Is there liver dysfunction, with elevated bilirubin, AST, or ALT? (Tag: liver_dysfunction)
Is there a history of heart failure? (Tag: heart_failure)
Does the patient have a poor performance status and/or ECOG performance status of 2 or more? (Tag: poor_ps)
What adverse side effects of treatment has the patient had? (Tag: adverse_event)
Here is an example of the output format:
[{"excerpt": "80M with metastatic lung adenocarcinoma.", "tags": ["age", "sex", "cancer_type", "cancer_burden"]},
{"excerpt": "The tumor was HER2 positive.", "tags": ["biomarker"]},
{"excerpt": "Imaging demonstrated new bilateral lung infiltrates.", "tags": ["pneumonitis", "adverse_event"]},
{"excerpt": "LV ejection fraction was 35%.", "tags": ["heart_failure"]}
]
Do not include excerpts that are not relevant to the questions.
Do not abbreviate or alter excerpts that you do include; copy them verbatim from the prompt.
Do not add disclaimers or introductory text.
If there are no excerpts relevant to the above questions, just output blank JSON {} .
"""
PATIENT_SUM_USER_START = """
You are an experienced clinical oncology history summarization bot.
Your job is to construct a summary of the cancer history for a patient based on an excerpt of the patient's electronic health record. The text in the excerpt is provided in chronological order. Each paragraph in the excerpt represents a summary of a clinical document written on the date indicated in the paragraph.
Document the patient's most recent age; sex; cancer type/primary site (eg breast cancer, lung cancer, etc); histology (eg adenocarcinoma, squamous carcinoma, etc); current extent (localized, advanced, metastatic, etc); biomarkers (genomic results, protein expression, etc); and treatment history (surgery, radiation, chemotherapy/targeted therapy/immunotherapy, etc, including start and stop dates and best response if known).
Do not consider localized basal cell or squamous carcinomas of the skin, or colon polyps, to be cancers for your purposes.
Do not include the patient's name, but do include relevant dates whenever documented, including dates of diagnosis and start/stop dates of each treatment.
If a patient has a history of more than one cancer, document the cancers one at a time.
CRITICAL: Format your response as free text ONLY. Do NOT output markdown, Unicode, or tables.
Also document any history of conditions that might meet "boilerplate" exclusion criteria, including uncontrolled brain metastases, lack of measurable disease, congestive heart failure, pneumonitis, renal dysfunction, liver dysfunction, and HIV or hepatitis infection. For each of these, present the evidence from the history that the patient has a history of such a condition, including dates.
Clearly separate the "boilerplate" section by labeling it "Boilerplate: " before describing any such conditions.
Here is an example of the desired output format:
Age: 70
Sex: Male
Cancer type: Lung cancer
Histology: Adenocarcinoma
Current extent: Metastatic
Biomarkers: PD-L1 75%, KRAS G12C mutant
Treatment history:
# 1/5/2020-2/5/2021: carboplatin/pemetrexed/pembrolizumab
# 1/2021: Palliative radiation to progressive spinal metastases
# 3/2021-present: docetaxel
Boilerplate:
No evidence of common boilerplate exclusion criteria
"""
PATIENT_SUM_USER_END = """
Now, write your summary. Do not add preceding text before the abstraction, and do not add notes or commentary afterwards. This will not be used for clinical care, so do not write any disclaimers or cautionary notes."""
EMBEDDING_PROMPT = "Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. "
TRIAL_CHECKER_USER_START = (
"You are a brilliant oncologist with encyclopedic knowledge about cancer and its treatment. "
"Your job is to evaluate whether a given clinical trial is a reasonable consideration for a patient, "
"given a clinical trial summary and a patient summary.\n\n"
)
TRIAL_CHECKER_USER_END = (
"Base your judgment on whether the patient generally fits the age requirements if any, sex requirements if any, cancer type(s), cancer burden, prior treatment(s), "
"and biomarker criteria specified for the trial.\n"
"You do not have to determine if the patient is actually eligible; instead please just evaluate whether it is reasonable "
"for the trial to be considered further by the patient's oncologist.\n"
"Biomarker criteria have to be considered carefully. Some trials have biomarker requirements that are not assessed until "
"formal trial screening. A trial may therefore sometimes be a reasonable consideration for a patient even if a required "
"biomarker is not known to be present in the patient.\n"
"However, if a required biomarker is known to be absent, or can be assumed to be absent based on other information, the trial "
"is not a reasonable consideration. For example, if a trial for lung cancer requires an EGFR mutation, documentation that there "
"is no EGFR mutation indicates the trial is not a reasonable consideration. Similarly, documentation of a KRAS mutation in the "
"patient indicates the trial is not a reasonable consideration, since, as you know, KRAS and EGFR driver mutations in lung cancer "
"are mutually exclusive.\n"
"Many trials describe required washout periods for prior treatments for eligibility. For example, the eligibility criteria might state "
"that patients may not have received radiation or chemotherapy in the last 14 days or 30 days. It is CRITICAL that you IGNORE these "
"eligibility criteria when considering prior treatment requirements. Assume that patients could wait for the washout period to enroll. "
"Also CRITICAL: Ignore your knowledge of today's current date. Pretend that you are evaluating the patient's eligibility based on the "
"most recent information available in their summary, at the time of that most recently available information. "
"Do not provide ethical judgments or comment on resource constraints with respect whether the trial is a reasonable clinical "
"consideration; just evaluate whether it is, given the available information.\n"
'Reason step by step, then answer the question "Is this trial a reasonable consideration for this patient?" with a one-word '
'"Yes!" or "No!" answer.\n'
"Make sure to include the exclamation point in your final one-word answer."
)
BOILERPLATE_CHECKER_USER_START = (
"You are a brilliant oncologist with encyclopedic knowledge about cancer and its treatment.\n"
"Your job is to evaluate whether a patient has any underlying medical conditions that would exclude him or her from a specific clinical trial.\n\n"
)
BOILERPLATE_CHECKER_USER_END = (
"Note that the extract was generated by prompting an LLM to determine whether the patient meets specific common exclusion criteria, "
"such as uncontrolled brain metastases, lack of measurable disease, congestive heart failure, pneumonitis, renal dysfunction, "
"liver dysfunction, and HIV or hepatitis infection, and to present evidence for whether the patient met the criterion.\n"
"You should therefore not assume that mention of such condition means the patient has the condition; it may represent the LLM reasoning "
"about whether the patient has the condition.\n"
"Based on the extract, you should determine whether the patient clearly meets one of the exclusion criteria for this specific trial.\n"
"Do not evaluate exclusion criteria other than those listed for this trial.\n"
"Reason through one exclusion criterion at a time. Generate a numbered list of the criteria as you go. For each one, decide whether the patient clearly "
"meets the exclusion criteron. If it is not completely clear that the patient meets the exclusion criterion, give the patient the benefit of the doubt, "
"and err on the side of deciding the patient is not excluded. A description in the patient extract that a condition is mild, low-grade, or resolved is even "
"more of a reason not to exclude the patient based on that condition.\n"
'Once you have evaluated all exclusion criteria, answer the question "Is this patient clearly excluded from this trial?" with a one-word "Yes!" or "No!" answer, '
"based on whether the patient clearly met any of the individual exclusion criteria. It is critical that your final word be either \"Yes!\" or \"No!\", verbatim, and case-sensitive.\n"
"Make sure to include the exclamation point in your final one-word answer.\n"
"No introductory text or concluding text after that final answer."
)