Prompt word dynamic generation method based on domain ontology

By using a variable system and semantic structure dynamic generation method based on domain ontology, the problems of semantic ambiguity and low reusability in existing prompt word generation technologies are solved, and efficient and accurate prompt word generation is achieved.

CN121301587AActive Publication Date: 2026-01-09广州极天信息技术股份有限公司

Patent Information

Application Number
CN202511851520.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-10
Publication Date
2026-01-09
Estimated Expiration
2045-12-10

AI Technical Summary

Technical Problem

Existing prompt generation technologies lack a structured understanding of global knowledge, leading to semantic ambiguity, inability to accurately adapt to professional and complex business scenarios, and low template reusability and maintenance efficiency.

Method used

A variable system is built based on the domain ontology. The semantic structure of the scene variables is used to deeply extract and interpret the context data, dynamically generate prompt words, and use the assigned scene variables to generate high-quality, structured prompt words.

Benefits of technology

It improves the reusability and maintenance efficiency of prompt word templates, meets the needs of large models for high-quality, structured contextual information, and achieves accurate adaptation of prompt words.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121301587A_ABST
    Figure CN121301587A_ABST
Patent Text Reader

Abstract

The invention provides a dynamic cue word generation method based on domain ontology, and relates to the technical field of cue word engineering. Firstly, a user request is received, the intention of the user request is analyzed to determine a specific application scene, an ontology variable system is constructed based on an ontology structure of a current application scene field, and a structured cue word template containing a preset scene variable is matched; on the basis, context data of a current session is deeply extracted and explained, unstructured user input is mapped into instance data of a domain ontology, and accurate real-time assignment is performed on a structured cue word template of a scene variable strictly according to a semantic path defined by the scene variable. The reusability and the maintenance efficiency of the cue word template are greatly improved, and finally the cue word is dynamically generated by using the assigned scene variable, so that the urgent demand of a large model for high-quality and structured context information is met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of prompt word engineering, and more specifically, to a method for dynamically generating prompt words based on domain ontology. Background Technology

[0002] Prompt word engineering, as an interaction method relying on natural language, focuses on designing appropriate prompts to guide large language models in generating the desired output. Ontology, a high-quality and rigorous knowledge graph, establishes modeling meta-terms such as classes, relations, attributes, individuals, instances, and rules, and defines typical relations and attributes. It establishes a structural framework and semantic standards for the definition of entities and relations. Domain ontology, in particular, deeply organizes concepts and their interrelationships within a specific domain, possessing strong professionalism and logical constraints. It is widely used in information retrieval, deep analysis, and knowledge automation, serving as a key foundation for improving system intelligence. Therefore, applying domain ontology to prompt word engineering has significant application prospects.

[0003] While dynamic generation techniques for prompts have emerged in the existing field of prompt engineering, incorporating the concept of object variables, these solutions have significant limitations. Current variable handling largely remains at a superficial level of contextual text replacement. Dynamic generation relies solely on local information from the current dialogue (such as the user's last sentence), lacking a structured understanding of global knowledge and the support of a structured variable system based on a semantic knowledge base. This means that variables in existing prompt templates are typically unconstrained and non-standardized, making it difficult to leverage inherent logical relationships within domain knowledge to verify data accuracy or supplement deeper background knowledge. This leads to semantic ambiguity during prompt generation, hindering accurate adaptation to specialized and complex business scenarios. Furthermore, the reusability and maintenance efficiency of prompt templates are low, failing to meet the urgent needs of large models for high-quality, structured contextual information. Summary of the Invention

[0004] To address the issues of low semantic accuracy and inability to accurately adapt to specialized business scenarios in existing prompt generation methods, this invention proposes a dynamic prompt generation method based on domain ontology. This method improves the semantic accuracy of prompts during the generation process, accurately adapts to specialized and complex business scenarios, and offers high reusability and maintenance efficiency of prompt templates, thus meeting the urgent need of large models for high-quality, structured contextual information.

[0005] To achieve the above-mentioned technical effects, the technical solution of the present invention is as follows: Firstly, this application proposes a method for dynamically generating prompts based on domain ontology, comprising the following steps: Receive user requests, determine the requested application scenario based on the user requests, and match pre-set prompt word templates and scenario variables based on the requested application scenario; Based on the domain ontology structure of the current application scenario, an ontology variable system is constructed, and the semantic structure of scenario variables is defined based on the ontology variable system. The context data of the current session in which the user request is located and the domain ontology of the application scenario of the request are extracted and interpreted, and the scenario variables are assigned values ​​in real time based on the semantic structure of the defined scenario variables. The prompt words are dynamically generated using the assigned scene variables.

[0006] In this technical solution, the user request is first received to determine the specific application scenario. Based on the ontology structure of the current application scenario domain, an ontology variable system is constructed and a structured prompt word template containing preset scenario variables is matched. On this basis, the context data of the current session is deeply extracted and interpreted, and the unstructured user input is mapped to instance data of the domain ontology. The structured prompt word template of the scenario variable is accurately assigned in real time according to the semantic path defined by the scenario variable, which greatly improves the reusability and maintenance efficiency of the prompt word template. Finally, prompt words are dynamically generated using the assigned scenario variables, thereby meeting the urgent need of large models for high-quality, structured context information.

[0007] Preferably, the prompt word template includes a role definition submodule, a task instruction submodule, a background knowledge submodule, and an output requirement submodule; the role definition submodule sets the identity of the large model in the current session; the task instruction submodule is used to describe the specific requirements of the business; the background knowledge submodule provides background information in the professional field; and the output requirement submodule defines the output format requirements of the data generated to complete the instruction requirements.

[0008] Preferably, the ontology variable system includes context-assigned variables and ontology data extraction variables. The context-assigned variables and ontology data extraction variables are used together as scenario variables in the prompt word template corresponding to a certain request application scenario, and are inserted into the prompt word template as placeholders. During the prompt word generation process, the scenario variables are dynamically assigned values.

[0009] Preferably, the semantic structure of the context-assigned variables supports multi-level structure definition. The context-assigned variables include: class-level sub-variables, attribute-level sub-variables, relation-level sub-variables, and relation-attribute-level sub-variables. The class-level sub-variables are used to extract individual instances and sets of instances belonging to a specified class from the context data of the current session in the application scenario and assign values. The attribute-level sub-variables are used to extract specific attribute values ​​corresponding to instances in the set of individual instances and assign values. The relation-level sub-variables are used to extract and assign values ​​to a set of associated objects that have a specific semantic relationship with the set of individual instances. The relation-attribute-level sub-variables are used to extract and assign values ​​to a set of associated objects in the set of individual instances whose attributes have specific attribute values ​​in the relation.

[0010] Preferably, the semantic structure of the ontology data extraction variables supports multi-level structure definition, including: architecture layer sub-variables, data layer sub-variables, and relationship layer sub-variables; the architecture layer sub-variables are used to extract the ontology's classification system and concept definitions, the data layer sub-variables are used to extract the data list of a specific category under the ontology's classification system, and the relationship layer sub-variables are used to extract the relationship between the classification system obtained by the architecture layer sub-variables and the specific data obtained by the data layer sub-variables, thus obtaining a complete knowledge description.

[0011] Preferably, the context-assigned variable is instantiated and assigned a value based on the user request and context data, and the process is as follows: Parse the context data in the user request, and identify and extract the attribute values ​​or relational objects in the context data; Based on the semantic structure defined by the context assignment variable, unstructured attribute values ​​or relational objects extracted from the context data are mapped to instances that conform to the semantic structure. The instance that conforms to the semantic structure is assigned to the context assignment variable, thus completing the instantiation assignment of the context assignment variable.

[0012] Preferably, the ontology data extraction variable extracts background knowledge data from the domain ontology of the requested application scenario, and injects the background knowledge data into the background knowledge submodule of the prompt word template. The process is as follows: Parse the sub-variables of the architecture layer and extract the complete classification system, concept definitions and their hierarchical structure involved in the request application scenario from the domain ontology; Use data layer sub-variables to traverse specific instance data belonging to the above architecture layer sub-variables from the domain ontology; By utilizing the relationship layer sub-variables, the classification system obtained from the architecture layer sub-variables is extracted, and the specific data obtained from the data layer sub-variables is used to form complete background knowledge data; Background knowledge data is injected into the prompt word template in natural language form, and the ontology data extraction variables in the scene variables are assigned values.

[0013] Secondly, this application also proposes a dynamic prompt word generation system based on domain ontology, the system comprising: The scenario variable matching module is used to receive user requests, determine the requested application scenario based on the user requests, and match pre-set prompt word templates and scenario variables based on the requested application scenario; The scene variable semantic structure definition module is used to construct an ontology variable system based on the domain ontology structure of the current application scenario, and to define the semantic structure of scene variables based on the ontology variable system. The scenario variable assignment module is used to extract and interpret the context data of the current session in which the user request is located and the domain ontology of the request application scenario, and to assign values ​​to the scenario variables in real time based on the semantic structure of the defined scenario variables. The prompt word generation module is used to dynamically generate prompt words using the assigned scene variable values.

[0014] Thirdly, this application also proposes a computer device, which includes a memory, a processor, and a computer program stored in the memory that can be run on the processor. The processor executes the computer program to implement the aforementioned method for dynamically generating prompts based on domain ontology.

[0015] Fourthly, this application also proposes a computer storage medium storing a computer program, the computer program including program instructions, which, when executed by a computer, cause the computer to execute the aforementioned method for dynamically generating prompts based on domain ontology.

[0016] Compared with the prior art, the beneficial effects of the present invention are: This invention proposes a method for dynamically generating prompt words based on domain ontology. First, it receives user requests to determine the specific application scenario. Then, it constructs an ontology variable system based on the ontology structure of the current application scenario domain and matches it with a structured prompt word template containing preset scenario variables. Next, it deeply extracts and interprets the context data of the current session, mapping unstructured user input to instance data of the domain ontology. Finally, it precisely assigns real-time values ​​to the structured prompt word templates of the scenario variables according to the semantic paths defined by the scenario variables. This significantly improves the reusability and maintenance efficiency of the prompt word templates. Ultimately, it dynamically generates prompt words using the assigned scenario variables, thus meeting the urgent need of large models for high-quality, structured contextual information. Attached Figure Description

[0017] Figure 1 This is a flowchart illustrating a method for dynamically generating prompts based on domain ontology, as proposed in Embodiment 1 of the present invention. Figure 2 A schematic diagram illustrating the structural definition and instantiation relationship of the ontology variable system proposed in Embodiment 2 of the present invention; Figure 3 This is a schematic diagram illustrating the structure of a prompt word dynamic generation system based on domain ontology proposed in Embodiment 3 of the present invention; Figure 4 This is a schematic diagram of the structure of the computer device proposed in Embodiment 4 of the present invention. Detailed Implementation

[0018] The accompanying drawings are for illustrative purposes only and should not be construed as limiting the scope of this patent. To better illustrate this embodiment, some parts of the accompanying drawings may be omitted, enlarged, or reduced, and do not represent the actual dimensions; It is understandable to those skilled in the art that some well-known details may be omitted from the accompanying drawings.

[0019] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.

[0020] The positional relationships depicted in the accompanying drawings are for illustrative purposes only and should not be construed as limiting this patent. Example 1 This embodiment proposes a method for dynamically generating prompts based on domain ontology. A flowchart illustrating this method can be found here. Figure 1 This includes the following steps: S1. Receive a user request, determine the requested application scenario based on the user request, and match a pre-set prompt word template and scenario variable based on the requested application scenario; S2. Based on the domain ontology structure of the current application scenario, construct an ontology variable system, and define the semantic structure of scenario variables based on the ontology variable system; S3. Extract and interpret the context data of the current session in which the user request is located and the domain ontology of the application scenario of the request, and assign values ​​to the scenario variables in real time based on the semantic structure of the defined scenario variables; S4. Dynamically generate prompt words using the assigned scene variables.

[0021] In this embodiment, a user request is first received, the specific application scenario is determined, and an ontology variable system is constructed based on the ontology structure of the current application scenario domain. A structured prompt word template containing preset scenario variables is then matched. Based on this, the context data of the current session is deeply extracted and interpreted, mapping unstructured user input to instance data of the domain ontology. The structured prompt word template of the scenario variables is then precisely assigned values ​​in real time according to the semantic path defined by the scenario variables. This significantly improves the reusability and maintenance efficiency of the prompt word template. Finally, prompt words are dynamically generated using the assigned scenario variables, thus meeting the urgent need of large models for high-quality, structured contextual information.

[0022] Example 2 In this embodiment, the prompt word template includes a role definition submodule, a task instruction submodule, a background knowledge submodule, and an output requirement submodule; the role definition submodule sets the identity of the large model in the current session; the task instruction submodule is used to describe the specific requirements of the business; the background knowledge submodule provides background information in the professional field; and the output requirement submodule defines the output format requirements of the data generated to complete the instruction requirements.

[0023] Specifically, the user requests include specific requirements for scenarios such as entity extraction, information classification, business review, paper search, and text summarization. For example, "check the papers written by Zhang San in the last 3 years" belongs to the "paper search" scenario. Some scenarios include contextual content. For example, to classify specified information, the classification criteria and the data to be classified must be given. Entity extraction also requires the target text to be extracted.

[0024] Specifically, taking the analysis of work order content in the telecommunications field as an example, the role definition submodule is used to set the identity of the large model in the current session, so that its reply conforms to the tone of a specific profession or expert. The specific sub-template content includes: "You are a professional telecommunications analyst, focusing on work order content analysis." The task instruction submodule is used to describe specific business requirements, embedding context-assigned variables prefixed with the symbol $ and ontology data extraction variables prefixed with the symbol $$. These variables are like "fill-in-the-blank questions," where the system will fill in the specific data input by the user (such as the specific work order text) at runtime. The specific sub-template content includes: "Analyze the problem products and phenomena mentioned in ${individual set: Thing\work order.content}, where the products must be in $${class set: Thing\product.name}, $${individual set: Thing\product.name} or $${class set: Thing\product.synonyms}, $${individual set: Thing\product.synonyms}, and find the classification path of each product as the product type. Output ${individual set: Thing\work order} and the corresponding product type, product, and problem phenomenon in a list." The background knowledge submodule is used to provide background information within a specific professional field. When the system runs on ontology data extraction variables, it will query the data in the domain ontology library. For example, for the variable instruction $${class set: Thing\product.name}, the system will scan all individual instances under the class "Thing\product" in the domain ontology and extract the names and attribute values ​​of these instances, ultimately forming a list or set.

[0025] In this embodiment, the ontology variable system includes context-assigned variables and ontology data extraction variables. The context-assigned variables and ontology data extraction variables are used together as scenario variables in the prompt word template corresponding to a certain request application scenario, and are inserted into the prompt word template as placeholders. During the prompt word generation process, the scenario variables are dynamically assigned values.

[0026] In this embodiment, the semantic structure of the context assignment variable supports multi-level structure definition. The context assignment variable includes: class-level sub-variables, attribute-level sub-variables, relation-level sub-variables, and relation-attribute-level sub-variables. The class-level sub-variables are used to extract individual instances and sets of instances belonging to a specified class from the context data of the current session in the application scenario and assign values. The attribute-level sub-variables are used to extract specific attribute values ​​corresponding to instances in the set of individual instances and assign values. The relation-level sub-variables are used to extract and assign values ​​to a set of associated objects that have a specific semantic relationship with the set of individual instances. The relation-attribute-level sub-variables are used to extract and assign values ​​to a set of associated objects in the set of individual instances that have the relationship and whose attribute has a specific attribute value.

[0027] Specifically, context-assigned variables include individual set variables and individual variables; wherein, the individual set variables are used to process batch data, which extracts a set of data that meets specific conditions from the context data of the current session and presents it in the form of a set or list, and is usually used in statistical, classification or batch analysis scenarios; the individual variables are used to process a single specific instance, which points to a specific object in the set, and is usually used to perform in-depth analysis or detailed display of a single complex object.

[0028] Table 1

[0029] Specifically, the syntax and definition of individual set variables in context assignment variables are shown in Table 1. Table 1 defines four levels of variable forms: First, class-level set variables, with the syntax ${individual set: class}, for example ${individual set: Thing\work order}, represent the set of all individual variables in the current session's context data that conform to the "work order" class structure, and implicitly include all attributes and relationships of that class; second, attribute-level set variables, with the syntax ${individual set: class.attribute}, for example ${individual set: Thing\work order.source}, specifically represent the "source" attribute in the "work order" class. The first set of variables is the set of objects at the relational object level. The third set is the set of objects at the relational object level, defined with the syntax ${individual set: class.relation}, for example, ${individual set: Things\work order.associated customer}. This represents the set of object variables pointed to by the "work order" class through the "associated customer" relationship. Finally, there is the set of objects at the relational object attribute level, defined with the syntax ${individual set: class.relation.attribute}, for example, ${individual set: Things\work order.associated customer.name}. This represents the set of "name" attribute variables of the object after the "work order" class finds the corresponding object through the "associated customer" relationship, demonstrating the system's ability to extract specific attribute data across entities.

[0030] Table 2

[0031] Specifically, the syntax and definition of individual variables in context assignment variables are shown in Table 2. Table 2 defines four levels of variable forms: First, single-class instance variables, with the syntax ${individual:class}, such as ${individual:Thing\work order}, refer to a specific work order instance in the context data of the current session, such as "work order 001", and serve as the basis for subsequent attribute references; second, single-attribute value variables, with the syntax ${individual:class.attribute}, such as ${individual:work order.source}, represent a specific attribute value of the specific work order instance; third, single-relationship variables... The first type is the object variable, defined by syntax ${individual: class.relationship}, for example ${individual: work order.associated customer}. It represents the specific customer object associated with the work order through the "associated customer" relationship. The second type is the single-relationship object attribute variable, defined by syntax ${individual: class.relationship.attribute}, for example ${individual: work order.associated customer.name} or ${individual: work order.associated customer.product}. It represents the attribute value such as "name" or "product" of the associated customer object of the work order (such as "Zhang San" or "mobile phone"), thus realizing precise referencing and assignment of cross-entity attributes of a single instance.

[0032] Specifically, the assignment process also involves an agent that analyzes the context of the current session and the reasoning results based on ontology, performs set operations in the maximum candidate space to obtain a specific subset of individuals. Finally, the variables in the prompt word template are filled only with data from this specific subset, completing the assignment of context-based variables.

[0033] In this embodiment, the semantic structure of the ontology data extraction variables supports multi-level structure definition, including: architecture layer sub-variables, data layer sub-variables, and relationship layer sub-variables; the architecture layer sub-variables are used to extract the ontology's classification system and concept definitions, the data layer sub-variables are used to extract the data list of a specific category under the ontology's classification system, and the relationship layer sub-variables are used to extract the relationship between the classification system obtained by the architecture layer sub-variables and the specific data obtained by the data layer sub-variables, thus obtaining a complete knowledge description.

[0034] Specifically, the architecture layer sub-variables include class set items and class name items, the data layer sub-variables include individual set items, and the relationship layer sub-variables include triples. The individual set item is used to extract the complete set of specific instance data under a given class. This is typically used to generate "whitelists," "standard lists," or "known entity libraries" for large models. The class set item is used to extract the ontology's taxonomy; it doesn't concern itself with specific instances (e.g., "Zhang San"), but only with the classification system itself (e.g., what subcategories are under "work order"). The class name item is used to extract the metadata of a single class definition. It focuses on the conceptual definition of the "class" itself, such as synonyms or aliases, rather than its instances or subclasses.

[0035] Table 3

[0036] Specifically, the syntax and definition of the individual set item are shown in Table 3, which details four variable extraction methods: First, extract all individual data of a specified class, with the syntax defined as $${individual set: class}, used to return all individual instances under the specified class in the ontology. These instances contain all attributes and relationships. For example, $${individual set: Thing\User} can extract all user instances. Second, extract only the specified attribute value of all individuals of a specified class, with the syntax defined as $${individual set: class.attribute}, used to return the single attribute value of all individuals under the specified class. For example, $${individual set: Thing\User.Name} is used to extract the names of all users. Third, extract the individual set of relation objects of the class, with the syntax defined as $${individual set: class.relation}, used to return the set of object variables pointed to by all individuals under the specified class through a specific relationship. Finally, extract the attribute of a specified relation object from all individual data of a specified class, with the syntax defined as $${individual set: class.relation.attribute}, realizing cross-entity information extraction. For example, $${individual set: Thing\work order.associated customer.name} represents extracting the set of attribute variables of customers associated with the work order class.

[0037] Table 4

[0038] Specifically, the syntax and definition of the class set item are shown in Table 4. Table 4 defines the variable form for extracting data from all subclasses (including subclasses of subclasses) of a specified class, with the syntax structure $${class set: class}. This variable can obtain the complete inheritance hierarchy of a class in the ontology, including entity classification, class hierarchy, and the attributes and relationships of concepts. For example, in the telecommunications domain ontology, using the variable ${class set: Thing\work order} can extract all related subclass sets, including "Thing\work order" itself, "Thing\work order\preprocessing", "Thing\work order\complaint", and "Thing\work order\extra-level complaint", thus providing a precise business classification scope background for the large model.

[0039] Table 5

[0040] Specifically, the syntax structure and definition of class names are shown in Table 5. Table 5 defines the syntax for four extraction dimensions, including extracting a specified class or individual, extracting the attribute values ​​of a specified class or individual, extracting objects connected by relationships, and further extracting the attribute values ​​of relational objects. The explanation column on the right side of the table further illustrates its application logic through an example of the "work order" ontology. For example, through the variable $${object: Thing\work order\escalation complaint.synonym}, the system can directly obtain the synonym "escalation complaint" defined in the ontology for this class. This demonstrates the use of ontology variables to achieve semantic and structural unity, and the use of ontology hierarchy and relationship networks (such as classes, attributes, and relationships) to enhance the accuracy and standardization of prompt word generation, thereby avoiding the limitations of traditional variables that require manual value definition.

[0041] Specifically, the triple includes a variable string in the prompt word template that starts with $$ and is identified as a "triple". It is used to extract the relationship between the classification system obtained by the architecture layer sub-variable and the specific data obtained by the data layer sub-variable in the domain ontology. For example, for $${triple: (Subject, property: Property, Value) pattern: the property of Subject is Value}, when the triple variable is assigned a value, the variable indicates that all instances of the extraction class "Product" and its subclasses are extracted from the domain ontology and natural language is generated according to the style of "the property of Subject is Value".

[0042] In this embodiment, the context assignment variable is instantiated and assigned a value based on the user request and context data. The process is as follows: Parse the context data in the user request, and identify and extract the attribute values ​​or relational objects in the context data; Based on the semantic structure defined by the context assignment variable, unstructured attribute values ​​or relational objects extracted from the context data are mapped to instances that conform to the semantic structure. The instance that conforms to the semantic structure is assigned to the context assignment variable, thus completing the instantiation assignment of the context assignment variable.

[0043] Specifically, after parsing the context data in the user request, the method further includes identifying entities in the context data based on entity feature definitions in the domain ontology; the entity feature definitions in the domain ontology include class names, class descriptions, class attributes, class relationships, and individual names, individual attributes, and individual relationships under each class. Specifically, the identification and extraction of attribute values ​​or relation objects in the context data also includes extraction according to the semantic structure of entity-attribute-attribute value and entity-relation object; Specifically, taking work order text as an example, the context data in a user request includes the input work order text, documents, etc. Semantic parsing is performed on this data, identifying a batch of work order texts uploaded by the user as instances of the "Thing\Work Order" class, thus transforming the raw data into structured instance data conforming to the ontology definition. Next, the system parses the semantic structure of predefined scene variables (i.e., context-assigned variables) in the prompt word template. This structure specifies the data navigation path, including class-level, attribute-level, relation-level, or cross-entity relation attribute-level paths, such as ${individual set: Thing\Work Order.Associated Customer.Name}. Finally, the system strictly follows the parsed semantic path, performing targeted retrieval in the mapped instance data or graph traversal through ontology relationships. It extracts the corresponding attribute values ​​or relation objects according to structures such as entity-attribute-attribute value and entity-relationship object, and assigns these extracted specific business data to the corresponding scene variables in the template in real time, thereby completing the instantiation and filling of variable placeholders in the prompt words.

[0044] In this embodiment, the ontology data extraction variable extracts background knowledge data from the domain ontology of the requested application scenario, and injects the background knowledge data into the background knowledge submodule of the prompt word template. The process is as follows: Parse the sub-variables of the architecture layer and extract the complete classification system, concept definitions and their hierarchical structure involved in the request application scenario from the domain ontology; Use data layer sub-variables to traverse specific instance data belonging to the above architecture layer sub-variables from the domain ontology; By utilizing the relationship layer sub-variables, the classification system obtained from the architecture layer sub-variables is extracted, and the specific data obtained from the data layer sub-variables is used to form complete background knowledge data; Background knowledge data is injected into the prompt word template in natural language form, and the ontology data extraction variables in the scene variables are assigned values.

[0045] Specifically, the concept definition includes concept attributes and relationships.

[0046] Specifically, the ontology variable system also includes an inheritance mechanism and a value constraint mechanism: the inheritance mechanism indicates that the variables of the subclass in the domain ontology automatically inherit the attribute variable structure and relation variable structure defined by the parent class, without having to redefine them for the subclass; the value constraint mechanism restricts the value type of the variable at instantiation to the data type defined by the corresponding attribute in the domain ontology.

[0047] Specifically, regarding the inheritance mechanism, if a parent class variable ${individual:Thing\work order.source} is defined, then for the subclass "complaint work order" (Thing\work order\complaint), the system automatically identifies and supports the variable path ${individual:Thing\work order\complaint.source} without manual intervention. This is in stark contrast to traditional variables, which typically lack contextual constraints, rely on naming conventions, and often require manual copying of the variable structure to different business objects.

[0048] Specifically, taking the analysis of work order content in the telecommunications field as an example, the structural definition of the ontology variable system and its instantiation relationship are shown in the following diagram. Figure 2 As shown, Figure 2 The leftmost "Work Order" node represents the parent class concept, from which three subclass nodes—"Preprocessing," "Ascending Complaint," and "Complaint"—are derived, reflecting the class inheritance hierarchy of the ontology. The diagram also defines the core semantic relationships between classes: the "Work Order" class and its subclasses point to the "User" class through the "Associated Customer" relationship, and to the "Product" class through the "Associated Product" relationship. This establishes the semantic path for cross-entity reference variables (such as ${individual set: Work Order.Associated Customer}). The center of the diagram displays a timestamp identifier (i.e....). Figure 2 The specific work order instance "202301031030055543" belongs to the "Extra-level Complaint" subclass. Based on the "Associated Customer" and "Associated Product" relationship structure defined in the ontology, it specifically points to the instance "Zhang San" of the "User" class and the instance "Mobile Phone" of the "Product" class. This vividly illustrates how the system instantiates the abstract variable path into specific business data (i.e., the customer associated with the work order is Zhang San, and the associated product is Mobile Phone) according to the ontology structure during the prompt word generation process.

[0049] Specifically, regarding the value constraint mechanism, the system uses standard data types such as xsd:string, xsd:integer, and xsd:date to constrain variables. When the system parses context data and attempts to assign values ​​to variables, it performs validation based on the ontology definition. For example, if the ontology defines the "work order quantity" attribute as an integer, then the variable cannot accept non-numeric text values. This differs from the traditional variable's "direct definition" and "lack of background constraints."

[0050] Example 3 This embodiment proposes a dynamic prompt word generation system based on domain ontology. In this embodiment, the system is used to implement a dynamic prompt word generation method based on domain ontology. The structural diagram is shown below. Figure 3 As shown, it includes: The scenario variable matching module is used to receive user requests, determine the requested application scenario based on the user requests, and match pre-set prompt word templates and scenario variables based on the requested application scenario; The scene variable semantic structure definition module is used to construct an ontology variable system based on the domain ontology structure of the current application scenario, and to define the semantic structure of scene variables based on the ontology variable system. The scenario variable assignment module is used to extract and interpret the context data of the current session in which the user request is located and the domain ontology of the request application scenario, and to assign values ​​to the scenario variables in real time based on the semantic structure of the defined scenario variables. The prompt word generation module is used to dynamically generate prompt words using the assigned scene variables.

[0051] Example 4 In this embodiment, a computer device 100 is proposed, which includes a memory 101, a processor 102, and a computer program stored in the memory 101 that can be executed by the processor. The processor 102 executes the computer program to implement a method for dynamically generating prompt words based on domain ontology. A schematic diagram of the device structure is shown below. Figure 4 As shown.

[0052] In this embodiment, a computer storage medium is also proposed, on which a computer program is stored. The computer program includes program instructions, which, when executed by a computer, cause the computer to execute the aforementioned method for dynamically generating prompts based on domain ontology.

[0053] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the implementation of the present invention. Those skilled in the art can make other variations or modifications based on the above description. It is neither necessary nor possible to exhaustively describe all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the claims of the present invention.

Claims

1. A method for dynamically generating prompt words based on domain ontology, characterized in that, Includes the following steps: Receive user requests, determine the requested application scenario based on the user requests, and match pre-set prompt word templates and scenario variables based on the requested application scenario; Based on the domain ontology structure of the current application scenario, an ontology variable system is constructed, and the semantic structure of scenario variables is defined based on the ontology variable system. The context data of the current session in which the user request is located and the domain ontology of the application scenario of the request are extracted and interpreted, and the scenario variables are assigned values ​​in real time based on the semantic structure of the defined scenario variables. The prompt words are dynamically generated using the assigned scene variables.

2. The method for dynamically generating prompt words based on domain ontology according to claim 1, characterized in that, The prompt word template includes a role definition submodule, a task instruction submodule, a background knowledge submodule, and an output requirement submodule; The role definition submodule sets the identity of the large model in the current session; the task instruction submodule describes the specific requirements of the business; the background knowledge submodule provides background information in the professional field; and the output requirement submodule defines the output format requirements of the data generated to complete the instruction requirements.

3. The method for dynamically generating prompt words based on domain ontology according to claim 1, characterized in that, The ontology variable system includes context-assigned variables and ontology data extraction variables. The context-assigned variables and ontology data extraction variables are used together as scenario variables in the prompt word template corresponding to a certain request application scenario, and are inserted into the prompt word template as placeholders. During the prompt word generation process, the scenario variables are dynamically assigned values.

4. The method for dynamically generating prompt words based on domain ontology according to claim 3, characterized in that, The semantic structure of the context-assigned variables supports multi-level structure definition. Context-assigned variables include: class-level sub-variables, attribute-level sub-variables, relation-level sub-variables, and relation-attribute-level sub-variables. The class-level sub-variables are used to extract individual instances and sets of instances belonging to a specified class from the context data of the current session in the application scenario and assign values. The attribute-level sub-variables are used to extract specific attribute values ​​corresponding to instances in the set of individual instances and assign values. The relation-level sub-variables are used to extract and assign values ​​to a set of associated objects that have a specific semantic relationship with the set of individual instances. The relation-attribute-level sub-variables are used to extract and assign values ​​to a set of associated objects in the set of individual instances whose attributes have specific attribute values ​​in the relation.

5. The method for dynamically generating prompt words based on domain ontology according to claim 3, characterized in that, The semantic structure of the ontology data extraction variables supports multi-level structure definition, including: architecture layer sub-variables, data layer sub-variables, and relationship layer sub-variables. The architecture layer sub-variables are used to extract the ontology's classification system and concept definitions. The data layer sub-variables are used to extract the data list of a specific category under the ontology's classification system. The relationship layer sub-variables are used to extract the relationship between the classification system obtained by the architecture layer sub-variables and the specific data obtained by the data layer sub-variables, thus obtaining a complete knowledge description.

6. The method for dynamically generating prompt words based on domain ontology according to claim 4, characterized in that, The context-assigned variables are instantiated and assigned values ​​based on user requests and context data, as follows: Parse the context data in the user request, and identify and extract the attribute values ​​or relational objects in the context data; Based on the semantic structure defined by the context assignment variable, unstructured attribute values ​​or relational objects extracted from the context data are mapped to instances that conform to the semantic structure. The instance that conforms to the semantic structure is assigned to the context assignment variable, thus completing the instantiation assignment of the context assignment variable.

7. The method for dynamically generating prompt words based on domain ontology according to claim 5, characterized in that, The ontology data extraction type variable extracts background knowledge data from the domain ontology of the requested application scenario, and injects the background knowledge data into the background knowledge submodule of the prompt word template. The process is as follows: Parse the sub-variables of the architecture layer and extract the complete classification system, concept definitions and their hierarchical structure involved in the request application scenario from the domain ontology; Use data layer sub-variables to traverse specific instance data belonging to the above architecture layer sub-variables from the domain ontology; By utilizing the relationship layer sub-variables, the classification system obtained from the architecture layer sub-variables is extracted, and the specific data obtained from the data layer sub-variables is used to form complete background knowledge data; Background knowledge data is injected into the prompt word template in natural language form, and the ontology data extraction variables in the scene variables are assigned values.

8. A system for dynamically generating prompt words based on domain ontology, characterized in that, include: The scenario variable matching module is used to receive user requests, determine the application scenario of the user request based on the user request, and match pre-set prompt word templates and scenario variables based on the application scenario; The scene variable semantic structure definition module is used to construct an ontology variable system based on the domain ontology structure, and to define the semantic structure of scene variables based on the ontology variable system. The scenario variable assignment module is used to assign values ​​to the scenario variables based on the semantic structure of the defined scenario variables, the context data and interpretation of the current session in which the user request is located, and the scenario variables. The prompt word generation module is used to dynamically generate prompt words using the assigned scene variable values.

9. A computer device, characterized in that, The computer device includes a memory, a processor, and a computer program stored in the memory that can be run on the processor. The processor executes the computer program to implement the method for dynamically generating prompt words based on a domain ontology as described in any one of claims 1 to 7.

10. A computer storage medium, characterized in that, It stores a computer program, which includes program instructions. When the program instructions are executed by the computer, the computer performs the prompt word dynamic generation method based on any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data generation method and device, equipment, storage medium and product

    CN119337918A

  • Methods and systems for ontology construction with ai-mediated crowdsourcing and concept mining for high-level activity understanding

    US20240112044A1

Cited By

  • Large model cue word construction method and device, equipment, medium and program product

    CN121809442A