llm-ie 0.2.2__py3-none-any.whl → 0.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- llm_ie/asset/PromptEditor_prompts/chat.txt +5 -0
- llm_ie/asset/PromptEditor_prompts/rewrite.txt +3 -1
- llm_ie/asset/PromptEditor_prompts/system.txt +1 -0
- llm_ie/asset/default_prompts/ReviewFrameExtractor_addition_review_prompt.txt +3 -0
- llm_ie/asset/default_prompts/ReviewFrameExtractor_revision_review_prompt.txt +2 -0
- llm_ie/asset/default_prompts/SentenceReviewFrameExtractor_addition_review_prompt.txt +4 -0
- llm_ie/asset/default_prompts/SentenceReviewFrameExtractor_revision_review_prompt.txt +3 -0
- llm_ie/asset/prompt_guide/BasicFrameExtractor_prompt_guide.txt +117 -7
- llm_ie/asset/prompt_guide/BinaryRelationExtractor_prompt_guide.txt +32 -12
- llm_ie/asset/prompt_guide/MultiClassRelationExtractor_prompt_guide.txt +35 -12
- llm_ie/asset/prompt_guide/ReviewFrameExtractor_prompt_guide.txt +117 -7
- llm_ie/asset/prompt_guide/SentenceCoTFrameExtractor_prompt_guide.txt +217 -0
- llm_ie/asset/prompt_guide/SentenceFrameExtractor_prompt_guide.txt +129 -24
- llm_ie/asset/prompt_guide/SentenceReviewFrameExtractor_prompt_guide.txt +145 -0
- llm_ie/engines.py +1 -1
- llm_ie/extractors.py +331 -24
- llm_ie/prompt_editor.py +150 -8
- {llm_ie-0.2.2.dist-info → llm_ie-0.3.1.dist-info}/METADATA +89 -44
- llm_ie-0.3.1.dist-info/RECORD +23 -0
- llm_ie-0.2.2.dist-info/RECORD +0 -15
- {llm_ie-0.2.2.dist-info → llm_ie-0.3.1.dist-info}/WHEEL +0 -0
|
@@ -1,40 +1,145 @@
|
|
|
1
|
-
Prompt
|
|
2
|
-
1. Task description (mention the task is to extract information from sentences)
|
|
3
|
-
2. Schema definition
|
|
4
|
-
3. Output format definition
|
|
5
|
-
4. Additional hints
|
|
6
|
-
5. Input placeholder (mention user will feed sentence by sentence)
|
|
1
|
+
Prompt Template Design:
|
|
7
2
|
|
|
8
|
-
|
|
3
|
+
1. Task Description:
|
|
4
|
+
Provide a detailed description of the task, including the background and the type of task (e.g., named entity recognition).
|
|
5
|
+
|
|
6
|
+
2. Schema Definition:
|
|
7
|
+
List the key concepts that should be extracted, and provide clear definitions for each one.
|
|
8
|
+
|
|
9
|
+
3. Output Format Definition:
|
|
10
|
+
The output should be a JSON list, where each element is a dictionary representing a frame (an entity along with its attributes). Each dictionary must include a key that holds the entity text. This key can be named "entity_text" or anything else depend on the context. The attributes can either be flat (e.g., {"entity_text": "<entity_text>", "attr1": "<attr1>", "attr2": "<attr2>"}) or nested (e.g., {"entity_text": "<entity_text>", "attributes": {"attr1": "<attr1>", "attr2": "<attr2>"}}).
|
|
11
|
+
|
|
12
|
+
4. Optional: Hints:
|
|
13
|
+
Provide itemized hints for the information extractors to guide the extraction process.
|
|
14
|
+
|
|
15
|
+
5. Optional: Examples:
|
|
16
|
+
Include examples in the format:
|
|
17
|
+
Input: ...
|
|
18
|
+
Output: ...
|
|
19
|
+
|
|
20
|
+
6. Input Placeholder:
|
|
21
|
+
The template must include a placeholder in the format {{<placeholder_name>}} for the input text. The placeholder name can be customized as needed.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
Example 1 (single entity type with attributes):
|
|
9
25
|
|
|
10
26
|
# Task description
|
|
11
|
-
The paragraph below is from the Food and Drug Administration (FDA) Clinical Pharmacology Section of Labeling for Human Prescription Drug and Biological Products, Adverse
|
|
27
|
+
The paragraph below is from the Food and Drug Administration (FDA) Clinical Pharmacology Section of Labeling for Human Prescription Drug and Biological Products, Adverse reactions section. Please carefully review it and extract the adverse reactions and percentages. Note that each adverse reaction is nested under a clinical trial and potentially an arm. Your output should take that into consideration.
|
|
12
28
|
|
|
13
29
|
# Schema definition
|
|
14
30
|
Your output should contain:
|
|
15
|
-
|
|
31
|
+
"ClinicalTrial" which is the name of the trial,
|
|
16
32
|
If applicable, "Arm" which is the arm within the clinical trial,
|
|
17
|
-
|
|
18
|
-
If applicable, "Percentage" which is the
|
|
33
|
+
"AdverseReaction" which is the name of the adverse reaction,
|
|
34
|
+
If applicable, "Percentage" which is the occurance of the adverse reaction within the trial and arm,
|
|
35
|
+
"Evidence" which is the EXACT sentence in the text where you found the AdverseReaction from
|
|
19
36
|
|
|
20
37
|
# Output format definition
|
|
21
|
-
Your output should follow JSON format,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{"ClinicalTrial": "<Clinical trial name or number>", "Arm": "<name of arm>", "AdverseReaction": "<Adverse reaction text>", "Percentage": "<a percent>"}
|
|
25
|
-
|
|
26
|
-
[]
|
|
38
|
+
Your output should follow JSON format, for example:
|
|
39
|
+
[
|
|
40
|
+
{"ClinicalTrial": "<Clinical trial name or number>", "Arm": "<name of arm>", "AdverseReaction": "<Adverse reaction text>", "Percentage": "<a percent>", "Evidence": "<exact sentence from the text>"},
|
|
41
|
+
{"ClinicalTrial": "<Clinical trial name or number>", "Arm": "<name of arm>", "AdverseReaction": "<Adverse reaction text>", "Percentage": "<a percent>", "Evidence": "<exact sentence from the text>"}
|
|
42
|
+
]
|
|
27
43
|
|
|
28
44
|
# Additional hints
|
|
29
45
|
Your output should be 100% based on the provided content. DO NOT output fake numbers.
|
|
30
|
-
If there is no specific
|
|
31
|
-
|
|
46
|
+
If there is no specific arm, just omit the "Arm" key. If the percentage is not reported, just omit the "Percentage" key. The "Evidence" should always be provided.
|
|
47
|
+
|
|
48
|
+
# Input placeholder
|
|
49
|
+
Below is the Adverse reactions section for your reference. I will feed you with sentences from it one by one.
|
|
50
|
+
{{input}}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
Example 2 (multiple entity types):
|
|
54
|
+
|
|
55
|
+
# Task description
|
|
56
|
+
This is a named entity recognition task. Given a sentence from a medical note, annotate the Drug, Form, Strength, Frequency, Route, Dosage, Reason, ADE, and Duration.
|
|
57
|
+
|
|
58
|
+
# Schema definition
|
|
59
|
+
Your output should contain:
|
|
60
|
+
"entity_text": the exact wording as mentioned in the note.
|
|
61
|
+
"entity_type": type of the entity. It should be one of the "Drug", "Form", "Strength", "Frequency", "Route", "Dosage", "Reason", "ADE", or "Duration".
|
|
62
|
+
|
|
63
|
+
# Output format definition
|
|
64
|
+
Your output should follow JSON format,
|
|
65
|
+
if there are one of the entity mentions: Drug, Form, Strength, Frequency, Route, Dosage, Reason, ADE, or Duration:
|
|
66
|
+
[{"entity_text": "<Exact entity mentions as in the note>", "entity_type": "<entity type as listed above>"},
|
|
67
|
+
{"entity_text": "<Exact entity mentions as in the note>", "entity_type": "<entity type as listed above>"}]
|
|
68
|
+
if there is no entity mentioned in the given note, just output an empty list:
|
|
69
|
+
[]
|
|
70
|
+
|
|
71
|
+
I am only interested in the extracted contents in []. Do NOT explain your answer.
|
|
72
|
+
|
|
73
|
+
# Examples
|
|
74
|
+
Below are some examples:
|
|
75
|
+
|
|
76
|
+
Input: Acetaminophen 650 mg PO BID 5.
|
|
77
|
+
Output: [{"entity_text": "Acetaminophen", "entity_type": "Drug"}, {"entity_text": "650 mg", "entity_type": "Strength"}, {"entity_text": "PO", "entity_type": "Route"}, {"entity_text": "BID", "entity_type": "Frequency"}]
|
|
78
|
+
|
|
79
|
+
Input: Mesalamine DR 1200 mg PO BID 2.
|
|
80
|
+
Output: [{"entity_text": "Mesalamine DR", "entity_type": "Drug"}, {"entity_text": "1200 mg", "entity_type": "Strength"}, {"entity_text": "BID", "entity_type": "Frequency"}, {"entity_text": "PO", "entity_type": "Route"}]
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# Input placeholder
|
|
84
|
+
Below is the medical note for your reference. I will feed you with sentences from it one by one.
|
|
85
|
+
"{{input}}"
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
Example 3 (multiple entity types with corresponding attributes):
|
|
89
|
+
|
|
90
|
+
# Task description
|
|
91
|
+
This is a named entity recognition task. Given a sentence from a medical note, annotate the events (EVENT) and time expressions (TIMEX3):
|
|
92
|
+
|
|
93
|
+
# Schema definition
|
|
94
|
+
Your output should contain:
|
|
95
|
+
"entity_text": the exact wording as mentioned in the note.
|
|
96
|
+
"entity_type": type of the entity. It should be one of the "EVENT" or "TIMEX3".
|
|
97
|
+
if entity_type is "EVENT",
|
|
98
|
+
"type": the event type as one of the "TEST", "PROBLEM", "TREATMENT", "CLINICAL_DEPT", "EVIDENTIAL", or "OCCURRENCE".
|
|
99
|
+
"polarity": whether an EVENT is positive ("POS") or negative ("NAG"). For example, in “the patient reports headache, and denies chills”, the EVENT [headache] is positive in its polarity, and the EVENT [chills] is negative in its polarity.
|
|
100
|
+
"modality": whether an EVENT actually occurred or not. Must be one of the "FACTUAL", "CONDITIONAL", "POSSIBLE", or "PROPOSED".
|
|
101
|
+
|
|
102
|
+
if entity_type is "TIMEX3",
|
|
103
|
+
"type": the type as one of the "DATE", "TIME", "DURATION", or "FREQUENCY".
|
|
104
|
+
"val": the numeric value 1) DATE: [YYYY]-[MM]-[DD], 2) TIME: [hh]:[mm]:[ss], 3) DURATION: P[n][Y/M/W/D]. So, “for eleven days” will be
|
|
105
|
+
represented as “P11D”, meaning a period of 11 days. 4) R[n][duration], where n denotes the number of repeats. When the n is omitted, the expression denotes an unspecified amount of repeats. For example, “once a day for 3 days” is “R3P1D” (repeat the time interval of 1 day (P1D) for 3 times (R3)), twice every day is “RP12H” (repeat every 12 hours)
|
|
106
|
+
"mod": additional information regarding the temporal value of a time expression. Must be one of the:
|
|
107
|
+
“NA”: the default value, no relevant modifier is present;
|
|
108
|
+
“MORE”, means “more than”, e.g. over 2 days (val = P2D, mod = MORE);
|
|
109
|
+
“LESS”, means “less than”, e.g. almost 2 months (val = P2M, mod=LESS);
|
|
110
|
+
“APPROX”, means “approximate”, e.g. nearly a week (val = P1W, mod=APPROX);
|
|
111
|
+
“START”, describes the beginning of a period of time, e.g. Christmas morning, 2005 (val= 2005-12-25, mod= START).
|
|
112
|
+
“END”, describes the end of a period of time, e.g. late last year, (val = 2010, mod = END)
|
|
113
|
+
“MIDDLE”, describes the middle of a period of time, e.g. mid-September 2001 (val = 2001-09, mod = MIDDLE)
|
|
114
|
+
|
|
115
|
+
# Output format definition
|
|
116
|
+
Your output should follow JSON format,
|
|
117
|
+
if there are one of the EVENT or TIMEX3 entity mentions:
|
|
118
|
+
[
|
|
119
|
+
{"entity_text": "<Exact entity mentions as in the note>", "entity_type": "EVENT", "type": "<event type>", "polarity": "<event polarity>", "modality": "<event modality>"},
|
|
120
|
+
{"entity_text": "<Exact entity mentions as in the note>", "entity_type": "TIMEX3", "type": "<TIMEX3 type>", "val": "<time value>", "mod": "<additional information>"}
|
|
121
|
+
...
|
|
122
|
+
]
|
|
123
|
+
if there is no entity mentioned in the given note, just output an empty list:
|
|
124
|
+
[]
|
|
125
|
+
|
|
126
|
+
I am only interested in the extracted contents in []. Do NOT explain your answer.
|
|
127
|
+
|
|
128
|
+
# Examples
|
|
129
|
+
Below are some examples:
|
|
130
|
+
|
|
131
|
+
Input: At 9/7/93 , 1:00 a.m. , intravenous fluids rate was decreased to 50 cc's per hour , total fluids given during the first 24 hours were 140 to 150 cc's per kilo per day .
|
|
132
|
+
Output: [{"entity_text": "intravenous fluids", "entity_type": "EVENT", "type": "TREATMENT", "polarity": "POS", "modality": "FACTUAL"},
|
|
133
|
+
{"entity_text": "decreased", "entity_type": "EVENT", "type": "OCCURRENCE", "polarity": "POS", "modality": "FACTUAL"},
|
|
134
|
+
{"entity_text": "total fluids", "entity_type": "EVENT", "type": "TREATMENT", "polarity": "POS", "modality": "FACTUAL"},
|
|
135
|
+
{"entity_text": "9/7/93 , 1:00 a.m.", "entity_type": "TIMEX3", "type": "TIME", "val": "1993-09-07T01:00", "mod": "NA"},
|
|
136
|
+
{"entity_text": "24 hours", "entity_type": "TIMEX3", "type": "DURATION", "val": "PT24H", "mod": "NA"}]
|
|
137
|
+
|
|
138
|
+
Input: At that time it appeared well adhered to the underlying skin .
|
|
139
|
+
Output: [{"entity_text": "it", "entity_type": "EVENT", "type": "TREATMENT", "polarity": "POS", "modality": "FACTUAL"},
|
|
140
|
+
{"entity_text": "well adhered", "entity_type": "EVENT", "type": "OCCURRENCE", "polarity": "POS", "modality": "FACTUAL"}]
|
|
32
141
|
|
|
33
|
-
The Adverse reactions section often has a sentence in the first paragraph:
|
|
34
|
-
"The following clinically significant adverse reactions are described elsewhere in the labeling:..." Make sure to extract those adverse reaction mentions.
|
|
35
|
-
The Adverse reactions section often has summary sentences like:
|
|
36
|
-
"The most common adverse reactions were ...". Make sure to extract those adverse reaction mentions.
|
|
37
142
|
|
|
38
143
|
# Input placeholder
|
|
39
|
-
Below is the entire
|
|
144
|
+
Below is the entire medical note for your reference. I will feed you with sentences from it one by one.
|
|
40
145
|
"{{input}}"
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Prompt Template Design:
|
|
2
|
+
|
|
3
|
+
1. Task Description:
|
|
4
|
+
Provide a detailed description of the task, including the background and the type of task (e.g., named entity recognition).
|
|
5
|
+
|
|
6
|
+
2. Schema Definition:
|
|
7
|
+
List the key concepts that should be extracted, and provide clear definitions for each one.
|
|
8
|
+
|
|
9
|
+
3. Output Format Definition:
|
|
10
|
+
The output should be a JSON list, where each element is a dictionary representing a frame (an entity along with its attributes). Each dictionary must include a key that holds the entity text. This key can be named "entity_text" or anything else depend on the context. The attributes can either be flat (e.g., {"entity_text": "<entity_text>", "attr1": "<attr1>", "attr2": "<attr2>"}) or nested (e.g., {"entity_text": "<entity_text>", "attributes": {"attr1": "<attr1>", "attr2": "<attr2>"}}).
|
|
11
|
+
|
|
12
|
+
4. Optional: Hints:
|
|
13
|
+
Provide itemized hints for the information extractors to guide the extraction process.
|
|
14
|
+
|
|
15
|
+
5. Optional: Examples:
|
|
16
|
+
Include examples in the format:
|
|
17
|
+
Input: ...
|
|
18
|
+
Output: ...
|
|
19
|
+
|
|
20
|
+
6. Input Placeholder:
|
|
21
|
+
The template must include a placeholder in the format {{<placeholder_name>}} for the input text. The placeholder name can be customized as needed.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
Example 1 (single entity type with attributes):
|
|
25
|
+
|
|
26
|
+
# Task description
|
|
27
|
+
The paragraph below is from the Food and Drug Administration (FDA) Clinical Pharmacology Section of Labeling for Human Prescription Drug and Biological Products, Adverse reactions section. Please carefully review it and extract the adverse reactions and percentages. Note that each adverse reaction is nested under a clinical trial and potentially an arm. Your output should take that into consideration.
|
|
28
|
+
|
|
29
|
+
# Schema definition
|
|
30
|
+
Your output should contain:
|
|
31
|
+
"ClinicalTrial" which is the name of the trial,
|
|
32
|
+
If applicable, "Arm" which is the arm within the clinical trial,
|
|
33
|
+
"AdverseReaction" which is the name of the adverse reaction,
|
|
34
|
+
If applicable, "Percentage" which is the occurance of the adverse reaction within the trial and arm,
|
|
35
|
+
"Evidence" which is the EXACT sentence in the text where you found the AdverseReaction from
|
|
36
|
+
|
|
37
|
+
# Output format definition
|
|
38
|
+
Your output should follow JSON format, for example:
|
|
39
|
+
[
|
|
40
|
+
{"ClinicalTrial": "<Clinical trial name or number>", "Arm": "<name of arm>", "AdverseReaction": "<Adverse reaction text>", "Percentage": "<a percent>", "Evidence": "<exact sentence from the text>"},
|
|
41
|
+
{"ClinicalTrial": "<Clinical trial name or number>", "Arm": "<name of arm>", "AdverseReaction": "<Adverse reaction text>", "Percentage": "<a percent>", "Evidence": "<exact sentence from the text>"}
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
# Additional hints
|
|
45
|
+
Your output should be 100% based on the provided content. DO NOT output fake numbers.
|
|
46
|
+
If there is no specific arm, just omit the "Arm" key. If the percentage is not reported, just omit the "Percentage" key. The "Evidence" should always be provided.
|
|
47
|
+
|
|
48
|
+
# Input placeholder
|
|
49
|
+
Below is the Adverse reactions section for your reference. I will feed you with sentences from it one by one.
|
|
50
|
+
{{input}}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
Example 2 (multiple entity types):
|
|
54
|
+
|
|
55
|
+
# Task description
|
|
56
|
+
This is a named entity recognition task. Given a sentence from a medical note, annotate the Drug, Form, Strength, Frequency, Route, Dosage, Reason, ADE, and Duration.
|
|
57
|
+
|
|
58
|
+
# Schema definition
|
|
59
|
+
Your output should contain:
|
|
60
|
+
"entity_text": the exact wording as mentioned in the note.
|
|
61
|
+
"entity_type": type of the entity. It should be one of the "Drug", "Form", "Strength", "Frequency", "Route", "Dosage", "Reason", "ADE", or "Duration".
|
|
62
|
+
|
|
63
|
+
# Output format definition
|
|
64
|
+
Your output should follow JSON format,
|
|
65
|
+
if there are one of the entity mentions: Drug, Form, Strength, Frequency, Route, Dosage, Reason, ADE, or Duration:
|
|
66
|
+
[{"entity_text": "<Exact entity mentions as in the note>", "entity_type": "<entity type as listed above>"},
|
|
67
|
+
{"entity_text": "<Exact entity mentions as in the note>", "entity_type": "<entity type as listed above>"}]
|
|
68
|
+
if there is no entity mentioned in the given note, just output an empty list:
|
|
69
|
+
[]
|
|
70
|
+
|
|
71
|
+
I am only interested in the extracted contents in []. Do NOT explain your answer.
|
|
72
|
+
|
|
73
|
+
# Examples
|
|
74
|
+
Below are some examples:
|
|
75
|
+
|
|
76
|
+
Input: Acetaminophen 650 mg PO BID 5.
|
|
77
|
+
Output: [{"entity_text": "Acetaminophen", "entity_type": "Drug"}, {"entity_text": "650 mg", "entity_type": "Strength"}, {"entity_text": "PO", "entity_type": "Route"}, {"entity_text": "BID", "entity_type": "Frequency"}]
|
|
78
|
+
|
|
79
|
+
Input: Mesalamine DR 1200 mg PO BID 2.
|
|
80
|
+
Output: [{"entity_text": "Mesalamine DR", "entity_type": "Drug"}, {"entity_text": "1200 mg", "entity_type": "Strength"}, {"entity_text": "BID", "entity_type": "Frequency"}, {"entity_text": "PO", "entity_type": "Route"}]
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# Input placeholder
|
|
84
|
+
Below is the medical note for your reference. I will feed you with sentences from it one by one.
|
|
85
|
+
"{{input}}"
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
Example 3 (multiple entity types with corresponding attributes):
|
|
89
|
+
|
|
90
|
+
# Task description
|
|
91
|
+
This is a named entity recognition task. Given a sentence from a medical note, annotate the events (EVENT) and time expressions (TIMEX3):
|
|
92
|
+
|
|
93
|
+
# Schema definition
|
|
94
|
+
Your output should contain:
|
|
95
|
+
"entity_text": the exact wording as mentioned in the note.
|
|
96
|
+
"entity_type": type of the entity. It should be one of the "EVENT" or "TIMEX3".
|
|
97
|
+
if entity_type is "EVENT",
|
|
98
|
+
"type": the event type as one of the "TEST", "PROBLEM", "TREATMENT", "CLINICAL_DEPT", "EVIDENTIAL", or "OCCURRENCE".
|
|
99
|
+
"polarity": whether an EVENT is positive ("POS") or negative ("NAG"). For example, in “the patient reports headache, and denies chills”, the EVENT [headache] is positive in its polarity, and the EVENT [chills] is negative in its polarity.
|
|
100
|
+
"modality": whether an EVENT actually occurred or not. Must be one of the "FACTUAL", "CONDITIONAL", "POSSIBLE", or "PROPOSED".
|
|
101
|
+
|
|
102
|
+
if entity_type is "TIMEX3",
|
|
103
|
+
"type": the type as one of the "DATE", "TIME", "DURATION", or "FREQUENCY".
|
|
104
|
+
"val": the numeric value 1) DATE: [YYYY]-[MM]-[DD], 2) TIME: [hh]:[mm]:[ss], 3) DURATION: P[n][Y/M/W/D]. So, “for eleven days” will be
|
|
105
|
+
represented as “P11D”, meaning a period of 11 days. 4) R[n][duration], where n denotes the number of repeats. When the n is omitted, the expression denotes an unspecified amount of repeats. For example, “once a day for 3 days” is “R3P1D” (repeat the time interval of 1 day (P1D) for 3 times (R3)), twice every day is “RP12H” (repeat every 12 hours)
|
|
106
|
+
"mod": additional information regarding the temporal value of a time expression. Must be one of the:
|
|
107
|
+
“NA”: the default value, no relevant modifier is present;
|
|
108
|
+
“MORE”, means “more than”, e.g. over 2 days (val = P2D, mod = MORE);
|
|
109
|
+
“LESS”, means “less than”, e.g. almost 2 months (val = P2M, mod=LESS);
|
|
110
|
+
“APPROX”, means “approximate”, e.g. nearly a week (val = P1W, mod=APPROX);
|
|
111
|
+
“START”, describes the beginning of a period of time, e.g. Christmas morning, 2005 (val= 2005-12-25, mod= START).
|
|
112
|
+
“END”, describes the end of a period of time, e.g. late last year, (val = 2010, mod = END)
|
|
113
|
+
“MIDDLE”, describes the middle of a period of time, e.g. mid-September 2001 (val = 2001-09, mod = MIDDLE)
|
|
114
|
+
|
|
115
|
+
# Output format definition
|
|
116
|
+
Your output should follow JSON format,
|
|
117
|
+
if there are one of the EVENT or TIMEX3 entity mentions:
|
|
118
|
+
[
|
|
119
|
+
{"entity_text": "<Exact entity mentions as in the note>", "entity_type": "EVENT", "type": "<event type>", "polarity": "<event polarity>", "modality": "<event modality>"},
|
|
120
|
+
{"entity_text": "<Exact entity mentions as in the note>", "entity_type": "TIMEX3", "type": "<TIMEX3 type>", "val": "<time value>", "mod": "<additional information>"}
|
|
121
|
+
...
|
|
122
|
+
]
|
|
123
|
+
if there is no entity mentioned in the given note, just output an empty list:
|
|
124
|
+
[]
|
|
125
|
+
|
|
126
|
+
I am only interested in the extracted contents in []. Do NOT explain your answer.
|
|
127
|
+
|
|
128
|
+
# Examples
|
|
129
|
+
Below are some examples:
|
|
130
|
+
|
|
131
|
+
Input: At 9/7/93 , 1:00 a.m. , intravenous fluids rate was decreased to 50 cc's per hour , total fluids given during the first 24 hours were 140 to 150 cc's per kilo per day .
|
|
132
|
+
Output: [{"entity_text": "intravenous fluids", "entity_type": "EVENT", "type": "TREATMENT", "polarity": "POS", "modality": "FACTUAL"},
|
|
133
|
+
{"entity_text": "decreased", "entity_type": "EVENT", "type": "OCCURRENCE", "polarity": "POS", "modality": "FACTUAL"},
|
|
134
|
+
{"entity_text": "total fluids", "entity_type": "EVENT", "type": "TREATMENT", "polarity": "POS", "modality": "FACTUAL"},
|
|
135
|
+
{"entity_text": "9/7/93 , 1:00 a.m.", "entity_type": "TIMEX3", "type": "TIME", "val": "1993-09-07T01:00", "mod": "NA"},
|
|
136
|
+
{"entity_text": "24 hours", "entity_type": "TIMEX3", "type": "DURATION", "val": "PT24H", "mod": "NA"}]
|
|
137
|
+
|
|
138
|
+
Input: At that time it appeared well adhered to the underlying skin .
|
|
139
|
+
Output: [{"entity_text": "it", "entity_type": "EVENT", "type": "TREATMENT", "polarity": "POS", "modality": "FACTUAL"},
|
|
140
|
+
{"entity_text": "well adhered", "entity_type": "EVENT", "type": "OCCURRENCE", "polarity": "POS", "modality": "FACTUAL"}]
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
# Input placeholder
|
|
144
|
+
Below is the entire medical note for your reference. I will feed you with sentences from it one by one.
|
|
145
|
+
"{{input}}"
|
llm_ie/engines.py
CHANGED
|
@@ -243,7 +243,7 @@ class OpenAIInferenceEngine(InferenceEngine):
|
|
|
243
243
|
for chunk in response:
|
|
244
244
|
if chunk.choices[0].delta.content is not None:
|
|
245
245
|
res += chunk.choices[0].delta.content
|
|
246
|
-
print(chunk.choices[0].delta.content, end="")
|
|
246
|
+
print(chunk.choices[0].delta.content, end="", flush=True)
|
|
247
247
|
return res
|
|
248
248
|
|
|
249
249
|
return response.choices[0].message.content
|