Algorithm test method and device based on KG enhanced large language model
By building a multi-source heterogeneous knowledge graph and a large language model training architecture, combined with reinforcement learning algorithms, the problems of low AI model test generation ability and query accuracy are solved, dynamic testing and accurate query with high coverage are achieved, and the security and reliability of algorithms in high-risk fields are improved.
Patent Information
- Application Number
- CN202510548541.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-28
- Publication Date
- 2025-08-15
AI Technical Summary
The static test scenarios that rely on manual design in the existing technology cannot effectively simulate dynamic environmental disturbances and long-tail risks, resulting in poor generation capabilities of AI large-scale tests combined with knowledge graphs and low query accuracy.
Build a multi-source heterogeneous knowledge graph, combine the large language model training architecture, and use the knowledge graph and reinforcement learning algorithm to generate optimized query data sets, automatically generate high coverage test scenarios and improve query accuracy.
It realizes the test generation ability with high coverage in dynamic environments and the accuracy of knowledge graph query, and supports the iterative upgrade of security and reliability of algorithms in high-risk fields.
Smart Images

Figure CN120492571A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of knowledge graphs and natural language processing technologies, and in particular to an algorithm testing method and device for enhancing a large language model based on a knowledge graph (KG). Background Art
[0002] With the rapid development of artificial intelligence (AI) technology, particularly breakthroughs in complex decision-making simulation and knowledge reasoning with AI big models, the integration of AI big models with knowledge graphs (KGs) can more effectively improve the testing and evaluation efficiency of classic decision-making algorithms (such as game theory and reinforcement learning). KG-enhanced AI big models must not only be able to dynamically generate multi-dimensional test scenarios (such as resource competition, strategic games, and environmental perturbations), but also leverage the AI big model's natural language understanding and generation technology to automatically design high-coverage test cases to verify the robustness and generalization of the algorithm in complex dynamic environments. Furthermore, by integrating domain rules within the knowledge graph (such as financial compliance clauses and traffic regulations), a multi-dimensional evaluation system (performance, explainability, and ethical compliance) can be constructed to accurately identify algorithmic flaws and provide optimization recommendations. Therefore, integrating KG-based AI big model testing with an automated closed-loop testing process supports the iterative upgrade of decision-making algorithms in an efficient and scalable manner, which is crucial for ensuring the security and reliability of algorithms in high-risk domains such as autonomous driving and smart healthcare.
[0003] Currently, the testing of large AI models combined with KG relies on expert experience to design limited test scenarios (such as fixed game rules and preset environmental parameters), and manually adjust parameters to generate test cases to evaluate the performance of the algorithm under specific conditions. However, existing technologies rely on manually designed static use cases (such as fixed game rules and preset environmental parameters). The test scenarios are limited to the scope of expert experience and cannot simulate dynamic environmental disturbances (such as real-time competition for resources and sudden changes in opponent strategies) and long-tail risks (such as low-probability extreme events). This makes the test scenario coverage incomplete, resulting in poor test generation capabilities for large AI models combined with KG. Manually constructed data query templates may be difficult to cover all query types and semantic scenarios. For example, some complex nested queries, queries with aggregation operations, or joint queries involving multiple entity relationships may appear less frequently in the dataset, resulting in low query accuracy on the knowledge graph. Summary of the Invention
[0004] The purpose of the embodiments of the present invention is to provide an algorithm testing method and device based on a KG-enhanced large language model to solve the problems of poor test generation capability of the AI large model combined with KG and low query accuracy on the knowledge graph.
[0005] To solve the above technical problems, the embodiments of the present invention provide the following technical solutions:
[0006] A first aspect of the present invention provides an algorithm testing method based on a KG-enhanced large language model, comprising:
[0007] Build a knowledge graph based on multi-source heterogeneous domain rules and historical game scenario data;
[0008] Build a large language model training architecture, which includes a knowledge graph encoding layer, a large language model, and a knowledge graph integration layer connected in sequence;
[0009] Use the knowledge graph, pre-processed historical game scene data, and annotated text sets to train the large language model training architecture to obtain a trained large language model training architecture;
[0010] Based on the questions entered by the user, we use the trained large language model training architecture and reinforcement learning algorithm to determine the optimized query data set;
[0011] The knowledge graph is used to enhance the trained large language model training architecture to obtain an enhanced large language model training architecture;
[0012] Based on the question entered by the user, the knowledge graph is used to determine the prompt words of the large language model;
[0013] The user task and prompt word are input into the enhanced large language model training architecture to query the user task and prompt word using the optimized query dataset and generate an answer report.
[0014] A second aspect of the present invention provides an algorithm testing device based on a KG-enhanced large language model, comprising:
[0015] The first building module is used to build a knowledge graph based on multi-source heterogeneous domain rules and historical game scene data;
[0016] The second building block is used to build a large language model training architecture, which includes a knowledge graph encoding layer, a large language model, and a knowledge graph integration layer connected in sequence;
[0017] The training module is used to train the large language model training architecture using the knowledge graph, pre-processed historical game scene data, and annotated text sets to obtain a trained large language model training architecture;
[0018] The first determination module is used to determine the optimized query data set based on the question input by the user using the trained large language model training architecture and reinforcement learning algorithm;
[0019] The enhancement module is used to enhance the trained large language model training architecture using the knowledge graph to obtain an enhanced large language model training architecture;
[0020] The second determination module is used to determine the prompt word of the large language model based on the question input by the user using the knowledge graph;
[0021] The generation module is used to input user tasks and prompt words into the enhanced large language model training architecture to query the user tasks and prompt words using the optimized query dataset and generate an answer report.
[0022] Compared with the prior art, the present invention provides an algorithm testing method and device based on a KG-enhanced large language model, which constructs a knowledge graph based on multi-source heterogeneous domain rules and historical game scene data; constructs a large language model training architecture, which includes a knowledge graph encoding layer, a large language model, and a knowledge graph integration layer connected in sequence; uses the knowledge graph, pre-processed historical game scene data, and annotated text set to train the large language model training architecture to obtain a trained large language model training architecture; determines an optimized query data set based on the question input by the user using the trained large language model training architecture and a reinforcement learning algorithm; enhances the trained large language model training architecture using the knowledge graph to obtain an enhanced large language model training architecture; determines prompt words for the large language model based on the question input by the user using the knowledge graph; inputs the user task and prompt words into the enhanced large language model training architecture, and uses the optimized query data set to query the user task and prompt words to generate an answer report. In this way, since the large language model training architecture also introduces a knowledge graph encoding layer and a knowledge graph integration layer in addition to the large language model, and also uses the knowledge graph to train the large language model training architecture, the trained large language model training architecture can automatically generate high-coverage test scenarios and adapt to different testing requirements, so that the trained large language model training architecture has better test generation capabilities; using the trained large language model training architecture and reinforcement learning algorithm, the quality of the optimized query data set determined is higher, which makes the query accuracy of the knowledge graph higher. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0024] Figure 1 The flowchart of the algorithm testing method based on KG enhanced large language model is schematically shown;
[0025] Figure 2 The diagram schematically shows the large language model training architecture;
[0026] Figure 3 The structure diagram of the algorithm testing device based on the KG enhanced large language model is schematically shown. DETAILED DESCRIPTION
[0027] Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments described herein. Rather, these embodiments are provided to enable a more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art.
[0028] It should be noted that, unless otherwise specified, the technical or scientific terms used in the present invention should have the common meanings understood by those skilled in the art to which the present invention belongs.
[0029] The method in the embodiment of the present invention is described in detail below.
[0030] Figure 1 The flowchart of the algorithm testing method based on KG enhanced large language model in the embodiment of the present invention is schematically shown. Figure 1 As shown, the algorithm testing method based on the KG enhanced large language model may include:
[0031] S101. Build a knowledge graph based on multi-source heterogeneous domain rules and historical game scenario data.
[0032] Among them, multi-source heterogeneous domain rules include skill release safety rules, game environment dynamic constraint rules and output timeliness rules.
[0033] In game AI testing scenarios, the testing environment can be divided into stand-alone training mode and multiplayer battle mode. Stand-alone training requires support for skill release rule retrieval, operation path standardization verification, and training data visualization and analysis; multiplayer battles require capabilities such as dynamic enemy behavior prediction, team strategy collaborative optimization, and real-time battlefield environment evolution. Taking hero skill testing in a multiplayer online battle arena (MOBA) as an example, a typical scenario involves identifying eight types of skill effects (such as damage range, cooldown, and resource consumption) and executing 42 operational processes (such as combo sequence and positioning avoidance). Each operational process node contains 2-10 interactive operations, and all interactive operations must meet multi-source heterogeneous domain rules, namely, skill release safety rules (such as avoiding accidental injury to teammates), dynamic game environment constraints (such as terrain obstruction), and output timeliness rules (such as skill connection intervals <0.5 seconds).
[0034] The constructed knowledge graph will cover multi-dimensional information such as scenario logic constraints, algorithm performance baselines, and ethical risk rules to ensure the comprehensiveness and adaptability of the test model.
[0035] The operation in step S101 can be considered the knowledge layer of the game AI testing scenario. The entire knowledge layer includes multi-source data fusion, ontology engineering, knowledge extraction and storage, and a dynamic evolution mechanism. The data sources for multi-source data fusion include: integrating the structured clauses of the "MOBA Game Character Skill Manual," public esports platform match replays, equipment attribute databases (including skill cooldowns / damage ranges), and player historical operation logs; balance rule injection: embedding the "Game Balance Design Guidelines" (such as hero power gradient control), teamwork and accidental injury prevention strategies (such as skill release friendly force protection mechanisms), and map resource refresh rules. The conceptual system constructed by ontology engineering: defining nine top-level concepts such as "skill release," "equipment attributes," and "map mechanics"; attribute modeling: adding game-specific parameters such as movement speed (±5% fluctuation), economic growth coefficient (levels 1-5), and skill combo interval (≤1.5 seconds) to the "jungle hero" entity; and rule constraints: establishing the spatiotemporal dependencies of task processes, such as the irreversible temporal sequence of "jungle clearing → river vision layout → teamfight support." Knowledge extraction and storage involves parsing unstructured text using a fine-tuned Bidirectional Encoder Representations from Transformers-Game (BERT-Game) model. Entity relationships are extracted from match reports to form SPO triples: (healing skill, recovery amount, ≥500 HP) (invisibility item, reduction probability, local reconnaissance effectiveness). A multidimensional attribute graph structure is constructed and implemented in a Neo4j database. The dynamic evolution mechanism is designed with a dual-channel update strategy: batch updates, which inject new game balance patches and other rule files monthly; and real-time updates, which receive skill cast delay data from players in battle via WebSocket and dynamically adjust the skill hit rate parameter.
[0036] The construction of the knowledge graph is a continuous iterative process. Hero selection, skills, and other aspects are constantly changing, requiring timely evaluation and improvement. The knowledge layer continuously refines the test logic and defect associations within the knowledge graph by leveraging multi-source, heterogeneous domain rules and historical game scenario data.
[0037] S102. Build a large language model training architecture.
[0038] Among them, the large language model training architecture includes a knowledge graph encoding layer, a large language model, and a knowledge graph integration layer connected in sequence.
[0039] Figure 2 The schematic diagram of the large language model training architecture is shown schematically. Figure 2The large language model shown includes an embedding layer, a multi-head attention layer, a first normalization layer, a bitwise feedforward network layer, and a second normalization layer, all connected in sequence. The embedding layer is connected to the knowledge graph encoding layer, and the second normalization layer is connected to the knowledge graph fusion layer. The bitwise feedforward network layer includes an input layer, a first linear transformation layer, an activation function layer, a second linear transformation layer, and an output layer, all connected in sequence.
[0040] Specifically, the knowledge graph encoding layer is used to use the graph neural network to convert the knowledge graph into a vector representation to obtain a knowledge graph vector.
[0041] The knowledge graph fusion layer is used to fuse the knowledge graph vector and the data output by the second normalization layer to obtain fused data. The data output by the second normalization layer is the data obtained by passing the knowledge graph vector through the embedding layer, multi-head attention layer, first normalization layer, bit-by-bit feedforward network layer and second normalization layer in sequence.
[0042] The multi-head attention layer can calculate the attention distribution of multiple "heads" in parallel, and can capture the relationship between elements in the sequence from different representation subspaces, thereby understanding the sequence information more comprehensively and meticulously.
[0043] The first linear transformation layer, activation function layer, and second linear transformation layer in a bitwise feedforward network can be called hidden layers. Information in a bitwise feedforward network flows unidirectionally, from the input layer through the hidden layer to the output layer. There are no reverse connections, and there are no cross-layer or intra-layer connections between neurons. The activation function layer can use ReLU and Sigmoid functions.
[0044] The bit-by-bit feedforward network layer includes an input layer, a first linear transformation layer, an activation function layer, a second linear transformation layer, and an output layer that are connected in sequence.
[0045] The large language model training architecture can improve the accuracy of subsequent answer reports and knowledge reasoning capabilities, helping to implement an intelligent testing engine that can automatically generate high-coverage test scenarios (such as dynamic resource competition and incomplete information games).
[0046] S103. Use the knowledge graph, pre-processed historical game scene data and annotated text set to train the large language model training architecture to obtain a trained large language model training architecture.
[0047] The annotated text set is a text set that is annotated with key tactical tags (such as "successful case of four-one split push strategy" and "analysis of wrong decision-making in dragon group").
[0048] Specifically, before training the large language model training architecture using the knowledge graph, pre-processed historical game scene data, and annotated text set to obtain a trained large language model training architecture, the method further includes:
[0049] Step A1: Obtain historical game scene data.
[0050] Step A2: normalize the historical game scene data to obtain normalized historical game scene data.
[0051] Step A3: performing data patching processing on the normalized historical game scene data to obtain patched historical game scene data.
[0052] Step A4: Perform data embedding processing on the patched historical game scene data to obtain pre-processed historical game scene data.
[0053] Normalize historical game scene data to ensure that the trained large language model training architecture can better learn and represent the semantic information in sentences.
[0054] Patching is the process of repairing missing or abnormal normalized historical game scene data (such as interpolating to fill missing values of environmental parameters). Patching reduces the complexity of the data, facilitates subsequent processing and analysis, and can also better capture the local characteristics of the data.
[0055] Data embedding processing can convert discrete patched historical game scene data into continuous vector representation, so that the patched historical game scene data can be better processed and understood by computers in a low-dimensional space.
[0056] Steps A1 through A4 above can be considered preprocessing operations, and the processing operations can be considered the data layer. The data layer is primarily used to acquire and preprocess historical game scenario data. The data layer also includes test input data, namely test case configurations (such as resource allocation rules and opponent strategy parameters); test execution data, namely method execution logs (such as performance metrics and decision path records); and historical test results, namely defect type statistics and optimization suggestion records.
[0057] The knowledge graph, pre-processed historical game scene data and annotated text set are used as training samples.
[0058] The cross-loss entropy function is used in the training architecture of the large language model. The expression of the cross-loss entropy function is:
[0059]
[0060] Among them, loss is the loss value of the cross loss entropy function, L is the total number of training samples, l is the lth training sample, K is the number of categories, k is the kth category, is the true label of the lth training sample belonging to the kth category, To predict the probability that the lth training sample belongs to the kth category.
[0061] S104. Based on the question input by the user, an optimized query data set is determined using the trained large language model training architecture and reinforcement learning algorithm.
[0062] Specifically, based on the user's input question, we use the trained large language model training architecture and reinforcement learning algorithm to determine the optimized query data set, including:
[0063] Step B1: Use the trained large language model training architecture as the generator.
[0064] Step B2: Use the generator to generate query statements based on the question input by the user.
[0065] The query statement is a Cypher query statement.
[0066] Step B3: Optimize the query statement using a reinforcement learning algorithm to obtain an optimized query data set.
[0067] Step B3 includes:
[0068] Step B31: Using the loss function of the reinforcement learning algorithm, the current generation strategy is compared with the query statement to obtain the current loss value.
[0069] The current generation strategy is a strategy that includes language model parameters, mapping parameters, and context parameters.
[0070] Step B32: Feedback the current loss value to the generator, and use the generator and the current loss value to modify the language model parameters, mapping parameters and context parameters in the current generation strategy to obtain multiple modified parameter values.
[0071] The multiple modified parameter values include modified language model parameters, modified mapping parameters and modified context parameters.
[0072] Step B33: Generate the current query statement using multiple modified parameter values, replace the query statement with the current query statement, return the loss function using the reinforcement learning algorithm, compare the current generation strategy with the query statement, and obtain the current loss value. When the current loss value is lower than the preset value, stop the return operation and obtain the optimized query data set.
[0073] The default value range is 0-1.
[0074] A large, trained language model training architecture, driven by a reinforcement learning algorithm, automatically generates a large number of Cypher queries. After each generated Cypher query, the reinforcement learning algorithm uses dynamic interactive feedback to comprehensively calculate multi-dimensional rewards and feeds them back to the trained language model training architecture. This gradually optimizes the conversion strategy from user questions to Cypher queries, improving the semantic accuracy and execution efficiency of queries while ensuring grammatical compliance. By continuously screening high-quality Cypher queries for review and converting incorrect Cypher queries into adversarial training examples, this closed-loop iteration of "generate-verify-optimize" ultimately accumulates a precise and reliable optimized query dataset, improving the efficiency and accuracy of knowledge graph queries and providing a more optimized query dataset for subsequent enhancements to the large language model training architecture.
[0075] S105. Use the knowledge graph to enhance the trained large language model training architecture to obtain an enhanced large language model training architecture.
[0076] Knowledge graphs can significantly improve the performance of large language models. At the knowledge reserve level, they can fill blind spots and integrate fragmented knowledge, allowing large language models to acquire professional content and grasp knowledge logic; in reasoning, they can provide logical guidance and assist complex reasoning, making the conclusions they produce more accurate and reliable; they can also reduce hallucinations, ensure that the output is in line with reality through factual basis and scope constraints; enhance interpretability, facilitate tracing knowledge sources and displaying reasoning paths; help large language models quickly adapt to multi-domain tasks and optimize domain language understanding; and assist in training, optimize data, guide training goals, and comprehensively consolidate the capabilities of large language models.
[0077] After the knowledge graph receives the question input by the user, it provides a question-answering knowledge base for the trained large language model training architecture through the subgraph retrieval strategy to enhance the trained large language model training architecture and obtain an enhanced large language model training architecture.
[0078] S106. Based on the question input by the user, the knowledge graph is used to determine the prompt words of the large language model.
[0079] Specifically, based on the question entered by the user, the knowledge graph is used to determine the prompt words of the large language model, including:
[0080] Step C1: Use the knowledge graph to query the question entered by the user and obtain the query results.
[0081] Step C2: Use the query results and the question input by the user as prompt words for the large language model.
[0082] Steps S102, S103, and S106 can be considered the model layer. The model layer determines the trained large language model training architecture and the prompt words for the large language model. The model layer also performs multi-dimensional testing, including performance testing, robustness testing, interpretability analysis testing, ethical compliance testing, and defect location and attribution testing.
[0083] S107: Input the user task and prompt word into the enhanced large language model training architecture to query the user task and prompt word using the optimized query data set to generate an answer report.
[0084] Specifically, the user task and prompt word are input into the enhanced large language model training architecture, which uses the optimized query dataset to query the user task and prompt word and generate an answer report, including:
[0085] Step D1: Generate a new user task based on the user task and prompt words.
[0086] Step D2: Input the new user task into the enhanced large language model training architecture to query the new user task using the optimized query dataset and generate an answer report.
[0087] The answer report can be presented as a visual chart.
[0088] Step S107 is regarded as an application layer, and an answer report can be generated using the application layer.
[0089] The answer report generation efficiency, defect detection rate and optimization guidance capabilities can be verified on the simulation platform and real data sets.
[0090] The present invention integrates multi-source heterogeneous domain rules and historical game scene data to construct a knowledge graph that can cover key information such as scenario logic constraints, algorithm performance baselines, and ethical risk rules; this knowledge graph will serve as the reasoning basis for the AI large model, providing structured knowledge support and dynamic scenario generation capabilities. The present invention constructs an optimized query data set through a reinforcement learning algorithm, and realizes the automated construction of a high-quality data set through dynamic interactive generation and screening. The present invention utilizes an enhanced large language model training architecture to dynamically generate high-pressure test scenarios, and associates answer reports with optimization suggestions (such as adjusting strategy parameters and repairing logical conflicts) based on the knowledge graph to improve the iterative efficiency and reliability of the algorithm. The method of the present invention is integrated into the algorithm development platform to support algorithm security verification in high-risk fields such as autonomous driving and smart healthcare, while formulating test processes and evaluation index standards to promote the credibility and large-scale application of AI decision-making systems.
[0091] Based on the above Figure 1It can be seen from the implementation method that the embodiment of the present invention constructs a knowledge graph based on multi-source heterogeneous domain rules and historical game scene data; constructs a large language model training architecture, which includes a knowledge graph encoding layer, a large language model and a knowledge graph integration layer connected in sequence; uses the knowledge graph, preprocessed historical game scene data and annotated text set to train the large language model training architecture to obtain a trained large language model training architecture; according to the question input by the user, the trained large language model training architecture and the reinforcement learning algorithm are used to determine the optimized query data set; the trained large language model training architecture is enhanced by using the knowledge graph to obtain an enhanced large language model training architecture; according to the question input by the user, the prompt word of the large language model is determined by using the knowledge graph; the user task and prompt word are input into the enhanced large language model training architecture to query the user task and prompt word using the optimized query data set to generate an answer report. In this way, since the large language model training architecture also introduces a knowledge graph encoding layer and a knowledge graph integration layer in addition to the large language model, and also uses the knowledge graph to train the large language model training architecture, the trained large language model training architecture can automatically generate high-coverage test scenarios and adapt to different testing requirements, so that the trained large language model training architecture has better test generation capabilities; using the trained large language model training architecture and reinforcement learning algorithm, the quality of the optimized query data set determined is higher, which makes the query accuracy of the knowledge graph higher.
[0092] Based on the same inventive concept, as an implementation of the above-mentioned algorithm testing method based on KG-enhanced large language model, an embodiment of the present invention also provides an algorithm testing device based on KG-enhanced large language model. Figure 3 This is a structural diagram of the algorithm testing device based on the KG enhanced large language model in an embodiment of the present invention, see Figure 3 As shown, the algorithm testing device based on the KG enhanced large language model may include:
[0093] The first construction module 301 is used to construct a knowledge graph based on multi-source heterogeneous domain rules and historical game scene data;
[0094] The second construction module 302 is used to construct a large language model training architecture, which includes a knowledge graph encoding layer, a large language model, and a knowledge graph integration layer connected in sequence;
[0095] A training module 303 is configured to train the large language model training architecture using the knowledge graph, pre-processed historical game scene data, and annotated text set to obtain a trained large language model training architecture;
[0096] A first determination module 304 is configured to determine an optimized query data set based on the question input by the user using the trained large language model training architecture and reinforcement learning algorithm;
[0097] An enhancement module 305 is configured to enhance the trained large language model training architecture using the knowledge graph to obtain an enhanced large language model training architecture;
[0098] The second determination module 306 is used to determine the prompt word of the large language model using the knowledge graph according to the question input by the user;
[0099] The generation module 307 is used to input the user task and the prompt word into the enhanced large language model training architecture to query the user task and the prompt word using the optimized query data set and generate an answer report.
[0100] The second construction module 302 is a knowledge graph encoding layer, which is used to use a graph neural network to convert the knowledge graph into a vector representation to obtain a knowledge graph vector; the knowledge graph fusion layer is used to fuse the knowledge graph vector and the data output by the second normalization layer to obtain fused data. The data output by the second normalization layer is the data obtained by passing the knowledge graph vector through the embedding layer, the multi-head attention layer, the first normalization layer, the bit-by-bit feedforward network layer and the second normalization layer in sequence.
[0101] The device may also include: a preprocessing module, which is used to obtain historical game scene data before training the large language model training architecture using the knowledge graph, preprocessed historical game scene data and annotated text set to obtain the trained large language model training architecture; normalize the historical game scene data to obtain normalized historical game scene data; perform data patching on the normalized historical game scene data to obtain patched historical game scene data; perform data embedding on the patched historical game scene data to obtain preprocessed historical game scene data.
[0102] The first determination module 304 is specifically configured to use the trained large language model training architecture as a generator; use the generator to generate a query statement from the question input by the user; and use a reinforcement learning algorithm to optimize the query statement to obtain an optimized query data set.
[0103] The first determination module 304 optimizes the query statement using a reinforcement learning algorithm to obtain an optimized query data set, including: using the loss function of the reinforcement learning algorithm to compare the current generation strategy with the query statement to obtain a current loss value, where the current generation strategy is a strategy that includes language model parameters, mapping parameters, and context parameters; feeding the current loss value back to the generator, and using the generator and the current loss value to modify the language model parameters, mapping parameters, and context parameters in the current generation strategy to obtain multiple modified parameter values, where the multiple modified parameter values include modified language model parameters, modified mapping parameters, and modified context parameters; generating the current query statement using the multiple modified parameter values, replacing the query statement with the current query statement, returning to the step of using the loss function of the reinforcement learning algorithm to compare the current generation strategy with the query statement to obtain the current loss value, and stopping the return operation until the current loss value is lower than the preset value to obtain an optimized query data set.
[0104] The second determination module 306 is specifically used to use the knowledge graph to query the question input by the user to obtain the query result; and use the query result and the question input by the user as prompt words of the large language model.
[0105] The generation module 307 is specifically used to generate a new user task based on the user task and the prompt word; input the new user task into the enhanced large language model training architecture to query the new user task using the optimized query data set and generate an answer report.
[0106] It should be noted that the above description of the embodiment of the algorithm testing apparatus based on a KG-enhanced large language model is similar to the description of the embodiment of the algorithm testing method based on a KG-enhanced large language model, and has similar beneficial effects as the embodiment of the algorithm testing method based on a KG-enhanced large language model. For any technical details not disclosed in the embodiment of the algorithm testing apparatus based on a KG-enhanced large language model of the present invention, please refer to the description of the embodiment of the algorithm testing method based on a KG-enhanced large language model of the present invention for understanding.
[0107] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.
Claims
1. An algorithm testing method based on KG-enhanced large language model, characterized in that: include: Build a knowledge graph based on multi-source heterogeneous domain rules and historical game scenario data; Constructing a large language model training architecture, wherein the large language model training architecture includes a knowledge graph encoding layer, a large language model, and a knowledge graph integration layer connected in sequence; Using the knowledge graph, the pre-processed historical game scene data, and the annotated text set, the large language model training architecture is trained to obtain a trained large language model training architecture; Determine an optimized query dataset based on the question input by the user using the trained large language model training architecture and reinforcement learning algorithm; Using the knowledge graph to enhance the trained large language model training architecture to obtain an enhanced large language model training architecture; Determining prompt words of the large language model using the knowledge graph according to the question input by the user; The user task and the prompt word are input into the enhanced large language model training architecture to query the user task and the prompt word using the optimized query data set to generate an answer report.
2. The algorithm testing method based on KG-enhanced large language model according to claim 1, characterized in that: The large language model includes an embedding layer, a multi-head attention layer, a first normalization layer, a bit-by-bit feedforward network layer and a second normalization layer connected in sequence. The embedding layer is connected to the knowledge graph encoding layer, and the second normalization layer is connected to the knowledge graph fusion layer; the bit-by-bit feedforward network layer includes an input layer, a first linear transformation layer, an activation function layer, a second linear transformation layer and an output layer connected in sequence.
3. The algorithm testing method based on KG-enhanced large language model according to claim 2, characterized in that: The knowledge graph encoding layer is used to convert the knowledge graph into a vector representation using a graph neural network to obtain a knowledge graph vector; The knowledge graph fusion layer is used to fuse the knowledge graph vector and the data output by the second normalization layer to obtain fused data. The data output by the second normalization layer is the data obtained by passing the knowledge graph vector through the embedding layer, the multi-head attention layer, the first normalization layer, the bit-by-bit feedforward network layer and the second normalization layer in sequence.
4. The algorithm testing method based on KG-enhanced large language model according to claim 1, characterized in that: Before training the large language model training framework using the knowledge graph, pre-processed historical game scene data, and annotated text set to obtain a trained large language model training framework, the method further includes: Get historical game scene data; Normalizing the historical game scene data to obtain normalized historical game scene data; Performing data patching processing on the normalized historical game scene data to obtain patched historical game scene data; Data embedding processing is performed on the patched historical game scene data to obtain the pre-processed historical game scene data.
5. The algorithm testing method based on KG enhanced large language model according to claim 1 is characterized in that: Determining an optimized query data set based on the question input by the user using the trained large language model training architecture and reinforcement learning algorithm includes: Using the trained large language model training architecture as a generator; Using the generator, generating a query statement from the question input by the user; The query statement is optimized using the reinforcement learning algorithm to obtain the optimized query data set.
6. The algorithm testing method based on KG-enhanced large language model according to claim 5, characterized in that: The step of optimizing the query statement using the reinforcement learning algorithm to obtain the optimized query data set includes: Using the loss function of the reinforcement learning algorithm, a current generation strategy is compared with the query statement to obtain a current loss value, wherein the current generation strategy is a strategy including language model parameters, mapping parameters, and context parameters; Feeding the current loss value back to the generator, and using the generator and the current loss value to modify the language model parameters, the mapping parameters, and the context parameters in the current generation strategy to obtain a plurality of modified parameter values, wherein the plurality of modified parameter values include modified language model parameters, modified mapping parameters, and modified context parameters; The method further comprises the steps of generating a current query statement using the multiple modified parameter values, replacing the query statement with the current query statement, returning the loss function using the reinforcement learning algorithm, comparing the current generation strategy with the query statement, and obtaining a current loss value, and stopping the return operation until the current loss value is lower than a preset value to obtain the optimized query data set.
7. The algorithm testing method based on KG-enhanced large language model according to claim 1, characterized in that: Determining the prompt words of the large language model using the knowledge graph according to the question input by the user includes: Utilizing the knowledge graph to query the question input by the user and obtain query results; The query result and the question input by the user are used as prompt words of the large language model.
8. The algorithm testing method based on KG-enhanced large language model according to claim 1, characterized in that: Inputting the user task and the prompt word into the enhanced large language model training architecture, querying the user task and the prompt word using the optimized query dataset, and generating an answer report, includes: Generate a new user task according to the user task and the prompt word; The new user task is input into the enhanced large language model training architecture to query the new user task using the optimized query data set to generate the answer report.
9. The algorithm testing method based on KG-enhanced large language model according to claim 7, characterized in that: The multi-source heterogeneous domain rules include skill release safety rules, game environment dynamic constraint rules and output timeliness rules.
10. An algorithm testing device based on KG-enhanced large language model, characterized in that: include: The first building module is used to build a knowledge graph based on multi-source heterogeneous domain rules and historical game scene data; The second construction module is used to construct a large language model training architecture, which includes a knowledge graph encoding layer, a large language model, and a knowledge graph integration layer connected in sequence; A training module, configured to train the large language model training framework using the knowledge graph, pre-processed historical game scene data, and annotated text set to obtain a trained large language model training framework; A first determination module is configured to determine an optimized query data set based on a question input by a user using the trained large language model training architecture and a reinforcement learning algorithm; An enhancement module, configured to enhance the trained large language model training architecture using the knowledge graph to obtain an enhanced large language model training architecture; A second determination module is configured to determine a prompt word of the large language model using the knowledge graph according to the question input by the user; A generation module is used to input the user task and the prompt word into the enhanced large language model training architecture, so as to query the user task and the prompt word using the optimized query data set and generate an answer report.
Citation Information
Cited By
LLM-based sample enhancement and network iterative training method, apparatus and device
CN121599131A
Seed-metering device design method based on artificial large model
CN121683114A