LLM_IE v0.4.5
Documentation
Changes
-
Added option to adjust the number of context sentences in sentence-based extractors.
Thecontext_sentencessets number of sentences before and after the sentence of interest to provide additional context. Whencontext_sentences=2, 2 sentences before and 2 sentences after are included in the user prompt as context. Whencontext_sentences="all", the entire document is included as context. Whencontext_sentences=0, no context is provided and LLM will only extract based on the current sentence of interest.from llm_ie.extractors import SentenceFrameExtractor extractor = SentenceFrameExtractor(inference_engine=inference_engine, prompt_template=prompt_temp, context_sentences=2) frames = extractor.extract_frames(text_content=text, entity_key="Diagnosis", case_sensitive=False, fuzzy_match=True, stream=True)
For the sentence:
The patient has a history of hypertension, hyperlipidemia, and Type 2 diabetes mellitus.
The context is "previous sentence 2" "previous sentence 1" "the sentence of interest" "proceeding sentence 1" "proceeding sentence 2":
*Emily Brown, MD (Cardiology), Dr. Michael Green, MD (Pulmonology)
#### Reason for Admission
John Doe, a 49-year-old male, was admitted to the hospital with complaints of chest pain, shortness of breath, and dizziness. The patient has a history of hypertension, hyperlipidemia, and Type 2 diabetes mellitus. #### History of Present Illness
The patient reported that the chest pain started two days prior to admission. The pain was described as a pressure-like sensation in the central chest, radiating to the left arm and jaw. -
Added support for OpenAI reasoning models ("o" series).
For reasoning models ("o" series), use thereasoning_model=Trueflag. Themax_completion_tokenswill be used instead of themax_tokens.temperaturewill be ignored.from llm_ie.engines import OpenAIInferenceEngine inference_engine = OpenAIInferenceEngine(model="o1-mini", reasoning_model=True)