graphragzen.prompt_tuning.entities.generate_entity_categories

graphragzen.prompt_tuning.entities.generate_entity_categories(llm, documents, domain, persona, prompt='\nThe goal is to study the connections and relations between the entity categories and their features in order to understand all available information from the text.\nThe user\'s task is to Identify the relations and structure of the community of interest, specifically within the {domain} domain.\nAs part of the analysis, you want to identify the entity categories present in the following text.\nThe entity categories must be relevant to the user task.\nAvoid general entity categories such as "other" or "unknown".\nThis is VERY IMPORTANT: Do not generate redundant or overlapping entity categories. For example, if the text contains "company" and "organization" entity categories, you should return only one of them.\nDon\'t worry about quantity, always choose quality over quantity. And make sure EVERYTHING in your answer is relevant to the context of entity extraction.\nAnd remember, it is ENTITY CATEGORIES what we need.\nReturn the entity categories in as a list of comma separated strings.\n=====================================================================\nEXAMPLE SECTION: The following section includes example output. These examples **must be excluded from your answer**.\n\nEXAMPLE 1\nTask: Determine the connections and organizational hierarchy within the specified community.\nText: Example_Org_A is a company in Sweden. Example_Org_A\'s director is Example_Individual_B.\nRESPONSE:\norganization, person\nEND OF EXAMPLE 1\n\nEXAMPLE 2\nTask: Identify the key concepts, principles, and arguments shared among different philosophical schools of thought, and trace the historical or ideological influences they have on each other.\nText: Rationalism, epitomized by thinkers such as René Descartes, holds that reason is the primary source of knowledge. Key concepts within this school include the emphasis on the deductive method of reasoning.\nRESPONSE:\nconcept, person, school of thought\nEND OF EXAMPLE 2\n\nEXAMPLE 3\nTask: Identify the full range of basic forces, factors, and trends that would indirectly shape an issue.\nText: Industry leaders such as Panasonic are vying for supremacy in the battery production sector. They are investing heavily in research and development and are exploring new technologies to gain a competitive edge.\nRESPONSE:\norganization, technology, sectors, investment strategies\nEND OF EXAMPLE 3\n======================================================================\n\n======================================================================\nREAL DATA: The following section is the real data. You should use only this real data to prepare your answer. Generate Entity Categories only.\nTask: Identify the relations and structure of the community of interest, specifically within the {domain} domain.\nText: {input_text}\nRESPONSE:\n{{<entity_categories>}}\n', output_structure=<class 'graphragzen.prompt_tuning.llm_output_structures.ExtractedCategories'>, entity_categories=None)[source]

Generate entity categories from a given set of (small) documents.

Example Output [‘military unit’, ‘organization’, ‘person’, ‘location’, ‘event’, ‘date’, ‘equipment’]

Parameters:
  • llm (LLM)

  • documents (List[str]) – Sample of documents that later will be used to create a graph. You likely want this to be chunks of the whole documents.

  • domain (str) – Relevant to the documents

  • persona (str) – Relevant to the domain

  • prompt (str, optional) – Prompt to use for generating entity categories. Defaults to graphragzen.prompts.prompt_tuning.entity_categories.GENERATE_ENTITY_CATEGORIES_PROMPT If entity_categories is not specified this will be used to infer the entity categories.

  • output_structure (ModelMetaclass, optional) – Output structure to force, e.g. grammars from llama.cpp. This SHOULD NOT be an instance of the pydantic model, just the reference. Correct = BaseLlamaCpp(“some text”, MyPydanticModel) Wrong = BaseLlamaCpp(“some text”, MyPydanticModel()) Defaults to graphragzen.prompt_tuning.llm_output_structures.ExtractedCategories

  • entity_categories (List[str], optional) – The entity categories relevant to a set of documents. If not specified, the prompt will be used to infer the entity categories. Defaults to None.

Returns:

entity categories

Return type:

list[str]