Routing configuration inter-translation method and device based on large language model, equipment and medium
Through the routing configuration mutual translation method based on the large language model, the source template of the router configuration file is extracted and the large language model is trained, and the configuration file mutual translation between routers of different manufacturers is realized, which solves the problem of limitations of configuration parsers in the existing technology, and improves the accuracy and efficiency of configuration conversion.
Patent Information
- Application Number
- CN202411423001.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-10-12
AI Technical Summary
In the prior art, configuration parsers are limited to parsing configurations from specific vendors, and cannot implement mutual translation between routers of different vendors, resulting in difficulties in network configuration and verification.
The routing configuration mutual translation method based on the large language model is adopted. By obtaining the original configuration file of the router to be converted and the configuration manual of the target manufacturer's router, the source configuration template is extracted, and the configuration manual is used to train the large language model to obtain the target large language model, and then the source configuration template is translated into the target configuration template to realize the mutual translation of the configuration file.
It realizes configuration file translation between routers of different manufacturers, improves the accuracy and efficiency of configuration conversion, and solves the problem of limitations of configuration parsers in the prior art.
Smart Images

Figure CN119544500A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of computer network configuration, and in particular to a method, device, equipment and medium for routing configuration mutual translation based on a large language model. Background Art
[0002] The current Internet is generally a distributed system composed of many routers to exchange routing information and forward data packets to achieve normal network access. These routers are mostly composed of routers from different manufacturers or different series of routers from the same manufacturer. The syntax commands between routers from different manufacturers or different series of routers from the same manufacturer are generally different, which makes it difficult to perform configuration conversion when configuring the network or migrating the configuration. In addition, in order to ensure the reliability of the network, it is generally necessary to verify the correctness of the network configuration to be deployed before deploying it to the actual network.
[0003] However, all current verification tools rely on the Batfish parser to parse router configurations and lack support for domestic router configurations, so it is difficult to verify when using domestic routers to build networks. In addition, in the operational practice of FITI (Future Internet Technology Infrastructure) networks, it is not easy to directly apply previous verification tools to the verification of FITI networks due to the challenges faced by configuration parsing. Although there are multiple existing solutions, when building the FITI configuration verifier Ladybug, no network configuration verification tool could successfully parse the FITI configuration composed of Huawei and H3C routers. Parsing the configuration is the first stage of network verification.
[0004] Due to the complexity of the vendor-specific configuration language of routers, it is challenging to customize and develop corresponding configuration parsers for routers from different vendors: development engineers must thoroughly understand the configuration manual, including various configuration items, commands and parameters, as well as related grammatical rules. In addition, it is necessary to create lexical and grammatical parsers based on the grammatical rules to form an abstract syntax tree. And functions must be designed to traverse the abstract syntax tree, extract parameter values and store them in a specified data structure. Therefore, writing a specific parser for each vendor is a very time-consuming and difficult task. However, the configuration parsers in existing verification tools are limited to parsing configurations from specific vendors (such as Cisco, Juniper). Summary of the invention
[0005] The present application provides a method, apparatus, device and medium for routing configuration mutual translation based on a large language model to solve the problem that the configuration parser in the related art is limited to parsing configurations from a specific vendor and cannot achieve mutual translation between routers from different vendors.
[0006] The first aspect of the present application provides a method for routing configuration translation based on a large language model, comprising the following steps: obtaining an original configuration file of a router to be converted and a configuration manual of a target manufacturer's router; extracting a source configuration template of the original configuration file based on the large language model; training the large language model using the configuration manual to obtain a target large language model, translating the source configuration template into a target configuration template based on the target large language model, and translating the original configuration file into a target format configuration file corresponding to the target manufacturer's router based on the target configuration template, wherein the target large language model has vertical domain knowledge of the target manufacturer's router configuration method.
[0007] Optionally, translating a source configuration template into a target configuration template based on a target large language model includes: obtaining a directory of a configuration manual; inputting the source configuration template and the directory of the configuration manual into the target large language model, wherein the target large language model searches the directory of the configuration manual based on the source configuration template to obtain a target chapter; obtaining the content of the target chapter; training the target large language model based on the content of the target chapter to obtain a first target large language model, wherein the first target large language model has vertical domain knowledge of a target configuration segment configuration method of a router of a target manufacturer; and translating the source configuration template into a target configuration template based on the first target large language model.
[0008] Optionally, based on the target configuration template, the original configuration file is translated into a target format configuration file corresponding to the router of the target manufacturer, including: obtaining a translation mapping relationship between the source configuration template and the target configuration template; using the translation mapping relationship to train a first target large language model to obtain a second target large language model, wherein the second target large language model has vertical domain knowledge of the source manufacturer and target manufacturer's translation method for the router to be converted; based on the second target large language model and the translation mapping relationship, the original configuration file is translated into a target format configuration file corresponding to the router of the target manufacturer.
[0009] Optionally, after translating the source configuration template into the target configuration template based on the target large language model, it also includes: obtaining an initial translation result of the source configuration template into the target configuration template; identifying errors in the initial translation result, and training a second target large language model based on the errors and the configuration manual, wherein the trained second target large language model outputs the final target configuration template, and iteratively correcting errors during the training process until a preset number of iterations is reached or a correct translation result is generated.
[0010] Optionally, the error type includes at least one of a grammatical error, a view structure error and a semantic error, and identifying errors in the initial translation result includes: using a preset parser to identify grammatical errors and view structure errors, wherein the preset parser is a Batfish parser, and the Batfish parser is generated based on the unified grammar rules of the target manufacturer.
[0011] Optionally, the error is corrected iteratively until a preset number of iterations is reached or a correct translation result is generated, including: if the error is a grammatical error, determining the corresponding chapter in the configuration manual that solves the erroneous grammar according to the erroneous grammar, and correcting the erroneous grammar according to the correction method of the corresponding chapter; if the error is a view structure error, determining the erroneous part and the corresponding chapter according to the erroneous view structure, extracting a configuration example from the corresponding chapter, and correcting the erroneous view structure according to the configuration example, wherein the configuration example and the erroneous part run the same protocol and have a correct view structure; if the error is a semantic error, generating a first semantic for each source fragment in the source configuration template based on a large language model, generating a second semantic for the target configuration template, and correcting the erroneous semantics according to the similarity between the first semantics and the second semantics.
[0012] Optionally, extracting a source configuration template of the original configuration file based on the large language model includes: segmenting the original configuration file according to the structure of the original configuration file to obtain multiple fragments; synthesizing the source configuration template according to the structure of the multiple fragment configurations, wherein the source configuration template encapsulates all features in the original configuration file.
[0013] The second aspect of the present application provides a routing configuration translation device based on a large language model, including: an acquisition module, used to obtain the original configuration file of the router to be converted and the configuration manual of the router of the target manufacturer; an extraction module, used to extract the source configuration template of the original configuration file based on the large language model; a translation module, used to train the large language model using the configuration manual to obtain a target large language model, translate the source configuration template into a target configuration template based on the target large language model, and translate the original configuration file into a target format configuration file corresponding to the router of the target manufacturer based on the target configuration template, wherein the target large language model has vertical domain knowledge of the router configuration method of the target manufacturer.
[0014] Optionally, the mutual translation module is further used to: obtain the directory of the configuration manual; input the source configuration template and the directory of the configuration manual into the target large language model, wherein the target large language model searches the directory of the configuration manual based on the source configuration template to obtain the target chapter; obtain the content of the target chapter; train the target large language model based on the content of the target chapter to obtain a first target large language model, wherein the first target large language model has vertical domain knowledge of the target configuration segment configuration method of the router of the target manufacturer; and translate the source configuration template into the target configuration template based on the first target large language model.
[0015] Optionally, the mutual translation module is further used to: obtain a translation mapping relationship between a source configuration template and a target configuration template; use the translation mapping relationship to train a first target large language model to obtain a second target large language model, wherein the second target large language model has vertical domain knowledge of the mutual translation method between the source manufacturer and the target manufacturer of the router to be converted; based on the second target large language model and the translation mapping relationship, translate the original configuration file into a target format configuration file corresponding to the router of the target manufacturer.
[0016] Optionally, it also includes: a training module, which is used to obtain an initial translation result of the source configuration template into the target configuration template after translating the source configuration template into the target configuration template based on the target large language model; identify errors in the initial translation result, and train a second target large language model based on the errors and the configuration manual, wherein the trained second target large language model outputs the final target configuration template, and iteratively corrects errors during the training process until a preset number of iterations is reached or a correct translation result is generated.
[0017] Optionally, the error type includes at least one of a grammatical error, a view structure error and a semantic error, and the training module is further used to: identify grammatical errors and view structure errors using a preset parser, wherein the preset parser is a Batfish parser, and the Batfish parser is generated based on the unified grammar rules of the target manufacturer.
[0018] Optionally, the training module is further used to: if the error is a grammatical error, determine the corresponding chapter in the configuration manual that solves the erroneous grammar according to the erroneous grammar, and correct the erroneous grammar according to the correction method of the corresponding chapter; if the error is a view structure error, determine the erroneous part and the corresponding chapter according to the erroneous view structure, extract a configuration example from the corresponding chapter, and correct the erroneous view structure according to the configuration example, wherein the configuration example and the erroneous part run the same protocol and have a correct view structure; if the error is a semantic error, generate a first semantic for each source fragment in the source configuration template based on a large language model, generate a second semantic for the target configuration template, and correct the erroneous semantics according to the similarity between the first semantics and the second semantics.
[0019] Optionally, the extraction module is further used to: segment the original configuration file according to the structure of the original configuration file to obtain multiple fragments; synthesize a source configuration template according to the structure of the multiple fragment configurations, wherein the source configuration template encapsulates all features in the original configuration file.
[0020] The third aspect of the present application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to execute the routing configuration translation method based on a large language model as described in the above embodiment.
[0021] The fourth aspect of the present application provides a computer-readable storage medium on which a computer program or instruction is stored. The computer program or instruction is executed by a processor to perform the routing configuration translation method based on a large language model as described in the above embodiment.
[0022] Therefore, this application has at least the following beneficial effects:
[0023] This application uses a large language model to extract the source configuration template of the original configuration file of the router to be converted, and uses the configuration manual to train the large language model to obtain a target large language model, so that it has the vertical domain knowledge of the router configuration method of the target manufacturer, and translates the source configuration template into a target configuration template based on the target large language model and the configuration manual, and then translates the original configuration file into a target format configuration file corresponding to the router of the target manufacturer based on the target configuration template, uses the configuration manual to guide the translation of the large language model, improves the accuracy of the large language model translation, and realizes the mutual translation of configuration files between different manufacturers or different series of routers of the same manufacturer, and first translates the configuration template, and guides the translation of the entire original configuration file based on the translated target configuration template, effectively avoiding the problem of the accuracy of the large language model decreasing when processing large-scale configuration. As a result, the technical problems in the related art that the configuration parser is limited to parsing configurations from a specific supplier and cannot realize mutual translation between routers of different manufacturers are solved.
[0024] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0026] Figure 1 A flowchart of a method for inter-translation of routing configurations based on a large language model provided according to an embodiment of the present application;
[0027] Figure 2A schematic diagram of routing configuration mutual translation based on a large language model provided according to an embodiment of the present application;
[0028] Figure 3 A schematic diagram of a routing configuration translation device based on a large language model provided according to an embodiment of the present application;
[0029] Figure 4 It is a schematic diagram of the structure of an electronic device provided according to an embodiment of the present application. DETAILED DESCRIPTION
[0030] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0031] The following describes the routing configuration mutual translation method, device, equipment and medium based on the large language model of the embodiment of the present application with reference to the accompanying drawings. In view of the complexity of the specific configuration language of the router manufacturer mentioned in the above background technology, it is difficult to customize and develop corresponding configuration parsers for routers of different manufacturers, and the configuration parsers in the existing verification tools are limited to parsing problems from specific suppliers. The present application provides a routing configuration mutual translation method based on a large language model, in which a source configuration template of the original configuration file of the router to be converted is extracted using a large language model, and a large language model is trained using a configuration manual to obtain a target large language model, so that it has the vertical domain knowledge of the router configuration method of the target manufacturer, and the source configuration template is translated into a target configuration template based on the target large language model and the configuration manual, and then the original configuration file is mutually translated into a target format configuration file corresponding to the router of the target manufacturer based on the target configuration template. Thus, the problem that the configuration parser in the related art is limited to parsing the configuration from a specific supplier and cannot realize the mutual translation between routers of different manufacturers is solved.
[0032] Specifically, Figure 1 A flowchart of a method for inter-translation of routing configurations based on a large language model provided in an embodiment of the present application.
[0033] like Figure 1 As shown, the routing configuration translation method based on the large language model includes the following steps:
[0034] In step S101, the original configuration file of the router to be converted and the configuration manual of the router of the target manufacturer are obtained.
[0035] The router to be converted may be, for example, a first series router of Huawei, and the router of the target manufacturer may be, for example, Cisco or a second series router of Huawei. That is to say, the two routers may be from different manufacturers or different series of routers of the same manufacturer.
[0036] It is understandable that the embodiment of the present application can obtain the original configuration file of the router to be converted and the configuration manual of the target manufacturer's router, so as to subsequently translate the original configuration file into a configuration file of the corresponding format of the target manufacturer's router based on the configuration manual.
[0037] In step S102, a source configuration template of the original configuration file is extracted based on the large language model.
[0038] It can be understood that the embodiment of the present application can extract the source configuration template of the original configuration file based on the large language model ChatGPT, and the specific extraction process is as follows.
[0039] In an embodiment of the present application, a source configuration template of an original configuration file is extracted based on a large language model, including: segmenting the original configuration file according to the structure of the original configuration file to obtain multiple fragments; synthesizing the source configuration template according to the structure of the multiple fragment configurations, wherein the source configuration template encapsulates all features in the original configuration file.
[0040] It can be understood that the embodiments of the present application can segment the original configuration file according to the structure of the original configuration file to obtain multiple fragments, and synthesize the source configuration template according to the structure of the multiple fragment configurations, so that the source configuration template contains all configuration commands and corresponding structures that can represent the fragment characteristics, and the source configuration template accurately encapsulates all the features existing in the configuration file.
[0041] In step S103, the configuration manual is used to train the large language model to obtain a target large language model, the source configuration template is translated into the target configuration template based on the target large language model, and the original configuration file is mutually translated into a target format configuration file corresponding to the target manufacturer based on the target configuration template, wherein the target large language model has the vertical domain knowledge of the router configuration method of the target manufacturer. Based on the large language model and the configuration manual, the source configuration template is translated into the target configuration template, and based on the target configuration template, the original configuration file is mutually translated into a target format configuration file corresponding to the second router.
[0042] It can be understood that the embodiment of the present application can use the configuration manual to perform lightweight training on the large language model to obtain the target large language model, so that the target large language model has a large language model with vertical domain knowledge of the target manufacturer's router configuration method, and use the target large language model to translate the source configuration template into the target configuration template, and based on the target configuration template, translate the original configuration file into the target format configuration file corresponding to the target manufacturer, thereby realizing the translation process of the large language model guided by the configuration manual, improving the accuracy of the translation, realizing the mutual translation of configuration files of routers from different manufacturers or routers of the same manufacturer, and first translating the configuration template, and guiding the translation of the entire original configuration file based on the translated target configuration template, effectively avoiding the problem of decreased accuracy of the large language model when processing large-scale configurations.
[0043] In an embodiment of the present application, a source configuration template is translated into a target configuration template based on a target large language model, including: obtaining a directory of a configuration manual; inputting the source configuration template and the directory of the configuration manual into the target large language model, wherein the target large language model searches the directory of the configuration manual based on the source configuration template to obtain a target chapter; obtaining the content of the target chapter; training the target large language model based on the content of the target chapter to obtain a first target large language model, wherein the first target large language model has vertical domain knowledge of a target configuration segment configuration method of a router of a target manufacturer.
[0044] It can be understood that the embodiment of the present application can obtain the directory of the configuration manual, and then the target large language model can identify the possibly relevant target chapters in the target manufacturer's configuration manual based on the source configuration template, and use the content of the target chapter to train the target large language model to obtain the first target large language model, so that the first target large language model has the vertical domain knowledge of the target configuration segment configuration method of the target manufacturer's router.
[0045] In an embodiment of the present application, an original configuration file is translated into a target format configuration file corresponding to a router of a target manufacturer based on a target configuration template, including: obtaining a translation mapping relationship between a source configuration template and a target configuration template; using the translation mapping relationship to train a first target large language model to obtain a second target large language model, wherein the second target large language model has vertical domain knowledge of a method for translating between a source manufacturer and a target manufacturer of a router to be configured to be converted; based on the second target large language model and the translation mapping relationship, the original configuration file is translated into a target format configuration file corresponding to a router of the target manufacturer.
[0046] It can be understood that the embodiments of the present application can obtain the translation mapping relationship between the configuration template and the target configuration template, use the translation mapping relationship to train the first target large language model to obtain the second target large language model, so that the second target large language model has a vertical domain large language model of knowledge related to the mutual translation method between the source manufacturer and the target manufacturer of the router to be converted, and based on the second target large language model and the translation mapping relationship, translate the original configuration file into a target format configuration file corresponding to the router of the target manufacturer, so that the original configuration file can be scalably converted into a format corresponding to the router of the target manufacturer with high precision and minimal manual intervention.
[0047] In an embodiment of the present application, after translating the source configuration template into the target configuration template based on the target large language model, it also includes: obtaining an initial translation result of the source configuration template into the target configuration template; identifying errors in the initial translation result, and training a second target large language model based on the errors and the configuration manual, wherein the trained second target large language model outputs the final target configuration template, and iteratively corrects errors during the training process until a preset number of iterations is reached or a correct translation result is generated.
[0049] The preset number of iterations may be set according to specific circumstances and is not specifically limited thereto, for example, it may be 8 or 10 times.
[0050] The error type includes at least one of a syntax error, a view structure error, and a semantic error.
[0051] Since there may be some errors in the initial translation, the embodiment of the present application can obtain the initial translation result of the source configuration template into the target configuration template, and train the second target large language model based on the errors in the initial translation result and the configuration manual. The trained second target large language model outputs the final target configuration template, and iterates and corrects errors during the training process until a preset number of iterations is reached or a correct translation result is generated.
[0052] In the embodiment of the present application, identifying errors in the initial translation result includes: using a preset parser to identify grammatical errors and view structure errors.
[0053] Among them, the preset parser is a modified Batfish parser, which can be used to identify syntax errors and view structure errors. The Batfish parser is generated based on the unified syntax rules of the target manufacturer. Specifically, the corresponding g4 syntax file can be written according to the unified syntax rules specified by the target manufacturer, and the syntax parser and lexical parser can be generated by using ANTLR according to the g4 syntax file; then, the syntax tree corresponding to the configuration file is generated by inputting the configuration file into the parser, and the errors in the process of constructing the syntax tree are identified by extending the generated listener in the process, and the errors are classified into syntax errors and view structure errors according to the error type.
[0054] In an embodiment of the present application, the error is iteratively corrected until a preset number of iterations is reached or a correct translation result is generated, including: if the error is a grammatical error, the corresponding chapter in the configuration manual that solves the erroneous grammar is determined according to the erroneous grammar, and the erroneous grammar is corrected according to the correction method of the corresponding chapter; if the error is a view structure error, the erroneous part and the corresponding chapter are determined according to the erroneous view structure, and a configuration example is extracted from the corresponding chapter, and the erroneous view structure is corrected according to the configuration example, wherein the configuration example and the erroneous part run the same protocol and have a correct view structure; if the error is a semantic error, a first semantic is generated for each source fragment in the source configuration template based on a large language model, and a second semantic is generated for the target configuration template, and the erroneous semantic is corrected according to the similarity between the first semantic and the second semantic.
[0055] Among them, syntax errors include: commands in the configuration template do not comply with the syntax rules specified by the target manufacturer, such as incorrect parameter names, incorrect parameter order, etc.; view structure errors refer to situations where the position or order of certain commands in the configuration does not comply with the rules set by the manufacturer, such as the command to configure BGP (Border Gateway Protocol) neighbors appears before the command to enable the BGP protocol, which is considered a view structure error; semantic errors refer to the mismatch in function or intent between the source configuration template and the translated target configuration template, such as there is a BGP neighbor relationship between AS A and AS B in the source configuration, while the neighbor relationship between AS A and AS B is missing or incorrectly configured in the translated target configuration template.
[0056] It is understandable that the embodiments of the present application can use different methods to correct the error according to the type of error, specifically:
[0057] If the error type is a syntax error, then determine the corresponding section in the configuration manual for resolving the incorrect syntax according to the incorrect syntax, and correct the incorrect syntax according to the correction method in the corresponding section;
[0058] If the error type is a view structure error, the error part and the corresponding chapter are determined according to the erroneous view structure, a configuration example is extracted from the corresponding chapter, and the erroneous view structure is corrected according to the configuration example, wherein the configuration example and the erroneous part run the same protocol and have a correct view structure;
[0059] If the error type is a semantic error, a first semantic is generated for each source segment in the source configuration template based on the large language model, and a second semantic is generated for the translated target configuration template, and the erroneous semantic is corrected according to the similarity between the first semantic and the second semantic.
[0060] In summary, the routing configuration translation method based on the large language model in the embodiment of the present application has the following specific process: Figure 2 As shown, including:
[0061] 1. Configuration template extraction
[0062] Considering the challenges that ChatGPT faces when processing large amounts of text, we first let ChatGPT segment the configuration according to the original configuration file structure to aggregate configurations with strong similarity. Then, these fragments are gradually input into ChatGPT, so that it can synthesize the source configuration template from different fragments according to the structure of the fragment configuration, so that the template contains all the configuration commands and corresponding structures that can represent the characteristics of the fragment. Finally, this process can successfully output a source configuration template that accurately encapsulates all the features present in the original configuration file.
[0063] 2. Configuration template translation
[0064] Correct template configuration translation is achieved through two main steps: (1) using expert knowledge (i.e., configuration manual) for initial configuration translation; and (2) using accurate feedback information for error correction.
[0065] 2.1 Initial Configuration Translation
[0066] According to the configuration manual of the target manufacturer provided by the user, ChatGPT is used to translate the configuration template. First, the configuration manual provided by the user is parsed to extract the directory and the contents of each chapter. Then, the directory and original configuration of the manual are provided to ChatGPT, and a prompt is given, "If I want to translate Huawei's configuration into the corresponding Cisco configuration, please help me determine which parts of the manual I need", so that ChatGPT can provide the relevant chapter names. Finally, the content of the relevant chapters is extracted from the parsed configuration manual and provided to ChatGPT, with a prompt, "Please study the content in this configuration manual and translate the previously provided Huawei configuration into the corresponding Cisco configuration." In this way, the preliminary results after the source configuration template is translated into the target configuration template can be obtained using accurate expert knowledge (the content of the relevant chapters).
[0067] 2.2 Error Iteration Correction
[0068] The initial translation results may contain some errors. The accuracy of the results is ensured by correcting the errors and providing precise feedback information for each error. All errors in the translation process are divided into three types: syntax errors, view structure errors, and semantic errors. In order to identify the error type, the Batfish parser is modified to distinguish between syntax errors and view structure errors.
[0069] Syntax Error: Syntax error means that the command in the configuration file does not conform to the syntax rules specified by the target vendor, such as incorrect parameter name, incorrect parameter order, etc. The translated configuration is input into the modified Batfish parser to identify such errors, and the modified Batfish parser can accurately determine which line contains the syntax error. For each syntax error, ChatGPT is again used to determine the manual chapter that may help to resolve this error. Finally, the content of the corresponding chapter is extracted and fed back to ChatGPT together with the error information. Based on the precise error location and the accurate correction method provided by the specific manual chapter, ChatGPT can effectively correct these syntax errors.
[0070] View structure error: A view structure error refers to a situation where the position or order of certain commands in the configuration does not conform to the rules established by the manufacturer. For example, if the command to configure a BGP neighbor appears before the command to enable the BGP protocol, it is considered a view structure error. By inputting the translated configuration into the modified Batfish parser, it is possible to identify which part of the configuration contains a view structure error. Then, based on the functions and protocols related to the erroneous part, ChatGPT is requested to extract configuration examples from the relevant chapters. The configuration examples extracted from the manual run the same protocol as the erroneous part and have the correct view structure. Therefore, this example can be fed back to ChatGPT to enable it to correct the error. By leveraging accurate error type information and correct view structure examples, ChatGPT can significantly correct view structure errors in translated configurations.
[0071] Semantic Errors: Semantic errors refer to a mismatch in functionality or intent between the original configuration and the translated configuration. For example, there is a BGP neighbor relationship between AS A and AS B in the original configuration, but the neighbor relationship between AS A and AS B is missing or misconfigured in the translated configuration. To resolve such errors, ChatGPT is first provided with the original configuration template, allowing ChatGPT to generate semantics for each fragment in the configuration. The semantics of each source fragment is saved, and then ChatGPT is used to generate the semantics of the translated target configuration. Subsequently, ChatGPT is allowed to correct the translated configuration by comparing the semantic similarity between the original configuration segment and the translated configuration segment. With its powerful language processing capabilities, when there is a semantic difference between the two fragments, ChatGPT can usually correct the translated configuration based on the semantics provided by the source configuration fragment.
[0072] The above error correction process is iterated continuously until a correct translation configuration is generated or the number of iterations reaches a threshold, at which point it is returned to the operator for further processing. In practice, most of the time, a basically correct translation configuration can be obtained through a small number of iterations.
[0073] 3. Full configuration translation
[0074] Given that the configuration template can cover all key aspects of the original configuration file, the mapping relationship between the source configuration template and the translated configuration template can be used to effectively guide the translation of other parts of the configuration file. In this process, the source configuration template, the translated configuration template, and the original configuration file are provided to ChatGPT, and a prompt is given to "Please understand the translation mapping relationship between the original configuration template and the translated configuration template, and use it as a reference to translate the original configuration file." In this way, the configuration file can be scalably converted to the target vendor's format with high accuracy and minimal manual intervention.
[0075] The above embodiment first extracts the template configuration from the configuration provided by the user, and then performs an initial translation based on expert knowledge (configuration manual). Subsequently, iterative corrections are made based on accurate information feedback of different errors until the correct translation template configuration is generated. Ultimately, this translated template configuration is used to guide the translation of other similar components in the configuration using ChatGPT to ensure scalability, and effectively ensure the accuracy of the translation configuration through template-based translation and accurate error information feedback.
[0076] The following is a specific example to illustrate the routing configuration translation method based on a large language model of the present application, and the real configuration data from the FITI network is used to evaluate the accuracy and efficiency of the configuration conversion method. The configuration consists of configurations from 80 Huawei routers, each of which runs ISIS, BGP, and EVPN protocols. There are two roles in the network: border routers and core routers. Each border router has an average of 130,000 lines of configuration, while each core router has an average of 1,000 lines of configuration. In this experiment, Huawei's configuration was chosen to be converted into Cisco IOS configuration. There are significant differences in the command syntax and view structure between the two, and the Cisco IOS configuration manual was used as expert knowledge input.
[0077] 1. Configuration template translation
[0078] Configuration templates are extracted from routers of two different roles. After processing, the border router configuration template has about 300 lines, while the core configuration template has about 200 lines. Then, the main focus of the evaluation is on the performance of the method in translating configuration templates.
[0079] The translation mainly targets three types of configurations that appear in network configuration: BGP, ISIS, and EVPN. In BGP configuration, this includes regular BGP, IPv4 family, IPv6 family, and VRF configuration. ISIS configuration includes basic ISIS configuration, IPv4 family, IPv6 family, and VRF-related ISIS configuration. EVPN configuration involves basic EVPN settings (such as EVPN instance configuration and VPN instance configuration) and related BGP settings.
[0080] As shown in Table 1, Table 1 is a statistical table of BGP configuration translation. For the BGP configuration translation part, after five iterations of correction, the accuracy of the translated configuration increased from 44% to 97%. However, it is worth mentioning that due to the differences between the two vendors, the complete accuracy of the translated configuration cannot be guaranteed. For example, in practice, the lack of the "fake-as" command in Cisco leads to incorrect translation of this part.
[0081] Table 1
[0082]
[0083] As shown in Table 2, Table 2 is a table of mutual translation results of ISIS configuration. Similarly, after five iterations of correction, the accuracy of the translated Cisco ISIS configuration reached 80%.
[0084] Table 2
[0085]
[0086] As shown in Table 3, Table 3 is the translation result table of EVPN configuration. The translation result of EVPN configuration is worse than BGP and ISIS. After five iterations of correction, the accuracy rate is only 83%. This is due to the significant differences in the EVPN protocol between Huawei and Cisco NXOS, as well as the instability of the large language generation model, which leads to errors in the final result. These errors need to be corrected by the network operator in subsequent steps.
[0087] Table 3
[0088]
[0089] 2. Full configuration translation
[0090] After obtaining the translation configuration template, the corresponding relationship in the template is used to guide the complete configuration translation. The most common errors in this process are identified as: (1) structural errors in the view; (2) command syntax errors; (3) redundant commands. These errors are all present in the translated configuration file in a structured form. By using the translated configuration template to guide ChatGPT to correct the translation results, the correct result can be obtained after an average of 2 iterations of correction.
[0091] In addition, it is worth mentioning that the effectiveness of the translation is affected by the configuration manual provided by the user for guidance. The limitations of the configuration manual will have an impact on the experimental results. In addition, preliminary experiments were conducted to port Huawei configurations to the more common Cisco IOS, and it was found that for common protocols such as BGP and ISIS, an average of two iterations were corrected to achieve an accuracy of 90%. In addition, each router has unique configuration commands specific to each series of routers. These configurations may not be universally applicable, so translation for practical applications may require more efforts from network administrators.
[0092] This application is based on a large language model to solve the problem of configuration translation between different manufacturers, and proposes a new configuration translation method: extracting configuration templates according to feature slicing, and then translating the configuration templates. This method effectively solves the problem of decreased accuracy of large language models when processing large-scale configurations, and proposes a method for classifying errors that occur in the configuration translation process: grammatical errors, view structure errors, and semantic errors, and proposes corresponding correction methods for each type of error.
[0093] According to the routing configuration translation method based on a large language model proposed in an embodiment of the present application, a source configuration template of the original configuration file of the router to be converted is extracted using a large language model, and a configuration manual is used to train the large language model to obtain a target large language model, so that it has the vertical domain knowledge of the router configuration method of the target manufacturer, and the source configuration template is translated into a target configuration template based on the target large language model and the configuration manual, and then the original configuration file is translated into a target format configuration file corresponding to the router of the target manufacturer based on the target configuration template, and the configuration manual is used to guide the translation of the large language model to improve the accuracy of the large language model translation, and realize the translation of configuration files between routers of different manufacturers or different series of the same manufacturer, and the configuration template is translated first, and the translation of the entire original configuration file is guided based on the translated target configuration template, which effectively avoids the problem of decreased accuracy of the large language model when processing large-scale configurations.
[0094] Next, a routing configuration translation device based on a large language model proposed in accordance with an embodiment of the present application will be described with reference to the accompanying drawings.
[0095] Figure 3 It is a block diagram of a routing configuration translation device based on a large language model according to an embodiment of the present application.
[0096] like Figure 3 As shown, the routing configuration mutual translation device 10 based on the large language model includes: an acquisition module 100, an extraction module 200 and a mutual translation module 300.
[0097] Among them, the acquisition module 100 is used to obtain the original configuration file of the router to be converted and the configuration manual of the router of the target manufacturer; the extraction module 200 is used to extract the source configuration template of the original configuration file based on the large language model; the translation module 300 is used to train the large language model using the configuration manual to obtain a target large language model, translate the source configuration template into a target configuration template based on the target large language model, and translate the original configuration file into a target format configuration file corresponding to the router of the target manufacturer based on the target configuration template, wherein the target large language model has the vertical domain knowledge of the router configuration method of the target manufacturer.
[0098] In an embodiment of the present application, the mutual translation module 300 is further used to: obtain the directory of the configuration manual; input the source configuration template and the directory of the configuration manual into the target large language model, wherein the target large language model searches the directory of the configuration manual based on the source configuration template to obtain the target chapter; obtain the content of the target chapter; train the target large language model based on the content of the target chapter to obtain a first target large language model, wherein the first target large language model has vertical domain knowledge of the target configuration segment configuration method of the router of the target manufacturer; and translate the source configuration template into the target configuration template based on the first target large language model.
[0099] In an embodiment of the present application, the mutual translation module 300 is further used to: obtain a translation mapping relationship between a source configuration template and a target configuration template; use the translation mapping relationship to train a first target large language model to obtain a second target large language model, wherein the second target large language model has vertical domain knowledge of the mutual translation method between the source manufacturer and the target manufacturer of the router to be converted; based on the second target large language model and the translation mapping relationship, translate the original configuration file into a target format configuration file corresponding to the router of the target manufacturer.
[0100] In the embodiment of the present application, the device 10 of the embodiment of the present application further includes: a training module.
[0101] Among them, the training module is used to obtain the initial translation result of the source configuration template into the target configuration template after translating the source configuration template into the target configuration template based on the target large language model; identify errors in the initial translation result, and train the second target large language model based on the errors and the configuration manual, wherein the trained second target large language model outputs the final target configuration template, and iteratively corrects errors during the training process until a preset number of iterations is reached or a correct translation result is generated.
[0102] In an embodiment of the present application, the types of errors include at least one of grammatical errors, view structure errors and semantic errors, and the training module is further used to: use a preset parser to identify grammatical errors and view structure errors, wherein the preset parser is a Batfish parser, and the Batfish parser is generated based on the unified grammar rules of the target manufacturer.
[0103] In an embodiment of the present application, the training module is further used to: if the error is a grammatical error, determine the corresponding chapter in the configuration manual that solves the erroneous grammar according to the erroneous grammar, and correct the erroneous grammar according to the correction method of the corresponding chapter; if the error is a view structure error, determine the erroneous part and the corresponding chapter according to the erroneous view structure, extract a configuration example from the corresponding chapter, and correct the erroneous view structure according to the configuration example, wherein the configuration example and the erroneous part run the same protocol and have a correct view structure; if the error is a semantic error, generate a first semantic for each source fragment in the source configuration template based on the large language model, generate a second semantic for the target configuration template, and correct the erroneous semantics according to the similarity between the first semantics and the second semantics.
[0104] In the embodiment of the present application, the extraction module 200 is further used to: segment the original configuration file according to the structure of the original configuration file to obtain multiple fragments; synthesize a source configuration template according to the structure of the multiple fragment configurations, wherein the source configuration template encapsulates all the features in the original configuration file.
[0105] It should be noted that the above explanation of the embodiment of the method for mutual translation of routing configurations based on a large language model is also applicable to the apparatus for mutual translation of routing configurations based on a large language model in this embodiment, and will not be repeated here.
[0106] According to the routing configuration mutual translation device based on the large language model proposed in the embodiment of the present application, the large language model can be used to extract the source configuration template of the original configuration file of the router to be converted, and the large language model can be trained with the configuration manual to obtain the target large language model, so that it has the vertical domain knowledge of the router configuration method of the target manufacturer, and the source configuration template is translated into the target configuration template based on the target large language model and the configuration manual, and then the original configuration file is mutually translated into the target format configuration file corresponding to the router of the target manufacturer based on the target configuration template, and the configuration manual is used to guide the translation of the large language model to improve the accuracy of the large language model translation, so as to realize the mutual translation of configuration files between routers of different manufacturers or different series of the same manufacturer, and the configuration template is translated first, and the translation of the entire original configuration file is guided based on the translated target configuration template, which effectively avoids the problem of decreased accuracy of the large language model when processing large-scale configuration.
[0107] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may include:
[0108] Memory 401 , processor 402 , and a computer program stored in the memory 401 and executable on the processor 402 .
[0109] When the processor 402 executes the program, the routing configuration translation method based on the large language model provided in the above embodiment is implemented.
[0110] Furthermore, the electronic device further comprises:
[0111] The communication interface 403 is used for communication between the memory 401 and the processor 402 .
[0112] The memory 401 is used to store computer programs that can be executed on the processor 402 .
[0113] The memory 401 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0114] If the memory 401, the processor 402 and the communication interface 403 are implemented independently, the communication interface 403, the memory 401 and the processor 402 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0115] Optionally, in a specific implementation, if the memory 401, the processor 402 and the communication interface 403 are integrated on a chip, the memory 401, the processor 402 and the communication interface 403 can communicate with each other through an internal interface.
[0116] The processor 402 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.
[0117] The embodiment of the present application also provides a computer-readable storage medium on which a computer program or instruction is stored. When the computer program or instruction is executed by a processor, the routing configuration translation method based on a large language model as described above is implemented.
[0118] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0119] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0120] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or N executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0121] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above embodiment, the N steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one or a combination of multiple of the following technologies known in the art: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0122] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
Claims
1. A method for routing configuration translation based on a large language model, characterized in that: The following steps are involved: Obtain the original configuration file of the router to be converted and the configuration manual of the router of the target manufacturer; Extracting a source configuration template of the original configuration file based on a large language model; The large language model is trained using the configuration manual to obtain a target large language model, the source configuration template is translated into a target configuration template based on the target large language model, and the original configuration file is translated into a target format configuration file corresponding to the router of the target manufacturer based on the target configuration template, wherein the target large language model has vertical domain knowledge of the router configuration method of the target manufacturer.
2. The method for routing configuration translation based on a large language model according to claim 1, characterized in that: The translating the source configuration template into a target configuration template based on the target large language model includes: Obtain a directory of the configuration manual; Inputting the source configuration template and the directory of the configuration manual into the target large language model, wherein the target large language model searches the directory of the configuration manual based on the source configuration template to obtain a target chapter; Obtain the content of the target chapter; Training the target large language model based on the content of the target chapter to obtain a first target large language model, wherein the first target large language model has vertical domain knowledge of a target configuration segment configuration method of a router of the target manufacturer; The source configuration template is translated into a target configuration template based on the first target large language model.
3. The method for routing configuration translation based on a large language model according to claim 2, characterized in that: The translating the original configuration file into a target format configuration file corresponding to the router of the target manufacturer based on the target configuration template includes: Obtaining a translation mapping relationship between the source configuration template and the target configuration template; The first target large language model is trained by using the translation mapping relationship to obtain a second target large language model, wherein the second target large language model has vertical domain knowledge of the mutual translation method between the source manufacturer and the target manufacturer of the router to be converted; The original configuration file is translated into a target format configuration file corresponding to the router of the target manufacturer based on the second target large language model and the translation mapping relationship.
4. The method for routing configuration translation based on a large language model according to claim 3, characterized in that: After translating the source configuration template into a target configuration template based on the target large language model, the method further includes: Obtaining an initial translation result of the source configuration template into the target configuration template; Identify errors in the initial translation result, and train the second target large language model based on the errors and the configuration manual, wherein the trained second target large language model outputs a final target configuration template, and iteratively correct the errors during the training process until a preset number of iterations is reached or a correct translation result is generated.
5. The method for routing configuration translation based on a large language model according to claim 4, characterized in that: The type of the error includes at least one of a grammatical error, a view structure error, and a semantic error, and the identifying the error in the initial translation result includes: The grammatical errors and the view structure errors are identified using a preset parser, wherein the preset parser is a Batfish parser, and the Batfish parser is generated based on the unified grammar rules of the target manufacturer.
6. According to the method for routing configuration mutual translation based on a large language model in claim 4, the iterative correction of the error until a preset number of iterations is reached or a correct translation result is generated comprises: If the error is a syntax error, determining a corresponding section in the configuration manual that solves the syntax error according to the syntax error, and correcting the syntax error according to the correction method of the corresponding section; If the error is a view structure error, determine the error part and the corresponding chapter according to the erroneous view structure, extract a configuration example from the corresponding chapter, and correct the erroneous view structure according to the configuration example, wherein the configuration example and the erroneous part run the same protocol and have a correct view structure; If the error is a semantic error, a first semantic is generated for each source segment in the source configuration template based on the large language model, and a second semantic is generated for the target configuration template, and the erroneous semantic is corrected according to the similarity between the first semantic and the second semantic.
7. The method for routing configuration translation based on a large language model according to claim 1, characterized in that: The extracting the source configuration template of the original configuration file based on the large language model includes: Segmenting the original configuration file according to the structure of the original configuration file to obtain a plurality of segments; A source configuration template is synthesized according to the structure of the multiple fragment configurations, wherein the source configuration template encapsulates all features in the original configuration file.
8. A method for routing configuration translation based on a large language model, characterized in that: include: An acquisition module, used to acquire the original configuration file of the router to be converted and the configuration manual of the router of the target manufacturer; An extraction module, used for extracting a source configuration template of the original configuration file based on a large language model; A translation module is used to use the configuration manual to train the large language model to obtain a target large language model, translate the source configuration template into a target configuration template based on the target large language model, and translate the original configuration file into a target format configuration file corresponding to the router of the target manufacturer based on the target configuration template, wherein the target large language model has vertical domain knowledge of the router configuration method of the target manufacturer.
9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the routing configuration mutual translation method of a large language model as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: The computer program or instruction is executed by a processor to implement the routing configuration translation method of a large language model as described in any one of claims 1-7.
Citation Information
Patent Citations
Method and system for transiting router configuration
CN102420754A
Neural network hyper-parameter extracting and converting method, system and device and storage medium
CN107992299A
Authority configuration method and device for Kubernetes platform, computer equipment and storage medium
CN110020525A
Natural language intention translation method oriented to intention-driven data link network
CN117350286A
Cited By
A method and system for large-scale network configuration verification based on destination-independent compression
CN122783403A