Competition question automatic rewriting and correction method based on structured semantic verification
By rewriting and correcting competition questions using structured semantic verification, the problems of incomplete rewriting, unreasonable semantic logic, and insufficient quality assessment in existing technologies are solved. This achieves high-quality automated question rewriting and correction, improving the logical consistency and scenario rationality of the questions.
Patent Information
- Application Number
- CN202611118705.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-27
- Publication Date
- 2026-11-06
AI Technical Summary
Existing methods for rewriting competition questions suffer from problems such as incomplete rewriting, unreasonable semantic logic, inconsistent expression of attributes and relationships, and lack of automatic quality assessment mechanisms, resulting in poor rewriting effects and difficulty in guaranteeing quality.
A structured semantic verification-based approach is adopted. The competition problem statement is parsed using a large language model to generate a logic graph and a scene relationship graph. Similar logic graphs are retrieved using a dual-graph database for scene transfer. The rewritten problem statement is automatically checked and corrected through a set of structured verification questions to ensure that the algorithm logic and the standard answer remain unchanged.
It improves the logical consistency, scenario rationality, and understandability of the rewritten competition questions, realizes automated quality checks and corrections, and enhances the stability and diversity of question rewriting.
Smart Images

Figure CN123050359A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of text generation based on large language models, and particularly relates to a method for automatically rewriting and correcting competition questions based on structured semantic verification. Background Technology
[0002] Programming competitions are an important part of computer science education and algorithm research, and are widely used in online evaluation systems, programming instruction, and algorithm training. A problem statement describes the problem context, input / output requirements, constraints, and solution objectives, serving as a crucial link between the problem designer and the solver.
[0003] In recent years, with the rapid development of large language model technology, automatic generation and automatic rewriting techniques have gradually become important research directions in the field of natural language processing. In the field of programming competitions, existing research has utilized large language models to automatically generate new algorithm problems based on existing problems, or to generate new problems with different algorithmic structures while maintaining some constraints, in order to expand the problem set and training data. However, such research mainly focuses on innovation and changes at the algorithmic logic level, and its goal is usually to generate new problems rather than rewriting the description and background of existing problem statements.
[0004] For problem rewriting tasks in competitions, the goal is to reconstruct the background scenario, entities, narrative style, and expression of the problem while maintaining the original algorithm logic, input / output format, and standard answer, thereby generating a new problem description. This type of method can not only be used for data augmentation and problem bank expansion, but also prevent users from directly associating the problem with its background, improving the diversity and subtlety of problem rewriting. Furthermore, problem rewriting can provide technical support for programming education, intelligent problem generation, and the construction of algorithm problem banks, thus possessing high research and application value.
[0005] Currently, research on rewriting competition problem statements is relatively limited. Most existing methods directly rewrite the original problem statement using large language models, guiding the model to generate new background stories and scene descriptions through prompts. Due to the lack of systematic constraints and quality control mechanisms, these methods typically suffer from the following problems:
[0006] (1) Incomplete rewriting. Although the model has modified some entity names or background stories, it still retains a large number of expressions and narrative structures from the original question, making it easy for users to associate the rewritten question with the original question, thus reducing the effectiveness of the rewriting.
[0007] (2) Unreasonable semantic logic. During the scene transfer process, the model may generate descriptions that do not conform to common sense or the scene setting. For example, it may directly map behaviors in the real world to entities that are not suitable for performing the behaviors, or generate operations that do not match the attributes of the entities, thus leading to difficulties in understanding the question or even logical errors.
[0008] (3) Inconsistent expression of attributes and relationships. The model may introduce new entity attributes, relationship definitions or constraints during the rewriting process, but this is not clearly stated in the question; or different expressions are used for the same attribute and relationship in the context, which leads to ambiguity in the understanding of the question.
[0009] (4) Lack of an automatic quality assessment mechanism. Existing methods usually rely on manual review to judge the quality of the questions, which not only consumes a lot of time and manpower, but is also difficult to apply to large-scale automated question rewriting scenarios.
[0010] Therefore, how to automatically perform quality checks on the rewritten problem statements while keeping the original algorithm logic and standard answer unchanged, to discover semantic errors, logical conflicts and inconsistencies in expression, and to further complete automatic corrections, has become a pressing technical problem to be solved in the field of automatic rewriting of competition problem statements. Summary of the Invention
[0011] The technical problem this invention aims to solve is to achieve high-quality automatic rewriting of competition problem statements while maintaining the original algorithm logic, input / output format, and standard answer. This involves automatically identifying and correcting semantic inconsistencies that arise during the rewriting process, thereby improving the logical consistency, scenario rationality, and understandability of the rewritten problem statements. To this end, this invention proposes an automatic rewriting and correction method for competition problem statements based on structured semantic verification.
[0012] To achieve the above-mentioned objectives, the present invention specifically adopts the following technical solution:
[0013] In a first aspect, the present invention provides a method for automatically rewriting and correcting competition problem statements based on structured semantic verification, comprising the following steps:
[0014] S1. Obtain the original competition problem statement to be rewritten, wherein the original competition problem statement is the text description corresponding to the calculation problem to be solved; perform structured semantic parsing on the original competition problem statement based on the large language model, extract key semantic information from the background description of the original competition problem statement, and generate an original logical graph containing a set of nodes and a set of edges;
[0015] S2. Obtain a pre-built dual-graph database. Each piece of data stored in the dual-graph database contains a candidate logic graph and a scene relationship graph corresponding to the same candidate competition question. The scene relationship graph is used to provide background reference for rewriting the original competition question.
[0016] S3. Using a graph similarity retrieval method based on structure-semantic joint modeling, multiple candidate logical graphs that are similar to the original logical graph in structure and semantics are retrieved in the dual-graph database as reference logical graphs, and the scene relationship graph corresponding to the reference logical graph is used as the reference scene graph;
[0017] S4. By prompting engineering constraints, the large language model, while keeping the original algorithm logic, input and output format, solution objective and standard answer of the calculation problem unchanged, firstly, based on the original competition problem statement, the original logic diagram and the reference scenario diagram, generates a new scenario diagram as the rewritten scenario diagram. Then, based on the original competition problem statement, the original logic diagram and the rewritten scenario diagram, generates a new competition problem statement corresponding to the rewritten scenario diagram as the rewritten competition problem statement.
[0018] S5. For the rewritten competition problem statement, the large language model first generates a set of structured verification questions consisting of multiple verification questions, then answers each verification question to obtain the corresponding answer results, and then judges whether there are defects in the rewritten competition problem statement based on the answer results. If there are no defects, the rewritten competition problem statement is directly output. If there are defects, the large language model corrects the rewritten competition problem statement, and finally outputs the corrected competition problem statement without defects.
[0019] Based on the above scheme, each step can be implemented in the following preferred manner.
[0020] As a preferred embodiment of the first aspect above, in step S1, the node set includes four types of nodes: variable nodes, resource nodes, constraint nodes, and conceptual semantic nodes, with each node representing a semantic entity; the edges in the edge set are used to represent the logical relationships between nodes.
[0021] As a preferred embodiment of the first aspect above, the variable node is used to represent the input variables extracted from the original competition problem statement; the resource node is used to represent the quantifiable resource objects in the original competition problem statement; the constraint node is used to represent the rules, restrictions, and judgment conditions that must be satisfied during the execution of the algorithm, and the algorithm is used to solve the computational problem; the conceptual semantic node is used to represent the solution objective, key events, and algorithm termination conditions of the original competition problem statement.
[0022] As a preferred embodiment of the first aspect mentioned above, in step S2, the original competition question in S1 is replaced with a candidate competition question, a candidate logic graph is generated according to the method in S1, and then the candidate competition question is input into a large language model for structured semantic parsing to extract the background information of the candidate competition question and generate a scene relationship graph corresponding to the candidate logic graph. The scene relationship graph uses people, places, objects, and events as nodes and the relationships between nodes as edges.
[0023] As a preferred embodiment of the first aspect mentioned above, in step S3, the process of retrieving candidate logical graphs using the graph similarity retrieval method based on structure-semantic joint modeling is as follows:
[0024] S31. Concatenate the node attributes and edge attributes in the original logic graph into a text string, concatenate the node attributes and edge attributes in the candidate logic graph into another text string, take the text string of a candidate logic graph as a document, take the text strings of all candidate logic graphs as a corpus, use TF-IDF to vectorize the text strings of all candidate logic graphs and the text string of the original logic graph, calculate the cosine similarity between the original logic graph and each candidate logic graph, and take the cosine similarity calculation result as the semantic similarity score of the candidate logic graph.
[0025] S32. The Jaccard similarity calculation result between the set corresponding to the original logic graph and the set corresponding to the candidate logic graph is used as the structural similarity score of the candidate logic graph; wherein, the two sets contain the same content, both consisting of logical association type, relationship strength, node degree, two-hop path, and the number of nodes corresponding to each node type.
[0026] S33. The semantic similarity score and the structural similarity score are weighted and summed to calculate the comprehensive similarity score of the candidate logic graphs. The top-K candidate logic graphs with the highest comprehensive similarity scores are used as reference logic graphs, and the scene relationship graphs corresponding to the reference logic graphs are read from the dual-graph database; where K is the number of candidate logic graphs retrieved.
[0027] As a preferred embodiment of the first aspect mentioned above, the specific process of step S5 is as follows:
[0028] S51. Input the rewritten competition problem statement into the large language model. With the prompts for engineering constraints, the large language model automatically analyzes the entity information, entity attributes, entity relationships, constraints and solution objectives involved in the rewritten competition problem statement and constructs a set of structured verification questions.
[0029] S52. Input the rewritten competition problem statement and the set of structured validation questions into the large language model. For each validation question, the large language model gives the corresponding answer based on the existing description in the rewritten competition problem statement.
[0030] S53. The large language model analyzes the answer results item by item to determine the logical errors, semantic conflicts, missing definitions, inconsistent relationships, and / or ambiguities in the rewritten competition questions.
[0031] S54. When there are no defects, the large language model directly outputs the rewritten competition problem statement; when there are defects, the large language model outputs a judgment result containing a description of the defect content and a description of the cause of the defect, and, while keeping the original algorithm logic, input and output format, solution objective and standard answer of the calculation problem unchanged, the large language model corrects the defects in the rewritten competition problem statement based on the judgment result, and generates a corrected competition problem statement.
[0032] S55. Replace the rewritten competition problem with the revised competition problem, and repeat S52~S54 until the revised competition problem is free of defects.
[0033] As a preferred embodiment of the first aspect above, in step S51, the verification problems in the set of structured verification problems include:
[0034] Entity-related verification issues are used to verify whether the entities in the rewritten competition problem statement are clearly defined and conform to the setting of the rewritten scenario diagram.
[0035] Attribute-related validation issues are used to verify whether the entity attributes in the rewritten competition problem statement are consistent with the original competition problem statement.
[0036] Relationship-related validation problems are used to verify whether the entity relationships in the rewritten competition problem statement are correctly expressed.
[0037] Constraint-related verification problems are used to verify whether the constraints in the rewritten competition problem statement are complete and unambiguous.
[0038] Goal-related verification questions are used to verify whether the solution objective in the rewritten competition problem statement is clearly expressed.
[0039] In a second aspect, the present invention provides a computer program product, including a computer program / instruction, which, when executed by a processor, can realize the automatic rewriting and correction method for competition questions based on structured semantic verification as described in any of the solutions in the first aspect above.
[0040] Thirdly, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the automatic rewriting and correction method for competition questions based on structured semantic verification as described in any of the solutions in the first aspect above.
[0041] Fourthly, the present invention provides a computer electronic device, which includes a memory and a processor;
[0042] The memory is used to store computer programs;
[0043] The processor is configured to, when executing the computer program, implement the automatic rewriting and correction method for competition questions based on structured semantic verification as described in any of the solutions in the first aspect above.
[0044] Compared with the prior art, the present invention has the following advantages:
[0045] Compared to traditional methods that directly use prompts to rewrite competition problems, the method of this invention introduces a logical graph structured modeling mechanism, which can explicitly represent the core algorithm logic, constraints, and solution objectives in the competition problem. This effectively reduces the risk of algorithm logic deviation during the rewriting process and improves the stability and consistency of the problem rewriting results.
[0046] This invention further constructs a dual-graph database and uses retrieval technology to obtain reference logic graphs that are similar to the original problem's logical structure and semantics. By using reference scenario graphs to guide the rewriting process of the competition problem, semantic transfer from the original scenario to the new scenario is achieved, avoiding the direct generation of free scenarios by large language models and improving the richness and diversity of scenario rewriting.
[0047] Furthermore, this invention proposes a problem-driven inspection mechanism based on structured semantic verification, which can more reliably detect logical errors, semantic conflicts, and inconsistencies in competition problem statements, enabling automatic defect location and analysis. Further combined with an issue-driven targeted correction mechanism, it achieves automatic optimization of competition problem statement quality, thereby improving the overall quality and automation level of automatic problem statement rewriting. Attached Figure Description
[0048] Figure 1 This is an overall framework diagram of the method of the present invention;
[0049] Figure 2 This is a flowchart illustrating the image retrieval stage.
[0050] Figure 3 This is a schematic diagram of a computer electronic device provided by the present invention. Detailed Implementation
[0051] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of the present invention. However, the present invention can be practiced in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below. Technical features in the various embodiments of the present invention can be combined accordingly without mutual conflict.
[0052] In the description of this invention, it should be understood that the terms "first" and "second" are used only for descriptive purposes and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined with "first" and "second" may explicitly or implicitly include at least one of those features.
[0053] like Figure 1 As shown, in a preferred embodiment of the present invention, the above-mentioned method for automatically rewriting and correcting competition questions based on structured semantic verification includes the following steps S1 to S5. The specific implementation process of each step will be described in detail below.
[0054] S1. Obtain the original competition problem statement to be rewritten, wherein the original competition problem statement is the text description corresponding to the computation problem to be solved; perform structured semantic parsing on the original competition problem statement based on the large language model, extract key semantic information from the background description of the original competition problem statement, and generate an original logic graph containing a set of nodes and a set of edges.
[0055] It should be noted that in step S1 of this invention, the node set includes four types of nodes: variable nodes, resource nodes, constraint nodes, and conceptual semantic nodes. Each node is used to represent a semantic entity. The edges in the edge set are used to represent the logical relationships between nodes.
[0056] In step S1 of this embodiment, a programming competition problem statement is used as the input object. This problem statement can come from a public algorithm competition platform, such as Codeforces, AtCoder, CodeChef, POJ, HDU, and other online evaluation systems. The input content mainly includes the background description of the original competition problem statement, the task requirements, and the core logical information related to the solution objective of the original competition problem statement. Since traditional competition problem statements usually contain a large amount of natural language content such as scene descriptions, story backgrounds, character settings, and example descriptions, and this content is not necessary for algorithm solution, this embodiment first uses a large language model to perform structured semantic parsing on the original competition problem statement, retaining only the information directly related to the algorithm logic.
[0057] Specifically, this embodiment designs a logic graph extraction prompt template (PromptTemplate) for original competition problem statements. By prompting the engineering constraint large language model, it extracts only the entities and their logical relationships necessary for the solution process. To improve the consistency of structural representation across different competition problem statements, this embodiment uniformly classifies all entities into four predefined categories:
[0058] VARIABLE node: Used to represent input variables extracted from the original competition problem statement;
[0059] Resource node RESOURCE: Used to represent quantifiable resource objects in the original competition problem statement;
[0060] CONSTRAINT: Used to represent the rules, restrictions, and judgment conditions that must be met during the execution of the algorithm, which is used to solve the computational problem;
[0061] CONCEPT (Conceptual Semantic Node): Used to represent the solution objective, key events, and algorithm termination conditions of the original competition problem statement.
[0062] In the above description, quantifiable resource objects refer to entities that have quantitative attributes and can be traversed or allocated for consumption during the algorithm's solution process. Rules that must be satisfied during algorithm execution refer to the legality conditions and operational prerequisites that the algorithm's operations must follow, such as state transition rules or preconditions for operations. Constraints that must be satisfied during algorithm execution refer to hard numerical constraints on variable values or operation results, such as inequality constraints or equality constraints. Judgment conditions that must be satisfied during algorithm execution refer to branch decision conditions used to determine the range of affected data or select the execution path, such as determining the set of subtree nodes by a specified node. The solution objective of the original competition problem refers to the final computational result that the algorithm needs to achieve, i.e., the objective function or decision result in the optimization problem, such as the minimum number of segments or the number of shortest paths. Key events in the original competition problem refer to the core decision and processing nodes that trigger specific logic, state transitions, or operation execution during algorithm execution, such as the level traversal and counting of the shortest path. Algorithm termination conditions refer to the conditions under which the algorithm stops execution and returns a result, such as the completion of all node traversals or all operation processing.
[0063] Furthermore, each entity in this embodiment includes three fields: Entity Name, Entity Type, and Entity Description. The entity name uses semantic English phrases to avoid using single letters or difficult-to-understand abbreviations, thereby improving the interpretability and stability of the graph structure representation.
[0064] After entity extraction, this embodiment further analyzes the logical relationships between entities and constructs directed edges. These logical relationships include computational dependencies, condition-triggered relationships, rule-constrained relationships, and state-change relationships. For each edge, this embodiment records information such as the source entity, target entity, relationship description, and relationship strength. Relationship strength characterizes the degree of logical association between two entities, with a value ranging from 1 to 10.
[0065] Through the above process, the original competition problem statement can be converted into a unified structured representation of the original logic graph. This logic graph is essentially a semantic graph structure oriented towards algorithmic logic. It is stored in JSON format and can effectively describe the logical entities and their dependencies in the competition problem statement. It also removes background information and retains only the core logic required for the algorithm to solve the problem. This allows the subsequent scenario rewriting process to be carried out while keeping the original solution logic of the algorithm unchanged, thus providing a unified intermediate representation for subsequent graph retrieval, scenario migration, and problem statement generation.
[0066] S2. Obtain a pre-built dual-graph database. Each piece of data stored in the dual-graph database contains a candidate logic graph and a scene graph corresponding to the same candidate competition problem. The scene graph is used to provide background reference for rewriting the original competition problem.
[0067] It should be noted that in step S2 of this invention, the original competition question in S1 is replaced with a candidate competition question, a candidate logic graph is generated according to the method in S1, and then the candidate competition question is input into a large language model for structured semantic parsing to extract the background information of the candidate competition question and generate a scene relationship graph corresponding to the candidate logic graph. The scene relationship graph uses people, places, objects and events as nodes and the relationship between nodes as edges.
[0068] In step S2 of this embodiment, to achieve scene transfer and diversified rewriting of competition problem statements, a dual-graph database is further constructed. The candidate competition problem statement materials in this database are crawled from the VJudge platform, whose original source is the Codeforces algorithm competition platform. Simultaneously, this embodiment collects existing rewritten competition problem statements from VJudge as a supplement, and after rigorous screening, eliminates a large number of low-quality rewritten competition problem statements, ultimately retaining those with reference value. These screened rewritten competition problem statements, while maintaining the original algorithm logic, introduce new backgrounds and narrative methods, thus possessing high reference value for rewriting the original competition problem statements.
[0069] After obtaining these candidate competition questions, this embodiment further automatically generates candidate logic graphs and scene relationship graphs based on a large language model, and the candidate logic graphs and scene relationship graphs are... Figure 1One-to-one correspondence. It's worth noting that in this embodiment, the candidate logic diagram and the scene relationship diagram each serve different functions. The candidate logic diagram primarily describes the algorithmic logic structure of the candidate competition problem, including the logical relationships between variables, resources, constraints, and the solution objective; it focuses on "what the problem is asking for." The scene relationship diagram primarily describes the background semantic information of the candidate competition problem, including scene elements such as people, places, objects, and events, as well as the relationships between these scene elements; it focuses on "what story the problem tells." For example, for the same algorithm, the candidate competition problem might be described as: "A farmer counts the number of cows," while the rewritten competition problem might be described as: "A warehouse manager counts the number of goods." Although the backgrounds are completely different, their candidate logic diagrams may remain highly consistent, while their scene relationship diagrams will show significant differences.
[0070] Once the candidate logic graph and scene relationship graph are generated, these two graphs, along with the corresponding candidate competition problem statements, are stored together in a dual-graph database in a structured record format. By simultaneously storing the logic graph and scene graph, decoupled representation of algorithm logic and background scene can be achieved, providing a foundation for subsequent scene migration. The larger the scale of the dual-graph database, the more competition problem statement types, scene types, and narrative styles it can cover, providing richer references for subsequent scene migration and rewriting of original competition problem statements, thus improving the diversity and rationality of problem statement rewriting. For each piece of data in the dual-graph database, this embodiment establishes the following structured record:
[0071] { Original Statement, Logic Graph, Scene Graph}
[0072] Wherein: Original Statement represents a candidate competition problem statement; Logic Graph represents a candidate logic graph; Scene Graph represents a scene relationship graph; both the candidate logic graph and the scene relationship graph correspond to the candidate competition problem statement.
[0073] S3. Using a graph similarity retrieval method based on structure-semantic joint modeling, multiple candidate logical graphs that are similar to the original logical graph in structure and semantics are retrieved in the dual-graph database as reference logical graphs, and the scene relationship graph corresponding to the reference logical graph is used as the reference scene graph.
[0074] It should be noted that in step S3 of this invention, traditional problem retrieval methods typically rely on keyword matching or text semantic similarity for searching. However, for programming competition problems, different problems may employ completely different background scenarios and narrative styles, yet their underlying algorithmic logic structures are highly consistent. For example, one problem might be described as "the pattern deletion problem in an animal queue," while another might be described as "the continuous segment elimination problem in string editing." Although their textual expressions differ significantly, their solution logic may correspond to the same data structure and algorithmic model. Therefore, relying solely on text similarity is insufficient to accurately identify reference competition problems with similar logical structures. To address this issue, this invention employs a graph similarity retrieval method based on structure-semantic joint modeling. Using the original logic graph as the retrieval object, it calculates the similarity of candidate logic graphs in a dual-graph database by comprehensively analyzing textual features.
[0075] It should be noted that in step S3 of this invention, as Figure 2 As shown, the process of retrieving candidate logical graphs using the graph similarity retrieval method based on structure-semantic joint modeling is as follows:
[0076] S31. Concatenate the node attributes and edge attributes in the original logic graph into a text string, and concatenate the node attributes and edge attributes in the candidate logic graph into another text string. Use the text string of one candidate logic graph as a document, and use the text strings of all candidate logic graphs as a corpus. Use TF-IDF (Term Frequency-Inverse Document Frequency) to vectorize the text strings of all candidate logic graphs and the text string of the original logic graph to calculate the cosine similarity between the original logic graph and each candidate logic graph. Use the cosine similarity calculation result as the semantic similarity score of the candidate logic graph.
[0077] S32. The Jaccard similarity calculation result between the set corresponding to the original logic graph and the set corresponding to the candidate logic graph is used as the structural similarity score of the candidate logic graph; wherein, the two sets contain the same content, both consisting of logical association type, relationship strength, node degree, two-hop path, and the number of nodes corresponding to each node type.
[0078] In step S32 of this embodiment, a two-hop path refers to a path in a graph structure that starts from one node, passes through exactly two edges, and reaches another node. This is commonly referred to in the art as a 2-hop path, which is used to describe the indirect connectivity between nodes in the graph that spans an intermediate node.
[0079] S33. The semantic similarity score and the structural similarity score are weighted and summed to calculate the comprehensive similarity score of the candidate logic graphs. The top-K candidate logic graphs with the highest comprehensive similarity scores are used as reference logic graphs, and the scene relationship graphs corresponding to the reference logic graphs are read from the dual-graph database; where K is the number of candidate logic graphs retrieved.
[0080] In step S33 of this embodiment, since the reference scene graph is derived from a candidate logic graph that is similar to the original logic graph in terms of semantics and structure, its scene relationship graph can provide a reasonable background reference for the subsequent scene migration process while maintaining the consistency of the algorithm logic.
[0081] S4. By prompting engineering constraints, the large language model, while keeping the original algorithm logic, input and output format, solution objective and standard answer unchanged, first generates a new scenario diagram based on the original competition problem statement, the original logic diagram and the reference scenario diagram, and uses it as the rewritten scenario diagram. Then, based on the original competition problem statement, the original logic diagram and the rewritten scenario diagram, it generates a new competition problem statement corresponding to the rewritten scenario diagram and uses it as the rewritten competition problem statement.
[0082] It should be noted that in step S4 of this embodiment, the scene relationship graphs corresponding to the Top-3 candidate logic graphs with the highest similarity are selected as the reference scene graph set. Multiple reference scene graphs serve as a source of scene knowledge to improve the richness and diversity of scene generation and avoid scene duplication or excessive rewriting traces caused by a single reference scene. At the same time, the original competition problem corresponding to the original logic graph is loaded. The large language model extracts the input and output formats, data ranges, and sample descriptions from the original competition problem as a constraint context to maintain interface compatibility in the subsequent generation process. In this embodiment, the original logic graph is regarded as an unmodifiable logical skeleton. Its number of nodes, node types, edge connections, and logical dependency structures remain unchanged during the rewriting process. Only the node names, node semantic descriptions, and edge relationship descriptions are allowed to be reconstructed in a scene-based manner.
[0083] Before generating a new scene graph, this embodiment constructs a scene semantic gene pool based on multiple reference scene graphs. First, it parses the scene entities and scene relationship information in the reference scene graph set. Since the entity names differ significantly across scene graphs, this embodiment does not directly reuse the original entity names. Instead, it uses a large language model to abstract and analyze the entities and relationships in multiple scene graphs, extracting scene semantic features and constructing a scene semantic gene pool. This pool covers dimensions such as quantifiable attribute semantics, individual entity semantics, group organizational structure semantics, spatial location relationship semantics, temporal sequence relationship semantics, resource flow semantics, competitive relationship semantics, collaborative relationship semantics, statistical target semantics, and event triggering semantics. For example, although "student grades" and "commodity prices" appear in multiple reference scenarios have different names, they can both be abstracted into "quantifiable numerical attribute" semantics. This invention utilizes such abstraction results to establish a semantic gene pool, providing a knowledge foundation for subsequent scene migration.
[0084] Subsequently, the semantic gene pool identifies the scene environments corresponding to multiple reference scene graphs, and selects one or more scenes with high semantic consistency as target scenes. After determining the target scenes, a scene vocabulary mapping relationship is established, mapping each logical node in the original logic graph to an entity concept in the corresponding scene. For example, nodes such as "input sequence" and "final statistical target" in the original logic graph can be mapped to scene-specific expressions such as "student queue" and "number of award winners" respectively, depending on the target scene.
[0085] After entity mapping is completed, the large language model regenerates node names, node descriptions, and edge descriptions based on the mapping results, constructing a new scene graph. Subsequently, structural consistency verification is performed to check whether the number of nodes, node types, and edge connections are consistent, and whether any logical constraints have been introduced or removed, or whether the input and output semantics have changed. If inconsistencies or logical deviations are detected, the scene mapping and graph generation process is repeated until a scene graph that meets the requirements is obtained, ultimately resulting in a structured foundation that combines the new scene semantics with the original algorithm logic.
[0086] In step S4 of this embodiment, the prompt words used when the large language model generates a new scene graph are as follows:
[0087] "You are a 'scene reconstructor' for an algorithm competition problem. Your task is to take the pure logical skeleton (logic diagram) of a problem as a 'fill-in-the-blank' template, inject new natural scene vocabulary extracted from scene diagrams of other problems, and thus generate a completely novel competition problem statement that can be solved by the original solution code without any modification."
[0088] You will receive the following: the original competition problem statement, the original logic graph (i.e., the skeleton diagram extracted from the algorithmic logic of the original problem), and a reference scenario graph, which are extracted from the complete statements of other competition problems. When generating a new scenario graph, the following constraints must be met: First, the node types remain unchanged; the four types of nodes are still mapped to the same type of entity in the new scenario graph. Second, the number of nodes, the number of edges, and the edge connections in the new scenario graph are completely consistent with the original logic graph. Third, the logical semantics remain unchanged; all dependencies, constraints, and triggering relationships represented by edges must not be added or deleted. Fourth, the input / output interfaces remain unchanged; the new scenario graph must be able to use the input / output format and data range of the original competition problem statement, ensuring that the original algorithm can correctly solve the rewritten competition problem statement without modification.
[0089] Your task is to generate a new scene graph with the following requirements: the new scene graph must have the exact same number of nodes, the same node types, and the same set of edges (source / target relationships) as the original logic graph.
[0090] Workflow steps:
[0091] Step 1: Read the original competition problem statement and extract the pure interface information (input format, output format, data range). List all nodes (numbered sequentially) and their types in the original logic graph, as well as all edges. Describe the algorithmic role of each node in pure computational language (completely stripping away the context). For each node in the original logic graph, distinguish two independent levels: (1) Algorithmic role: What the node does computationally; (2) Narrative role: What type of thing the node represents in the original story.
[0092] Step Two: Browse all reference scenario graphs. For each node and edge in each reference scenario graph, identify its underlying semantic pattern, assign it an abstract label, consider different specific implementations in other domains, and add the domain of the reference scenario graph to the semantic gene pool. The semantic gene pool needs to list all story backgrounds / domains that are explicitly present or can be reasonably inferred from all reference scenario graphs. These environments are the only legitimate source for your selection of new scenarios.
[0093] Step 3: Select an environment from the semantic gene pool, ensuring that the replacement environment belongs to a different category than the original question environment. Construct a mapping from semantic roles to specific words in the selected environment.
[0094] Step 4: Using the structure of the original logic graph as a template, rename and redescribe each node and edge using localized vocabulary to generate a new scene graph.
[0095] Step 5: Verify structural consistency: Does the number, type, and edge structure of the nodes in the new scene graph completely match the original logic graph? Verify environment compliance: Is the environment entirely derived from the semantic gene pool? Verify lexical naturalness: Does the new scene graph contain awkwardly copied vocabulary from the reference scene graph? Verify algorithm compatibility: Can each field be mapped back to the original problem without changing the solution code? If any check fails, backtrack and regenerate the scene graph.
[0096] It should be noted that after generating the rewritten scenario graph, this embodiment further utilizes a large language model to generate new competition problem statements. Specifically, this embodiment inputs the original competition problem statement, the original logic graph, and the rewritten scenario graph into the large language model. The original competition problem statement provides a complete description of the computation problem, input format, output format, sample data, and explanatory information; the original logic graph represents the original algorithmic logic structure of the computation problem; and the rewritten scenario graph describes the entity semantics, scenario relationships, and narrative concepts after scenario migration. During the generation of the new competition problem statement, the large language model first establishes a node mapping relationship between the original logic graph and the rewritten scenario graph. Since the rewritten scenario graph is obtained by completing scenario migration while maintaining the original logic graph structure, the two graphs have a one-to-one correspondence of node and edge relationships. Based on this mapping relationship, the large language model replaces the entity names, scenario objects, behavioral descriptions, and narrative semantics in the original competition problem statement with the corresponding scenario expressions in the rewritten scenario graph, while maintaining the logical dependencies between nodes. Furthermore, during the rewriting of the competition questions, the large language model must maintain the original question's computational objectives, input / output interfaces, constraints, and standard answers completely unchanged, only reconstructing the natural language expression of the questions. Specifically, this includes: (a) replacing the story background in the original question with the background description corresponding to the new scenario; (b) replacing the entity objects in the original question with the corresponding entities in the new scenario; (c) replacing the actions, events, and causal relationships in the original question with the corresponding semantic expressions in the new scenario; (d) replacing the optimization objectives, statistical objectives, or judgment objectives in the original question with objective descriptions that conform to the semantics of the new scenario; and (e) simultaneously adjusting the input descriptions, output descriptions, and supplementary descriptions in the original question to a consistent expression style with the new scenario.
[0097] Since the reference scene graph only provides scene reference information, some narrative relationships may not be explicitly represented in the graph structure. Therefore, this embodiment allows the large language model to automatically supplement necessary background descriptions, causal explanations, and transitional statements based on the entity relationships in the new scene graph, in order to enhance the readability and naturalness of the competition problem text and make the generated competition problem text conform to the expression habits of real competition problems. In order to ensure that the rewritten competition problem text is strictly equivalent to the original competition problem text at the algorithm level, this embodiment imposes the following constraints on the generation process: (a) The algorithm and solution objective corresponding to the original problem shall not be modified; (b) The format, order, and semantic meaning of the input data shall not be modified; (c) The calculation method and semantic meaning of the output results shall not be modified; (d) The actual meaning of the data range and constraints shall not be modified; (e) The sample input data and sample output data shall not be modified; (f) The rewritten competition problem text must ensure that the original algorithm can pass all test data without any modification. Under the premise of satisfying the above constraints, the large language model generates a complete rewritten competition question based on the scene semantics in the new scene graph, including the question description, input instructions, output instructions, sample data, and supplementary notes.
[0098] In step S4 of this embodiment, when the large language model generates a new competition question, the following prompt words are used:
[0099] "You are an algorithm competition problem rewriting expert. Your task is to rewrite a competition problem based on the original problem statement, the original logic diagram, and the rewriting scenario diagram. The algorithm logic must remain consistent before and after the rewrite. The original problem statement's code must remain unchanged and still correctly solve the new problem statement. Furthermore, the underlying mathematical meaning, actual input / output structure, meaning of constraints, sample input values, and sample output values must not be altered. The narrative setting, entities, motivations, terminology, causal explanations, and semantic interpretations of the problem statement must be rewritten."
[0100] The new problem statement must match the rewritten scenario diagram as closely as possible, although the rewritten scenario diagram may omit some natural language logic or causal explanations. You must intelligently fill in any missing narrative connections as necessary to make the final statement read naturally and logically consistent; do not mechanically rewrite the original problem statement. The rewritten problem statement should feel like a truly different problem story. The narrative of the rewritten problem statement must be logically consistent, and all operations, objectives, constraints, and optimization goals should have a natural explanation in the new problem statement. If necessary, rewrite the input / output descriptions and comments to maintain consistency with the new narrative terminology.
[0101] You should avoid: copying the original sentence structure, directly reusing the original causal explanation, using the same optimized wording, and simply making obvious object renamings.
[0102] The rewritten scenario diagram is the primary specification for rewriting the narrative and should be followed when choosing entities, terminology, motivations, and causal explanations. The rewritten scenario diagram is also the primary source of your scenario vocabulary—prioritize using terms from it rather than any terms appearing in the original statement. The original problem statement is only used to preserve algorithmic semantics and interface compatibility. Every node and relationship in the original logic diagram should be reflected in the rewritten statement, whether explicit or implicit. You can add narrative motivations, causal explanations, and contextual details to make the story natural and consistent. However, you must not introduce new algorithmic conditions, constraints, or decision points that are not present in the original logic diagram or the original problem statement. Minimize the reuse of entity types, role identities, and relationship terms from the original problem.
[0103] S5. For the rewritten competition problem statement, the large language model first generates a set of structured verification questions consisting of multiple verification questions, then answers each verification question to obtain the corresponding answer results, and then judges whether there are defects in the rewritten competition problem statement based on the answer results. If there are no defects, the rewritten competition problem statement is directly output. If there are defects, the large language model corrects the rewritten competition problem statement, and finally outputs the corrected competition problem statement without defects.
[0104] It should be noted that the specific process of step S5 of the present invention is as follows:
[0105] S51. Input the rewritten competition problem statement into the large language model. With the prompting of engineering constraints, the large language model automatically analyzes the entity information, entity attributes, entity relationships, constraints and solution objectives involved in the rewritten competition problem statement, and constructs a set of structured verification questions.
[0106] Furthermore, in step S51 of this embodiment, the verification problems in the set of structured verification problems include:
[0107] Entity-related verification issues are used to verify whether the entities in the rewritten competition problem statement are clearly defined and conform to the setting of the rewritten scenario diagram.
[0108] Attribute-related validation issues are used to verify whether the entity attributes in the rewritten competition problem statement are consistent with the original competition problem statement.
[0109] Relationship-related validation problems are used to verify whether the entity relationships in the rewritten competition problem statement are correctly expressed.
[0110] Constraint-related verification problems are used to verify whether the constraints in the rewritten competition problem statement are complete and unambiguous.
[0111] Goal-related verification questions are used to verify whether the solution objective in the rewritten competition problem statement is clearly expressed.
[0112] The generated verification questions are stored in a unified structured format, with each question containing the question content and corresponding question type information. Through this method, the present invention can transform competition questions in natural language form, which are originally difficult to verify directly, into a set of structured verification questions that can be automatically checked, providing a basis for subsequent quality verification of competition questions. Compared to methods that directly require a large language model to freely evaluate the entire competition question, the present invention adopts a verification question-driven semantic inspection mechanism, transforming the competition question quality evaluation process into a local verification process of multiple fine-grained semantic components, thereby reducing the uncertainty of model output and improving the stability, accuracy, and interpretability of question discovery.
[0113] S52. Input the rewritten competition problem statement and the set of structured validation questions into the large language model. For each validation question, the large language model gives the corresponding answer based on the existing description in the rewritten competition problem statement.
[0114] In step S52 of this embodiment, when the information corresponding to the verification question can be clearly found in the rewritten competition question, the large language model provides a specific answer. The answer result may be: the entity definition in the rewritten competition question is clear, the entity attributes are consistent with the original competition question, and the entity relationship is correctly expressed, etc. When the rewritten competition question lacks relevant descriptions, has unclear expressions, or cannot determine the answer, the corresponding verification question is marked as an abnormal question. Since all verification questions are directly derived from the entity, attribute, relationship, and constraint information in the rewritten competition question, the answer result can reflect the completeness and consistency of the rewritten competition question at the semantic expression level. For example, when an entity is used in the rewritten competition question but is not defined, the verification question related to that entity will not be clearly answered; when the relationship between two entities is contradictory in the rewritten competition question, the answer result of the corresponding verification question will also show inconsistency.
[0115] S53. The large language model analyzes the answer results item by item to determine the logical errors, semantic conflicts, missing definitions, inconsistent relationships, and / or ambiguities in the rewritten competition questions.
[0116] S54. When there are no defects, the large language model directly outputs the rewritten competition problem statement; when there are defects, the large language model outputs a judgment result containing a description of the defect content and a description of the cause of the defect, and, while keeping the original algorithm logic, input and output format, solution objective and standard answer of the calculation problem unchanged, the large language model corrects the defects in the rewritten competition problem statement based on the judgment result, and generates a corrected competition problem statement.
[0117] Specifically, in steps S53-S54 of this embodiment, the rewritten competition problem statement and the judgment result are used as input to guide the large language model to locally correct the defective entity attributes, entity relationships, constraints, or solution objectives in the rewritten competition problem statement based on the defects pointed out in the judgment result. This avoids unnecessary overall rewriting, improves the stability of the competition problem statement correction process, and obtains a competition problem statement that is semantically more complete and logically more consistent. For entity-related verification problems, the large language model adjusts the entity name, entity definition, and entity description to improve the rationality and understandability of the entity in the current scenario. For attribute-related verification problems, the large language model optimizes the entity attribute definition and entity attribute expression to ensure consistency between entity attributes and entities. For relationship-related verification problems, the large language model supplements or corrects entity relationships to enhance the completeness and interpretability of entity relationship expression. For constraint-related and goal-related verification problems, the large language model optimizes the constraints and solution objectives to ensure the consistency and completeness of the overall description of the rewritten competition problem statement.
[0118] In step S54 of this embodiment, the prompt words used by the large language model when correcting the competition problem statement are as follows:
[0119] "You are an algorithm competition problem-fixing agent. The current dialogue contains: 1. the original competition problem statement; 2. a previously generated competition problem statement. Your goal is to improve the narrative quality of the current competition problem statement, resolve any logical flaws, maintain complete computational equivalence, and finally output the fixed competition problem statement in JSON format. Provide the fix records as context—to continue improving upon existing fixes, not to undo them. The fixed competition problem statement must be computationally identical to the original competition problem statement in the following ways: 1. Same algorithm; 2. Same solution code; 3. Same input format; 4. Same output format; 5. Same constraints; 6. Same sample data. Furthermore, the original correct code of the original competition problem statement must be able to solve the fixed competition problem statement without any modification."
[0120] Apply the following repair strategies based on the defect type.
[0121] For entities whose definitions are unreasonable within the story world (entity_definition_unreasonable), the priority for fixing is: 1. Adjust the entity to fit the established settings naturally. 2. If the entity is indispensable, add at most one sentence of background information to justify its existence.
[0122] For the goal-unclear defect (goal_unclear), the fix is to add clear task terminology.
[0123] For output-goal mismatch defects where the output is inconsistent with the story motivation, the priority for remediation is: 1. Adjust the story motivation. 2. Adjust the wording of the output. If the mismatch is minor and unlikely to confuse the reader, skip it.
[0124] For an attribute undefined defect (where an attribute appears but is not explained), the remediation strategy is to check the complete input and constraint sections before adding a definition. If the attribute is already defined there, skip it—no remediation is needed. Otherwise, define the attribute where it first appears.
[0125] For an attribute that is used numerically but lacks numerical interpretation, the unquantifiable attribute defect is addressed by providing a simple, measurable definition.
[0126] For relationships between entities that are introduced but not supported, the unsupported relationship defect is addressed by adding a concise statement to solidify the relationship.
[0127] For constraint contradiction defects where two constraints conflict with each other, the remediation strategy is to modify the wording of the conflict while maintaining the computational meaning. The more stringent interpretation is preferred.
[0128] For constraint missing defects (lacking necessary restrictions or conditions), the repair strategy is to add the missing constraint in a concise statement, ensuring that the added constraint corresponds to the content already implicitly assumed by the original algorithm—do not create new constraints out of thin air.
[0129] For a reference ambiguity defect, the remediation strategy is to replace pronouns or vague references with explicit noun phrases.
[0130] S55. Replace the rewritten competition problem with the revised competition problem, and repeat S52~S54 until the revised competition problem is free of defects.
[0131] Specifically, in step S55 of this embodiment, the structured verification process consisting of S52-S54 is executed again on the corrected competition problem statement. Specifically, this embodiment generates verification questions again, answers the verification questions, determines whether defects exist, and corrects the defects, thereby forming a closed-loop optimization mechanism. During each iteration, this embodiment evaluates the semantic quality of the current competition problem statement and counts the defects found in the verification process. When the number of newly discovered defects is lower than a preset threshold, or the corrected competition problem statement meets the preset quality requirements, the iteration process terminates and the final competition problem statement is output. Otherwise, the above structured verification process continues to achieve continuous optimization of the competition problem statement quality.
[0132] Compared with existing methods of generating problem statements in one go, this invention introduces an iterative closed-loop mechanism of "generation-verification-correction" to continuously improve the quality of competition problem statements through multiple rounds of optimization. This effectively reduces problems such as semantic deviation, expression ambiguity, and narrative inconsistency that occur during scene migration, thereby improving the naturalness, consistency, and readability of the final rewritten competition problem statements.
[0133] The present invention will now demonstrate the application effect of the automatic rewriting and correction method for competition questions based on structured semantic verification described in S1 to S5 of the above embodiments on a specific dataset through a specific example, so as to facilitate understanding of the essence of the present invention.
[0134] Example
[0135] The specific implementation process of the automatic rewriting and correction method for competition questions based on structured semantic verification used in this embodiment is as described above and will not be repeated here.
[0136] To verify the rewriting effect of the competition questions generated by this invention, this invention evaluates the rewriting results from two aspects: scene difference and code compatibility. These two aspects correspond to the two core objectives of this invention: "scene migration" and "logic preservation".
[0137] (1) Evaluation of scene differences
[0138] Scene difference is used to measure the degree of difference between the rewritten competition question (hereinafter referred to as "rewritten question") and the original competition question (hereinafter referred to as "original question") at the narrative scene level. This embodiment uses BLEU-4 and ROUGE-L indices to measure the overlap between the rewritten and original questions at the surface text level; the lower the value, the greater the difference in vocabulary and sentence structure. ENS (Entity Novelty Score) and RNS (Relation Novelty Score) indices are used to measure the novelty of the rewritten question relative to the original question at the entity and relation levels. ENS is defined as the proportion of questions where the rewritten and original question sets have no overlap in entity set. That is, for a single question, if the intersection of the rewritten and original entity sets is empty, the value is 1; otherwise, it is 0. The macroscopic result is the average of all questions. RNS uses the same calculation method as ENS, but applies to the relation set. Higher values for both indices indicate more questions that introduce entirely new entities and relations.
[0139] This embodiment conducts experiments on the CPRewriting dataset. The CPRewriting dataset consists of two parts: a topic database containing 5,317 problems collected from the Codeforces algorithm competition platform, used to construct a dual-graph database to support retrieval and scene transfer; and a rewriting evaluation set containing 303 problems collected from Luogu and LibreOJ platforms, of which 68 are non-contextual problems (without story background) and 235 are contextual problems (with rich scene descriptions), used to evaluate the rewriting effect. The evaluation set does not overlap with the topic database at all. The rewriting evaluation set includes 104 problems with manually rewritten versions, of which 65 are contextual problems and 39 are non-contextual problems, used for comparison with the method of this invention. The experiment selects Direct, ThemeRAG, MathScale, and KPDDS as baseline methods, and uses DeepSeek-V4-Pro and GPT-5.4-mini as two backbone large language models. Table 1 shows the comparison results of scene differences.
[0140] Table 1. Comparison of Scene Differences (%)
[0141]
[0142] As shown in Table 1, the method of this invention significantly outperforms all baseline methods in both backbone models and evaluation scenarios, achieving significantly lower BLEU-4 and ROUGE-L scores, while reaching the highest levels in both ENS and RNS. Taking DeepSeek-V4-Pro in a non-contextual scenario as an example, BLEU-4 scores are only 4.08%, and ROUGE-L scores are only 18.86%, indicating a significant reduction in textual overlap between the rewritten and original problem statements.
[0143] Furthermore, this embodiment utilizes manually rewritten versions from the rewritten evaluation set to compare with the method of the present invention in terms of both automatic metrics and LLM evaluation.
[0144] Regarding the automatic metrics, Table 2 presents the comparison results. As can be seen from Table 2, the method of this invention outperforms the manually rewritten version in all automatic metrics. Taking DeepSeek-V4-Pro as an example, in non-contextual scenarios, BLEU-4 is only 4.34%, while the manually rewritten version is 10.27%; ENS reaches 95.38%, higher than the 89.23% of the manually rewritten version.
[0145] Table 2. Comparison results with manually rewritten automatic indicators (%)
[0146]
[0147] In terms of LLM evaluation, this embodiment adopts the LLM-as-a-Judge approach, using three large language models—Qwen3.5 Plus, GLM5.2, and Gemini 3.5 Flash—as judges. The rewritten prompts generated by the method of this invention and the manually rewritten prompts are compared in pairs blindly based on three dimensions: theme diversity, readability, and reasonability. During the evaluation process, the sources of the two rewritten prompts are hidden from the judges' models, and the display order is randomly shuffled. Judges must determine which one is better or whether both are equal. Table 3 shows the evaluation results, with the values representing the proportions of the method of this invention winning, both being equal, and the manually rewritten prompts winning, respectively.
[0148] Table 3. Comparison of LLM assessment results (%)
[0149]
[0150] As shown in Table 3, in terms of readability and rationality, the success rate of the method of this invention exceeded 90% in all judge models, with a tie rate of 0%. This indicates that the rewritten prompts generated by the method of this invention comprehensively surpass the level of manual rewriting in terms of fluency, naturalness of narrative, and logical consistency of scene. In terms of topic diversity, the success rate of the method of this invention was higher than that of manual rewriting in all three judge models. Among them, the success rate reached 67.7% in the Qwen3.5 Plus judge model, significantly higher than the 23.1% of manual rewriting, indicating that the method of this invention can generate rewritten prompts with greater scene diversity. Combining the three dimensions and the three judge models, the success rate of the method of this invention was higher than that of manual rewriting in all nine comparison groups, verifying that the method of this invention meets or surpasses the level of manual rewriting in terms of scene diversity, readability, and rationality.
[0151] (2) Code compatibility evaluation
[0152] To verify whether the rewritten problem statements maintain consistency with the original problem statements at the algorithmic logic level, this embodiment randomly selects 100 original problem statements and their corresponding rewritten problem statements from the rewritten evaluation set. Solving programs are generated using a code generation model and submitted to an online evaluation platform. The programs are then tested using the standard test data corresponding to the original problem statements. The evaluation results are categorized into four types: both programs pass all test data; only the program corresponding to the original problem statement passes; only the program corresponding to the rewritten problem statement passes; and neither program passes.
[0153] Table 4. Code compatibility evaluation results
[0154]
[0155] As shown in Table 4, the proportion of both programs passing all test data under the DeepSeek-V4-Pro backbone model is 88%, and under the GPT-5.4-mini backbone model it is 87%, indicating that the rewritten problem statement generated by this invention maintains the same algorithm logic as the original problem statement in most cases.
[0156] Through joint evaluation of scenario differences and code compatibility, the above experimental results show that while achieving significant transfer of the problem scenario, the present invention can effectively maintain the original problem algorithm logic unchanged. Moreover, it is superior to the level of manual rewriting in terms of topic diversity, readability and rationality, which verifies the effectiveness of the present invention in combining "problem scenario innovation" and "logic preservation".
[0157] In summary, this invention proposes an automatic rewriting and correction method for competition problem statements based on structured semantic verification, utilizing large language models, logical graph structured modeling, and structured semantic verification techniques. The method first constructs an original logical graph from the original competition problem statement and obtains a reference scenario graph by retrieving data from a dual-graph database. This rewrites the competition problem statement while maintaining the original algorithm logic, input / output format, and standard answer. Subsequently, a problem-driven structured semantic verification mechanism automatically identifies semantic defects generated during the rewriting process and, combined with a defect list, automatically corrects and optimizes the competition problem statement. This method effectively improves the semantic correctness, logical consistency, and scenario rationality of the rewritten competition problem statement, reduces manual review costs, and increases the efficiency of competition problem statement rewriting. This invention is applicable to application scenarios such as competition problem bank construction, programming education, intelligent problem generation, data augmentation, and large language model training data construction. It is also suitable for tasks requiring scenario migration and style reconstruction of text expression while maintaining the underlying logic.
[0158] It is understood that the automatic rewriting and correction method for competition questions based on structured semantic verification described in S1-S5 above can essentially be implemented by a computer program. Therefore, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer program product corresponding to the automatic rewriting and correction method for competition questions based on structured semantic verification provided in the above embodiments. This product includes a computer program / instruction, which, when executed by a processor, can implement the automatic rewriting and correction method for competition questions based on structured semantic verification as described in the above embodiments.
[0159] Similarly, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer electronic device corresponding to the automatic rewriting and correction method for competition questions based on structured semantic verification provided in the above embodiments, such as... Figure 3 As shown, it includes a memory and a processor;
[0160] The memory is used to store computer programs;
[0161] The processor is configured to implement the automatic rewriting and correction method for competition questions based on structured semantic verification in the above embodiments when executing the computer program.
[0162] Furthermore, the logical instructions in the aforementioned memory can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.
[0163] Therefore, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer-readable storage medium corresponding to the automatic rewriting and correction method for competition questions based on structured semantic verification provided in the above embodiments. The storage medium stores a computer program, which, when executed by a processor, can realize the automatic rewriting and correction method for competition questions based on structured semantic verification in the above embodiments.
[0164] Specifically, in the computer-readable storage medium of the above three embodiments, the stored computer program is executed by a processor, which can perform the aforementioned steps S1 to S5.
[0165] It is understood that the aforementioned storage media may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Furthermore, the storage media may also be various media capable of storing program code, such as USB flash drives, external hard drives, magnetic disks, or optical discs.
[0166] It is understood that the processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0167] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the invention. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the invention. Therefore, all technical solutions obtained through equivalent substitution or transformation fall within the protection scope of the present invention.
Claims
1. A method for automatically rewriting and correcting competition problem statements based on structured semantic verification, characterized in that, Includes the following steps: S1. Obtain the original competition problem statement to be rewritten, wherein the original competition problem statement is the text description corresponding to the calculation problem to be solved; perform structured semantic parsing on the original competition problem statement based on the large language model, extract key semantic information from the background description of the original competition problem statement, and generate an original logical graph containing a set of nodes and a set of edges; S2. Obtain a pre-built dual-graph database. Each piece of data stored in the dual-graph database contains a candidate logic graph and a scene relationship graph corresponding to the same candidate competition question. The scene relationship graph is used to provide background reference for rewriting the original competition question. S3. Using a graph similarity retrieval method based on structure-semantic joint modeling, multiple candidate logical graphs that are similar to the original logical graph in structure and semantics are retrieved in the dual-graph database as reference logical graphs, and the scene relationship graph corresponding to the reference logical graph is used as the reference scene graph; S4. By prompting engineering constraints, the large language model, while keeping the original algorithm logic, input and output format, solution objective and standard answer of the calculation problem unchanged, firstly, based on the original competition problem statement, the original logic diagram and the reference scenario diagram, generates a new scenario diagram as the rewritten scenario diagram. Then, based on the original competition problem statement, the original logic diagram and the rewritten scenario diagram, generates a new competition problem statement corresponding to the rewritten scenario diagram as the rewritten competition problem statement. S5. For the rewritten competition problem statement, the large language model first generates a set of structured verification questions consisting of multiple verification questions, then answers each verification question to obtain the corresponding answer results, and then judges whether there are defects in the rewritten competition problem statement based on the answer results. If there are no defects, the rewritten competition problem statement is directly output. If there are defects, the large language model corrects the rewritten competition problem statement, and finally outputs the corrected competition problem statement without defects.
2. The method for automatic rewriting and correction of competition problem statements based on structured semantic verification as described in claim 1, characterized in that, In step S1, the node set includes four types of nodes: variable nodes, resource nodes, constraint nodes, and conceptual semantic nodes. Each node is used to represent a semantic entity. The edges in the edge set are used to represent the logical relationships between nodes.
3. The method for automatic rewriting and correction of competition problem statements based on structured semantic verification as described in claim 2, characterized in that, The variable nodes represent the input variables extracted from the original competition problem statement; the resource nodes represent quantifiable resource objects in the original competition problem statement; the constraint nodes represent the rules, restrictions, and judgment conditions that must be satisfied during the algorithm execution process, and the algorithm is used to solve the computational problem; the concept semantic nodes represent the solution objective, key events, and algorithm termination conditions of the original competition problem statement.
4. The method for automatic rewriting and correction of competition problem statements based on structured semantic verification as described in claim 1, characterized in that, In step S2, the original competition question from S1 is replaced with a candidate competition question. A candidate logic graph is generated using the method in S1. The candidate competition question is then input into a large language model for structured semantic parsing to extract the background information of the candidate competition question and generate a scene relationship graph corresponding to the candidate logic graph. This scene relationship graph uses people, places, objects, and events as nodes and the relationships between nodes as edges.
5. The method for automatic rewriting and correction of competition problem statements based on structured semantic verification as described in claim 2, characterized in that, In step S3, the process of retrieving candidate logical graphs using the graph similarity retrieval method based on structure-semantic joint modeling is as follows: S31. Concatenate the node attributes and edge attributes in the original logic graph into a text string, concatenate the node attributes and edge attributes in the candidate logic graph into another text string, take the text string of a candidate logic graph as a document, take the text strings of all candidate logic graphs as a corpus, use TF-IDF to vectorize the text strings of all candidate logic graphs and the text string of the original logic graph, calculate the cosine similarity between the original logic graph and each candidate logic graph, and take the cosine similarity calculation result as the semantic similarity score of the candidate logic graph. S32. The Jaccard similarity calculation result between the set corresponding to the original logic graph and the set corresponding to the candidate logic graph is used as the structural similarity score of the candidate logic graph; wherein, the two sets contain the same content, both consisting of logical association type, relationship strength, node degree, two-hop path, and the number of nodes corresponding to each node type. S33. The semantic similarity score and the structural similarity score are weighted and summed to calculate the comprehensive similarity score of the candidate logic graphs. The top-K candidate logic graphs with the highest comprehensive similarity scores are used as reference logic graphs, and the scene relationship graphs corresponding to the reference logic graphs are read from the dual-graph database; where K is the number of candidate logic graphs retrieved.
6. The method for automatic rewriting and correction of competition problem statements based on structured semantic verification as described in claim 2, characterized in that, The specific process of step S5 is as follows: S51. Input the rewritten competition problem statement into the large language model. With the prompts for engineering constraints, the large language model automatically analyzes the entity information, entity attributes, entity relationships, constraints and solution objectives involved in the rewritten competition problem statement and constructs a set of structured verification questions. S52. Input the rewritten competition problem statement and the set of structured validation questions into the large language model. For each validation question, the large language model gives the corresponding answer based on the existing description in the rewritten competition problem statement. S53. The large language model analyzes the answer results item by item to determine the logical errors, semantic conflicts, missing definitions, inconsistent relationships, and / or ambiguities in the rewritten competition questions. S54. When there are no defects, the large language model directly outputs the rewritten competition problem statement; when there are defects, the large language model outputs a judgment result containing a description of the defect content and a description of the cause of the defect, and, while keeping the original algorithm logic, input and output format, solution objective and standard answer of the calculation problem unchanged, the large language model corrects the defects in the rewritten competition problem statement based on the judgment result, and generates a corrected competition problem statement. S55. Replace the rewritten competition problem with the revised competition problem, and repeat S52~S54 until the revised competition problem is free of defects.
7. The method for automatic rewriting and correction of competition problem statements based on structured semantic verification as described in claim 6, characterized in that, In step S51, the verification questions in the set of structured verification questions include: Entity-related verification issues are used to verify whether the entities in the rewritten competition problem statement are clearly defined and conform to the setting of the rewritten scenario diagram. Attribute-related validation issues are used to verify whether the entity attributes in the rewritten competition problem statement are consistent with the original competition problem statement. Relationship-related validation problems are used to verify whether the entity relationships in the rewritten competition problem statement are correctly expressed. Constraint-related verification problems are used to verify whether the constraints in the rewritten competition problem statement are complete and unambiguous. Goal-related verification questions are used to verify whether the solution objective in the rewritten competition problem statement is clearly expressed.
8. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instruction is executed by the processor, it can realize the automatic rewriting and correction method for competition questions based on structured semantic verification as described in any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the automatic rewriting and correction method for competition questions based on structured semantic verification as described in any one of claims 1 to 7.
10. A computer electronic device, characterized in that, Including memory and processor; The memory is used to store computer programs; The processor is configured to, when executing the computer program, implement the automatic rewriting and correction method for competition questions based on structured semantic verification as described in any one of claims 1 to 7.
