graphragzen.entity_extraction.utils.loop_extraction

graphragzen.entity_extraction.utils.loop_extraction(document, prompts, prompts_formatting, llm, max_gleans=5, output_structure=None)[source]
Extract entities in a loop, asking a few times if all entities are extracted using the

correct prompts.

Parameters:
  • document (str) – Document to extract entities from

  • prompts (EntityExtractionPrompts) – Base prompts. See graphragzen.typing.EntityExtractionPrompts

  • prompts_formatting (EntityExtractionPromptFormatting) – Values used to format the entity extraction prompt. See graphragzen.typing.EntityExtractionPromptFormatting.

  • llm (LLM)

  • max_gleans (int, optional) – How often the LLM should be asked if all entities have been extracted. Defaults to 5.

  • output_structure (ModelMetaclass, optional) – Output structure to force, using e.g. grammars from llama.cpp.

Returns:

Raw json string of extracted entities.

Return type:

List[str]