Scene corpus-based query method and device, equipment and storage medium
By constructing a knowledge base for network resource data and generating a high-quality corpus, the problem of inaccurate user input was solved, the accuracy of responses from large language models was improved, and network resource data analysis across all scenarios was realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-28
- Publication Date
- 2026-03-24
AI Technical Summary
Users' lack of understanding of online resource data leads to inaccurate information in the large language model queries they input, affecting the accuracy of the answers.
A query method based on scenario-based corpus is constructed. By analyzing network resource data, a knowledge base containing entities, attributes, and relationships is generated. Attribute types are classified and prompt word templates are set. A comprehensive and high-quality corpus is automatically instantiated. The corpus results that accurately match user intent are then integrated into the input of a large language model.
It improves the accuracy of responses from large language models, ensures accurate input information, and covers full-scenario analysis of network resource data.
Smart Images

Figure CN121722962A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and in particular to a query method and device based on scenario corpus, equipment and storage medium. BACKGROUND
[0002] For network resource data analysis tasks based on large language models, high-quality input is the core foundation to ensure the analysis accuracy and generalization ability of large models.
[0003] If the user's query information about network resource data is directly input into the large language model for querying, the user's query information will be inaccurate due to the user's lack of understanding of network resource data, thereby resulting in low accuracy of the final answer generated by the large language model.
[0004] How to adjust user input to improve the accuracy of the large language model answer is an important issue that needs to be solved in the industry at present. SUMMARY
[0005] The present application provides a query method and device based on scenario corpus, equipment and storage medium to adjust user input and improve the accuracy of the large language model answer.
[0006] The present application provides a query method based on scenario corpus, comprising the following steps: Based on the user input query information, determine the corpus result matched with the query information from the multiple scenario corpora in the corpus library; Based on the query information and the corpus result, construct a text input for large language model query; Wherein, the construction process of the corpus library comprises: Based on the network resource entities, entity parameters, entity attributes and entity relationships extracted from the network resource data, construct a knowledge base of the network resource data; Classify the entity attributes in the knowledge base, determine multiple attribute types, and generate a prompt word template for each attribute type to obtain multiple prompt word templates; Based on the data in the knowledge base, instantiate the prompt word template of each attribute type to obtain multiple scenario corpora of the network resource data, and construct the corpus library based on the multiple scenario corpora.
[0007] According to the query method based on scenario corpus provided by the present application, the attribute types include description type, relationship type and enumeration type; Wherein, the description type is used to represent that the network resource entity contains parameter information; the relationship type is used to represent that different network resource entities contain association relationships; and the enumeration type is used to represent that the entity attribute of the network resource entity is an enumeration value.
[0008] A query method based on a scene corpus is provided according to the present application, wherein network resource entities, entity parameters, entity attributes and entity relationships extracted from network resource data are used to construct a knowledge base of the network resource data, including: network resource entities, entity parameters, entity attributes and entity relationships extracted from the network resource data; determining a first entity with a description type attribute from the extracted network resource entities, and constructing a description corresponding table based on the first entity and entity parameters of the first entity; determining a second entity with a relationship type attribute from the extracted network resource entities, and constructing an entity relationship corresponding table based on the second entity and entity relationships of the second entity; determining a third entity with an enumeration type attribute from the extracted network resource entities, and constructing structured enumeration information of the third entity based on the third entity and enumeration values in the entity parameters of the third entity; constructing the knowledge base based on the description corresponding table, the entity relationship corresponding table and the structured enumeration information.
[0009] A query method based on a scene corpus is provided according to the present application, wherein data in the knowledge base is used to instantiate a prompt word template for each attribute type to obtain multiple scene corpora of the network resource data, including: calling the description corresponding table, the entity relationship corresponding table and the structured enumeration information to fill in the prompt word template for each attribute type to obtain multiple scene corpora of the network resource data.
[0010] A query method based on a scene corpus is provided according to the present application, wherein data in the knowledge base is used to instantiate a prompt word template for each attribute type to obtain multiple scene corpora of the network resource data, including: calling a large language model to fill in the prompt word template for each attribute type according to the format of the prompt word template, and obtaining data from the knowledge base to obtain multiple scene corpora of the network resource data.
[0011] A query method based on a scene corpus is provided according to the present application, wherein based on user input query information, a corpus result matching the query information is determined from multiple scene corpora in a corpus library, including: extracting keywords from the user input query information to determine the keywords input by the user; performing keyword matching based on the keywords and multiple corpora in the corpus library to determine a corpus result matching the query information.
[0012] According to the query method based on the scene corpus provided by the application, after the corpus is constructed, the method further comprises: verifying each scene corpus in the corpus to determine repeated corpora in the corpus; deleting the repeated corpora in the corpus.
[0013] The application further provides a query device based on a scene corpus, comprising the following modules: A matching module is configured to determine a corpus result matched with the query information from a plurality of scene corpora in the corpus based on the query information input by a user. An input construction module is configured to construct a text input for a large language model query based on the query information and the corpus result. The construction process of the corpus comprises: constructing a knowledge base of network resource data based on network resource entities, entity parameters, entity attributes and entity relationships extracted from the network resource data; classifying entity attributes in the knowledge base to determine a plurality of attribute types, and generating a prompt word template for each attribute type to obtain a plurality of prompt word templates; instantiating the prompt word template of each attribute type based on the data in the knowledge base to obtain a plurality of scene corpora of the network resource data, and constructing the corpus based on the plurality of scene corpora.
[0014] The application further provides an electronic device comprising a memory, a processor and a computer program stored in the memory and running on the processor, wherein the processor implements the query method based on a scene corpus as described above when executing the program.
[0015] The application further provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the query method based on a scene corpus as described above.
[0016] The query method based on a scene corpus, the device, the equipment and the storage medium provided by the application can automatically and batch generate a corpus with wide coverage and high quality by analyzing massive network resource data, constructing a knowledge base containing entities, attributes and relationships, classifying attributes and setting prompt word templates, and automatically instantiating real data in the knowledge base. When responding to a user query, the corpus result related to the user's intention can be accurately matched from the constructed high-quality corpus, and the corpus result can be combined with the original query information of the user to provide an accurate input for a large language model, thereby improving the accuracy of the large language model in answering content. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0018] Figure 1 This is a flowchart illustrating the query method based on scene corpus provided by the present invention.
[0019] Figure 2 This is a schematic diagram of the verification process of the corpus provided by the present invention.
[0020] Figure 3 This is a schematic diagram of the structure of the query device based on scene corpus provided by the present invention.
[0021] Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0023] If users directly input their queries about online resource data into the large language model, the users' lack of understanding of online resource data will lead to inaccurate query information, resulting in a lower accuracy of the final answer generated by the large language model.
[0024] One approach to improve the accuracy of large language model responses is to use manually created corpora as a reference for user queries. However, the process of manually creating corpora is inefficient and has limited coverage. It requires staff to be familiar with the business logic of network resources and the corpus requirements of large models. This is not only time-consuming and labor-intensive, but also difficult to cover all professional network resource scenarios (such as data center equipment, residential areas, outdoor sites, etc.), resulting in insufficient corpus coverage and an inability to support full-scenario analysis by large models.
[0025] In addition, the artificially created corpus does not match the attribute type, and the quality is uneven. The model attribute types of network resource data are various (characters, numbers, enumerations, associations, etc.), and the attribute type characteristics are easily ignored during the artificial creation of the corpus, for example, the number type attribute corpus does not contain a specific numerical range, and the association type attribute corpus does not reflect the relationship between entities, so that the corpus does not match the attribute type, and the large language model is easy to have logical deviation when analyzing the network resource data using such corpus, thereby affecting the accuracy of the analysis result.
[0026] In view of the defects in the related method, the present application provides a query method based on scenario corpus, Figure 1 is a flowchart of the query method based on scenario corpus provided by the present application, as Figure 1 shown, the method comprises the following steps: Step 110, based on the query information input by the user, determining the corpus result matched with the query information from the multiple scenario corpora in the corpus library; Step 120, based on the query information and the corpus result, constructing a text input for the query of the large language model; Wherein, the construction process of the corpus library comprises: Based on the network resource entities, entity parameters, entity attributes and entity relationships extracted from the network resource data, constructing a knowledge base of the network resource data; Classifying the entity attributes in the knowledge base, determining multiple attribute types, and generating a prompt word template for each attribute type to obtain multiple prompt word templates; Based on the data in the knowledge base, instantiating the prompt word template of each attribute type to obtain multiple scenario corpora of the network resource data, and constructing the corpus library based on the multiple scenario corpora.
[0027] The execution subject of the query method based on scenario corpus provided by the present application can be an electronic device, a component in the electronic device, an integrated circuit, or a chip. The electronic device can be a mobile electronic device or a non-mobile electronic device. Illustratively, the mobile electronic device can be a mobile phone, a tablet computer, a notebook computer, a palm computer, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc., and the non-mobile electronic device can be a server, a network attached storage (NAS), or a personal computer (PC), etc., and the present application is not limited specifically.
[0028] The technical solutions of the present application will be described in detail below with the computer executing the scene corpus-based query method provided by the present application as an example.
[0029] In step 110, before constructing the text input for the large language model query, a corpus needs to be constructed first. The constructed corpus is the basis for subsequent query and analysis.
[0030] For the construction process of the corpus, first, a knowledge base of network resource data is constructed based on network resource data. The network resource data can be all data information about the network infrastructure owned by the operator or network service provider, such as attribute data about various resources including devices, machine rooms, cells, ports, etc. From these raw data, network resource entities, entity parameters, entity attributes, and entity relationships can be extracted.
[0031] Specifically, a network resource entity refers to a specific object in the network, such as a device named Core Router M, or a machine room located in Area A. An entity parameter is a specific numerical value or descriptive information of the entity, such as device power, machine room area, etc. An entity attribute is the category of the parameter, such as device name, device model. Entity relationships describe the relationship between entities, such as the ownership relationship between a device and a machine room, or the binding relationship between a port and a board.
[0032] The extracted information is structured and organized to construct a knowledge base of network resource data. The constructed knowledge base can be regarded as a structured and associated digital twin of the entire network resource. Optionally, the constructed knowledge base can be stored and managed using a database such as Elasticsearch (ES) to facilitate subsequent efficient retrieval processes.
[0033] Classify the entity attributes in the knowledge base to determine multiple attribute types of the network resource data. Attribute classification is used to implement the fine-grained corpus generation process. For example, attributes can be classified into different types according to their properties. For each determined attribute type, at least one prompt word template is generated. A prompt word template is a pre-defined text structure containing placeholders, which defines the sentence pattern and core logic for generating corpus of a specific type. For example, a prompt word template for describing numerical attributes can be Query the individual with [attribute field] greater than [numerical value] in [resource entity].
[0034] Based on specific data in the knowledge base, the prompt word templates of each attribute type are instantiated. The instantiation process is to fill the placeholders in the prompt word templates with real data in the knowledge base. For example, using real data such as Optical Line Terminal (OLT) port, rate, 200Mbps, etc. to fill the prompt word templates, a specific scenario corpus can be generated: query the individuals with a rate greater than 200Mbps in the OLT port.
[0035] By traversing and instantiating the massive data in the knowledge base and all prompt word templates, multiple scenario corpora covering network resource data can be obtained. The generated scenario corpus set constitutes the corpus.
[0036] After constructing the corpus, the user input query information is received. For example, the user asks in natural language: What are the core machine rooms in area A? The matching corpus result can be determined from the multiple scenario corpora in the corpus.
[0037] In step 120, based on the user's query information and the matched corpus result, a text input for large language model query is constructed.
[0038] The text input usually combines the user's original question with relevant background information, data, scenario description, etc. found from the corpus, forming an input content with more information. In this way, the large language model can give a more accurate and professional answer in the context of fully understanding the user's intention and relevant field knowledge.
[0039] It should be noted that in the process of querying network resource data by the user, the user's query statement can be input into the large language model based on the large language model, and the large language model can realize the query process of the network resource data. However, in many cases, the user does not understand the network resource entities contained in the network resource data. When it is necessary to query, it is not possible to organize a query statement that can be understood by the large language model, or the organized query statement is not accurate. In this case, the answer obtained by the large language model may deviate greatly from the answer the user wants, resulting in low query accuracy.
[0040] In the present application, based on automatically generating a corpus with wide coverage and high quality, the corpus is used for reference of query information, according to the query information, the scenario sentence in the corpus is matched, and the text input for large language model query is obtained. The constructed text input conforms to the expression habit of network resource data and is accurate, and the large language model can accurately determine the query result the user wants based on the text input, greatly improving the accuracy of the large language model answer content.
[0041] This invention provides a scenario-based corpus-based query method that analyzes massive amounts of online resource data to construct a knowledge base containing entities, attributes, and relationships. By classifying attributes and setting prompt word templates, and then automatically instantiating the data using real data from the knowledge base, a comprehensive and high-quality corpus can be automatically generated in batches. When responding to user queries, the method can accurately match relevant results from the constructed high-quality corpus and integrate them with the user's original query information, providing accurate input for a large language model and thus improving the accuracy of the model's responses.
[0042] In one embodiment, the attribute type includes descriptive, relational, and enumeration types; The descriptive type is used to characterize that the network resource entity contains parameter information; the relational type is used to characterize that there is an association relationship between different network resource entities; and the enumeration type is used to characterize that the entity attributes of the network resource entity are enumeration values.
[0043] Specifically, descriptive attributes are used to characterize the parameter information contained within a network resource entity itself. These attributes are inherent to the entity. For example, the device name, network access time, and device power of a device entity are all descriptive attributes. Based on the characteristics of their values, descriptive attributes can be further subdivided into character-based attributes (such as device name), numeric attributes (such as antenna height and speed), and time-based attributes (such as device network access time), etc.
[0044] Relational types are used to represent the relationships between network resource entities. Relational types reflect complex inter-entity connections such as network topology, ownership, and service delivery. For example, the ownership relationship between a device entity and a data center entity, the binding relationship between a port entity and a board entity, and the access relationship between a community entity and an OLT device all belong to relational types.
[0045] Enumerated types are used to represent network resource entities whose entity attributes are enumerated values. An enumerated value refers to an attribute whose range of values is a predefined, finite set. For example, the device type could be router, switch, server, etc.; the manufacturer could be manufacturer A, manufacturer B, manufacturer C, etc.; and the data center level could be access data center, core data center, etc.
[0046] By categorizing attributes in this way, more suitable prompt templates can be designed for different types of data. For example, for descriptive numeric attributes, templates can be designed for scenarios such as comparing numerical values, summing, and averaging; for relational attributes, templates can be designed for scenarios such as querying the number of associated entities and querying missing relationships; and for enumerated attributes, templates can be designed for scenarios such as classifying and statistically analyzing enumerated values.
[0047] In one embodiment, constructing a knowledge base for the network resource data based on network resource entities, entity parameters, entity attributes, and entity relationships extracted from the network resource data includes: Network resource entities, entity parameters, entity attributes, and entity relationships extracted from the network resource data; From the extracted network resource entities, identify the first entity with the attribute type of description, and construct a description mapping table based on the first entity and the entity parameters of the first entity; From the extracted network resource entities, identify the second entity with the attribute type of relation, and construct an entity relation mapping table based on the second entity and the entity relations of the second entity; From the extracted network resource entities, identify the third entity with the attribute type of enumeration, and construct the structured enumeration information of the third entity based on the third entity and the enumeration values in the entity parameters of the third entity. The knowledge base is constructed based on the description correspondence table, the entity relationship correspondence table, and the structured enumeration information.
[0048] First, structured information is extracted from massive, heterogeneous network resource data, including network resource entities, entity parameters, entity attributes, and entity relationships.
[0049] The extracted entities are categorized: from the extracted network resource entities, those with descriptive attribute types are identified as first entities. Based on these first entities and their corresponding entity parameters, a description mapping table is constructed. This table is essentially a collection of entity-attribute-value pairs, for example, (Device A, Power, 50W), (Device B, Name, Core Switch 01).
[0050] Simultaneously, from the extracted network resource entities, those second entities with relational attribute types are identified. Based on these second entities and their corresponding entity relationships, an entity relationship mapping table is constructed. This table records the topological relationships between entities, for example, (Device A, belongs to, Data Center X), (Port P, bound to, Board C).
[0051] From the extracted network resource entities, identify those third entities whose attribute type is enumeration. Based on these third entities and the enumeration values in their entity parameters, construct structured enumeration information. This information clarifies the complete value range of each enumeration attribute, for example, (data center level: core data center, access data center, aggregation data center) and (equipment ownership: self-built, leased).
[0052] Based on the constructed description mapping table, entity relationship mapping table, and structured enumeration information, a complete knowledge base is built. This knowledge base integrates the originally scattered data into an interconnected knowledge network, providing an accurate and comprehensive data source for subsequent corpus generation.
[0053] In the actual implementation, these tables and information can be stored in an Elasticsearch database, and multi-dimensional data association indexes can be established to support subsequent fast invocation and dynamic instantiation.
[0054] In one embodiment, based on the data in the knowledge base, prompt word templates for each attribute type are instantiated to obtain multiple scene corpora of the network resource data, including: The description correspondence table, the entity relationship correspondence table, and the structured enumeration information are called to populate the prompt word template for each attribute type, thereby obtaining multiple scene corpora of the network resource data.
[0055] Based on the description mapping table, entity relationship mapping table, and structured enumeration information constructed by the call, each prompt word template is traversed, and data is retrieved from the corresponding table or information to populate it according to the placeholder type defined in the template.
[0056] For example, for a descriptive prompt template: to count the number of individuals in [resource entity] whose [attribute field] is less than [numerical value], the resource entity base station can be found in the description correspondence table, its attribute field antenna height can be set to a value of 50 meters, and then the scene corpus can be instantiated to generate: count the number of individuals in the base station whose antenna height is less than 50 meters.
[0057] For example, for a relational prompt template: to query the number of [resource entity 2] associated with [resource entity 1], we can find resource entity 1 base station and resource entity 2 cell from the entity relationship correspondence table, and instantiate to generate scenario corpus: to query the number of cells associated with the base station.
[0058] For enumeration types, a template could be: classify and statistically analyze [resource entities] according to [enumeration information]. You can find the enumeration information data center ownership from the structured enumeration information and combine it with the resource entity data center to instantiate the scenario corpus: classify and statistically analyze data centers according to data center ownership.
[0059] Instantiation is accomplished through direct data querying and filling, ensuring that the generated corpus is strictly consistent with the data in the knowledge base, thus guaranteeing the accuracy of the corpus.
[0060] In one embodiment, the instantiation of prompt word templates for each attribute type based on data in the knowledge base to obtain multiple scene corpora of the network resource data includes: The large language model is invoked, and data is retrieved from the knowledge base according to the format of the prompt word template for each attribute type. The prompt word template for each attribute type is then populated to obtain multiple scene corpora of the network resource data.
[0061] Invoke a pre-trained large language model. Provide the large language model with the format of the prompt word templates for each attribute type. Then, instruct the large language model to actively retrieve the required data from the built knowledge base according to the format of these templates.
[0062] For example, show the large language model the deployment location of the template description [resource entity] within [related entity] and instruct it to find suitable entities and relationships from the knowledge base to populate it.
[0063] The large language model can identify devices and data centers as appropriate entities from the knowledge base and establish a deployment relationship. Then, it extracts specific device names and data center names from the knowledge base and finally fills in and generates scenario corpus, such as describing the deployment location of device U in the core data center H.
[0064] In one embodiment, based on user-input query information, determining corpus results matching the query information from multiple scene corpora in a corpus includes: Extract keywords from the query information input by the user to determine the keywords input by the user; Based on the keywords, keyword matching is performed with multiple corpora in the corpus to determine the corpus results that match the query information.
[0065] Keyword extraction is performed on the user-input query information. It should be noted that the user-input query information is generally a piece of natural language text. Keyword extraction is the core method for identifying the user's query intent.
[0066] Based on the extracted keywords, keyword matching is performed on multiple corpora in the corpus. The matching process can be exact matching, fuzzy matching, or semantic similarity matching based on word vectors. All corpora containing one or more keywords, or those highly semantically related to the keywords, will be identified as corpora matching the user's query information.
[0067] In one embodiment, after constructing the corpus, the method further includes: Each scene corpus in the corpus is validated to identify duplicate corpora in the corpus; Duplicate data in the corpus are deleted.
[0068] Each scene corpus in the corpus is validated. One purpose of validation is to determine whether duplicate corpora exist in the corpus. For example, different instantiation paths may generate completely identical corpora, such as a rented data center in region A and a rented data center in Hangzhou.
[0069] Once duplicate data is identified, it will be deleted or merged, leaving only one version.
[0070] In addition, the verification process can also include logical correctness checks. For example, checking for logical contradictions in the corpus, such as illogical data containing a count of -5 devices. Corpus data containing logical errors should also be identified and removed during the verification process.
[0071] By adding steps to verify and deduplicate the scene data in the corpus, we can ensure that the final generated corpus is accurate and free of redundancy, thus guaranteeing that the data input to the model is of high quality.
[0072] Optionally, the validation process can be performed based on the constructed corpus, such as... Figure 2 The verification process of the corpus provided by this invention is illustrated in the diagram.
[0073] First, a corpus containing multiple scenario corpora of network resource data is constructed. Entity attributes in the knowledge base are then classified, with attribute types including descriptive, relational, and enumerable.
[0074] Based on attribute type, construct a description mapping table, a relationship mapping table, and structured enumeration information.
[0075] Generate prompt word templates for each of the attribute types.
[0076] By calling the description mapping table, entity relationship mapping table, and structured enumeration information, the prompt word templates for each attribute type are populated to obtain multiple scenario corpora of network resource data.
[0077] A corpus is built based on multiple scenario corpora produced, and the scenario corpora in the corpus are verified to remove duplicate or logically contradictory corpora.
[0078] The following describes the query device based on scene corpus provided by the present invention. The query device based on scene corpus described below and the query method based on scene corpus described above can be referred to in correspondence.
[0079] like Figure 3 As shown, the device includes: The matching module 310 is used to determine the corpus results that match the query information from multiple scene corpora in the corpus based on the query information input by the user. The input construction module 320 is used to construct text input for large language model queries based on the query information and the corpus results; The corpus construction process includes: A knowledge base for the network resource data is constructed based on the network resource entities, entity parameters, entity attributes, and entity relationships extracted from the network resource data. The entity attributes in the knowledge base are classified to determine multiple attribute types, and prompt word templates are generated for each attribute type to obtain multiple prompt word templates. Based on the data in the knowledge base, prompt word templates for each attribute type are instantiated to obtain multiple scenario corpora of the network resource data, and the corpus is constructed based on the multiple scenario corpora.
[0080] The scenario-based corpus-based query device provided by this invention analyzes massive amounts of online resource data to construct a knowledge base containing entities, attributes, and relationships. By classifying attributes and setting prompt word templates, and then automatically instantiating the data in the knowledge base, a comprehensive and high-quality corpus can be automatically generated in batches. When responding to user queries, the device can accurately match corpus results related to the user's intent from the constructed high-quality corpus and integrate them with the user's original query information, providing accurate input for a large language model and thus improving the accuracy of the large language model's responses.
[0081] In one embodiment, the matching module 310 is specifically used for: The attribute types are defined as descriptive, relational, and enumeration. The descriptive type is used to characterize that the network resource entity contains parameter information; the relational type is used to characterize that there is an association relationship between different network resource entities; and the enumeration type is used to characterize that the entity attributes of the network resource entity are enumeration values.
[0082] In one embodiment, the matching module 310 is further configured to: The knowledge base for the network resource data is constructed based on the network resource entities, entity parameters, entity attributes, and entity relationships extracted from the network resource data, including: Network resource entities, entity parameters, entity attributes, and entity relationships extracted from the network resource data; From the extracted network resource entities, identify the first entity with the attribute type of description, and construct a description mapping table based on the first entity and the entity parameters of the first entity; From the extracted network resource entities, identify the second entity with the attribute type of relation, and construct an entity relation mapping table based on the second entity and the entity relations of the second entity; From the extracted network resource entities, identify the third entity with the attribute type of enumeration, and construct the structured enumeration information of the third entity based on the third entity and the enumeration values in the entity parameters of the third entity. The knowledge base is constructed based on the description correspondence table, the entity relationship correspondence table, and the structured enumeration information.
[0083] In one embodiment, the matching module 310 is further configured to: Based on the data in the knowledge base, prompt word templates for each attribute type are instantiated to obtain multiple scene corpora of the network resource data, including: The description correspondence table, the entity relationship correspondence table, and the structured enumeration information are called to populate the prompt word template for each attribute type, thereby obtaining multiple scene corpora of the network resource data.
[0084] In one embodiment, the matching module 310 is further configured to: Based on the data in the knowledge base, prompt word templates for each attribute type are instantiated to obtain multiple scene corpora of the network resource data, including: The large language model is invoked, and data is retrieved from the knowledge base according to the format of the prompt word template for each attribute type. The prompt word template for each attribute type is then populated to obtain multiple scene corpora of the network resource data.
[0085] In one embodiment, the matching module 310 is further configured to: The process of determining the corpus results matching the query information from multiple scene corpora in the corpus based on user-input query information includes: Extract keywords from the query information input by the user to determine the keywords input by the user; Based on the keywords, keyword matching is performed with multiple corpora in the corpus to determine the corpus results that match the query information.
[0086] In one embodiment, the matching module 310 is further configured to: After constructing the corpus, the following is also included: Each scene corpus in the corpus is validated to identify duplicate corpora in the corpus; Duplicate data in the corpus are deleted.
[0087] Figure 4 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 4As shown, the electronic device may include a processor 410, a communication interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other via the communication bus 440. The processor 410 may call logical instructions in the memory 430 to execute a scenario-based query method, which includes: determining corpus results matching the query information from multiple scenario corpora in a corpus based on user-input query information; Based on the query information and the corpus results, construct the text input for querying the large language model; The corpus construction process includes: A knowledge base for the network resource data is constructed based on the network resource entities, entity parameters, entity attributes, and entity relationships extracted from the network resource data. The entity attributes in the knowledge base are classified to determine multiple attribute types, and prompt word templates are generated for each attribute type to obtain multiple prompt word templates. Based on the data in the knowledge base, prompt word templates for each attribute type are instantiated to obtain multiple scenario corpora of the network resource data, and the corpus is constructed based on the multiple scenario corpora.
[0088] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory, random access memory, magnetic disks, or optical disks.
[0089] On the other hand, the present invention also provides a computer program product, the computer program product including a computer program, the computer program being able to be stored on a non-transitory computer-readable storage medium, the computer program being executed by a processor, the computer being able to execute the query method based on the scene corpus provided by the above methods, the method including: determining the corpus result matching the query information from multiple scene corpora in the corpus based on the query information input by the user; Based on the query information and the corpus results, construct the text input for querying the large language model; The corpus construction process includes: A knowledge base for the network resource data is constructed based on the network resource entities, entity parameters, entity attributes, and entity relationships extracted from the network resource data. The entity attributes in the knowledge base are classified to determine multiple attribute types, and prompt word templates are generated for each attribute type to obtain multiple prompt word templates. Based on the data in the knowledge base, prompt word templates for each attribute type are instantiated to obtain multiple scenario corpora of the network resource data, and the corpus is constructed based on the multiple scenario corpora.
[0090] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the query method based on scene corpus provided by the above methods, the method comprising: determining, based on query information input by a user, a corpus result matching the query information from multiple scene corpora in a corpus; Based on the query information and the corpus results, construct the text input for querying the large language model; The corpus construction process includes: A knowledge base for the network resource data is constructed based on the network resource entities, entity parameters, entity attributes, and entity relationships extracted from the network resource data. The entity attributes in the knowledge base are classified to determine multiple attribute types, and prompt word templates are generated for each attribute type to obtain multiple prompt word templates. Based on the data in the knowledge base, prompt word templates for each attribute type are instantiated to obtain multiple scenario corpora of the network resource data, and the corpus is constructed based on the multiple scenario corpora.
[0091] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0092] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0093] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A query method based on scene corpus, characterized in that, include: Based on the query information input by the user, determine the corpus results that match the query information from multiple scene corpora in the corpus; Based on the query information and the corpus results, construct the text input for querying the large language model; The corpus construction process includes: A knowledge base for the network resource data is constructed based on the network resource entities, entity parameters, entity attributes, and entity relationships extracted from the network resource data. The entity attributes in the knowledge base are classified to determine multiple attribute types, and prompt word templates are generated for each attribute type to obtain multiple prompt word templates. Based on the data in the knowledge base, prompt word templates for each attribute type are instantiated to obtain multiple scenario corpora of the network resource data, and the corpus is constructed based on the multiple scenario corpora.
2. The query method based on scene corpus according to claim 1, characterized in that, The attribute types include descriptive, relational, and enumeration types; The descriptive type is used to characterize that the network resource entity contains parameter information; the relational type is used to characterize that there is an association relationship between different network resource entities; and the enumeration type is used to characterize that the entity attributes of the network resource entity are enumeration values.
3. The query method based on scene corpus according to claim 2, characterized in that, The knowledge base for the network resource data is constructed based on the network resource entities, entity parameters, entity attributes, and entity relationships extracted from the network resource data, including: Network resource entities, entity parameters, entity attributes, and entity relationships extracted from the network resource data; From the extracted network resource entities, identify the first entity with the attribute type of description, and construct a description mapping table based on the first entity and the entity parameters of the first entity; From the extracted network resource entities, identify the second entity with the attribute type of relation, and construct an entity relation mapping table based on the second entity and the entity relations of the second entity; From the extracted network resource entities, identify the third entity with the attribute type of enumeration, and construct the structured enumeration information of the third entity based on the third entity and the enumeration values in the entity parameters of the third entity. The knowledge base is constructed based on the description correspondence table, the entity relationship correspondence table, and the structured enumeration information.
4. The query method based on scene corpus according to claim 3, characterized in that, Based on the data in the knowledge base, prompt word templates for each attribute type are instantiated to obtain multiple scene corpora of the network resource data, including: The description correspondence table, the entity relationship correspondence table, and the structured enumeration information are called to populate the prompt word template for each attribute type, thereby obtaining multiple scene corpora of the network resource data.
5. The query method based on scene corpus according to claim 1, characterized in that, Based on the data in the knowledge base, prompt word templates for each attribute type are instantiated to obtain multiple scene corpora of the network resource data, including: The large language model is invoked, and data is retrieved from the knowledge base according to the format of the prompt word template for each attribute type. The prompt word template for each attribute type is then populated to obtain multiple scene corpora of the network resource data.
6. The query method based on scene corpus according to claim 1, characterized in that, The process of determining the corpus results matching the query information from multiple scene corpora in the corpus based on user-input query information includes: Extract keywords from the query information input by the user to determine the keywords input by the user; Based on the keywords, keyword matching is performed with multiple corpora in the corpus to determine the corpus results that match the query information.
7. The query method based on scene corpus according to claim 1, characterized in that, After constructing the corpus, the following is also included: Each scene corpus in the corpus is validated to identify duplicate corpora in the corpus; Duplicate data in the corpus are deleted.
8. A query device based on scene corpus, characterized in that, include: The matching module is used to determine the corpus results that match the query information from multiple scene corpora in the corpus based on the query information input by the user; An input construction module is used to construct text input for large language model queries based on the query information and the corpus results; The corpus construction process includes: A knowledge base for the network resource data is constructed based on the network resource entities, entity parameters, entity attributes, and entity relationships extracted from the network resource data. The entity attributes in the knowledge base are classified to determine multiple attribute types, and prompt word templates are generated for each attribute type to obtain multiple prompt word templates. Based on the data in the knowledge base, prompt word templates for each attribute type are instantiated to obtain multiple scenario corpora of the network resource data, and the corpus is constructed based on the multiple scenario corpora.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the query method based on scene corpus as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the query method based on scene corpus as described in any one of claims 1 to 7.