System and method for real-time detection and automatic repair of general text logic vulnerabilities based on large models

By using a real-time text logic vulnerability detection system based on a large model, an event chain graph is constructed and repair patches are generated, which solves the problem of automatic detection and repair of deep logical breaks in long scripts, improving detection accuracy and creation efficiency.

CN122388166APending Publication Date: 2026-07-14CHINA JILIANG UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA JILIANG UNIV
Filing Date
2026-05-29
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Existing technologies are insufficient to comprehensively and accurately detect and automatically repair deep logical breaks in long or serialized scripts, resulting in high costs for manual adjustments and verification.

Method used

A real-time detection system for general text logic vulnerabilities based on a large model is adopted. An event chain graph is constructed through a graph construction engine, the rationality of nodes is calculated by an inference engine, and a repair output engine generates repair patches to achieve automated detection and repair.

Benefits of technology

It improves the automation and accuracy of script logic detection, reduces the cost of manual repair, and enhances the stability of the creative process and the precision of film and television production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122388166A_ABST
    Figure CN122388166A_ABST
Patent Text Reader

Abstract

The application provides a large model-based general text logical vulnerability real-time detection and automatic repair system and method, comprising a text sending and receiving engine, a graph construction engine, an inference engine and a repair output engine; the text sending and receiving engine receives a to-be-detected film and television script text; the graph construction engine divides the text into event units and constructs an event chain graph with weights; the inference engine calculates a rationality value of a node based on a causal inference algorithm and marks a logical contradiction point; and the repair output engine calls a large model to generate a candidate repair patch and selects an optimal suggestion based on a rationality improvement amount. In this way, the automatic detection and intelligent repair of the script logical vulnerability can be realized, and the detection accuracy and repair efficiency are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of natural language processing technology, and in particular to a system and method for real-time detection and automatic repair of general text logic vulnerabilities based on a large model. Background Technology

[0002] In the scriptwriting process, screenwriters need to construct a vast network of character relationships, complex timelines, and rigorous causal chains. With the increasing length of TV series and the widespread adoption of serialization, the number of storylines in scripts has risen, and the logical dependencies across scenes and chapters have become intricate. The industry primarily relies on manual review or basic auxiliary tools to ensure script quality. Manual review is usually performed by senior editors or script doctors, who read through the entire text to identify issues such as timeline inconsistencies, inconsistent character behavior, or a lack of foreshadowing for key settings. Existing auxiliary tools often employ rule-based matching or simple statistical methods, such as searching a pre-set keyword database or identifying potential errors based on fixed sentence patterns. These tools can, to some extent, assist creators in discovering superficial textual errors or obvious formatting issues.

[0003] However, existing technologies often struggle to fully and accurately capture and automatically repair deep logical inconsistencies hidden within long-form or series dramas. Due to a lack of understanding of the deep causal relationships between events, current methods cannot effectively handle the dynamic changes in character intentions and complex spatiotemporal logical deductions. As a result, even after contradictions are detected, extensive manual adjustments and repeated verifications are still required, leading to a long overall optimization cycle and high costs. Summary of the Invention

[0004] In view of the aforementioned problems, this disclosure provides a real-time detection and automatic repair system for general text logic vulnerabilities based on a large model, which aims to improve the accuracy and efficiency of script logic checking while reducing costs.

[0005] In conjunction with embodiments of the present invention, a first aspect provides a real-time detection and automatic repair system for general text logic vulnerabilities based on a large model, comprising:

[0006] A text transceiver engine, a graph construction engine that communicates with the text transceiver engine, an inference engine that communicates with the graph construction engine, and a repair output engine that communicates with the inference engine;

[0007] The text transceiver engine is used to receive the film and television script text to be detected;

[0008] The graph construction engine is used to divide the film and television script text into multiple event units according to film and television scenes. Each event unit carries a timestamp, a character identifier, and a character behavior description. Using all the event units as nodes and the causal dependencies between the events as directed edges, an event chain graph corresponding to the film and television script text is constructed. The weight of each directed edge is calculated through a conditional probability table, which is obtained by a large model from statistical analysis of the sample script corpus.

[0009] The inference engine is used to traverse each path in the event chain graph using a causal inference algorithm, calculate the occurrence rationality value of each node under the joint probability of all predecessor nodes, and mark the corresponding node as a logical contradiction point if any occurrence rationality value is lower than a preset rationality threshold.

[0010] The repair output engine is used to generate multiple candidate repair patches by calling the large model for each logical contradiction point. Each candidate repair patch corresponds to a modified event description. By calculating the rationality improvement of the entire path after the candidate repair patch is replaced, the candidate repair patch with the largest rationality improvement is selected as the repair suggestion and sent by the text sending and receiving engine.

[0011] Optionally, the graph construction engine includes:

[0012] The first kernel is used to extract the temporal sequence relationship, spatial location relationship and role intention relationship from each event unit, calculate the weight of each directed edge through a conditional probability table, and construct the temporal subgraph, spatial subgraph and intention subgraph respectively.

[0013] The second kernel is used to fuse the time subgraph, the spatial subgraph, and the intent subgraph through shared nodes to form a multi-dimensional heterogeneous event chain graph, wherein the edges between nodes in the heterogeneous event chain graph are assigned different color labels according to the relationship type.

[0014] The third kernel is used to calculate the absolute value of the time interval between adjacent nodes in the time subgraph. If the absolute value of the time interval exceeds the maximum allowed time difference, a time conflict marker is added between the two nodes.

[0015] The fourth kernel is used to treat the edges marked with the time conflict as hard constraints in causal reasoning, so that any causal path that crosses the edge is judged as an unreasonable logical path, thereby obtaining the event chain graph corresponding to the film and television script text.

[0016] Optionally, the first kernel is specifically used for:

[0017] For each event unit, its timestamp is parsed to obtain the temporal order relationship of multiple event units, the scene description is parsed to obtain the spatial position relationship of the multiple event units, and the character behavior is parsed to obtain the character intent relationship of the characters in the multiple event units;

[0018] The temporal sequence relationship, spatial position relationship, and role intention relationship of the multiple event units are used as conditions to query the frequency of the corresponding transition in the conditional probability table.

[0019] Based on the frequencies corresponding to the temporal sequence relationship, the spatial position relationship, and the role intention relationship, the weights of the corresponding directed edges are determined, and then a temporal subgraph, a spatial subgraph, and an intention subgraph are constructed respectively.

[0020] Optionally, the fourth kernel is specifically used for:

[0021] For the aforementioned temporal order relationship, the temporal weight of the corresponding directed edge is obtained based on the frequency of the successor event occurring after the corresponding predecessor event and the total frequency of all possible successor events.

[0022] For the spatial positional relationship, extract the spatial positional label corresponding to each event unit, and obtain the spatial weight of the directed edge in space based on the number of times the transition from the previous position to the next position and the total number of transitions starting from the previous position.

[0023] For the aforementioned character intention relationships, the character's intention state is obtained through semantic parsing. Based on the frequency of changes from any intention to another intention and the total number of changes starting from any intention, the intention weight of the directed edge on the intention is obtained.

[0024] Using the event unit as a node and the temporal sequence relationship as a directed edge, with each edge assigned a temporal weight, the temporal subgraph is constructed.

[0025] Using the spatial positional relationships as directed edges, and attaching the spatial weight to each edge, the spatial subgraph is constructed;

[0026] Using the aforementioned role intention relationships as directed edges, and attaching the aforementioned intention weight to each edge, the intention subgraph is constructed.

[0027] Optionally, the inference engine is specifically used for:

[0028] Taking each node as the target node, obtain all the predecessor nodes of the target node to form the condition set of the target node;

[0029] The transition probability from each predecessor node to the target node is extracted from the event chain graph. The transition probability is estimated by the statistical frequency of similar event sequences in the same script by a large model.

[0030] Substitute the state values ​​of all the predecessor nodes in the condition set into the conditional probability table, and calculate the joint conditional probability of the node using the chain rule. The state values ​​are used to characterize the probability of the event corresponding to the predecessor node.

[0031] The logical contradiction score of the target node is obtained by taking the natural logarithm of the joint conditional probability of the target node, and is used as the occurrence rationality value of the target node.

[0032] Optionally, the inference engine is specifically used for:

[0033] For each predecessor node, its corresponding event description is combined with the event description of the corresponding target node to obtain multiple event pairs corresponding to the target node. The event pairs are constructed by using the event description of the predecessor node as a predecessor event description and using the event description of the target node as a successor event description.

[0034] By using a pre-configured similarity matching function in the large model, the semantic similarity of characters, actions, and scenes in the event pairs is compared to determine the similarity value of any two event pairs corresponding to the target node.

[0035] The statistical interface of the large model is called, and the event pairs with similarity values ​​greater than the similarity threshold are input into the large model. The target event pairs corresponding to the target node in all historical script corpora are retrieved. The semantic description similarity of the event pairs is satisfied with the preset conditions. The target event pairs are event pairs whose predecessor event description and successor event description both reach the preset matching threshold.

[0036] Count the first total number of times the target event occurs after the preceding event occurs in the target event pair, and count the second total number of times any event occurs after the preceding event occurs;

[0037] The transition probability from the corresponding predecessor node to the target node is determined based on the ratio of the first total number of iterations to the second total number of iterations.

[0038] Optionally, the repair output engine is also used for:

[0039] For the same logical contradiction, if the improvement of multiple candidate repair patches differs by less than a preset difference threshold, then the multi-ending patch generation mode is entered.

[0040] In the multi-ending patch generation mode, the film and television script text to be detected is split into multiple branch paths from the corresponding logical contradiction points, and a candidate patch is applied to each branch path to form a multi-ending script structure.

[0041] Run a causal reasoning test once for each branch path and record the number of remaining logical contradictions in each branch path;

[0042] The branch path with the fewest remaining logical contradictions is selected as the primary recommended repair solution, while the remaining branch paths are saved in abbreviated form in the repair history for users to manually switch between and select.

[0043] Highlight all the differences in the branch paths and add them as annotations to the corresponding positions in the film and television script text.

[0044] Optionally, the repair output engine is specifically used for:

[0045] Read the event node marked as the logical contradiction point, and obtain the event description of the event node and the event descriptions of the two adjacent event nodes before and after it;

[0046] Based on the time description of the event node and the event descriptions of the two adjacent event nodes before and after it, the contradiction type of the logical contradiction point is determined. The contradiction type includes one or more of the following: timeline contradiction, character behavior contradiction, prop setting contradiction, and spatial location contradiction.

[0047] The contradiction type of the logical contradiction point is used as a constraint condition and concatenated into a natural language prompt that includes the contextual logical relationship. The natural language prompt is used to guide the large model to generate multiple alternative event descriptions.

[0048] The natural language prompts are input into the large model, so that the large model outputs the multiple candidate repair patches based on the contextual logical relationships in the natural language prompts.

[0049] In conjunction with embodiments of the present invention, a second aspect provides a method for real-time detection and automatic repair of general text logic vulnerabilities based on a large model, the method comprising:

[0050] Send the film and television script text to be detected to the general text logic vulnerability real-time detection and automatic repair system based on a large model, as described in any of the first aspects, via any device;

[0051] Repair suggestions are obtained through the aforementioned real-time detection and automatic repair system for general text logic vulnerabilities based on large models;

[0052] The device receives and displays the repair suggestions sent by the large-model-based general text logic vulnerability real-time detection and automatic repair system.

[0053] Through the above-described technical solution, this disclosure can achieve at least the following effective effects:

[0054] The text to be detected is received by a text transceiver engine. Then, a graph construction engine segments the text into event units carrying timestamps, character identifiers, and behavioral descriptions. An event chain graph is constructed using directed edges representing causal dependencies between events. Edge weights are calculated based on conditional probability tables obtained from statistical analysis of sample script corpora by a large model, thus quantifying the inherent logical connections within the event sequence. Next, an inference engine uses a causal inference algorithm to traverse the graph path, calculating the occurrence rationality value of each node under the joint probability of all its predecessor nodes. Nodes with occurrence rationality values ​​below a preset threshold are marked as logical contradictions, capturing deep semantic breaks that traditional rule matching cannot identify. Finally, a repair output engine calls the large model to generate multiple candidate repair patches for the marked contradictions. The optimal solution is selected by calculating the improvement in rationality of the entire path after replacement, ensuring that the repair suggestions are not only locally reasonable but also optimize the overall narrative coherence. This solves the problems of missed detections and difficult repairs caused by the lack of deep causal understanding in existing technologies when processing long scripts, avoiding the high cost and low efficiency of repeated manual verification. It improves the automation and accuracy of script logic testing, enhances the stability and reliability of the creative process, and improves the precision and accuracy of film and television creation.

[0055] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description

[0056] The accompanying drawings are provided to further illustrate the present disclosure and form part of the specification. They are used together with the following detailed description to explain the present disclosure, but do not constitute a limitation thereof. In the drawings:

[0057] Figure 1 This is a system block diagram of a general text logic vulnerability real-time detection and automatic repair system based on a large model, as shown in an embodiment of this disclosure. Detailed Implementation

[0058] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0059] The specific embodiments of this disclosure will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit this disclosure.

[0060] In conjunction with the embodiments of the present invention, a real-time detection and automatic repair system for general text logic vulnerabilities based on a large model is provided. See [link to relevant documentation]. Figure 1 As shown, the real-time detection and automatic repair system 100 for general text logic vulnerabilities based on a large model includes:

[0061] A text transceiver engine 110, a graph construction engine 120 communicatively connected to the text transceiver engine 110, an inference engine 130 communicatively connected to the graph construction engine 120, and a repair output engine 140 communicatively connected to the inference engine 130.

[0062] The text transceiver engine 110 can be an interface module used to establish communication links between the system and external user devices or storage media. This text transceiver engine can interact with internal modules such as the graph construction engine and the repair output engine to form a complete data flow closed loop.

[0063] For example, the text transceiver engine can be deployed on the server side to receive film and television script text files uploaded by users via an API interface; alternatively, it can be integrated into client software to directly read text content from the local editor. After receiving the film and television script text to be detected, the text transceiver engine transmits it to the graph construction engine for preprocessing. Upon receiving the repair suggestions generated by the repair output engine, it returns the results to the user, thereby realizing the access of the data to be detected and the feedback of the processing results.

[0064] The text transceiver engine is used to receive the film and television script text to be detected.

[0065] The film and television script text to be detected can include script files stored in digital format. A communication link can be established between the device and the system via a wired or wireless network. Using Hypertext Transfer Protocol (HTTP), WebSocket long connections, or Remote Procedure Call (RPC) interfaces, the data stream of the film and television script text is uploaded to the system's text transceiver engine. For example, after completing the first draft of an episode's script in a scriptwriting application on a tablet, clicking the smart detection button automatically encapsulates the script file into a data packet and sends it via the internet to the detection system server deployed in the cloud. This enables flexible initiation of detection tasks and real-time data transmission.

[0066] The graph construction engine is used to divide the film and television script text into multiple event units according to film and television scenes. Each event unit carries a timestamp, a character identifier, and a character behavior description. Using all the event units as nodes and the causal dependencies between the events as directed edges, an event chain graph corresponding to the film and television script text is constructed. The weight of each directed edge is calculated through a conditional probability table, which is obtained by a large model from statistical analysis of the sample script corpus.

[0067] In this embodiment, the graph construction engine is communicatively connected to the text transceiver engine, receiving the original script text sent by the text transceiver engine. The graph construction engine can be used to divide the continuous script text into multiple discrete event units according to film and television scenes. Each event unit can carry attribute information such as timestamps, character identifiers, and character behavior descriptions. Among them, the timestamp can be used to represent the chronological order or specific time of events, and can be set to absolute time or relative time according to the actual situation; the character identifier can be used to uniquely distinguish different characters in the script, such as character names or ID codes; the character behavior description is a natural language description of the character's actions, lines, or state in the event.

[0068] The weight of each directed edge quantifies the probability of transitions between events. For example, the graph construction engine can use natural language processing techniques for script segmentation, entity recognition, and relation extraction, and can also combine rule templates for scene segmentation. By constructing an event chain graph, the graph construction engine can transform complex narrative logic into a computable graph structure.

[0069] The inference engine is used to employ a causal inference algorithm to traverse each path in the event chain graph, calculate the occurrence rationality value of each node under the joint probability of all predecessor nodes, and mark the corresponding node as a logical contradiction point if any occurrence rationality value is lower than a preset rationality threshold.

[0070] In this embodiment, the inference engine may include a computational module that performs logical consistency checks based on graph theory and probabilistic statistics principles. The inference engine is communicatively connected to the graph construction engine to obtain the event chain graph it constructs. The inference engine can be used to employ a causal inference algorithm to traverse each path in the event chain graph and calculate the occurrence rationality value of each node under the joint probability of all its predecessor nodes. The occurrence rationality value can be used to characterize the logical coherence of the current event occurring in the context of its preceding event sequence, and its calculation process can be based on mathematical models such as Bayesian networks or Markov chains.

[0071] The preset reasonableness threshold can be set according to the detection sensitivity requirements of the actual application scenario. The inference engine, in conjunction with the graph construction engine, achieves a quantitative assessment of script logic flaws, transforming subjective logical judgments into objective probability values, thereby accurately locating problematic plot points.

[0072] The repair output engine is used to generate multiple candidate repair patches by calling the large model for each logical contradiction point. Each candidate repair patch corresponds to a modified event description. By calculating the rationality improvement of the entire path after the candidate repair patch is replaced, the candidate repair patch with the largest rationality improvement is selected as the repair suggestion and sent by the text sending and receiving engine.

[0073] In this embodiment, the repair output engine may include an intelligent processing component that provides logical correction schemes using the large model generation capability. The repair output engine is communicatively connected to the inference engine and receives information on logical contradictions marked by the inference engine. The improvement in reasonableness may include the difference or ratio of the reasonableness values ​​of the entire event path before and after applying the repair patch, used to measure the degree to which the repair scheme improves the overall logical coherence. For example, the repair output engine can construct contextual information of logical contradictions into prompt words and input them into the large model, guiding the large model to generate a rewrite scheme that conforms to the context; it can also combine reinforcement learning mechanisms to rank and optimize multiple generated schemes. Through its linkage with the inference engine, the repair output engine not only achieves vulnerability detection but also completes an automated repair loop, significantly reducing the cost of manual modification.

[0074] The text to be detected is received by a text transceiver engine. Then, a graph construction engine segments the text into event units carrying timestamps, character identifiers, and behavioral descriptions. An event chain graph is constructed using directed edges representing causal dependencies between events. Edge weights are calculated based on conditional probability tables obtained from statistical analysis of sample script corpora by a large model, thus quantifying the inherent logical connections within the event sequence. Next, an inference engine uses a causal inference algorithm to traverse the graph path, calculating the occurrence rationality value of each node under the joint probability of all its predecessor nodes. Nodes with occurrence rationality values ​​below a preset threshold are marked as logical contradictions, capturing deep semantic breaks that traditional rule matching cannot identify. Finally, a repair output engine calls the large model to generate multiple candidate repair patches for the marked contradictions. The optimal solution is selected by calculating the improvement in rationality of the entire path after replacement, ensuring that the repair suggestions are not only locally reasonable but also optimize the overall narrative coherence. This solves the problems of missed detections and difficult repairs caused by the lack of deep causal understanding in existing technologies when processing long scripts, avoiding the high cost and low efficiency of repeated manual verification. It improves the automation and accuracy of script logic testing, enhances the stability and reliability of the creative process, and improves the precision and accuracy of film and television creation.

[0075] In one embodiment, this disclosure also provides a graph construction engine, including: a first kernel, used to extract temporal sequence relationships, spatial location relationships, and role intention relationships from each event unit, calculate the weight of each directed edge through a conditional probability table, and construct a temporal subgraph, a spatial subgraph, and an intention subgraph respectively; a second kernel, used to fuse the temporal subgraph, the spatial subgraph, and the intention subgraph through shared nodes to form a multi-dimensional heterogeneous event chain graph, wherein the edges between nodes in the heterogeneous event chain graph are assigned different color labels according to the relationship type; a third kernel, used to calculate the absolute value of the time interval between adjacent nodes in the temporal subgraph, and if the absolute value of the time interval exceeds the maximum allowable time difference, add a time conflict marker between the two nodes; a fourth kernel, used to use the edges with time conflict markers as hard constraints in causal reasoning, so that any causal path crossing the edge is judged as an unreasonable logical path, thereby obtaining an event chain graph corresponding to the film and television script text.

[0076] The first kernel may include a processing module responsible for decoupling and extracting multi-dimensional logical relationships from the basic event data. The first kernel receives event units carrying timestamps, role identifiers, and role behavior descriptions obtained from the previous steps, and can be used to transform unstructured text descriptions into structured relational data.

[0077] For example, the first kernel parses the timestamps of event units to obtain temporal order relationships, parses scene descriptions to obtain spatial location relationships, and parses character behaviors to obtain character intention relationships. These relationships are used as conditions to query the frequency of corresponding transitions in a conditional probability table obtained by the large model from statistical analysis of the sample script corpus, thereby determining the weights of directed edges. The first kernel then constructs independent temporal subgraphs, spatial subgraphs, and intention subgraphs respectively.

[0078] Regarding the extraction of temporal relationships, the settings can be tailored to the specific circumstances. For example, it could involve directly comparing the order of timestamps, or a time sequence modified based on the narrative's flashback or interlude logic. Spatial relationships could be specific geographic coordinates or relative location descriptions such as indoors or outdoors. Character intent relationships can be derived from semantic analysis to obtain the character's psychological state or action goals. The first kernel ensures that different types of logical dependencies do not interfere with each other and that features are clear during the initial modeling phase by processing these three dimensions of relationships in parallel.

[0079] The second kernel may include a fusion processing module responsible for integrating single-dimensional subgraphs into a unified multi-dimensional graph. The second kernel communicates with the first kernel, receiving the temporal, spatial, and intent subgraphs output by the first kernel. Its operation involves identifying shared nodes in different subgraphs and performing topological fusion of the three subgraphs to form a multi-dimensional heterogeneous event chain graph. To distinguish different types of logical dependencies, the second kernel assigns different color labels to the edges between nodes in the heterogeneous event chain graph based on the relationship type during the fusion process. For example, edges representing temporal order can be marked in red, edges representing spatial location in blue, and edges representing role intent in green. The specific color scheme can be set according to visualization requirements. Through this fusion method, the second kernel interconnects previously isolated logical dimensions within the same graph structure, preserving the independence of each dimension while achieving collaborative expression of multi-dimensional information, thus improving the integrity of the causal reasoning context.

[0080] The third kernel may include a detection module responsible for performing time consistency checks and generating conflict markers. The third kernel operates on the temporal subgraph portion of the heterogeneous event chain graph generated by the second kernel, or directly operates on the edges of the time dimension in the fused graph. It is used to identify and mark time jumps that violate physical common sense or plot logic.

[0081] For example, the third kernel traverses adjacent nodes in the time subgraph and calculates the absolute value of the time interval between corresponding adjacent nodes. If the absolute value of this time interval exceeds the preset maximum allowable time difference, the third kernel adds a time conflict marker between these two nodes. The value of the maximum allowable time difference can be set according to the script type. For example, for modern urban dramas, instantaneous movement of characters may be considered unreasonable, so the time difference threshold is set relatively small; while for science fiction or fantasy themes, the threshold can be appropriately relaxed. The third kernel transforms ambiguous temporal logical contradictions into clear marker signals through quantified time interval calculations.

[0082] The fourth kernel may include a logic decision module responsible for transforming temporal conflicts into hard constraints for reasoning. The fourth kernel receives graph data marked with temporal conflicts from the third kernel and passes it as input to the inference engine. Edges marked with temporal conflicts are defined as insurmountable obstacles, i.e., hard constraints, in the causal reasoning process. During the traversal of any causal path, if a path attempts to cross an edge marked with a temporal conflict, the path will be directly judged as an illogical path, without further probability calculation. In this way, the fourth kernel ensures that obvious temporal paradoxes, such as a character arriving before starting or a deceased person appearing after death, will not be misjudged as low-probability but reasonable events, thereby improving the system's ability to filter out basic logical errors. Finally, the graph processed by the fourth kernel is the event chain graph corresponding to the film script text. This graph not only contains probabilistic causal dependencies but also embeds deterministic logical forbidden zones.

[0083] In another embodiment, this disclosure also provides a first kernel, specifically used for: parsing the timestamp of each event unit to obtain the temporal order relationship corresponding to multiple event units, parsing the scene description to obtain the spatial position relationship corresponding to multiple event units, and parsing the role behavior to obtain the role intention relationship of the role in multiple event units; using the temporal order relationship, spatial position relationship and role intention relationship of multiple event units as conditions, querying the frequency of the corresponding transition in the conditional probability table; and after determining the weight of the corresponding directed edge according to the frequency corresponding to the temporal order relationship, spatial position relationship and role intention relationship, constructing a temporal subgraph, a spatial subgraph and an intention subgraph respectively.

[0084] The process of parsing timestamps to obtain the temporal sequence of multiple event units can involve a first kernel reading the timestamp data carried in each event unit. This timestamp data can be either absolute or relative. The first kernel sorts and compares this time data to determine the chronological order of different event units on the timeline, thus forming a temporal sequence relationship. This temporal sequence relationship is used to define the causal sequence of events, and it, along with spatial location relationships and character intention relationships, serves as input conditions for constructing a subgraph, ensuring that the directed edges in the time subgraph accurately reflect the temporal logic flow of the plot development. The parsing precision of the timestamps can be set according to the actual situation; for example, it can be accurate to the second to handle rapidly changing scenes, or accurate to the day to handle long-span plot jumps.

[0085] Parsing the scene description yields the spatial relationships between multiple event units. The first kernel performs semantic analysis on the text content within each event unit, identifying nouns, directional words, or scene tags describing locations, such as "living room," "palace," or "Martian surface." Spatial relationships can be based on the similarity, adjacency, or distance between the locations of two event units. Combined with temporal order relationships, this constrains the probability of events occurring spatially; for example, characters cannot appear at two locations far apart at the same time. Spatial relationships can be extracted through matching based on a predefined location knowledge base or by clustering the semantic vectors of the scene description using a large model. By parsing the scene description to obtain spatial relationships, the constructed spatial subgraph reflects the coherence and plausibility of the plot in physical space.

[0086] The analysis of character behavior reveals the relationships between character intentions across multiple event units. The first kernel analyzes the characters' actions, dialogues, and psychological descriptions within each event unit to infer changes in their intrinsic motivations or intention states. Character intention relationships can be logical connections between different intention states, such as shifting from the intention to find clues to the intention to discover the truth. This technical feature is used in the overall solution to capture the intrinsic driving forces behind character behavior, which, together with temporal and spatial relationships, constitute a multi-dimensional event association network. The analysis of character intentions can be based on the classification and mapping of action verbs, or it can combine contextual information with deep semantic reasoning through a large model. For example, it can directly extract explicit intention descriptions or implicitly deduce potential behavioral motivations.

[0087] Using the temporal sequence, spatial location, and character intention relationships of multiple event units as conditions, the frequency of corresponding transitions is queried in the conditional probability table. The first kernel uses these three types of relationships as query keys to access the conditional probability table, which is pre-generated by a large model based on statistical analysis of sample script corpora. The conditional probability table stores the statistical frequency or probability values ​​of subsequent events under different preceding conditions. In this way, qualitative semantic relationships can be transformed into quantitative statistical data. The conditional probability table can be constructed from historical classic script libraries, script collections of similar themes, or general narrative corpora. The query process can be exact matching or fuzzy matching based on semantic similarity. By querying the conditional probability table, the system can utilize the statistical patterns of large-scale data to assess the frequency of event connections in the current script.

[0088] Based on the frequency of relationships corresponding to temporal sequence, spatial location, and role intent, the weights of the corresponding directed edges are determined, and time, space, and intent subgraphs are constructed respectively. The first kernel assigns weights to directed edges based on the frequency of the queries; higher frequency indicates a more reasonable relationship under normal logic, and the corresponding weight value can be set larger. The time subgraph consists of nodes with temporal sequence as edges, the space subgraph consists of nodes with spatial location as edges, and the intent subgraph consists of nodes with role intent as edges. These three subgraphs share the same event unit nodes in structure, but the attributes of the edges and the basis for weight calculation are different. This multi-dimensional construction method allows the system to independently examine the logical consistency of the three levels of time, space, and intent, avoiding the one-sidedness of single-dimensional analysis. The subgraphs can be constructed in the form of adjacency matrices, adjacency lists, or other graph data structures.

[0089] In another optional embodiment, the fourth kernel of this disclosure is specifically used for: for temporal order relationships, obtaining the temporal weight of the corresponding directed edge in time based on the frequency of the successor event occurring after the corresponding predecessor event and the total frequency of all possible successor events; for spatial position relationships, extracting the spatial position labels corresponding to each event unit, and obtaining the spatial weight of the directed edge in space based on the number of times the transition from the previous position to the next position and the total number of transitions starting from the previous position; for role intention relationships, obtaining the intention state of the role through semantic parsing, and obtaining the intention weight of the directed edge in intention based on the frequency of the change from any intention to another intention and the total number of changes starting from any intention; constructing a temporal subgraph with event units as nodes, temporal order relationships as directed edges, and attaching a temporal weight to each edge; constructing a spatial subgraph with spatial position relationships as directed edges, and attaching a spatial weight to each edge; and constructing an intention subgraph with role intention relationships as directed edges, and attaching an intention weight to each edge.

[0090] Specifically, regarding temporal order relationships, the temporal weight of the corresponding directed edge is obtained based on the frequency of the successor event occurring after its corresponding predecessor event and the total frequency of all possible successor events. When constructing the temporal subgraph, the fourth kernel uses the statistical principle of frequency estimation to quantify the temporal plausibility of events. For example, this temporal weight can be the ratio of the statistical frequency of the successor event occurring after the predecessor event to the total frequency of all possible successor events. For instance, if the predecessor event is character A entering a room and the successor event is character A sitting down, then the temporal weight equals the number of times character A enters the room and immediately sits down divided by the total number of times any action occurs after entering the room. This provides a quantitative confidence index for causal chains in the temporal dimension, which, in conjunction with the processing of spatial location relationships and character intention relationships, constitutes the foundational data for a multi-dimensional heterogeneous event chain graph. This allows for the identification of event combinations with extremely low probabilities of occurrence in the time series, thereby improving the accuracy of marking logical contradictions. The weight calculation can incorporate a time decay factor or a scene context weighting coefficient.

[0091] For spatial relationships, spatial location labels are extracted for each event unit. Based on the number of times a move occurs from one location to the next and the total number of moves originating from that previous location, the spatial weight of the directed edge is calculated. The fourth kernel analyzes location information in the script's scene description to calculate the physical plausibility of spatial moves. Spatial location labels can include specific location names extracted from the text or abstract spatial area identifiers, such as living room, office, or outdoors. Spatial weight can be the ratio of the frequency of a specific path to the sum of the frequencies of all moves originating from that path. This process works in conjunction with the handling of temporal order to ensure that events are not only temporally coherent but also logically consistent in physical space.

[0092] For example, if two consecutive events have a very large spatial span and lack descriptions of transportation, their spatial weight will be significantly reduced. This spatial weight is attached to a graph with directed edges representing spatial location relationships, forming a spatial subgraph used to detect logical flaws such as instantaneous teleportation or illogical scene transitions. The granularity of the spatial location labels can be set according to the actual situation; for example, it can be accurate to the room number or the building floor level.

[0093] Regarding character intention relationships, semantic parsing is used to obtain the character's intention state. Based on the frequency of changes from one intention to another and the total number of changes originating from any intention, the intention weight of directed edges on intentions is obtained. The fourth kernel utilizes natural language processing technology to deeply understand the psychological motivations behind the character's behavior and quantifies the naturalness of intention transitions. Intention states can include psychological goals extracted from character dialogue or behavioral descriptions through semantic analysis, such as seeking cooperation, expressing anger, or hiding secrets. Intention weights reflect the conditional probability of transitioning from one intention state to another, i.e., the likelihood of transitioning to the next intention under the current intention. This technical feature complements the preceding temporal and spatial dimensions, constituting a comprehensive verification of the script's logic.

[0094] For example, if a character abruptly changes from a calm intention to an angry intention without any intermediate context, the intention weight will be low. This weight is used to construct an intention subgraph, enabling the system to capture deeper logical issues such as sudden changes in character personality or lack of behavioral motivation. The method for extracting intention states can be set according to the actual situation; for example, it can be based on a predefined sentiment lexicon or dynamically generated by a large model.

[0095] Using event units as nodes and temporal relationships as directed edges, each edge is assigned a time weight to construct a temporal subgraph. This subgraph can include a fourth kernel that instantiates weighted temporal causal relationships into an independent graph structure. In this subgraph, nodes remain event units carrying timestamps, role identifiers, and descriptions of role behaviors, while the directed edges connecting nodes represent temporal dependencies, with the edge values ​​representing the previously calculated time weights. This feature serves to specifically carry and display the logical constraints of the time dimension, and it merges with other subgraphs through shared nodes. By constructing this subgraph, the coherence of the timeline can be independently assessed, improving the speed of the inference engine's troubleshooting.

[0096] Using spatial relationships as directed edges, each edge is assigned a spatial weight to construct a spatial subgraph. The fourth kernel maps the statistical patterns of spatial transfers into a graph structure. In this spatial subgraph, nodes are also event units, but edges represent changes in the location of the event, and edge weights characterize the frequency of the spatial transfer within the massive script corpus. This technical feature exists in parallel with the temporal subgraph, aiming to solve geographical logical errors that cannot be detected by simple time series analysis. For example, even if timestamps are continuous, if the spatial weights indicate that a transfer between two locations is physically impossible to complete in a short time, the path will be marked as an anomaly in the spatial subgraph. As an important component of the heterogeneous event chain graph, this spatial subgraph provides the inference engine with hard or soft constraints on spatial dimensions.

[0097] Using the relationships between characters' intentions as directed edges, each edge is assigned an intention weight to construct an intention subgraph. The fourth kernel visualizes the logical chain of a character's psychological changes. In this intention subgraph, edges represent the transitions in a character's intentional state, and weights reflect the rationality and smoothness of these psychological changes. This technical feature enhances the system's ability to uncover the internal logic of the script, enabling detection to go beyond superficial spatiotemporal consistency and delve deeper into the rationality of character development. The intention subgraph, along with the temporal and spatial subgraphs, jointly support the entire event chain graph. These three are interconnected through shared event unit nodes, allowing the system to sensitively detect any logical breaks in any dimension.

[0098] In one optional embodiment, the inference engine disclosed herein is specifically used for: taking each node as the target node, obtaining all predecessor nodes of the target node to form a condition set of the target node; extracting the transition probability from each predecessor node to the target node from the event chain graph, the transition probability being estimated by the statistical frequency of similar event sequences in the same type of script by a large model; substituting the state values ​​of all predecessor nodes in the condition set into the conditional probability table, calculating the joint conditional probability of the node through the chain rule, the state value being used to characterize the probability of the event corresponding to the predecessor node; and obtaining the logical contradiction score of the target node based on the natural logarithm of the joint conditional probability of the target node, which serves as the occurrence rationality value corresponding to the target node.

[0099] This process involves taking each node as the target node and obtaining all its predecessor nodes to form a condition set for the target node. This can be achieved by the inference engine, during the traversal of the event chain graph, setting the currently evaluated event unit node as the target node and tracing back through all directed edges in the graph structure that directly point to the target node, identifying these nodes as predecessor nodes. These predecessor nodes collectively constitute the condition set influencing the rationality of the target node's occurrence. The cooperative relationship between the target node and its predecessor nodes is manifested as a partial truncation of the causal dependency chain; that is, the occurrence state of the target node logically depends on the state combination of all its predecessor nodes. By constructing this condition set, the inference engine can establish the input boundary for probability calculations, improving the accuracy of probability evaluation based on a complete contextual causal environment.

[0100] The transition probability from each predecessor node to the target node is extracted from the event chain graph. This transition probability is estimated by a large model based on the statistical frequency of similar event sequences in similar scripts. A pre-trained large language model can be used as a statistical tool to retrieve massive amounts of similar film and television script text corpora and calculate the conditional frequency of transitioning from a predecessor event state to a target event state. This transition probability reflects the statistical probability that the target event will occur after a specific predecessor event.

[0101] Transition probabilities serve as a bridge connecting graph structure nodes and semantic logic content, and their magnitude directly determines the weight allocation in joint probability calculations. The role of the large model here is to transform unstructured script descriptions into structured probability parameters, enabling a unified measurement of the strength of event associations across different script contexts and improving the accuracy of cross-scenario logical consistency judgments.

[0102] Substituting the state values ​​of all predecessor nodes in the condition set into the conditional probability table, the joint conditional probability of the node is calculated using the chain rule. The state values ​​characterize the probability of the event corresponding to the predecessor node. This can be achieved by the inference engine using the occurrence probabilities of each predecessor node as input variables, combining them with the previously extracted transition probabilities, and iteratively calculating using the chain rule formula in probability theory to obtain the comprehensive probability value of the target node occurring when all predecessor conditions are simultaneously satisfied. The application of the chain rule reflects the logical deduction process under multi-factor coupling; that is, the rationality of the target event is not determined by a single predecessor, but is the result of the combined effect of all relevant predecessor events. This technical feature, closely integrated with the conditional probability table and state values, achieves the mathematical synthesis from local probability to global joint probability, ensuring the rigor and comprehensiveness of the logical evaluation results under complex dependencies among multiple predecessors, and avoiding misjudgments caused by ignoring certain predecessor conditions.

[0103] The logical contradiction score of a target node is obtained by taking the natural logarithm of its joint conditional probability. This score serves as the rationality value for the occurrence of the target node. This can be achieved by applying a natural logarithmic transformation function to the calculated joint conditional probability value, mapping probability values ​​between 0 and 1 to a negative real number range. This result is defined as the logical contradiction score. Since the smaller the probability value, the more negative its natural logarithmic value, this score can sensitively capture extremely low-probability events, i.e., serious logical breakpoints. The natural logarithm operation acts as a non-linear amplifier, significantly amplifying small probability differences at the scoring end, facilitating the system to set a uniform rationality threshold for quickly filtering abnormal nodes. This score, as a direct quantitative indicator of the rationality value, improves the accuracy of logical contradiction point marking.

[0104] In one embodiment, the inference engine is specifically used for: for each predecessor node, combining its corresponding event description with the event description of the corresponding target node to obtain multiple event pairs corresponding to the target node, wherein the event pairs are constructed by using the event description of the predecessor node as a predecessor event description and using the event description of the target node as a successor event description; comparing the semantic similarity of roles, actions, and scenes in the event pairs through a pre-configured similarity matching function in the large model to determine the similarity value of any two event pairs corresponding to the target node; calling the statistical interface of the large model to input event pairs with similarity values ​​greater than a similarity threshold into the large model, and retrieving target event pairs in all historical script corpora whose semantic description similarity to the event pairs corresponding to the target node meets preset conditions, wherein the target event pairs are event pairs whose predecessor event descriptions and successor event descriptions both reach preset matching thresholds; counting the first total number of times the target event occurs after the occurrence of the predecessor event in the target event pair, and counting the second total number of times any event occurs after the occurrence of the predecessor event; and determining the transition probability from the corresponding predecessor node to the target node based on the ratio of the first total number of times to the second total number of times.

[0105] For each predecessor node, its corresponding event description is combined with the event description of the corresponding target node to obtain multiple event pairs for the target node. When traversing the event chain graph, the inference engine backtracks all directly or indirectly connected predecessor nodes for the current target node to be calculated, and pairs each pair of predecessor nodes with the event description text of the target node. This event pair constructs the basic data unit for causal inference. Its predecessor event description carries the background or cause information of the event, while the successor event description represents the possible outcome under a specific background. This combination method aims to transform discrete node information into logically related sequence data. The process of constructing event pairs can be set according to the actual situation; for example, it can be simple string concatenation or object encapsulation based on structured data.

[0106] By pre-configuring a similarity matching function within a large model, the semantic similarity of characters, actions, and scenes in event pairs is compared. This determines the similarity value of any two event pairs corresponding to a target node. Leveraging the powerful natural language understanding capabilities of the large model, core semantic elements in event descriptions can be extracted and mapped to a high-dimensional vector space for distance calculation or cosine similarity evaluation. This similarity matching function quantifies the semantic closeness between different event descriptions, thereby identifying event patterns that, despite superficial differences in wording, have similar actual meanings. The determination of the similarity value relies on the large model's learning of terminology and expression habits in the film and television script domain; its value ranges from 0 to 1, with higher values ​​indicating greater semantic similarity. This technique works closely with the aforementioned event pair construction steps, overcoming the limitations of traditional keyword matching in handling synonym substitution and sentence structure transformation by introducing semantic-level comparison, thus improving the accuracy and representativeness of statistical samples.

[0107] By calling the statistical interface of a large model, event pairs with similarity values ​​greater than a similarity threshold are input into the model. The model retrieves target event pairs from all historical script corpora whose semantic descriptions of the corresponding event pairs meet preset conditions. Based on the initially selected high-similarity event pairs, further deep searching can be performed in the large-scale historical script database. The similarity threshold can be set according to the accuracy requirements of the actual application scenario, for example, 0.8, 0.85, or 0.9. The retrieval process aims to find historical cases that are highly consistent with the current event pair to be analyzed in semantic structure; these historical cases constitute the sample pool for calculating the transition probability. The selection criteria for target event pairs are strictly limited to both the preceding and succeeding event descriptions reaching a preset matching threshold. This ensures the purity of the statistical source data and avoids interference from noisy data in the probability calculation. Through the linkage with the statistical interface of the large model, a leap from local semantic matching to global corpus mining is achieved, significantly expanding the data support range for probability estimation.

[0108] In the statistical analysis of target event pairs, the first total number of occurrences of the target event after the occurrence of the preceding event, and the second total number of occurrences of any event after the occurrence of the preceding event, can include frequency counting operations on the retrieved set of target event pairs. The first total number reflects the actual frequency of the specific target event under a specific preceding condition, representing the strong correlation of the causal path; the second total number reflects the total frequency of all possible events under that preceding condition, representing the overall activity of that preceding condition. These two statistics are the core numerator and denominator basis for calculating conditional probability. The statistical process can be automatically completed by the counting module integrated within the large model, or it can be implemented by an external program calling database aggregation functions; the specific implementation method can be flexibly selected according to the system architecture. This technical feature transforms qualitative semantic matching results into quantitative probability calculation basis through quantified statistical data, reflecting the logical progression from qualitative analysis to quantitative reasoning.

[0109] The transition probability from the corresponding predecessor node to the target node is determined by the ratio of the first total probability to the second total probability. This can include using classic frequentist probability estimation methods, where the numerator is the first total probability and the denominator is the second total probability. This ratio directly represents the likelihood of the target event occurring given that the predecessor event has occurred, serving as the weighting basis for directed edges in the event chain graph. The magnitude of the transition probability directly affects the determination of logical contradictions; a lower probability means that the causal path is less consistent with conventional script logic and is more likely to be marked as an anomaly.

[0110] In another embodiment, this disclosure also provides a real-time detection and automatic repair system for general text logic vulnerabilities based on a large model. The repair output engine is further configured to: for the same logical contradiction, if the improvement of multiple candidate repair patches differs by less than a preset difference threshold, enter a multi-ending patch generation mode; in the multi-ending patch generation mode, split the film and television script text to be detected into multiple branch paths from the corresponding logical contradiction point, apply a candidate patch to each branch path, and form a multi-ending script structure; run causal reasoning detection once for each branch path and record the number of remaining logical contradiction points in each branch path; select the branch path with the fewest remaining logical contradiction points as the main recommended repair scheme, and save the remaining branch paths in abbreviated form in the repair history for users to manually switch and select; highlight the difference points of all branch paths and attach them as annotations to the corresponding positions of the film and television script text.

[0111] The preset difference threshold is a numerical limit used to judge the degree of difference in the reasonableness improvement among multiple candidate repair patches. This preset difference threshold can be flexibly adjusted according to the needs for distinguishability of repair solutions in actual application scenarios. When the difference in the reasonableness improvement among multiple candidate repair patches is less than this preset difference threshold, it indicates that these candidate patches are equally effective in improving logical coherence, and it is difficult to directly determine the optimal solution using a single numerical indicator. In this case, a multi-outcome patch generation mode is triggered to provide diverse repair options.

[0112] The multi-ending patch generation mode is a processing mechanism that, when multiple equivalent or nearly equivalent repair solutions are detected, does not forcibly merge or discard them, but instead preserves and evolves them in parallel, creating various plot development possibilities. In this mode, the repair output engine logically splits the script text to be detected from the marked logical contradictions, forming multiple independent branch paths. Each branch path applies a previously generated candidate repair patch, thereby constructing a multi-ending script structure with different plot developments. This approach allows the system to simulate the decision-making process of a screenwriter facing multiple possibilities during the creative process, preserving the diversity of plot development.

[0113] Branch paths can be independent sequences of plot development formed after logical inconsistencies, due to the application of different candidate fixes. Each branch path contains a complete sequence of events from the point of conflict to the end of the script or the next key node. A causal reasoning check is run separately for each generated branch path. This check process is consistent with the reasoning engine described earlier, namely, traversing the event chain graph in the branch path, calculating the plausibility value of each node, and counting the number of logical inconsistencies that still exist in the path.

[0114] The primary recommended solution is the branch path that, after causal reasoning detection, is determined by the system to have the fewest logical contradictions and the best logical coherence. After comparing the remaining logical contradictions across all branch paths, the path with the fewest contradictions is automatically selected as the default primary recommended solution and presented directly to the user. Other branch paths not selected as the primary recommendation are not discarded but saved in abbreviated form in the repair history. The abbreviated form can include displaying only key differences, summary descriptions, or path identifiers, aiming to save display space while allowing users to manually switch to view other potentially plausible plot developments when needed, thus giving users control and choice over the final script's direction.

[0115] Difference highlighting can be implemented in the user interface to visually highlight the differences in text content, event descriptions, or logical structures between different branch paths. By comparing the event descriptions of each branch path, textual differences arising from the application of different candidate patches can be identified, and these differences can be displayed in the corresponding positions in the script text using highlight colors, bolding, underlining, or other visual markers. Additionally, annotations can be added to explain the reasons for the differences or their impact on the plot, helping users quickly understand the subtle differences between different repair solutions and facilitating efficient manual review and decision-making.

[0116] In one possible implementation, the repair output engine is specifically used to: read event nodes marked as logical contradiction points, obtain the event description of the event node and the event descriptions of the two adjacent event nodes before and after it; determine the contradiction type of the logical contradiction point based on the time description of the event node and the event descriptions of the corresponding two adjacent event nodes before and after it, where the contradiction type includes one or more of the following: timeline contradiction, character behavior contradiction, prop setting contradiction, and spatial location contradiction; use the contradiction type of the logical contradiction point as a constraint condition to construct a natural language prompt that includes contextual logical relationships, where the natural language prompt is used to guide the large model to generate multiple replacement event descriptions; and input the natural language prompt into the large model so that the large model outputs multiple candidate repair patches based on the contextual logical relationships in the natural language prompt.

[0117] The repair output engine locates specific event units marked as having logical problems from the detection results output by the inference engine. These event nodes typically carry a unique identifier and a status flag. The engine obtains the event description of the event node and the event descriptions of its two preceding and following event nodes. This can involve tracing back two preceding event nodes in chronological or causal order and tracing back two following event nodes, thus constructing a local context window containing five event units. The scope of this local context window can be set according to the actual situation; for example, it could be one preceding and three following nodes. In this way, the repair output engine can capture the complete narrative context surrounding the logical contradiction. There is a close linkage between the event descriptions in the local context window and the logical contradiction. The preceding events provide the cause of the current state, and the following events reflect the result caused by the current state. Together, they define the functional positioning of the logical contradiction in the overall event chain, enabling the system to perform accurate analysis based on a coherent narrative flow.

[0118] Based on the extracted time description information and the semantic content of each event node in the context, specific manifestations of logical inconsistencies are classified and identified. Contradiction types include one or more of the following: timeline contradictions, character behavior contradictions, prop setting contradictions, and spatial location contradictions. Timeline contradictions may include events occurring in a sequence that violates causality or timestamp conflicts, such as a later event occurring before a previous event without a reasonable flashback explanation; character behavior contradictions may include a character's actions, dialogue, or psychological state contradicting their established persona or intentional state in previous events; prop setting contradictions may include key items appearing, disappearing, or changing in state in the plot without necessary foreshadowing or violating physical common sense; spatial location contradictions may include characters or objects appearing in scenes that are too far away or inaccessible without the ability to move. The determination of the contradiction type directly determines the constraint direction of the generated repair suggestions, forming a cooperative relationship with the contextual event descriptions. This guides the large model to focus on specific logical breakpoints for correction during the generation process, thereby achieving differentiated processing of logical loopholes of different natures.

[0119] By using the contradiction type of logical inconsistencies as constraints, natural language prompts that incorporate contextual logical relationships are constructed. This can include building a structured instruction text that contains both plot facts extracted from the local context window and explicitly embeds the identified contradiction type labels. These natural language prompts guide the large model in generating multiple alternative event descriptions. For example, natural language prompts can be templated, such as the current plot context being a preceding event, the current event, and a subsequent event. If a contradiction type is detected in the current event, multiple modified descriptions of the current event can be generated based on the aforementioned contextual logical relationships to eliminate the contradiction and maintain plot coherence. This prompt construction method transforms abstract logical constraints into natural language instructions understandable by the large model, serving as a bridge between human screenwriter thinking and the large model's generative capabilities. By embedding contradiction types as hard constraints into the prompt words, the system can limit the search space of the large model, strictly confining its generated candidate content to the scope of solving specific logical problems, avoiding irrelevant divergences that might arise from general generation.

[0120] Inputting natural language prompts into a large model can be achieved by calling the model's interface and sending the constructed prompt text as input parameters. The large model then outputs multiple candidate repair patches based on the contextual logic within the natural language prompts. This can be achieved by leveraging its pre-trained language understanding and generation capabilities to parse the contextual semantics and constraints within the prompts, generating various possible rewrite schemes for the identified logical contradictions. Each candidate repair patch corresponds to a modified event description. During the generation process, the large model adjusts its generation strategy based on the explicit contradiction type in the prompts, ensuring that the output patch is not only linguistically fluent but also logically compatible with the preceding and following events. The generated candidate repair patches are then evaluated, with the best one selected based on the calculated improvement in reasonableness. This process achieves a closed loop from problem localization and type identification to targeted generation, making the generation of repair suggestions highly targeted and controllable.

[0121] In one optional embodiment, this disclosure provides a method for real-time detection and automatic repair of general text logic vulnerabilities based on a large model, the method comprising:

[0122] Step 1: Send the film script text to be detected to the general text logic vulnerability real-time detection and automatic repair system based on a large model in the above embodiment through any device;

[0123] The device can include any terminal hardware with network communication capabilities and the ability to run text editing or transmission applications, including but not limited to desktop computers, laptops, tablets, smartphones, or dedicated scriptwriting workstations. The film and television script text to be detected can be a script file stored in a digital format, encompassing plain text, rich text, markup language, or industry-specific formats. The content includes structured or unstructured data such as scene titles, character action descriptions, dialogue, and time and location annotations. The sending operation establishes a communication link between the device and the system via a wired or wireless network, utilizing Hypertext Transfer Protocol (HTTP), WebSocket long connections, or Remote Procedure Call (RPC) interfaces to upload the film and television script text data stream to the system's text sending and receiving engine. For example, after a screenwriter completes the first draft of an episode's script in a scriptwriting application on a tablet, they click the smart detection button. The application automatically encapsulates the script file into a JSON data packet and sends it via the internet to the detection system server deployed in the cloud. This cross-device sending mechanism breaks through the functional limitations of traditional local software, allowing users to access powerful backend computing resources from any location using any compatible terminal, enabling flexible initiation of detection tasks and real-time data transmission.

[0124] Step 2: Obtain remediation suggestions through a real-time detection and automatic repair system for general text logic vulnerabilities based on a large model;

[0125] The general text logic vulnerability real-time detection and automatic repair system based on a large model is the complete technical architecture entity defined in the aforementioned embodiments. It integrates a text sending and receiving engine, a graph construction engine, an inference engine, and a repair output engine. The execution of this step is carried out by various collaborative components within the system: First, the text sending and receiving engine receives and parses the uploaded film script text; then, the graph construction engine, based on the conditional probability table statistically derived from the large model, segments the text into event units carrying timestamps, character identifiers, and behavioral descriptions, and constructs a heterogeneous event chain graph containing multi-dimensional relationships of time, space, and intent; next, the inference engine traverses the graph path, calculates the reasonableness value of nodes under joint probabilities, and identifies logical contradictions below a preset threshold; finally, the repair output engine generates natural language prompts for each logical contradiction, combining contextual logical relationships, driving the large model to produce multiple candidate repair patches, and selecting the optimal solution as a repair suggestion by calculating the reasonableness improvement.

[0126] For example, when the system detects that character A, who was injured and left the scene in the previous scene, reappears at the fight scene in the next scene without any prior setup, the reasoning engine determines this to be a contradiction in the character's behavior. The repair output engine then generates candidate solutions such as adding transitional descriptions of character A arriving injured or modifying the scene to have a stand-in participate in the fight. It calculates that the former maximizes the improvement of plot coherence and thus determines it as the final repair suggestion. This step automates the process of manual word-by-word review and repeated deliberation, and by leveraging the semantic understanding capabilities of large models and the deep integration of causal reasoning algorithms, it ensures the logical rigor and creative feasibility of the repair suggestions.

[0127] Step 3: Receive and display remediation suggestions from the real-time detection and automatic repair system for general text logic vulnerabilities based on large models via the device;

[0128] The receiving process can include any device acquiring a data packet containing repair suggestions from the system via a communication link. Display can involve the device's interface presenting the received data to the user in a visual format. Display formats include, but are not limited to, pop-up prompts, sidebar annotations, highlighted comparisons with the original text, or independent report detail pages. Specifically, the client software on the device parses the repair suggestion data returned by the system, locates the corresponding logical contradictions in the film / television script, and displays the original event description alongside or highlights the differences between the original and the recommended modified event descriptions. For example, on a mobile phone's script editing interface, the system's repair suggestions appear as floating cards next to logically broken paragraphs. The cards clearly list the contradiction type, the analysis of the contradiction's cause, and the recommended specific modifications. Users can directly click the "apply" button to replace the suggested content with the original text with one click, or click to view details and read the derivation process of multiple ending branches. Through this closed-loop receiving and display mechanism, complex backend reasoning results are transformed into interactive information that users can intuitively understand and quickly operate, significantly shortening the time cycle from problem discovery to problem resolution and improving the overall efficiency of script creation and revision.

[0129] The preferred embodiments of the present disclosure have been described in detail above with reference to the accompanying drawings. However, the present disclosure is not limited to the specific details of the above embodiments. Within the scope of the technical concept of the present disclosure, various changes, modifications, substitutions and variations can be made to these embodiments, and all such changes, modifications, substitutions and variations fall within the protection scope of the present disclosure.

[0130] It should also be noted that the various specific technical features described in the above embodiments can be combined in any suitable manner without contradiction, and such combinations should also be considered as part of this disclosure. To avoid unnecessary repetition, this disclosure will not further describe the various possible combinations. The technical scope of this application is not limited to the contents of the specification, but must be determined according to the scope of the claims.

Claims

1. A real-time detection and automatic repair system for general text logic vulnerabilities based on a large model, characterized in that, include: A text transceiver engine, a graph construction engine that is communicatively connected to the text transceiver engine, an inference engine that is communicatively connected to the graph construction engine, and a repair output engine that is communicatively connected to the inference engine; The text transceiver engine is used to receive the film and television script text to be detected; The graph construction engine is used to divide the film and television script text into multiple event units according to film and television scenes. Each event unit carries a timestamp, a character identifier, and a character behavior description. Using all the event units as nodes and the causal dependencies between the events as directed edges, an event chain graph corresponding to the film and television script text is constructed. The weight of each directed edge is calculated through a conditional probability table, which is obtained by a large model from statistical analysis of the sample script corpus. The inference engine is used to traverse each path in the event chain graph using a causal inference algorithm, calculate the occurrence rationality value of each node under the joint probability of all predecessor nodes, and mark the corresponding node as a logical contradiction point if any occurrence rationality value is lower than a preset rationality threshold. The repair output engine is used to generate multiple candidate repair patches by calling the large model for each logical contradiction point. Each candidate repair patch corresponds to a modified event description. By calculating the rationality improvement of the entire path after the candidate repair patch is replaced, the candidate repair patch with the largest rationality improvement is selected as the repair suggestion and sent by the text sending and receiving engine.

2. The real-time detection and automatic repair system for general text logic vulnerabilities based on a large model as described in claim 1, characterized in that, The graph construction engine includes: The first kernel is used to extract the temporal sequence relationship, spatial location relationship and role intention relationship from each event unit, calculate the weight of each directed edge through a conditional probability table, and construct the temporal subgraph, spatial subgraph and intention subgraph respectively. The second kernel is used to fuse the time subgraph, the spatial subgraph, and the intent subgraph through shared nodes to form a multi-dimensional heterogeneous event chain graph, wherein the edges between nodes in the heterogeneous event chain graph are assigned different color labels according to the relationship type. The third kernel is used to calculate the absolute value of the time interval between adjacent nodes in the time subgraph. If the absolute value of the time interval exceeds the maximum allowed time difference, a time conflict marker is added between the two nodes. The fourth kernel is used to treat the edges marked with the time conflict as hard constraints in causal reasoning, so that any causal path that crosses the edge is judged as an unreasonable logical path, thereby obtaining the event chain graph corresponding to the film and television script text.

3. The real-time detection and automatic repair system for general text logic vulnerabilities based on a large model according to claim 2, characterized in that, The first kernel is specifically used for: For each event unit, its timestamp is parsed to obtain the temporal order relationship of multiple event units, the scene description is parsed to obtain the spatial position relationship of the multiple event units, and the character behavior is parsed to obtain the character intent relationship of the characters in the multiple event units; The temporal sequence relationship, spatial position relationship, and role intention relationship of the multiple event units are used as conditions to query the frequency of the corresponding transition in the conditional probability table. Based on the frequencies corresponding to the temporal sequence relationship, the spatial position relationship, and the role intention relationship, the weights of the corresponding directed edges are determined, and then a temporal subgraph, a spatial subgraph, and an intention subgraph are constructed respectively.

4. The real-time detection and automatic repair system for general text logic vulnerabilities based on a large model according to claim 3, characterized in that, The fourth kernel is specifically used for: For the aforementioned temporal order relationship, the temporal weight of the corresponding directed edge is obtained based on the frequency of the successor event occurring after the corresponding predecessor event and the total frequency of all possible successor events. For the spatial positional relationship, extract the spatial positional label corresponding to each event unit, and obtain the spatial weight of the directed edge in space based on the number of times the transition from the previous position to the next position and the total number of transitions starting from the previous position. For the aforementioned character intention relationships, the character's intention state is obtained through semantic parsing. Based on the frequency of changes from any intention to another intention and the total number of changes starting from any intention, the intention weight of the directed edge on the intention is obtained. Using the event unit as a node and the temporal sequence relationship as a directed edge, with each edge assigned a temporal weight, the temporal subgraph is constructed. Using the spatial positional relationships as directed edges, and attaching the spatial weight to each edge, the spatial subgraph is constructed; Using the aforementioned role intention relationships as directed edges, and attaching the aforementioned intention weight to each edge, the intention subgraph is constructed.

5. The real-time detection and automatic repair system for general text logic vulnerabilities based on a large model according to claim 1, characterized in that, The inference engine is specifically used for: Taking each node as the target node, obtain all the predecessor nodes of the target node to form the condition set of the target node; The transition probability from each predecessor node to the target node is extracted from the event chain graph. The transition probability is estimated by the statistical frequency of similar event sequences in the same script by a large model. Substitute the state values ​​of all the predecessor nodes in the condition set into the conditional probability table, and calculate the joint conditional probability of the node using the chain rule. The state values ​​are used to characterize the probability of the event corresponding to the predecessor node. The logical contradiction score of the target node is obtained by taking the natural logarithm of the joint conditional probability of the target node, and is used as the occurrence rationality value of the target node.

6. The real-time detection and automatic repair system for general text logic vulnerabilities based on a large model according to claim 5, characterized in that, The inference engine is specifically used for: For each predecessor node, its corresponding event description is combined with the event description of the corresponding target node to obtain multiple event pairs corresponding to the target node. The event pairs are constructed by using the event description of the predecessor node as a predecessor event description and using the event description of the target node as a successor event description. By using a pre-configured similarity matching function in the large model, the semantic similarity of characters, actions, and scenes in the event pairs is compared to determine the similarity value of any two event pairs corresponding to the target node. The statistical interface of the large model is called, and the event pairs with similarity values ​​greater than the similarity threshold are input into the large model. The target event pairs corresponding to the target node in all historical script corpora are retrieved. The semantic description similarity of the event pairs is satisfied with the preset conditions. The target event pairs are event pairs whose predecessor event description and successor event description both reach the preset matching threshold. Count the first total number of times the target event occurs after the preceding event occurs in the target event pair, and count the second total number of times any event occurs after the preceding event occurs; The transition probability from the corresponding predecessor node to the target node is determined based on the ratio of the first total number of iterations to the second total number of iterations.

7. The real-time detection and automatic repair system for general text logic vulnerabilities based on a large model according to any one of claims 1-6, characterized in that, The repair output engine is also used for: For the same logical contradiction, if the improvement of multiple candidate repair patches differs by less than a preset difference threshold, then the multi-ending patch generation mode is entered. In the multi-ending patch generation mode, the film and television script text to be detected is split into multiple branch paths from the corresponding logical contradiction points, and a candidate patch is applied to each branch path to form a multi-ending script structure. Run a causal reasoning test once for each branch path and record the number of remaining logical contradictions in each branch path; The branch path with the fewest remaining logical contradictions is selected as the primary recommended repair solution, while the remaining branch paths are saved in abbreviated form in the repair history for users to manually switch between and select. Highlight all the differences in the branch paths and add them as annotations to the corresponding positions in the film and television script text.

8. The real-time detection and automatic repair system for general text logic vulnerabilities based on a large model according to any one of claims 1-6, characterized in that, The repair output engine is specifically used for: Read the event node marked as the logical contradiction point, and obtain the event description of the event node and the event descriptions of the two adjacent event nodes before and after it; Based on the time description of the event node and the event descriptions of the two adjacent event nodes before and after it, the contradiction type of the logical contradiction point is determined. The contradiction type includes one or more of the following: timeline contradiction, character behavior contradiction, prop setting contradiction, and spatial location contradiction. The contradiction type of the logical contradiction point is used as a constraint condition and concatenated into a natural language prompt that includes the contextual logical relationship. The natural language prompt is used to guide the large model to generate multiple alternative event descriptions. The natural language prompts are input into the large model, so that the large model outputs the multiple candidate repair patches based on the contextual logical relationships in the natural language prompts.

9. A method for real-time detection and automatic repair of general text logic vulnerabilities based on a large model, characterized in that, The method includes: Send the film and television script text to be detected to the general text logic vulnerability real-time detection and automatic repair system based on a large model according to any one of claims 1-8 via any device; Repair suggestions are obtained through the aforementioned real-time detection and automatic repair system for general text logic vulnerabilities based on large models; The device receives and displays the repair suggestions sent by the large-model-based general text logic vulnerability real-time detection and automatic repair system.