llm-ie 0.4.7__py3-none-any.whl → 1.0.0__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/__init__.py +4 -2
- llm_ie/asset/default_prompts/BasicReviewFrameExtractor_addition_review_prompt.txt +3 -0
- llm_ie/asset/default_prompts/BasicReviewFrameExtractor_revision_review_prompt.txt +2 -0
- llm_ie/asset/default_prompts/ReviewFrameExtractor_addition_review_prompt.txt +2 -1
- llm_ie/asset/default_prompts/ReviewFrameExtractor_revision_review_prompt.txt +2 -1
- llm_ie/asset/prompt_guide/BasicFrameExtractor_prompt_guide.txt +104 -86
- llm_ie/asset/prompt_guide/BasicReviewFrameExtractor_prompt_guide.txt +163 -0
- llm_ie/asset/prompt_guide/DirectFrameExtractor_prompt_guide.txt +163 -0
- llm_ie/asset/prompt_guide/ReviewFrameExtractor_prompt_guide.txt +103 -85
- llm_ie/asset/prompt_guide/SentenceFrameExtractor_prompt_guide.txt +103 -86
- llm_ie/asset/prompt_guide/SentenceReviewFrameExtractor_prompt_guide.txt +103 -86
- llm_ie/chunkers.py +191 -0
- llm_ie/data_types.py +75 -1
- llm_ie/engines.py +274 -183
- llm_ie/extractors.py +961 -850
- llm_ie/prompt_editor.py +39 -6
- llm_ie-1.0.0.dist-info/METADATA +18 -0
- llm_ie-1.0.0.dist-info/RECORD +27 -0
- llm_ie/asset/prompt_guide/SentenceCoTFrameExtractor_prompt_guide.txt +0 -217
- llm_ie-0.4.7.dist-info/METADATA +0 -1219
- llm_ie-0.4.7.dist-info/RECORD +0 -23
- {llm_ie-0.4.7.dist-info → llm_ie-1.0.0.dist-info}/WHEEL +0 -0
llm_ie/prompt_editor.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import sys
|
|
2
|
-
from typing import Dict
|
|
2
|
+
from typing import List, Dict, Generator
|
|
3
3
|
import importlib.resources
|
|
4
4
|
from llm_ie.engines import InferenceEngine
|
|
5
5
|
from llm_ie.extractors import FrameExtractor
|
|
@@ -79,7 +79,7 @@ class PromptEditor:
|
|
|
79
79
|
prompt_template=rewrite_prompt_template)
|
|
80
80
|
messages = [{"role": "system", "content": self.system_prompt},
|
|
81
81
|
{"role": "user", "content": prompt}]
|
|
82
|
-
res = self.inference_engine.chat(messages,
|
|
82
|
+
res = self.inference_engine.chat(messages, verbose=True, **kwrs)
|
|
83
83
|
return res
|
|
84
84
|
|
|
85
85
|
def comment(self, draft:str, **kwrs) -> str:
|
|
@@ -94,7 +94,7 @@ class PromptEditor:
|
|
|
94
94
|
prompt_template=comment_prompt_template)
|
|
95
95
|
messages = [{"role": "system", "content": self.system_prompt},
|
|
96
96
|
{"role": "user", "content": prompt}]
|
|
97
|
-
res = self.inference_engine.chat(messages,
|
|
97
|
+
res = self.inference_engine.chat(messages, verbose=True, **kwrs)
|
|
98
98
|
return res
|
|
99
99
|
|
|
100
100
|
|
|
@@ -126,7 +126,7 @@ class PromptEditor:
|
|
|
126
126
|
# Chat
|
|
127
127
|
messages.append({"role": "user", "content": user_input})
|
|
128
128
|
print(f"{Fore.BLUE}Assistant: {Style.RESET_ALL}", end="")
|
|
129
|
-
response = self.inference_engine.chat(messages,
|
|
129
|
+
response = self.inference_engine.chat(messages, verbose=True, **kwrs)
|
|
130
130
|
messages.append({"role": "assistant", "content": response})
|
|
131
131
|
|
|
132
132
|
|
|
@@ -186,7 +186,7 @@ class PromptEditor:
|
|
|
186
186
|
|
|
187
187
|
# Get assistant's response and append it to conversation
|
|
188
188
|
print("Assistant: ", end="")
|
|
189
|
-
response = self.inference_engine.chat(messages,
|
|
189
|
+
response = self.inference_engine.chat(messages, verbose=True, **kwrs)
|
|
190
190
|
messages.append({"role": "assistant", "content": response})
|
|
191
191
|
|
|
192
192
|
# Display the assistant's response
|
|
@@ -207,4 +207,37 @@ class PromptEditor:
|
|
|
207
207
|
if 'ipykernel' in sys.modules:
|
|
208
208
|
self._IPython_chat(**kwrs)
|
|
209
209
|
else:
|
|
210
|
-
self._terminal_chat(**kwrs)
|
|
210
|
+
self._terminal_chat(**kwrs)
|
|
211
|
+
|
|
212
|
+
def chat_stream(self, messages: List[Dict[str, str]], **kwrs) -> Generator[str, None, None]:
|
|
213
|
+
"""
|
|
214
|
+
This method processes messages and yields response chunks from the inference engine.
|
|
215
|
+
This is for frontend App.
|
|
216
|
+
|
|
217
|
+
Parameters:
|
|
218
|
+
----------
|
|
219
|
+
messages : List[Dict[str, str]]
|
|
220
|
+
List of message dictionaries (e.g., [{"role": "user", "content": "Hi"}]).
|
|
221
|
+
|
|
222
|
+
Yields:
|
|
223
|
+
-------
|
|
224
|
+
Chunks of the assistant's response.
|
|
225
|
+
"""
|
|
226
|
+
# Validate messages
|
|
227
|
+
if not isinstance(messages, list) or not all(isinstance(m, dict) and 'role' in m and 'content' in m for m in messages):
|
|
228
|
+
raise ValueError("Messages must be a list of dictionaries with 'role' and 'content' keys.")
|
|
229
|
+
|
|
230
|
+
# Always append system prompt and initial user message
|
|
231
|
+
file_path = importlib.resources.files('llm_ie.asset.PromptEditor_prompts').joinpath('chat.txt')
|
|
232
|
+
with open(file_path, 'r') as f:
|
|
233
|
+
chat_prompt_template = f.read()
|
|
234
|
+
|
|
235
|
+
prompt = self._apply_prompt_template(text_content={"prompt_guideline": self.prompt_guide},
|
|
236
|
+
prompt_template=chat_prompt_template)
|
|
237
|
+
|
|
238
|
+
messages = [{"role": "system", "content": self.system_prompt},
|
|
239
|
+
{"role": "user", "content": prompt}] + messages
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
stream_generator = self.inference_engine.chat(messages, stream=True, **kwrs)
|
|
243
|
+
yield from stream_generator
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: llm-ie
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: An LLM-powered tool that transforms everyday language into robust information extraction pipelines.
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: Enshuo (David) Hsu
|
|
7
|
+
Requires-Python: >=3.11,<4.0
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Requires-Dist: colorama (>=0.4.6,<0.5.0)
|
|
13
|
+
Requires-Dist: json_repair (>=0.30,<0.31)
|
|
14
|
+
Requires-Dist: nest_asyncio (>=1.6.0,<2.0.0)
|
|
15
|
+
Requires-Dist: nltk (>=3.8,<4.0)
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
This is the readme for llm-ie Python package.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
llm_ie/__init__.py,sha256=47E7fLY4vrNwZlvUmWdE_CkA024uFuQuovjNeuf59rQ,1426
|
|
2
|
+
llm_ie/asset/PromptEditor_prompts/chat.txt,sha256=Fq62voV0JQ8xBRcxS1Nmdd7DkHs1fGYb-tmNwctZZK0,118
|
|
3
|
+
llm_ie/asset/PromptEditor_prompts/comment.txt,sha256=C_lxx-dlOlFJ__jkHKosZ8HsNAeV1aowh2B36nIipBY,159
|
|
4
|
+
llm_ie/asset/PromptEditor_prompts/rewrite.txt,sha256=JAwY9vm1jSmKf2qcLBYUvrSmME2EJH36bALmkwZDWYQ,178
|
|
5
|
+
llm_ie/asset/PromptEditor_prompts/system.txt,sha256=QwGTIJvp-5u2P8CkGt_rabttlN1puHQwIBNquUm1ZHo,730
|
|
6
|
+
llm_ie/asset/default_prompts/BasicReviewFrameExtractor_addition_review_prompt.txt,sha256=pKes8BOAoJJgmo_IQh2ISKiMh_rDPl_rDUU_VgDQ4o4,273
|
|
7
|
+
llm_ie/asset/default_prompts/BasicReviewFrameExtractor_revision_review_prompt.txt,sha256=9Nwkr2U_3ZSk01xDtgiFJVABi6FkC8Izdq7zrzFfLRg,235
|
|
8
|
+
llm_ie/asset/default_prompts/ReviewFrameExtractor_addition_review_prompt.txt,sha256=NLEtnmx1aOsnwifAsXr65pX9WdrIWdx-MJ7aMtNKi8c,331
|
|
9
|
+
llm_ie/asset/default_prompts/ReviewFrameExtractor_revision_review_prompt.txt,sha256=lGGjdeFpzZEc56w-EtQDMyYFs7A3DQAM32sT42Nf_08,293
|
|
10
|
+
llm_ie/asset/default_prompts/SentenceReviewFrameExtractor_addition_review_prompt.txt,sha256=Of11LFuXLB249oekFelzlIeoAB0cATReqWgFTvhNz_8,329
|
|
11
|
+
llm_ie/asset/default_prompts/SentenceReviewFrameExtractor_revision_review_prompt.txt,sha256=kNJQK7NdoCx13TXGY8HYGrW_v4SEaErK8j9qIzd70CM,291
|
|
12
|
+
llm_ie/asset/prompt_guide/BasicFrameExtractor_prompt_guide.txt,sha256=-Cli7rwu4wM4vSmkG0nInNkpStUhRqKESQ3oqD38pbE,10395
|
|
13
|
+
llm_ie/asset/prompt_guide/BasicReviewFrameExtractor_prompt_guide.txt,sha256=-Cli7rwu4wM4vSmkG0nInNkpStUhRqKESQ3oqD38pbE,10395
|
|
14
|
+
llm_ie/asset/prompt_guide/BinaryRelationExtractor_prompt_guide.txt,sha256=Z6Yc2_QRqroWcJ13owNJbo78I0wpS4XXDsOjXFR-aPk,2166
|
|
15
|
+
llm_ie/asset/prompt_guide/DirectFrameExtractor_prompt_guide.txt,sha256=rBRIXg8JQWUHTRdoluTS0zkbTkBAacEtHHvr3lZaQCw,10437
|
|
16
|
+
llm_ie/asset/prompt_guide/MultiClassRelationExtractor_prompt_guide.txt,sha256=EQ9Jmh0CQmlfkWqXx6_apuEZUKK3WIrdpAvfbTX2_No,3011
|
|
17
|
+
llm_ie/asset/prompt_guide/ReviewFrameExtractor_prompt_guide.txt,sha256=rBRIXg8JQWUHTRdoluTS0zkbTkBAacEtHHvr3lZaQCw,10437
|
|
18
|
+
llm_ie/asset/prompt_guide/SentenceFrameExtractor_prompt_guide.txt,sha256=97_-y_vHMLG4Kb8fLsGgibLxB-3mest8k3LHfLo5h-I,10465
|
|
19
|
+
llm_ie/asset/prompt_guide/SentenceReviewFrameExtractor_prompt_guide.txt,sha256=97_-y_vHMLG4Kb8fLsGgibLxB-3mest8k3LHfLo5h-I,10465
|
|
20
|
+
llm_ie/chunkers.py,sha256=24h9l-Ldyx3EgfYicFqGhV_b-XofUS3yovC1nBWdDoo,5143
|
|
21
|
+
llm_ie/data_types.py,sha256=72-3bzzYpo7KZpD9bjoroWT2eiM0zmWyDkBr2nHoBV0,18559
|
|
22
|
+
llm_ie/engines.py,sha256=04wZgWc9a0wwZCLeWVr1dqrDU2-cDAxGB4b4rYik6gU,27438
|
|
23
|
+
llm_ie/extractors.py,sha256=iTF2U0_KmOlJiMX27Xr3-AKYckzK7Et-NE-__XFZ6tU,104520
|
|
24
|
+
llm_ie/prompt_editor.py,sha256=2sunCNLVlpmoF71tdUkCFDYp_YRcVYMvU7-n07Og93U,11062
|
|
25
|
+
llm_ie-1.0.0.dist-info/METADATA,sha256=EhpvJKYUEFPLIsDndhPgsnveCmhcb1mQyRh99tXEgMg,677
|
|
26
|
+
llm_ie-1.0.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
27
|
+
llm_ie-1.0.0.dist-info/RECORD,,
|
|
@@ -1,217 +0,0 @@
|
|
|
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. Thinking process:
|
|
10
|
-
Provide clear step-by-step instructions for analyzing the input text. Typically, this process should begin with an analysis section and proceed to the output generation. Each section should have a specific purpose:
|
|
11
|
-
|
|
12
|
-
Optional: Recall Section (<Recall>... </Recall>):
|
|
13
|
-
Write a brief recall of the task description and schema definition for better understanding of the task.
|
|
14
|
-
|
|
15
|
-
Analysis Section (<Analysis>... </Analysis>):
|
|
16
|
-
Break down the input text to identify important medical contents and clarify ambiguous concepts.
|
|
17
|
-
|
|
18
|
-
Output Section (<Outputs>... </Outputs>):
|
|
19
|
-
Based on the analysis, generate the required output in the defined format. Ensure that the extracted information adheres to the schema and task description.
|
|
20
|
-
|
|
21
|
-
4. Output Format Definition:
|
|
22
|
-
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>"}}).
|
|
23
|
-
|
|
24
|
-
5. Optional: Hints:
|
|
25
|
-
Provide itemized hints for the information extractors to guide the extraction process.
|
|
26
|
-
|
|
27
|
-
6. Optional: Examples:
|
|
28
|
-
Include examples in the format:
|
|
29
|
-
Input: ...
|
|
30
|
-
Output: ...
|
|
31
|
-
|
|
32
|
-
7. Input Placeholder:
|
|
33
|
-
The template must include a placeholder in the format {{<placeholder_name>}} for the input text. The placeholder name can be customized as needed.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Example 1 (single entity type with attributes):
|
|
37
|
-
|
|
38
|
-
# Task description
|
|
39
|
-
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.
|
|
40
|
-
|
|
41
|
-
# Schema definition
|
|
42
|
-
Your output should contain:
|
|
43
|
-
"ClinicalTrial" which is the name of the trial,
|
|
44
|
-
If applicable, "Arm" which is the arm within the clinical trial,
|
|
45
|
-
"AdverseReaction" which is the name of the adverse reaction,
|
|
46
|
-
If applicable, "Percentage" which is the occurance of the adverse reaction within the trial and arm,
|
|
47
|
-
"Evidence" which is the EXACT sentence in the text where you found the AdverseReaction from
|
|
48
|
-
|
|
49
|
-
# Thinking process
|
|
50
|
-
Approach this task step by step. Start with a recall section (<Recall>... </Recall>) that briefly summarize of the task description and schema definition for better understanding of the task. Then write an analysis section (<Analysis>... </Analysis>) to analyze the input sentence. Identify important pharmacology contents and clarify ambiguous concepts. Finally, the output section (<Outputs>... </Outputs>) that list your final outputs following the defined format.
|
|
51
|
-
|
|
52
|
-
# Output format definition
|
|
53
|
-
Your output should follow JSON format, for example:
|
|
54
|
-
[
|
|
55
|
-
{"ClinicalTrial": "<Clinical trial name or number>", "Arm": "<name of arm>", "AdverseReaction": "<Adverse reaction text>", "Percentage": "<a percent>", "Evidence": "<exact sentence from the text>"},
|
|
56
|
-
{"ClinicalTrial": "<Clinical trial name or number>", "Arm": "<name of arm>", "AdverseReaction": "<Adverse reaction text>", "Percentage": "<a percent>", "Evidence": "<exact sentence from the text>"}
|
|
57
|
-
]
|
|
58
|
-
|
|
59
|
-
# Additional hints
|
|
60
|
-
Your output should be 100% based on the provided content. DO NOT output fake numbers.
|
|
61
|
-
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.
|
|
62
|
-
|
|
63
|
-
# Input placeholder
|
|
64
|
-
Below is the Adverse reactions section:
|
|
65
|
-
"{{input}}"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Example 2 (multiple entity types):
|
|
69
|
-
|
|
70
|
-
# Task description
|
|
71
|
-
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.
|
|
72
|
-
|
|
73
|
-
# Schema definition
|
|
74
|
-
Your output should contain:
|
|
75
|
-
"entity_text": the exact wording as mentioned in the note.
|
|
76
|
-
"entity_type": type of the entity. It should be one of the "Drug", "Form", "Strength", "Frequency", "Route", "Dosage", "Reason", "ADE", or "Duration".
|
|
77
|
-
|
|
78
|
-
# Thinking process
|
|
79
|
-
Approach this task step by step. Start with an analysis section (<Analysis>... </Analysis>) to analyze the input sentence. Identify important medical contents and clarify ambiguous concepts. Then, the output section (<Outputs>... </Outputs>) that list your final outputs following the defined format.
|
|
80
|
-
|
|
81
|
-
# Output format definition
|
|
82
|
-
Your output should follow JSON format,
|
|
83
|
-
if there are one of the entity mentions: Drug, Form, Strength, Frequency, Route, Dosage, Reason, ADE, or Duration:
|
|
84
|
-
[{"entity_text": "<Exact entity mentions as in the note>", "entity_type": "<entity type as listed above>"},
|
|
85
|
-
{"entity_text": "<Exact entity mentions as in the note>", "entity_type": "<entity type as listed above>"}]
|
|
86
|
-
if there is no entity mentioned in the given note, just output an empty list:
|
|
87
|
-
[]
|
|
88
|
-
|
|
89
|
-
# Examples
|
|
90
|
-
Below are some examples:
|
|
91
|
-
|
|
92
|
-
Input: Acetaminophen 650 mg PO BID 5.
|
|
93
|
-
Output:
|
|
94
|
-
<Analysis>
|
|
95
|
-
The sentence "Acetaminophen 650 mg PO BID 5." contains several potential medical entities.
|
|
96
|
-
|
|
97
|
-
"Acetaminophen" is a Drug.
|
|
98
|
-
"650 mg" represents the Strength.
|
|
99
|
-
"PO" is the Route (meaning by mouth).
|
|
100
|
-
"BID" stands for a dosing frequency, which represents Frequency (meaning twice a day).
|
|
101
|
-
</Analysis>
|
|
102
|
-
|
|
103
|
-
<Outputs>
|
|
104
|
-
[{"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"}]
|
|
105
|
-
</Outputs>
|
|
106
|
-
|
|
107
|
-
Input: Mesalamine DR 1200 mg PO BID 2.
|
|
108
|
-
Output:
|
|
109
|
-
<Analysis>
|
|
110
|
-
The sentence "Mesalamine DR 1200 mg PO BID 2." contains the following medical entities:
|
|
111
|
-
|
|
112
|
-
"Mesalamine" is a Drug.
|
|
113
|
-
"DR" stands for Form (delayed-release).
|
|
114
|
-
"1200 mg" represents the Strength.
|
|
115
|
-
"PO" is the Route (by mouth).
|
|
116
|
-
"BID" is the Frequency (twice a day).
|
|
117
|
-
</Analysis>
|
|
118
|
-
|
|
119
|
-
<Outputs>
|
|
120
|
-
[{"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"}]
|
|
121
|
-
</Outputs>
|
|
122
|
-
|
|
123
|
-
# Input placeholder
|
|
124
|
-
Below is the medical note:
|
|
125
|
-
"{{input}}"
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
Example 3 (multiple entity types with corresponding attributes):
|
|
129
|
-
|
|
130
|
-
# Task description
|
|
131
|
-
This is a named entity recognition task. Given a sentence from a medical note, annotate the events (EVENT) and time expressions (TIMEX3):
|
|
132
|
-
|
|
133
|
-
# Schema definition
|
|
134
|
-
Your output should contain:
|
|
135
|
-
"entity_text": the exact wording as mentioned in the note.
|
|
136
|
-
"entity_type": type of the entity. It should be one of the "EVENT" or "TIMEX3".
|
|
137
|
-
if entity_type is "EVENT",
|
|
138
|
-
"type": the event type as one of the "TEST", "PROBLEM", "TREATMENT", "CLINICAL_DEPT", "EVIDENTIAL", or "OCCURRENCE".
|
|
139
|
-
"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.
|
|
140
|
-
"modality": whether an EVENT actually occurred or not. Must be one of the "FACTUAL", "CONDITIONAL", "POSSIBLE", or "PROPOSED".
|
|
141
|
-
|
|
142
|
-
if entity_type is "TIMEX3",
|
|
143
|
-
"type": the type as one of the "DATE", "TIME", "DURATION", or "FREQUENCY".
|
|
144
|
-
"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
|
|
145
|
-
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)
|
|
146
|
-
"mod": additional information regarding the temporal value of a time expression. Must be one of the:
|
|
147
|
-
“NA”: the default value, no relevant modifier is present;
|
|
148
|
-
“MORE”, means “more than”, e.g. over 2 days (val = P2D, mod = MORE);
|
|
149
|
-
“LESS”, means “less than”, e.g. almost 2 months (val = P2M, mod=LESS);
|
|
150
|
-
“APPROX”, means “approximate”, e.g. nearly a week (val = P1W, mod=APPROX);
|
|
151
|
-
“START”, describes the beginning of a period of time, e.g. Christmas morning, 2005 (val= 2005-12-25, mod= START).
|
|
152
|
-
“END”, describes the end of a period of time, e.g. late last year, (val = 2010, mod = END)
|
|
153
|
-
“MIDDLE”, describes the middle of a period of time, e.g. mid-September 2001 (val = 2001-09, mod = MIDDLE)
|
|
154
|
-
|
|
155
|
-
# Thinking process
|
|
156
|
-
Approach this task step by step. Start with a recall section (<Recall>... </Recall>) that briefly summarize of the task description and schema definition for better understanding of the task. Followed by an analysis section (<Analysis>... </Analysis>) to analyze the input sentence. Identify important medical contents and clarify ambiguous concepts. Then, the output section (<Outputs>... </Outputs>) that list your final outputs following the defined format.
|
|
157
|
-
|
|
158
|
-
# Output format definition
|
|
159
|
-
Your output should follow JSON format,
|
|
160
|
-
if there are one of the EVENT or TIMEX3 entity mentions:
|
|
161
|
-
[
|
|
162
|
-
{"entity_text": "<Exact entity mentions as in the note>", "entity_type": "EVENT", "type": "<event type>", "polarity": "<event polarity>", "modality": "<event modality>"},
|
|
163
|
-
{"entity_text": "<Exact entity mentions as in the note>", "entity_type": "TIMEX3", "type": "<TIMEX3 type>", "val": "<time value>", "mod": "<additional information>"}
|
|
164
|
-
...
|
|
165
|
-
]
|
|
166
|
-
if there is no entity mentioned in the given note, just output an empty list:
|
|
167
|
-
[]
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
# Examples
|
|
171
|
-
Below are some examples:
|
|
172
|
-
|
|
173
|
-
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 .
|
|
174
|
-
Output:
|
|
175
|
-
<Recall>
|
|
176
|
-
This is a named entity recognition task that focuses on extracting medical events (EVENT) and time expressions (TIMEX3). Events are categorized by their type (TEST, PROBLEM, TREATMENT, etc.), polarity (POS or NEG), and modality (FACTUAL, CONDITIONAL, POSSIBLE, or PROPOSED). Time expressions are identified as either DATE, TIME, DURATION, or FREQUENCY and include specific values or modifiers where applicable.
|
|
177
|
-
</Recall>
|
|
178
|
-
|
|
179
|
-
<Analysis>
|
|
180
|
-
In this sentence:
|
|
181
|
-
|
|
182
|
-
"9/7/93" represents a TIMEX3 entity for the date.
|
|
183
|
-
"1:00 a.m." is a TIMEX3 entity representing the time.
|
|
184
|
-
"first 24 hours" refers to a TIMEX3 entity of duration.
|
|
185
|
-
"intravenous fluids rate was decreased" is an EVENT referring to a TREATMENT event with a negative polarity (as it was "decreased") and a FACTUAL modality (it actually happened).
|
|
186
|
-
"total fluids given during the first 24 hours" is another EVENT representing a TREATMENT that is FACTUAL in its modality.
|
|
187
|
-
</Analysis>
|
|
188
|
-
|
|
189
|
-
<Outputs>
|
|
190
|
-
[{"entity_text": "intravenous fluids", "entity_type": "EVENT", "type": "TREATMENT", "polarity": "POS", "modality": "FACTUAL"},
|
|
191
|
-
{"entity_text": "decreased", "entity_type": "EVENT", "type": "OCCURRENCE", "polarity": "POS", "modality": "FACTUAL"},
|
|
192
|
-
{"entity_text": "total fluids", "entity_type": "EVENT", "type": "TREATMENT", "polarity": "POS", "modality": "FACTUAL"},
|
|
193
|
-
{"entity_text": "9/7/93 , 1:00 a.m.", "entity_type": "TIMEX3", "type": "TIME", "val": "1993-09-07T01:00", "mod": "NA"},
|
|
194
|
-
{"entity_text": "24 hours", "entity_type": "TIMEX3", "type": "DURATION", "val": "PT24H", "mod": "NA"}]
|
|
195
|
-
</Outputs>
|
|
196
|
-
|
|
197
|
-
Input: At that time it appeared well adhered to the underlying skin .
|
|
198
|
-
Output:
|
|
199
|
-
<Recall>
|
|
200
|
-
This is a named entity recognition task focused on extracting medical events (EVENT) and time expressions (TIMEX3). Events are categorized by their type (e.g., TEST, PROBLEM, TREATMENT), polarity (POS or NEG), and modality (FACTUAL, CONDITIONAL, POSSIBLE, or PROPOSED). Time expressions are categorized as DATE, TIME, DURATION, or FREQUENCY, and include values or modifiers where applicable.
|
|
201
|
-
</Recall>
|
|
202
|
-
|
|
203
|
-
<Analysis>
|
|
204
|
-
In this sentence:
|
|
205
|
-
|
|
206
|
-
"At that time" refers to a TIMEX3 entity that is vague, so it can be considered as a TIME with an unspecified value.
|
|
207
|
-
"appeared well adhered to the underlying skin" describes an EVENT that likely indicates a PROBLEM (the condition of the skin) and has a POS polarity (since it is "well adhered") with a FACTUAL modality (it actually occurred).
|
|
208
|
-
</Analysis>
|
|
209
|
-
|
|
210
|
-
<Outputs>
|
|
211
|
-
[{"entity_text": "it", "entity_type": "EVENT", "type": "TREATMENT", "polarity": "POS", "modality": "FACTUAL"},
|
|
212
|
-
{"entity_text": "well adhered", "entity_type": "EVENT", "type": "OCCURRENCE", "polarity": "POS", "modality": "FACTUAL"}]
|
|
213
|
-
</Outputs>
|
|
214
|
-
|
|
215
|
-
# Input placeholder
|
|
216
|
-
Below is the medical note:
|
|
217
|
-
"{{input}}"
|