Network equipment configuration instruction generation method and device based on large model and mixed knowledge retrieval
The hybrid knowledge retrieval system using graph and vector databases addresses the inefficiencies of manual network configuration by enhancing accuracy and reducing errors in generating device configuration commands through entity extraction and synthesis.
Patent Information
- Application Number
- CN202510361703.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-25
- Publication Date
- 2025-07-15
AI Technical Summary
In the prior art, network equipment configuration requires frequent human intervention and depends on the familiarity of expert developers, which makes the configuration process expensive and difficult, and large language models perform in professional fields and are expensive to train, which is prone to hallucination problems.
Using a method based on large models and mixed knowledge retrieval, a graph database and a vector database are combined to identify natural language information, knowledge reasoning and configuration instructions are generated, including entity extraction, relationship screening and knowledge reasoning of vector databases, and target configuration instructions are generated.
It realizes the convenience of generating configuration instructions while significantly reducing the error rate, improving the efficiency and accuracy of network equipment configuration.
Smart Images

Figure CN120316320A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of emerging information technologies, belongs to big data technologies, and specifically relates to a method and device for generating network device configuration instructions based on a large model and hybrid knowledge retrieval. Background Art
[0002] The network is the backbone of today's communication infrastructure, supporting everything from simple online interactions to mission-critical services. Network operators have significant control over the transmission of data flows in the network and direct the data from one device to the next by precisely specifying the configuration of each device in the network infrastructure. These configurations cover switches, routers, servers, network interfaces, network functions, and must be configured accurately to ensure reliable transmission of information. Although software-defined networking (SDN) has been adopted by operators to simplify network configuration, network configuration still requires frequent human intervention. Manual configuration is both expensive and difficult as it requires expert developers familiar with large and complex software documentation and API interfaces, as well as knowledge of libraries, protocols, and their potential vulnerabilities.
[0003] The development of large language models (LLMs) has opened up new opportunities. They have the ability to generate coherent and contextually appropriate content, answer questions, and engage in in-depth conversations with users. Moreover, LLMs are currently able to assist with a variety of programming-related tasks. These developments lead to the belief that LLMs can also be used to generate network configurations, thereby improving the convenience of generating network configurations. Summary of the Invention
[0004] Aiming at the above at least one technical problem, the purpose of the present invention is to provide a method and device for generating network device configuration instructions based on a large model and hybrid knowledge retrieval.
[0005] On the one hand, an embodiment of the present invention includes a method for generating network device configuration instructions based on a large model and hybrid knowledge retrieval, which is applied to an electronic device. The electronic device includes a graph database and a vector database. The method includes:
[0006] Obtain natural language information;
[0007] Identify the natural language information through the graph database to obtain a plurality of initial text fragments;
[0008] Perform knowledge reasoning on the plurality of initial text fragments through the vector database to obtain at least one target text fragment;
[0009] Generate a target configuration instruction according to the at least one target text fragment through a trained language synthesis model.
[0010] Further, after obtaining the natural language information, the method further includes:
[0011] Performing entity extraction on the natural language information to obtain query entity information corresponding to the natural language information;
[0012] Identifying the natural language information through the graph database to obtain a plurality of initial text segments, including:
[0013] Identifying the query entity information through the graph database to obtain a plurality of initial text segments.
[0014] Further, the identifying the query entity information through the graph database to obtain a plurality of initial text segments includes:
[0015] Iterating the query entity information through the graph database to obtain a plurality of initial relationship data corresponding to the query entity information;
[0016] Performing relationship screening on the plurality of initial relationship data to obtain a plurality of screened initial relationship data;
[0017] Retrieving the plurality of screened initial relationship data to obtain context information corresponding to each initial relationship data;
[0018] Synthesizing according to the respective initial relationship data and the context information corresponding to each initial relationship data to obtain a plurality of initial text segments.
[0019] Further, performing knowledge reasoning on the plurality of initial text segments through the vector database to obtain at least one target text segment, including:
[0020] Calculating segment scores corresponding to each initial text paragraph through the vector database;
[0021] Sorting the plurality of initial text segments according to the segment scores, and selecting the initial text segments with the top K sorted segment scores as at least one target text segment; the K is a positive integer.
[0022] Further, after performing knowledge reasoning on the plurality of initial text segments through the vector database to obtain at least one target text segment, the method further includes:
[0023] Obtaining retrieval feedback data corresponding to each of the at least one target text segment;
[0024] Generating a target configuration instruction by the trained language synthesis model according to the at least one target text segment, including:
[0025] If it is determined that the natural language information, the query entity information, at least one target text segment, and the retrieval feedback data respectively corresponding to the at least one target text segment are greater than a preset knowledge threshold, then a target configuration instruction is generated according to the at least one target text segment by the trained language synthesis model.
[0026] Further, after obtaining the retrieval feedback data respectively corresponding to the at least one target text segment, the method further includes:
[0027] If it is determined that the natural language information, the query entity information, at least one target text segment, and the retrieval feedback data respectively corresponding to the at least one target text segment are less than or equal to a preset knowledge threshold, then new retrieval feedback information is generated, and based on the new retrieval feedback information, the step of identifying the new retrieval feedback information through the graph database to obtain multiple initial text segments is re-executed.
[0028] Further, the method further includes:
[0029] Calculating the number of times of identifying the natural language information through the graph database;
[0030] If the number of times is greater than a preset number threshold, then a prompt message is output and new natural language information is obtained again.
[0031] On the other hand, an embodiment of the present invention includes a network device configuration instruction generation device based on a large model and hybrid knowledge retrieval, which is applied to an electronic device. The electronic device includes a graph database and a vector database. The device includes:
[0032] An information acquisition module, configured to acquire natural language information;
[0033] A language recognition module, configured to identify the natural language information through the graph database to obtain multiple initial text segments;
[0034] A text reasoning module, configured to perform knowledge reasoning on the multiple initial text segments through the vector database to obtain at least one target text segment;
[0035] An instruction synthesis module, configured to generate a target configuration instruction according to the at least one target text segment by the trained language synthesis model.
[0036] On the other hand, an embodiment of the present invention further includes an electronic device, including a memory and a processor. The memory is used to store at least one computer program, and the processor is used to load the at least one program to execute the network device configuration instruction generation method based on a large model and hybrid knowledge retrieval in the embodiment.
[0037] On the other hand, an embodiment of the present invention further includes a computer-readable storage medium, in which a computer program executable by a processor is stored, and the executable program is used to execute a method for generating network device configuration instructions based on a large model and hybrid knowledge retrieval in the embodiment when executed by the processor.
[0038] Compared with the related art, the embodiments of the present application have the following beneficial effects:
[0039] The embodiments of the present application provide a method and device for generating network device configuration instructions based on a large model and hybrid knowledge retrieval, which obtain natural language information; identify the natural language information through a graph database to obtain a plurality of initial text fragments; perform knowledge reasoning on the plurality of initial text fragments through a vector database to obtain at least one target text fragment; and generate a target configuration instruction according to the at least one target text fragment through a trained language synthesis model. By implementing the embodiments of the present application, an electronic device can identify the obtained natural language information through a graph database according to the obtained natural language information, and further perform knowledge reasoning on the identified plurality of initial text fragments through a vector database, so as to generate a target configuration instruction. Through double retrieval by the graph database and the vector database, the knowledge retrieval process of network device configuration can be more comprehensively covered, and while ensuring the convenience of generating configuration instructions, the error rate of generating configuration instructions can also be significantly reduced. Description of the Drawings
[0040] Figure 1 is an application scenario diagram of a method for generating network device configuration instructions based on a large model and hybrid knowledge retrieval disclosed in an embodiment of the present application;
[0041] Figure 2 is a flowchart of a method for generating network device configuration instructions based on a large model and hybrid knowledge retrieval disclosed in an embodiment of the present application;
[0042] Figure 3 is a flowchart of constructing a graph database in an embodiment;
[0043] Figure 4 is a flowchart of another method for generating network device configuration instructions based on a large model and hybrid knowledge retrieval disclosed in an embodiment of the present application;
[0044] Figure 5 is a flowchart of performing knowledge reasoning on a plurality of initial text fragments through a vector database to obtain at least one target text fragment disclosed in an embodiment of the present application;
[0045] Figure 6 is a flowchart of another method for generating network device configuration instructions based on a large model and hybrid knowledge retrieval disclosed in an embodiment of the present application;
[0046] Figure 7 It is a schematic flowchart of generating network device configuration instructions based on a large model and hybrid knowledge retrieval in an embodiment;
[0047] Figure 8 It is a schematic architecture diagram of a network device configuration instruction generation device based on a large model and hybrid knowledge retrieval in an embodiment;
[0048] Figure 9 It is a schematic structural diagram of a network device configuration instruction generation device based on a large model and hybrid knowledge retrieval disclosed in an embodiment of the present application;
[0049] Figure 10 It is a schematic structural diagram of an electronic device disclosed in an embodiment of the present application. Detailed implementation manners
[0050] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0051] It should be noted that the terms "including" and "having" and any variations thereof in the embodiments of the present application and the accompanying drawings are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally further include steps or units not listed, or may optionally further include other steps or units inherent to these processes, methods, products, or devices.
[0052] Using large language models for network configuration is challenging. First, large language models are prone to hallucination problems and may generate completely wrong outputs. The hallucination problem refers to the situation where large language models generate inaccurate, incomplete, or misleading outputs when facing certain inputs. Moreover, reducing the hallucination problem of large language models highly depends on the content input by users to prompt the large language models, which is called "prompt engineering". It should also be noted that the performance of general large language models in professional fields is average, and training different large language models for each professional field will result in high training costs.
[0053] The embodiments of the present application disclose a method, device, electronic device, and storage medium for generating network device configuration instructions based on a large model and hybrid knowledge retrieval, which can significantly reduce the error rate of generating configuration instructions while ensuring the convenience of generating configuration instructions. The following will be described in detail respectively.
[0054] Please refer to Figure 1 , Figure 1 which is an application scenario diagram of a method for generating network device configuration instructions based on a large model and hybrid knowledge retrieval disclosed in an embodiment of the present application. The method for generating network device configuration instructions based on a large model and hybrid knowledge retrieval is applicable to the electronic device 101, and the electronic device 101 may include, but is not limited to, mobile phones, tablet computers, wearable devices, laptop computers, PCs (Personal Computers), etc. The application scenario diagram may include the electronic device 101 and the user 102. The user 102 may input natural language information to the electronic device 101, including manually inputting natural language information or inputting the natural language information by voice. The electronic device 101 may obtain the natural language information input by the user 102, identify the natural language information through a graph database to obtain multiple initial text fragments, perform knowledge reasoning on the multiple initial text fragments through a vector database to obtain at least one target text fragment, and generate a target configuration instruction according to the at least one target text fragment through a trained language synthesis model.
[0055] Figure 2 is a schematic flowchart of a method for generating network device configuration instructions based on a large model and hybrid knowledge retrieval disclosed in an embodiment of the present application. Among them, Figure 2 the described method for generating network device configuration instructions based on a large model and hybrid knowledge retrieval is applicable to the above-mentioned electronic device. As Figure 2 shown, the method for generating network device configuration instructions based on a large model and hybrid knowledge retrieval may include the following steps:
[0056] Step S201, obtain natural language information.
[0057] In one embodiment, the electronic device may obtain the natural language information input by the user. Among them, the natural language information may be an instruction for describing the generated target configuration instruction. The user inputs the natural language information to the electronic device so that the electronic device can receive the instruction for generating the target configuration, thereby executing the algorithm steps for generating the target configuration instruction. Among them, the target configuration instruction may be an instruction for configuring the corresponding target device. Specifically, the user may manually input the natural language information or input the natural language information to the electronic device through voice data, so that the electronic device can obtain the natural language information by recognizing the voice data.
[0058] Step S202, identify the natural language information through a graph database to obtain multiple initial text fragments.
[0059] In one embodiment, the electronic device can index in the graph database according to the natural language information, retrieve multiple entities, and form initial text fragments corresponding to each entity based on the relationships between the entities, thereby obtaining multiple initial text fragments. Among them, the knowledge graph can be a structured semantic knowledge base used to describe concepts in the physical world and their interrelationships. The basic unit of the knowledge graph is the triple composed of "entity-relationship-entity", which is also the core of the knowledge graph. Among them, specific entity categories are established for each type of target device, including entity categories such as device type, device manufacturer (Huawei, ZTE), device model, configuration instruction, configuration parameter, device function, error, and alarm. The relationship types can include but are not limited to execution relationship, parameter dependency, hierarchical relationship, and error association. Among them, the execution relationship can refer to a certain configuration instruction supported by a certain target device, the parameter dependency can refer to a specific parameter on which a certain target configuration instruction depends, the hierarchical relationship can refer to a functional module that a certain target configuration instruction can be used to configure, and the error association can refer to an error that a certain target configuration instruction may cause.
[0060] As an alternative implementation, the graph database can be built based on the original data, where the original data can be instructions related to configuring each target device. Specifically, the knowledge database can extract triples of entities and relationships from the original data through knowledge extraction, knowledge fusion, and knowledge processing, and store them in the graph database, thereby obtaining a completed graph database. Among them, information extraction can be to extract entities, attributes, and the interrelationships between entities from various types of original data sources, and form an ontological knowledge expression on this basis; knowledge fusion can be to integrate the newly obtained knowledge to eliminate contradictions and ambiguities, such as some entities may have multiple expressions, and a specific appellation may correspond to multiple different entities, etc.; knowledge processing can be that for the newly fused knowledge, only the qualified part can be added to the knowledge base after quality assessment to ensure the quality of the knowledge base. Optionally, the graph database can use graph databases such as Neo4j and TigerGraph to store the knowledge graph of network device configuration instructions, including entities and their relationships.
[0061] Figure 3It is a schematic flowchart of constructing a graph database in an embodiment. As shown in the figure, the original data for constructing the graph database can include structured data, semi-structured data, and unstructured data. Among them, the knowledge extraction process for the original data can include attribute extraction, entity extraction, and relationship extraction. Attribute extraction can be to collect the attribute information of specific entities from different original data sources. For example, for the entity of a public figure, information such as the birthday, nationality, and educational background of this public figure can be collected from various original data sources. Entity extraction can be to automatically identify named entities from the original data set. Relationship extraction can be that after entity extraction is performed on the original data, a series of discrete named entities are obtained. The association relationships between entities are extracted from the relevant corpus, and the entities are connected through relationships to form a networked knowledge structure in order to obtain semantic information. The knowledge fusion process for the original data can include knowledge fusion, coreference resolution, and entity disambiguation. Knowledge fusion can be to perform a merged database process on structured data, generally it can be to merge external knowledge bases and merge relational databases. Coreference resolution can be to identify that multiple references may point to the same entity object and merge these reference names into the same entity object. Entity disambiguation can be to use the clustering method to perform part-of-speech disambiguation and semantic disambiguation on the context-based classification problem, thereby solving the problem of ambiguity caused by homonymous entities. The knowledge processing process for the original data can include knowledge reasoning, quality assessment, and ontology extraction. Knowledge reasoning can be to further improve the incomplete relationships between entities through knowledge reasoning techniques. Quality assessment can be to quantify the credibility of knowledge and discard the knowledge with lower confidence levels to ensure the quality of the graph database. Since there is no concept of upper and lower levels in the knowledge graph, ontology extraction is required to divide the upper and lower level relationships for each entity. Ontology extraction can be to calculate the similarity of the co-occurrence relationships between entities and perform upper and lower position relationship extraction of entities according to this similarity, thereby generating an ontology, and this ontology can be used as a large class to integrate multiple entities.
[0062] By processing a large amount of original data to construct a graph database, the reasoning ability of the graph database can be greatly improved, thereby providing a technical basis for reducing the error rate of generating target configuration instructions.
[0063] Step S203, perform knowledge reasoning on multiple initial text segments through a vector database to obtain at least one target text segment.
[0064] In some embodiments, a vector database can be used to store various vector data. Optionally, an electronic device can collect multiple text data, where the text data can include PDF files such as vendor CLI configuration guides, API documents, etc. Specifically, the electronic device can extract the text information in the document through PyPDF2 to obtain the text data, and segment the text data according to smaller manageable paragraphs such as individual configuration instructions and their descriptions, descriptions of individual functional modules, etc. When segmenting the text data, set chunk_size to 500 and chunk_overlap to 100. Among them, the parameter chunk_size can refer to the maximum length of each part when the text data is segmented into multiple parts, and the parameter chunk_overlap can refer to the number of overlapping tokens between two adjacent chunks to ensure the coherence of text semantics. After segmentation, use the pre-trained BGE-embedding model to vectorize the segmented text data, convert each paragraph into vector data, and store the data in the vector database. Among them, the database for storing vectors can be Milvus, Pinecone, and Weaviate. When storing, the electronic device can add more metadata (such as chapter, page number, configuration instruction name) to enhance the usability of query results. Vectorizing the data can help the electronic device more accurately match questions and answers, thereby reducing the error rate of generating configuration instructions.
[0065] As an alternative implementation, the electronic device can screen multiple initial text segments through the vector database to obtain at least one target text segment. The electronic device screens multiple initial text segments through the vector database, thereby deleting a part of the initial text segments to improve the speed of generating configuration instructions.
[0066] Step S204: Based on at least one target text segment, the trained language synthesis model generates a target configuration instruction. In some embodiments, the target configuration instruction may be used to configure a network device or device module that needs to be configured in various ways. The network device that needs to be configured may be this electronic device, or other electronic devices other than this electronic device, or may also be network devices related to network connection such as switches, routers, and servers. The device that needs to be configured may be a network interface, network function, etc., which is not limited herein. The electronic device may generate a target configuration instruction according to at least one target text segment screened by the language synthesis model. Specifically, the language synthesis model may be a large language model related to generating configuration instructions. Before generating the target configuration instruction, the electronic device may first calculate the knowledge amount of at least one target text segment and determine whether the knowledge amount is greater than a preset knowledge threshold. If it is determined that the knowledge amount is greater than the preset knowledge threshold, a target configuration instruction is generated according to at least one target text segment; if it is determined that the knowledge amount is less than or equal to the preset knowledge threshold, retrieval is performed again according to the natural language information through the graph database and the vector database. The electronic device generates a target configuration instruction according to at least one target text segment only when it is determined that the knowledge amount of at least one target text segment is greater than the preset knowledge threshold, which can avoid invalid reasoning by the language synthesis model and thus reduce the error rate of generating configuration instructions.
[0067] As an alternative implementation, the electronic device may configure a network device or device module that needs to be configured in various ways according to the generated target configuration instruction. For example, the network parameters of a server may be configured according to the generated target configuration instruction. The electronic device can directly configure a network device or device module that needs to be configured in various ways according to the generated target configuration instruction without manually considering generating the target configuration instruction, which can improve the efficiency of configuring various network devices or device modules.
[0068] In the embodiments of the present application, the electronic device obtains natural language information; identifies the natural language information through the graph database to obtain a plurality of initial text segments; performs knowledge reasoning on the plurality of initial text segments through the vector database to obtain at least one target text segment; and generates a target configuration instruction according to at least one target text segment by the trained language synthesis model. The electronic device can identify the natural language information through the graph database according to the obtained natural language information and further perform knowledge reasoning on the identified plurality of initial text segments through the vector database to generate a target configuration instruction. Through dual retrieval by the graph database and the vector database, the knowledge retrieval process for network device configuration can be more comprehensively covered, and while ensuring the convenience of generating configuration instructions, the error rate of generating configuration instructions can also be significantly reduced.
[0069] Please refer to Figure 4 , Figure 4 which is a schematic flowchart of another method for generating network device configuration instructions based on a large model and hybrid knowledge retrieval disclosed in the embodiments of the present application. As Figure 4 shown, the method for generating network device configuration instructions based on a large model and hybrid knowledge retrieval may further include the following steps:
[0070] Step S401, obtain natural language information.
[0071] For the description of step S401, reference can be made to the relevant description of step S201 in the above embodiments, which will not be elaborated here.
[0072] Step S402, perform entity extraction on the natural language information to obtain query entity information corresponding to the natural language information.
[0073] In some embodiments, the electronic device can perform entity recognition on the natural language information through the Qwen2-7B model to obtain query entity information corresponding to the natural language information. Among them, the query entity information can be used to query knowledge in the graph database. The natural language information contains questions and task instructions. The electronic device performs entity recognition on the natural language information through the Qwen2-7B model and identifies the entities and the entity types corresponding to the entities, thereby forming query entity information.
[0074] Furthermore, the electronic device identifies the entities in the natural language information through the Qwen2-7B model, such as device types, models, operations, etc., and thus returns the query entity information. Optionally, the electronic device can set the maximum number of tokens max_tokens returned to 150 to ensure that the generated target configuration instructions are not too long. At the same time, the model temperature parameter is set to zero to reduce the randomness of the generated target configuration instructions and ensure consistent results.
[0075] Step S403, identify the query entity information through the graph database to obtain multiple initial text fragments.
[0076] In some embodiments, the electronic device can search for entities in the graph database based on the query entity information through the graph database, so as to obtain multiple entities and multiple initial text segments corresponding to each entity. Further, the electronic device iterates the query entity information through the graph database to obtain multiple initial relationship data corresponding to the query entity information; performs relationship screening on the multiple initial relationship data to obtain multiple screened initial relationship data; retrieves the context information corresponding to each initial relationship data for the multiple screened initial relationship data; and synthesizes based on each initial relationship data and the context information corresponding to each initial relationship data to obtain multiple initial text segments.
[0077] Optionally, the electronic device can match the entities obtained from the entity recognition stage with the device instruction nodes in the graph database, find the relevant entities and return them. Each entity contains text and type. The electronic device queries the graph database according to the query entity information through the model Cypher to match the nodes in the graph database, and the type of the entity corresponds to the label in the graph database. The query entity information can be matched by the name of the entity. The query returns at most one matching node. If there are multiple matching nodes, the first matching node found is returned. After obtaining the matching node, it is added to the entity list.
[0078] After obtaining the entity list, the electronic device can use the Qwen2-7B model to evaluate the relevance between the entities and the question according to the query entity information, and filter out the most relevant entities from them. Specifically, the electronic device can convert the entity list into a text format, and the text and type of each entity are combined into a string. The electronic device constructs a prompt word containing the query entity information and the relevant information of all the queried entities, calculates the relevance between each entity and the query entity information, and returns the most relevant topic entity where is the set of the most relevant entities, e i , i = 1, 2…, N are the most relevant topic entities returned respectively, and the value of N is the maximum value of the returned relevant entities. The value of N can be set manually. Set the maximum number of tokens max_tokens returned by the model to 150 to ensure that the answer of the model is not too long. Set the model temperature to 0 to reduce the randomness of the generated text and ensure consistent results.
[0079] Extract the entity names from the returned results and separate them into a list by line. The returned entities only contain the entity information highly relevant to the query. The electronic device iterates multiple times in the graph database according to the query entity information. In the i-th iteration, the topic entity is represented as Their previous triple paths are represented as where j∈[1,W], W is a hyperparameter of exploration width, i.e., the maximum number of topic entities retained in each iteration, is a triple in In the knowledge graph and The relationship between can be bidirectional. It should be noted that i=0 indicates the initialization stage, when the entity list is empty.
[0080] The electronic device iterates the query entity information through the graph database to obtain multiple initial relationship data corresponding to the query entity information, which can be the entity in the current iteration (i-th round) Finding and Entities All directly related relationships are obtained to obtain the initial relationship data, and the entities in multiple iterations are All relations of are used as multiple initial relation data. Electronic device definition function This function retrieves the knowledge graph All the connected relationships are returned in the form A collection of . Among them, Representation and Entity A certain relationship connected; m Is a Boolean value indicating whether this relationship in the knowledge graph points to (i.e., the positive and negative directions of the relationship). Searching the graph database yields the A series of candidate relationships directly related. Further, the electronic device queries the relationship between the entity related to the query entity information and other entities by constructing a Cypher query on the neo4j graph database.
[0081] The electronic device performs relationship screening on the multiple initial relationship data to obtain multiple screened initial relationship data, which can screen out the relationship that is most likely to help answer the question from the above-discovered relationships to avoid redundancy. Give it to the Large Language Model (LLM), write prompt words and let it determine the entities with high relevance to the prompt words according to the requirements of the question Specifically, two prompt methods can be used: the first is to call LLM for each topic entity separately, which is suitable for scenes with simple structures, but the number of calls is relatively large, and can be expressed as The second method is to send all topic entities and their candidate relations to the large language model for unified screening at one time. This can be completed in one call, but it requires higher processing capabilities of the LLM. It can be expressed as Finally, a set of selected or retained relationships is obtained, denoted as The relationship retention strategy is as follows: Strongly retain the SUPPORTS relationship because it directly indicates whether a device can support a certain instruction; moderately retain the REQUIRES relationship because it can indicate what parameters an instruction requires; if there is a CAUSES relationship in the search results (e.g., (OSPF)-[:CAUSES]->(Configuration_Conflict)), it can be temporarily placed behind when the user does not mention troubleshooting. The electronic device passes through the relationship set of entities related to multiple filtered initial relationship data to the large language model, obtains the context information corresponding to each initial relationship data, and synthesizes according to each initial relationship data and the context information corresponding to each initial relationship data to obtain multiple initial text fragments.
[0082] After one iteration, the electronic device finds new "downstream" entities according to the filtered relationships to expand the graph search. The function is used to find entities related to the entity through the relationship to obtain the set of entities connected where h m can be used to describe the direction of the relationship After finding all potential connected entities, a context-driven screening is also required to select the entities that are most relevant to the problem and helpful for subsequent reasoning to form the set of "topic entities" for the next iteration The electronic device iterates through the graph database for query entity information, obtains multiple initial relationship data corresponding to the query entity information, performs relationship screening on the multiple initial relationship data to obtain multiple filtered initial relationship data, retrieves the multiple filtered initial relationship data to obtain the context information corresponding to each initial relationship data, and completes the graph database search stage of the i-th round, preparing for the next iteration. Before the next iteration, through the relationship find the entity that was iterated in the previous round to obtain the set of entities and according to the set of entities form the set of entities for the next iteration to use the new set of entities as the new query entity information and re-execute the steps to iterate through the graph database for the new query entity information to obtain multiple initial relationship data corresponding to the query entity information.
[0083] Step S404, perform knowledge reasoning on multiple initial text fragments through the vector database to obtain at least one target text fragment.
[0084] Step S405: Based on at least one target text segment, generate a target configuration instruction using the trained language synthesis model.
[0085] For the descriptions of Step S404 to Step S405, reference can be made to the relevant descriptions of Step S203 to Step S204 in the above embodiments, which will not be elaborated here.
[0086] In the embodiments of the present application, the electronic device acquires natural language information, performs entity extraction on the natural language information to obtain query entity information corresponding to the natural language information, and identifies multiple initial text segments through a graph database. Knowledge reasoning is performed on the multiple initial text segments through a vector database to obtain at least one target text segment. Based on at least one target text segment, a target configuration instruction is generated using the trained language synthesis model, which can significantly reduce the error rate of generating configuration instructions while ensuring the convenience of generating configuration instructions.
[0087] Please refer to Figure 5 , Figure 5 which is a schematic flowchart of performing knowledge reasoning on multiple initial text segments through a vector database to obtain at least one target text segment disclosed in the embodiments of the present application. As Figure 5 shown, the step of performing knowledge reasoning on multiple initial text segments through a vector database to obtain at least one target text segment further includes the following steps:
[0088] Step S501: Calculate the segment scores corresponding to each initial text paragraph through the vector database.
[0089] Step S502: Sort the multiple initial text segments according to the segment scores, and select the first K sorted initial text segments with the highest segment scores as at least one target text segment; K is a positive integer.
[0090] In some embodiments, the electronic device may collect the initial text segments corresponding to each entity to form the entity context pool for this iteration. The electronic device can calculate the segment scores corresponding to each initial text paragraph through a dense retrieval model, where the segment score can be used to describe the relevance between the corresponding initial text paragraph and the question. Since directly calculating the relevance score between the context and the question will ignore the relationship between each context and its corresponding entity, the electronic device can use the current triple of the candidate entity Convert it into a short sentence. For example, (Router)-[:SUPPORTS]->(OSPF) is transcribed into the sentence "Router supports OSPF command." Append the converted sentence to the document fragment to be retrieved, and calculate the fragment scores corresponding to each initial text fragment. Further, the relevance score of the z-th fragment of the candidate entity is expressed as: and select the top K fragments Ctx i as a reference for the inference stage. Optionally, K can be set to 10.
[0091] After calculating the fragment scores corresponding to each initial text paragraph, select candidate entities based on the ranking scores of their context fragments and delete the initial text paragraphs with lower fragment scores. The ranking score of the candidate entity is calculated by the weighted sum of the scores of its fragments (ranked in the top K) according to exponential decay. Its formula (1) is as follows:
[0092]
[0093] where w l = e -α·l is the weight of the k-th ranked fragment, s k is the score of the k-th ranked fragment, is the indicator function, and its value is 1 when the k-th fragment belongs to ; K and α are hyperparameters. The candidate entities with scores in the top W will be selected as the topic entities in the next iteration
[0094] In the embodiments of the present application, by calculating the fragment scores corresponding to each initial text paragraph through a vector database, sorting multiple initial text fragments according to the fragment scores, and selecting the initial text fragments with the top K sorted fragment scores as at least one target text fragment, the calculation of the initial text fragments with lower fragment scores can be reduced, thereby improving the efficiency of generating configuration instructions. Moreover, selecting the initial text paragraphs with higher fragment scores as target text fragments is beneficial to reducing the error rate of generating target configuration instructions according to the target text fragments.
[0095] Please refer to Figure 6 , Figure 6 which is a schematic flowchart of another method for generating network device configuration instructions based on a large model and hybrid knowledge retrieval disclosed in the embodiments of the present application. As Figure 6 shown, the method for generating network device configuration instructions based on a large model and hybrid knowledge retrieval may further include the following steps:
[0096] Step S601, obtain natural language information.
[0097] Step S602, identify the natural language information through the graph database to obtain multiple initial text segments.
[0098] Step S603, perform knowledge reasoning on the multiple initial text segments through the vector database to obtain at least one target text segment.
[0099] The descriptions of Steps S601 to S603 can refer to the relevant descriptions of Steps S201 to S203 in the above embodiments, and will not be elaborated here.
[0100] Step S604, obtain the retrieval feedback data corresponding to each of the at least one target text segment.
[0101] Step S605, if it is determined that the natural language information, the query entity information, the at least one target text segment, and the retrieval feedback data corresponding to each of the at least one target text segment are greater than a preset knowledge threshold, then generate a target configuration instruction according to the at least one target text segment through the trained language synthesis model.
[0102] In some embodiments, the retrieval feedback data corresponding to the target text segment can be used to describe the retrieval path of the target text segment and the data generated during the retrieval process. Among them, the retrieval feedback information can include Hints i-1 (i.e., the retrieval feedback of the previous iteration), triple paths, and the top K ranked entities. The electronic device determines whether the amount of knowledge contained in the at least one target text segment and the retrieval feedback data corresponding to each of the at least one target text segment is greater than a preset knowledge threshold. If it is determined that the natural language information, the query entity information, the at least one target text segment, and the retrieval feedback data corresponding to each of the at least one target text segment are greater than a preset knowledge threshold, then generate a target configuration instruction according to the at least one target text segment through the trained language synthesis model; if it is determined that the natural language information, the query entity information, the at least one target text segment, and the retrieval feedback data corresponding to each of the at least one target text segment are less than or equal to the preset knowledge threshold, then generate new retrieval feedback information, and according to the new retrieval feedback information, re - execute identifying the new retrieval feedback information through the graph database to obtain multiple initial text segments.
[0103] At the end of the i-th iteration, the electronic device checks through the large language model whether the current knowledge covers all key elements required to generate the instruction, such as device model, version information, parameter default values, dependency conditions, etc., and verifies the logical consistency of at least one target text segment and the retrieval feedback data corresponding to at least one target text segment respectively, to ensure that there are no conflicts among the retrieved knowledge segments, such as the syntax differences of device instructions in different versions. The electronic device also verifies whether the current knowledge can be directly mapped to the requirements of the question q in the natural language information. For example, whether an instruction that conforms to the grammar specification and has complete parameters can be constructed.
[0104] Further, at the end of the i-th iteration, the electronic device provides all the found knowledge to the large language model (LLM), including at least one target text segment and the retrieval feedback data corresponding to at least one target text segment respectively, and evaluates through the large language model whether the currently found knowledge is sufficient to answer the question in the natural language information, where, Hints i-1 is designed to retain useful knowledge in the historical context. If the large language model determines that the existing information is sufficient to generate the instruction, it directly generates the target configuration instruction according to at least one target text segment and the retrieval feedback data corresponding to at least one target text segment respectively. The target configuration instruction may include the complete writing of the configuration command, related parameters and their default / optional values, and possible precautions (such as starting the interface first, or configuring the IP first). If the found knowledge is insufficient, the large language model will output a prompt message of "more information is needed" and list keywords. For example, "the specific version of NE40 or the VRP software version information is needed", and then initiate a new round of retrieval. The electronic device prompts the large language model to summarize useful clues Hints i from the existing knowledge, and then reconstruct an optimized query based on the accurate information until the maximum depth D is reached, where the maximum depth D can be set manually.
[0105] Furthermore, it can be judged by formula (2) whether the amount of knowledge contained in at least one target text segment and the retrieval feedback data corresponding to at least one target text segment respectively is greater than a preset knowledge threshold, as shown in formula (2):
[0106]
[0107] Among them, formula (2) defines the logic of the large language model's reasoning based on the input knowledge in the i-th iteration: If the model judges the current knowledge (including question q, triple path T i ), context fragment Ctx i , and the previous clues Hints i-1If there is enough knowledge to answer the question, directly output the answer Ans. If the amount of knowledge is less than or equal to the preset knowledge threshold, generate new clues Hints i , providing guidance for the next round of exploration.
[0108] In some embodiments, the electronic device calculates the number of recognition times for recognizing the natural language information through the graph database; if the number of recognition times is greater than the preset number threshold, a prompt message is output and new natural language information is retrieved again. When the number of recognition times of the electronic device is greater than the preset number threshold, the inference iteration process is stopped, a prompt message is output, and new natural language information is retrieved again, avoiding the inference iteration from not stopping all the time due to insufficient knowledge, thereby reducing the efficiency of generating the target configuration instruction.
[0109] Figure 7 is a schematic flowchart of generating a configuration instruction in an embodiment, as Figure 7 shown. After the user inputs natural language information to describe the network device configuration requirements, the electronic device recognizes named entities, iteratively searches for downstream entities, discovers relationships in the graph database and filters the relationships to obtain multiple initial text fragments, retrieves the multiple initial text fragments through the vector database, and fuses the retrieval results to obtain the retrieval result. The fused retrieval result is inferred through the large language model, and it is determined whether the amount of knowledge contained in at least one target text fragment and the retrieval feedback data corresponding to at least one target text fragment respectively is greater than the preset knowledge threshold. If it is determined that the amount of knowledge contained in at least one target text fragment and the retrieval feedback data corresponding to at least one target text fragment respectively is greater than the preset knowledge threshold, a target configuration instruction is generated; if it is determined that the amount of knowledge contained in at least one target text fragment and the retrieval feedback data corresponding to at least one target text fragment respectively is less than or equal to the preset knowledge threshold, the iterative search for downstream entities is performed again.
[0110] Figure 8 is a device architecture diagram of generating a configuration instruction in an embodiment, as Figure 8As shown in the figure, the electronic device includes a data storage unit, a knowledge retrieval unit, a data processing and fusion unit, an inference and generation unit, and a user interaction and management unit. Among them, the data storage unit includes the knowledge graph stored in the database of the graph database and the vector file stored in the vector data. The knowledge retrieval unit includes a graph retrieval subunit and a vector retrieval subunit. The graph retrieval subunit can be used to retrieve through the graph database, and the vector retrieval subunit can be used to retrieve through the vector database. The data processing and fusion unit includes a named entity recognition subunit and a knowledge fusion subunit. The named entity recognition subunit can be used to identify entities in natural language information, and the knowledge fusion subunit can be used to fuse the knowledge retrieved from the graph database and the vector database respectively to obtain the target configuration instruction. The inference and generation unit can include a large language model interface subunit and a hybrid inference scheduling subunit. The inference and generation unit can be used to generate the target configuration instruction through the large language model based on the found knowledge. The user interaction and management unit includes an input processing subunit, an output display subunit, and a system management subunit. The input processing subunit is used to receive the information input by the user and process the information input by the user; the output display subunit is used to display the generated target configuration instruction or prompt information; the system management subunit is used to obtain and process the configuration parameters, logs, permissions, etc. of the electronic device.
[0111] In the embodiment of the present application, retrieve the retrieval feedback data corresponding to at least one target text segment respectively. If it is determined that the natural language information, the query entity information, the at least one target text segment, and the retrieval feedback data corresponding to the at least one target text segment are greater than the preset knowledge threshold, then generate the target configuration instruction according to the at least one target text segment through the trained language synthesis model, which can reduce the error rate of generating the configuration instruction.
[0112] Please refer to Figure 9 , Figure 9 is a schematic structural diagram of a network device configuration instruction generation device based on a large model and hybrid knowledge retrieval disclosed in the embodiment of the present application. This device can be applied to the above-mentioned electronic device. As Figure 9 shown, the network device configuration instruction generation device 900 based on a large model and hybrid knowledge retrieval may include: an information acquisition module 901, a language recognition module 902, a text inference module 903, and an instruction synthesis module 904.
[0113] The information acquisition module 901 is used to acquire natural language information;
[0114] The language recognition module 902 is used to identify the natural language information through the graph database to obtain multiple initial text segments;
[0115] A text reasoning module 903 is configured to perform knowledge reasoning on multiple initial text segments through a vector database to obtain at least one target text segment;
[0116] An instruction synthesis module 904 is configured to generate a target configuration instruction according to at least one target text segment through a trained language synthesis model.
[0117] In one embodiment, the network device configuration instruction generation device 900 based on a large model and hybrid knowledge retrieval further includes an entity extraction module:
[0118] The entity extraction module is configured to perform entity extraction on natural language information to obtain query entity information corresponding to the natural language information;
[0119] The language recognition module 902 is further configured to identify the query entity information through a graph database to obtain multiple initial text segments.
[0120] In one embodiment, the entity extraction module is further configured to iterate the query entity information through a graph database to obtain multiple initial relationship data corresponding to the query entity information; perform relationship screening on the multiple initial relationship data to obtain multiple screened initial relationship data; retrieve context information corresponding to each initial relationship data; and synthesize according to each initial relationship data and the context information corresponding to each initial relationship data to obtain multiple initial text segments.
[0121] In one embodiment, the text reasoning module 903 is further configured to calculate segment scores corresponding to each initial text paragraph through a vector database; sort the multiple initial text segments according to the segment scores, and select the initial text segments with the top K sorted segment scores as at least one target text segment; K is a positive integer.
[0122] In one embodiment, the network device configuration instruction generation device 900 based on a large model and hybrid knowledge retrieval further includes a feedback acquisition module:
[0123] The feedback acquisition module is configured to obtain retrieval feedback data corresponding to at least one target text segment respectively;
[0124] The instruction synthesis module 904 is further configured to, if it is determined that the natural language information, the query entity information, at least one target text segment, and the retrieval feedback data corresponding to at least one target text segment respectively are greater than a preset knowledge threshold, generate a target configuration instruction according to at least one target text segment through a trained language synthesis model.
[0125] In one embodiment, the instruction synthesis module 904 is further configured to generate new retrieval feedback information if it is determined that the natural language information, the query entity information, at least one target text segment, and the retrieval feedback data corresponding to each of the at least one target text segment are less than or equal to a preset knowledge threshold, and re-execute, according to the new retrieval feedback information, the recognition of the new retrieval feedback information through the graph database to obtain a plurality of initial text segments.
[0126] In one embodiment, the network device configuration instruction generation device 900 based on a large model and hybrid knowledge retrieval further includes a count calculation module and a prompt output module:
[0127] The count calculation module is configured to calculate the number of times of recognizing the natural language information through the graph database;
[0128] The prompt output module is configured to output a prompt message and re-obtain new natural language information if the number of recognition times is greater than a preset number threshold.
[0129] Please refer to Figure 10 , Figure 10 which is a schematic structural diagram of an electronic device disclosed in an embodiment of the present application. As Figure 10 shown, the electronic device 1000 may include:
[0130] A memory 1001 storing executable program code;
[0131] A processor 1002 coupled to the memory 1001;
[0132] Wherein, the processor 1002 calls the executable program code stored in the memory 1001 to execute any one of the network device configuration instruction generation methods disclosed in the embodiments of the present application.
[0133] An embodiment of the present application discloses a computer-readable storage medium storing a computer program, wherein when the computer program is executed by the processor, the processor is enabled to implement any one of the network device configuration instruction generation methods disclosed in the embodiments of the present application.
[0134] An embodiment of the present application discloses a computer program product including a computer program, and when the computer program is executable by a processor, it implements the method described in the above embodiments.
[0135] It should be understood that the "one embodiment" or "an embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, the appearances of "in one embodiment" or "in an embodiment" throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. Those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to the present application.
[0136] In various embodiments of the present application, it should be understood that the magnitude of the serial numbers of the above processes does not necessarily mean the inevitable sequence of execution. The execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
[0137] The units described as separate components above may or may not be physically separated. The components shown as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0138] In addition, in each embodiment of the present application, each functional unit can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0139] If the above integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-accessible memory. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions for causing a computer device (which can be a personal computer, a server or a network device, etc., specifically, the processor in the computer device) to execute some or all of the steps of the above methods in each embodiment of the present application.
[0140] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing relevant hardware through a program, and the program can be stored in a computer-readable storage medium. The storage medium includes read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc memories, magnetic disc memories, tape memories, or any other medium that can be used to carry or store data and is computer-readable.
[0141] The above has introduced in detail a method and device for generating network device configuration instructions based on large models and hybrid knowledge retrieval disclosed in the embodiments of the present application. Specific examples are used in this article to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application. At the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A method for generating network device configuration instructions based on large models and hybrid knowledge retrieval, characterized in that, Applied to an electronic device, the electronic device includes a graph database and a vector database, and the method includes: Obtain natural language information; Identify the natural language information through the graph database to obtain a plurality of initial text segments; Perform knowledge reasoning on the plurality of initial text segments through the vector database to obtain at least one target text segment; Generate a target configuration instruction according to the at least one target text segment through a trained language synthesis model.
2. The method for generating network device configuration instructions based on large models and hybrid knowledge retrieval according to claim 1, wherein, After obtaining the natural language information, the method further includes: Extract entities from the natural language information to obtain query entity information corresponding to the natural language information; The identifying the natural language information through the graph database to obtain a plurality of initial text segments includes: Identify the query entity information through the graph database to obtain a plurality of initial text segments.
3. The method for generating network device configuration instructions based on large models and hybrid knowledge retrieval according to claim 2, wherein, The identifying the query entity information through the graph database to obtain a plurality of initial text segments includes: Iterate the query entity information through the graph database to obtain a plurality of initial relationship data corresponding to the query entity information; Perform relationship screening on the plurality of initial relationship data to obtain a plurality of screened initial relationship data; Retrieve the plurality of screened initial relationship data to obtain context information corresponding to each initial relationship data; Synthesize according to each initial relationship data and the context information corresponding to each initial relationship data to obtain a plurality of initial text segments.
4. The method for generating network device configuration instructions based on large models and hybrid knowledge retrieval according to claim 1, characterized in that, The performing knowledge reasoning on the plurality of initial text segments through the vector database to obtain at least one target text segment includes: Calculate a segment score corresponding to each initial text paragraph through the vector database; Sort the plurality of initial text segments according to the segment score, and select the initial text segments with the top K sorted segment scores as at least one target text segment; K is a positive integer.
5. The method for generating network device configuration instructions based on large models and hybrid knowledge retrieval according to any one of claims 1-4, characterized in that, After performing knowledge reasoning on the plurality of initial text segments through the vector database to obtain at least one target text segment, the method further includes: Obtain retrieval feedback data corresponding to each of the at least one target text segment; The generating a target configuration instruction according to at least one target text segment through a trained language synthesis model includes: If it is determined that the natural language information, the query entity information, the at least one target text segment, and the retrieval feedback data corresponding to each of the at least one target text segment are greater than a preset knowledge threshold, then generate a target configuration instruction according to the at least one target text segment through a trained language synthesis model.
6. The method for generating network device configuration instructions based on large models and hybrid knowledge retrieval according to claim 5, wherein After obtaining the retrieval feedback data corresponding to each of the at least one target text segment, the method further includes: If it is determined that the natural language information, the query entity information, at least one target text segment, and the retrieval feedback data corresponding to the at least one target text segment are less than or equal to a preset knowledge threshold, new retrieval feedback information is generated, and based on the new retrieval feedback information, the new retrieval feedback information is re-identified through the graph database to obtain multiple initial text segments.
7. The method for generating network device configuration instructions based on large models and hybrid knowledge retrieval according to claim 6, wherein, The method further includes: Calculating the number of times of identifying the natural language information through the graph database; If the number of times of identification is greater than a preset number threshold, a prompt message is output and new natural language information is re-obtained.
8. A method and device for generating network device configuration instructions based on large models and hybrid knowledge retrieval, characterized in that, Applied to an electronic device, the electronic device includes a graph database and a vector database, and the device includes: An information acquisition module, configured to acquire natural language information; A language recognition module, configured to identify the natural language information through the graph database to obtain multiple initial text segments; A text inference module, configured to perform knowledge inference on the multiple initial text segments through the vector database to obtain at least one target text segment; An instruction synthesis module, configured to generate a target configuration instruction according to the at least one target text segment through a trained language synthesis model.
9. An electronic device, characterized in that, Including a memory and a processor, a computer program is stored in the memory, and when the computer program is executed by the processor, the processor is caused to implement the method for generating a network device configuration instruction based on a large model and hybrid knowledge retrieval according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the method for generating a network device configuration instruction based on a large model and hybrid knowledge retrieval according to any one of claims 1 to 7.