kazu.steps.ner.llm_ner¶
Classes
A class to interact with the Azure OpenAI API for LLMs. |
|
A step to perform Named Entity Recognition using a Language Model. |
|
A class to interact with the VertexAI API for LLMs. |
- class kazu.steps.ner.llm_ner.AzureOpenAILLMModel[source]¶
Bases:
LLMModel
A class to interact with the Azure OpenAI API for LLMs.
- class kazu.steps.ner.llm_ner.LLMModel[source]¶
Bases:
ABC
- __call__(text)[source]¶
Call the LLM model with the given text and return the raw response and parsed entities.
- class kazu.steps.ner.llm_ner.LLMNERStep[source]¶
Bases:
Step
A step to perform Named Entity Recognition using a Language Model.
The LLM is used to produce a raw json response per document section, which is then parsed into entities and their classes, then ahocorasick is used to find matches in the document text. If there are conflicts, the class of the first match in the document is used.
- __call__(doc)[source]¶
Process documents and respond with processed and failed documents.
Note that many steps will be decorated by
document_iterating_step()
ordocument_batch_step()
which will modify the ‘original’__call__
function signature to match the expected signature for a step, as the decorators handle the exception/failed documents logic for you.
- class kazu.steps.ner.llm_ner.VertexLLMModel[source]¶
Bases:
LLMModel
A class to interact with the VertexAI API for LLMs.
- __init__(project, prompt, model, generation_config, location, safety_settings=None)[source]¶
Initialize the VertexLLMModel.
- Parameters:
project (str) – The project to use.
prompt (str) – The prompt to use.
model (str) – The model to use.
generation_config (dict[str, Any]) – The generation config to use.
location (str) – The location to use.
safety_settings (List[SafetySetting] | Dict[HarmCategory, HarmBlockThreshold] | None) – The safety settings to use. Optional.
- Return type:
None