Skip to content

LLM_IE v0.4.5

Choose a tag to compare

@daviden1013 daviden1013 released this 17 Feb 07:10

Documentation

Changes

  • Added option to adjust the number of context sentences in sentence-based extractors.
    The context_sentences sets number of sentences before and after the sentence of interest to provide additional context. When context_sentences=2, 2 sentences before and 2 sentences after are included in the user prompt as context. When context_sentences="all", the entire document is included as context. When context_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 the reasoning_model=True flag. The max_completion_tokens will be used instead of the max_tokens. temperature will be ignored.

    from llm_ie.engines import OpenAIInferenceEngine
    
    inference_engine = OpenAIInferenceEngine(model="o1-mini", reasoning_model=True)