Fine-grained large model illusion processing method and system based on zero resource framework
Through the multi-dimensional anomaly detection and dynamic context window adjustment based on the zero-resource framework, the fine-grained illusion problem of large language models when generating text is solved, the accuracy and security of text are improved, and it is suitable for multi-language and multi-field applications.
Patent Information
- Application Number
- CN202510174481.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-18
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2045-02-18
AI Technical Summary
Existing large language models are prone to fine-grained illusions when generating text, such as incorrect grammar, semantic deviation, numerical errors, etc., which makes it difficult to guarantee the accuracy and security of the text, especially in application scenarios such as medical and legal high security requirements.
The fine-grained large-model illusion processing method based on the zero-resource framework is adopted, and efficient detection and correction of fine-grained illusion is achieved through multi-dimensional anomaly detection (including dimensions such as generation probability, semantic similarity, syntax consistency, etc.) and dynamic context window adjustment.
It significantly improves the hallucination detection and processing capabilities of large language models, especially on fine-grained hallucinations problems, ensuring the accuracy and security of generated texts, and is suitable for multilingual and multi-field application scenarios.
Smart Images

Figure CN119670760A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a fine-grained large model hallucination processing method and system based on a zero-resource framework. Background Art
[0002] The statements in this section merely provide background art related to the present invention and do not necessarily constitute prior art.
[0003] With the rapid development of deep learning technology, large language models (such as GPT, BERT, etc.) have achieved remarkable results in the field of natural language generation. These models have shown strong capabilities in tasks such as text generation, dialogue systems, and machine translation, especially in terms of language fluency and semantic relevance. However, despite their excellent performance, large language models still face a core problem - hallucination. Hallucination refers to the wrong information generated by the model when generating text, which is usually manifested as incorrect grammar, semantic deviation, inaccurate inference, etc., which may mislead users, especially in applications with high requirements for security and reliability, affecting their usability.
[0004] Existing hallucination detection and correction technologies mainly rely on supervised learning, external knowledge base comparison, and macro-granularity detection strategies. However, supervised learning methods rely on large-scale annotated data for model training, which is not only costly but also difficult to meet the needs of multiple fields and multiple languages; external knowledge base comparison methods are limited by the coverage of the knowledge base, and their effectiveness decreases significantly when there is insufficient field-specific data; macro-granularity detection methods focus on error detection of the entire text, and are difficult to capture subtle grammatical anomalies, semantic deviations, or local errors.
[0005] Therefore, existing methods have significant limitations in capturing and correcting fine-grained hallucinations, and cannot fully guarantee the accuracy and security of generated text. For example, in medical text generation, existing methods have difficulty effectively identifying fine-grained hallucination problems. When the original text describes "the patient's blood pressure is 120 / 80 mmHg", the large language model may generate "the patient's blood pressure is 130 / 85 mmHg". Although this deviation seems small, in medical decision-making, such subtle changes may mislead doctors to judge whether blood pressure is normal, thereby affecting treatment decisions. In application scenarios with high security and high reliability requirements, if such fine-grained hallucinations are not discovered and corrected in time, the risk of misleading will increase and affect the availability and reliability of the text. However, in complex and multi-field applications, existing methods often find it difficult to fully ensure the accuracy and consistency of generated texts, and cannot effectively guarantee the security and reliability of generated texts. Summary of the invention
[0006] In order to address the deficiencies in the prior art, the present invention provides a fine-grained large model hallucination processing method and system based on a zero-resource framework, which realizes the detection of over-confidence, subtle semantic and grammatical deviation hallucinations in the detection content, improves the hallucination detection and processing capabilities of large language models, especially the detection and processing capabilities for fine-grained hallucination problems.
[0007] In order to achieve the above object, the present invention adopts the following technical solution: In a first aspect, the present invention provides a fine-grained large model hallucination processing method based on a zero-resource framework.
[0008] A fine-grained large model hallucination processing method based on a zero-resource framework includes the following processes: Acquire the text to be detected and perform preprocessing, wherein the preprocessing includes: performing syntactic analysis to generate a syntactic dependency tree; Perform multi-dimensional anomaly detection on the pre-processed text using a large language model to obtain multi-dimensional anomaly detection results; Prioritize anomaly correction based on multi-dimensional anomaly detection results; Dynamically adjust the context window range based on the syntactic analysis results and the generated syntactic dependency tree; Combined with the adjusted context window range, the results of the abnormal correction priority ranking are used to prioritize the correction of high-risk words and sentences; The revised content is evaluated and the revised final text is obtained when the termination conditions are met.
[0009] As a further limitation of the first aspect of the present invention, the text content to be detected is segmented, punctuation is removed, and capitalization is unified, and a syntactic dependency tree is generated using a syntactic analysis tool; through syntactic analysis, a syntactic role is assigned to each word, and the syntactic relationship and its depth information are recorded.
[0010] As a further limitation of the first aspect of the present invention, the multi-dimensional anomaly detection of the pre-processed text content by the large language model is performed to obtain a multi-dimensional anomaly detection result, including: Generate a candidate word list through a large language model, calculate the generation probability of each word to be tested and the candidate word, and evaluate whether there is a generation probability anomaly based on the difference in generation probability between the word to be tested and the candidate word. When the difference is greater than the set threshold, it is marked as an anomaly and the anomaly score is calculated; The enhanced embedding vectors of each word to be detected and the context are obtained through the large language model, and semantic similarity anomaly detection is performed. When the semantic similarity is lower than the set threshold, it is marked as an anomaly and the anomaly score is calculated; Through the syntactic dependency tree and the recorded lexical and grammatical roles, grammatical consistency detection is performed. When the grammatical consistency is lower than the set threshold, it is marked as abnormal and the abnormality score is calculated; Check the rationality of the part-of-speech role, the legitimacy of the dependency relationship, and the integrity of the syntactic dependency tree structure of each word to be tested. If it does not conform to the regular syntactic pattern, it will be marked as abnormal and the abnormality score will be calculated; The obtained anomaly scores of different dimensions are weighted and summed as the comprehensive anomaly score corresponding to each word to be detected.
[0011] As a further limitation of the first aspect of the present invention, performing anomaly correction priority sorting according to the multi-dimensional anomaly detection result includes: According to the multi-dimensional anomaly detection results, the comprehensive anomaly score of each word to be detected and the proportion of abnormal words in each sentence are calculated; For each abnormal sentence, the correction priority is sorted based on the abnormal proportion; For the abnormal words that are not covered, the correction priorities are sorted according to their comprehensive scores.
[0012] As a further limitation of the first aspect of the present invention, dynamically adjusting the anomaly correction priority includes: recalculating the anomaly score of each to-be-detected word according to the adjusted context window range, adjusting the priority sorting, and giving priority to the part that has a significant impact on the global quality.
[0013] As a further limitation of the first aspect of the present invention, dynamically adjusting the context window range according to the syntactic analysis result and the generated syntactic dependency tree includes: Based on the recorded syntactic analysis results, the context window size is preliminarily allocated according to the part-of-speech role of each word to be tested; Through the syntactic dependency tree, the syntactic distance between each word to be detected and other words in the context is calculated, and the dependency strength is calculated; Calculate semantic similarity based on the semantic association between each word to be detected and the context words; By combining dependency strength and semantic similarity, the window range is dynamically adjusted to generate an adaptable MASK matrix. The generated MASK matrix is combined with the multi-head attention mechanism of the large language model to dynamically adjust the attention weight distribution and focus on the contextual information of highly correlated areas.
[0014] As a further limitation of the first aspect of the present invention, the first window range is determined according to the dependency strength, the second window range is determined according to the semantic similarity, and the intersection of the first window range and the second window range is used as the dynamically adjusted context window range to generate a highly adaptable MASK matrix; Combine the generated MASK matrix with the multi-head attention mechanism of the large language model, including: ,in, are query vector, key vector and value vector respectively, is the dimension of the key vector, is the normalized exponential function, is the attention mask, Represents transpose.
[0015] As a further limitation of the first aspect of the present invention, abnormal sentences marked as high risk are processed preferentially, a prompt-guided model is used to generate reconstruction prompts, candidate sentences are generated by a large language model according to the reconstruction prompts, the candidate sentences are evaluated, and the sentence with the highest comprehensive score is selected as the replacement result, and if the number of abnormal sentences is greater than a set threshold, they are modified in descending order according to the abnormal proportion and the abnormal score; After completing the correction of abnormal sentences, for the remaining high-risk words, use the adjusted context window to capture their context information, generate a candidate word list through the large language model, and select the candidate words with the highest scores from the candidate word list for replacement. If the number of abnormal words in the text to be corrected is greater than the set threshold, a batch correction strategy is adopted to correct the abnormal words in stages according to priority, and only the affected context is recalculated through the incremental update mechanism.
[0016] As a further limitation of the first aspect of the present invention, evaluating the revised content and obtaining a revised final text when a termination condition is met includes: After the correction is completed, the global anomaly score of the text is recalculated, and the scope of the remaining anomalies is analyzed in combination with the syntactic dependency tree; If the global consistency of the corrected syntactic dependency tree is greater than the set threshold, and the remaining anomalies are concentrated in the low-risk area, the final result is output in advance; otherwise, the remaining anomalies are marked and the next round of correction iteration is entered; Set the maximum number of iterations. When the number of iterations reaches the upper limit and the anomaly score is still not fully up to standard, the current correction result will be output as a suboptimal solution, and the remaining problems will be marked for manual intervention or further optimization.
[0017] In a second aspect, the present invention provides a fine-grained large model hallucination processing system based on a zero-resource framework.
[0018] A fine-grained large model hallucination processing system based on a zero-resource framework, comprising: The text preprocessing unit is configured to: obtain the text to be detected and perform preprocessing, wherein the preprocessing includes: performing syntactic analysis and generating a syntactic dependency tree; The multi-dimensional anomaly detection unit is configured to: perform multi-dimensional anomaly detection on the pre-processed text content through the large language model to obtain a multi-dimensional anomaly detection result; The anomaly correction priority sorting unit is configured to: sort the anomaly correction priorities according to the multi-dimensional anomaly detection results; The context window dynamic adjustment unit is configured to: dynamically adjust the context window range according to the syntactic analysis result and the generated syntactic dependency tree; The multi-round iterative correction unit is configured to: combine the adjusted context window range, and perform priority correction of high-risk words and sentences according to the abnormal correction priority sorting result; The correction evaluation unit is configured to: evaluate the corrected content and obtain the corrected final text when the termination condition is met.
[0019] Compared with the prior art, the present invention has the following beneficial effects: 1. The present invention innovatively proposes a zero-resource, fine-grained, large language model hallucination processing method, which realizes an efficient detection and correction process without relying on large-scale annotated data. It does not require additional annotated data and can adapt to multi-language and multi-field application scenarios, significantly reducing development costs and improving applicability and scalability.
[0020] 2. The present invention can accurately capture fine-grained hallucination problems such as numerical errors, semantic conflicts, and syntactic anomalies by using multi-dimensional detection strategies such as generation probability, grammatical consistency, and semantic similarity, thereby greatly improving detection coverage and accuracy.
[0021] 3. The present invention can automatically adjust the detection range according to the semantic relevance and syntactic structure of the text through a dynamic window mechanism, so that the method can flexibly respond to text scenes of different complexities, give priority to potential abnormal areas, and ensure that high-risk areas can be identified and corrected in a timely manner.
[0022] 4. The present invention uses multiple rounds of iterative corrections and prioritizes high-risk areas, which can reduce the introduction of new hallucinations during the correction process and ensure global consistency, ultimately achieving high-quality text output.
[0023] 5. The present invention provides a comprehensive correction log and basis, including anomalies, correction strategies and consistency scores, which enhances the explainability and user trust of the detection and correction process.
[0024] Advantages of additional aspects of the present invention will be given in part in the following description, and in part will become obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0026] Figure 1 A schematic flow chart of a fine-grained large model hallucination processing method based on a zero-resource framework provided in Example 1 of the present invention; Figure 2 A schematic diagram of a process for dynamically adjusting a context window range provided in Embodiment 1 of the present invention; Figure 3 A schematic diagram of a fine-grained large model hallucination processing system based on a zero-resource framework provided in Example 2 of the present invention. DETAILED DESCRIPTION
[0027] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0028] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.
[0029] In the absence of conflict, the embodiments of the present invention and the features of the embodiments may be combined with each other.
[0030] Embodiment 1: In the process of text generation and application of large language models, hallucination is a prominent challenge, among which fine-grained hallucination is particularly difficult to detect and correct. Among fine-grained hallucinations, semantic hallucination and grammatical hallucination are two typical types. Semantic hallucination is usually manifested as semantic inconsistency between words or sentences generated by the model, such as implicit conflict or semantic ambiguity between contexts; while grammatical hallucination is manifested as the existence of structures that do not conform to language norms in the text generated by the model, such as syntactic role mismatch and dependency error. The above two types of hallucinations not only belong to the category of factual hallucinations, but are also more subtle and complex than hallucinations such as logical errors that take the whole sentence as the basic unit, and are more difficult to detect. Traditional question-answering-based hallucination detection methods (such as asking whether the text is contradictory or whether there are grammatical errors) often cannot capture these problems well. In addition, the existence of fine-grained hallucination problems such as semantic conflict and syntactic mismatch in high-reliability scenarios (such as legal text generation) may cause the model output content to be misunderstood or directly applied, resulting in serious consequences. Therefore, how to effectively detect and correct fine-grained hallucinations has become a key issue in improving the reliability of large language models.
[0031] In view of this, this implementation proposes a fine-grained large model hallucination processing method based on a zero-resource framework, which can detect the over-confidence, subtle semantic and grammatical deviation hallucinations of the detection content, thereby improving the hallucination detection capability of the large language model, especially the detection capability of fine-grained hallucination problems. The following is a brief introduction to the technical terms and related concepts involved in this processing solution, including: Large Language Model (LLM) is a type of natural language processing (NLP) model based on deep learning. It can generate, understand and process natural language by training on large-scale text data. Hallucinations refer to content generated by the model that is inconsistent with actual facts or is completely fictitious. These content may be false information generated by the model based on its training data, irrelevant details, or completely fabricated facts; Zero-resource framework refers to a technical architecture that does not rely on external annotated data or external knowledge base. It performs tasks by leveraging existing models, algorithms, or other internal mechanisms without the need for additional external resources. Fine-grained detection and correction refers to identifying and correcting errors or hallucinations in generated text in a highly accurate and hierarchical manner. Fine-grained methods not only focus on the overall accuracy of the text, but also conduct in-depth analysis and correction in multiple dimensions (such as grammar, semantics, context, etc.); Anomaly detection is a method for identifying potential problems or errors by identifying behaviors in data that do not conform to normal patterns. In text generation, anomaly detection is used to find generated content that does not conform to normal language patterns, especially for detecting hallucinations. Semantic similarity measures the similarity between two texts in terms of meaning, rather than just the similarity in surface form. Semantic similarity is usually obtained by calculating word vectors, sentence vectors, or using deep learning models. Its purpose is to measure the semantic consistency of text content. The context window refers to the range of text context considered by the model when the large language model generates text. This window usually includes several words or sentences in the previous text and is used to generate the next word or sentence. Prioritization refers to sorting detected problems or tasks according to certain criteria to determine the order of priority; Model correction and feedback refers to a series of corrective measures and feedback mechanisms taken when the model generates errors or illusions; Grammatical consistency refers to the correctness and consistency of the grammatical structure of the generated text. Grammatical consistency ensures that the text conforms to the basic grammatical rules of the language, including vocabulary collocation, sentence structure, etc.
[0032] like Figure 1 As shown, the fine-grained large model hallucination processing method based on the zero-resource framework described in this implementation includes the following processes: S1: Obtain a large language model and the content to be detected and perform preprocessing, including performing syntactic analysis and building a syntactic dependency tree; Specifically, the large language model can be a pre-trained large model. The content to be detected is the text content that needs to be hallucinated. The content to be detected is preprocessed by word segmentation, punctuation removal, capitalization unification, etc., and then a syntactic analysis tool is used to generate a syntactic dependency tree. Through syntactic analysis, a syntactic role (such as subject, predicate, object) is assigned to each word, and the syntactic relationship and its depth information are recorded to provide basic data for subsequent processing.
[0033] More specifically, a syntactic analysis tool (such as hanlp) is used to perform syntactic analysis on the text to be tested. In the process of obtaining the syntactic analysis tree, the grammatical role and syntactic role of each word will be marked for subsequent related grammatical anomaly detection.
[0034] S2: Multi-dimensional anomaly detection with the help of large language models to evaluate generation probability anomalies, semantic similarity anomalies, and grammatical consistency anomalies.
[0035] Specifically, through the context understanding ability of the large language model, a candidate word list is generated, and the generation probability of each word to be tested and the candidate word is calculated; The probability of generating candidate words Differences (such as: ) to evaluate whether there is an anomaly in the generation probability.
[0036] For example, when the generation probability difference exceeds a set threshold (such as 0.3), it is marked as a potential anomaly. If the probability difference is too large, it means that the model selected an unexpected word when generating the text, which means that there is a high probability of hallucination here; by leveraging the contextual capabilities of the large language model, the enhanced embedding vectors of each word to be detected and the context are obtained, so as to perform semantic similarity anomaly detection.
[0037] Calculate the cosine similarity between each word to be detected and the context information: , the threshold is set to 0.7, where is the vector of the word to be detected, is the vector of context information. Words with semantic similarity below the threshold are marked as abnormal; grammatical consistency detection is performed with the help of syntactic analysis trees and recorded lexical grammatical roles and other information. By formulating corresponding rules, the rationality of the part-of-speech roles, the legality of dependency relationships, and the integrity of the dependency tree structure of each word to be tested are checked. If a pattern that does not conform to conventional syntax is found, it is marked as abnormal.
[0038] In this implementation, preferably, the grammatical role is the grammatical function of a word in a sentence, such as subject, predicate, object, etc., and the syntactic role is the (interdependent) grammatical relationship (subject-predicate, verb-object) between words in a sentence.
[0039] S3: Anomaly scoring and anomaly correction priority ranking are performed based on anomaly detection results.
[0040] Specifically, first, based on the multi-dimensional evaluation results, the comprehensive anomaly score of each word and the proportion of abnormal words in each sentence are calculated. These scores and anomaly results are used to determine the priority of correction and focus on the abnormal items that have the greatest impact on text quality. For each abnormal sentence, the correction priority is sorted based on the abnormal proportion, and sentences marked as syntactic anomalies (such as unreasonable dependency tree structure) are given priority in the correction sequence. For abnormal words that are not covered, the correction priority is sorted according to their comprehensive scores, and words with semantic and grammatical abnormalities are given priority; generally, the higher the score, the more priority the correction of the abnormal item needs.
[0041] More specifically, the process includes the following: S31: Receive anomaly detection results.
[0042] Specifically, the detection results of each word or sentence are obtained from the multi-dimensional anomaly detection model, including: anomaly marking: identifying whether it is an anomaly point; anomaly scoring: such as semantic deviation score, generation probability score, syntactic consistency score, etc.
[0043] S32: Integrate multi-dimensional anomaly information according to the anomaly detection result.
[0044] Specifically, in order to integrate the scores of different dimensions into a comprehensive score, weighted average or other nonlinear calculations can be performed according to preset weights. For example, the weighted sum method is selected: (1); Among them, the weight According to the influence of abnormal dimension on text quality, For the For example, the grammatical consistency score in technical documents has a higher weight, while the generation probability score has a relatively lower weight.
[0045] To ensure the uniformity of the scores, the quantile normalization method (selecting the first quantile Q1 and the third quantile Q3) can be used: (2); This normalization method is suitable for score distributions with many outliers. It can effectively reduce the impact of extreme values on the overall score and normalize the comprehensive score to the range of [0,1] to facilitate subsequent priority sorting. If the comprehensive anomaly score is greater than the threshold, it is marked as high risk.
[0046] In order to assess the degree of abnormality at the sentence level and avoid the occurrence of large-scale hallucinations, the proportion of abnormal words in the sentence was calculated: (3); Based on the abnormal ratio, the whole sentence is processed first, and a reasonable abnormal ratio threshold is set. For example, the threshold for technical documents is 30%, and that for narrative texts is 50%. If the abnormal ratio exceeds the threshold, it is marked as a high-risk sentence and included in the correction list; high-risk words in sentences that do not exceed the abnormal ratio need to be corrected separately.
[0047] S33: Generate a correction list and sort the correction priorities based on the abnormal mark and comprehensive score information.
[0048] Specifically, the anomaly detection results are traversed, and the abnormal items marked as high-risk are included in the correction list, and the words and sentences marked as grammatical anomalies are included first. The correction list should include: the position of the abnormal words or sentences, the comprehensive score of the abnormal points, and the abnormal scores of various dimensions (such as grammar, semantics, etc.). Dynamic context information of the abnormal points, etc. In sentences where the abnormal ratio does not exceed the standard, high-risk words (comprehensive abnormality scores exceed the set threshold) are included in the correction list in descending order of abnormality scores to ensure that abnormal points with higher scores are processed first. The correction order follows the principle of "global first, local later", giving priority to the overall sentence to ensure the correctness of the grammatical and semantic framework, and then gradually correcting the high-risk words in the sentence. Through this order, the damage to the global semantic framework caused by local corrections can be reduced, ensuring grammatical and contextual consistency.
[0049] Understandably, the correction priority is adjusted dynamically, including recalculating the comprehensive anomaly score according to context changes, adjusting the priority ranking of anomaly points, and giving priority to parts that have a significant impact on global quality. For example, the corrected part may reduce the importance of unprocessed anomalies, thereby adjusting its priority. The correction priority ranking takes into account the following factors: anomaly type, importance of anomaly location, and context relevance. Through the above priority ranking and dynamic adjustment process, the degree of text anomaly is gradually reduced. After each round of correction, the correction effect is comprehensively evaluated through indicators such as global anomaly score, grammatical structure consistency, and contextual semantic coherence to ensure that the text quality is efficiently and significantly improved.
[0050] S4: Dynamically adjust the context window range based on the dependency relationship and semantic relevance combined with the MASK matrix; Specifically, in order to improve the accuracy and pertinence of anomaly detection and correction, this step dynamically adjusts the context window range based on the content to be detected. First, according to the recorded syntactic analysis results, the context window size is preliminarily allocated according to the part-of-speech role of each word to be detected. Then, through syntactic dependency tree analysis, the syntactic distance between each word to be detected and other words in the context is calculated to evaluate the strength of each dependency relationship, and context words with strong dependencies are given priority. Next, based on the semantic association between each word to be detected and its context words, the similarity is calculated and comprehensively evaluated to further adjust the window range to ensure that the window focuses on the context with higher relevance to the target word. Finally, by combining the dependency strength and semantic similarity, the window range is dynamically adjusted to generate an adaptable MASK matrix to optimize the accuracy of context selection.
[0051] More specifically, Figure 2 As shown, the following process is included: S41: Based on the syntactic analysis result, the size of the context window is preliminarily determined according to the part-of-speech role of the vocabulary to be detected.
[0052] Specifically, the information such as part-of-speech tagging, syntactic components, head words and dependency type of the content to be detected can be extracted through syntactic analysis, and the preliminary division of the context window size can be assisted. According to the part-of-speech tagging of each word to be detected, the size of the context window of each word to be detected is preliminarily allocated. For example, core words such as subjects and predicates can be given a larger initial context window, and auxiliary words and modifying words such as attributives, adverbials, and complements can be given a smaller initial context window.
[0053] S42: Based on the obtained syntactic dependency tree, the context window is adjusted according to the dependency weights of the context words related to the vocabulary to be detected.
[0054] Specifically, for each word to be detected, according to the syntactic dependency tree, the syntactic distance between it and other words in the context can be calculated by algorithms such as depth-first or breadth-first. The shorter the syntactic distance, the higher the dependency strength, and the closer the word to be detected is to the syntactic dependency tree, the closer the word to be detected is to the syntactic dependency tree. With context words Dependence strength: (4); in, Represents the words to be tested With context words distance.
[0055] Adjust the window range based on the dependency strength to provide each word to be detected , filter out context words with high dependency strength and include them in the window range: (5); in, To adjust the generated context window based on the dependency strength; A preset dependency strength threshold can be used to filter out strong dependency context words; The vocabulary to be tested With context words The strength of the dependence between is the syntactic distance between the word to be detected and the context word.
[0056] For example, strong dependencies with a dependency path (syntactic distance) of 1 are preferentially included in the context window, ensuring that words with close grammatical associations with the target word are prioritized.
[0057] S43: adjusting the context window based on the semantic association between the word to be detected and its context words; Specifically, a large language model is used to generate embedding vectors for each word to be detected and the context words, and the cosine similarity between them is calculated to ensure that context words with high semantic relevance are preferentially selected into the window range, forming more accurate semantic support.
[0058] (6); in, A context window is obtained by adjusting the semantic relevance of the vocabulary to be detected; is the semantic correlation between the word to be detected and the context word; is a preset semantic similarity threshold.
[0059] For example, if the semantic relevance of a word to the current word is higher than 0.7, it will be included in the dynamic window.
[0060] S44: The final context window is obtained based on the dependency weight and semantic relevance, and a dynamic MASK matrix is realized; specifically, the context window range is finally adjusted based on the syntactic dependency strength and semantic relevance: (7); For example, words with low semantic relevance but short syntactic distance are retained first, while words with low semantic relevance and distant syntactic relationship are eliminated to generate a dynamically adjusted context window. Based on the final adjusted context window range, a binary MASK matrix is introduced, where 0 marks the selected related words, and 1 is used to cover the non-related areas: (8); In this way, during the attention weight calculation process, the masked positions will become -∞, thereby ensuring that their weights after softmax are close to zero. The MASK matrix can be directly input into the attention mechanism, and the results are recorded in the window list for use in the subsequent anomaly detection process.
[0061] S45: Dynamic MASK matrix is combined with attention mechanism to realize dynamic context window; Specifically, the generated MASK matrix ( ) is combined with the multi-head attention mechanism of the large language model to dynamically adjust the attention weight distribution and focus on the contextual information of highly relevant areas: (9); Understandably, the dynamic window method significantly improves the accuracy of anomaly detection and correction by accurately filtering context information. This method combines the strength of syntactic dependency and semantic relevance, and includes the vocabulary that is most closely related to the target word into the window to ensure that the model can obtain the most valuable contextual support. By generating a dynamic MASK matrix and combining it with the attention mechanism, the weight distribution is dynamically adjusted to focus on highly relevant areas and reduce the interference of redundant context on detection and correction effects. At the same time, the dynamic window has strong adaptability in complex syntactic and semantic scenarios, and ensures high-precision anomaly identification and correction by evaluating syntactic dependency and semantic similarity.
[0062] It should be noted that when adjusting the context window, the window size is crucial to obtaining context information. Larger windows cover more information, but may introduce noise, leading to semantic deviation; smaller windows reduce noise, but may miss key information, affecting the detection effect. Therefore, the window size needs to be optimized according to the application scenario. In this embodiment, a threshold is set to limit the window range to ensure that the size is moderate. For example, the window covers a maximum of 50% of the sentence length, and the minimum range is controlled between 3 and 5 tokens. The initial window expands to both sides with the vocabulary to be detected as the center, balancing information coverage and noise control to improve the detection effect.
[0063] It should be noted that in the dynamic window mechanism, for complex structures, a pruning strategy can be used to limit the dependency depth and dynamically optimize the dependency strength threshold to accurately capture the core dependency relationship. For long inputs, a priority-based context truncation strategy can be used to retain only words with high semantic relevance or strong dependencies to reduce computational overhead. At the same time, a sparse attention mechanism is used to effectively reduce the computational requirements of non-relevant areas.
[0064] S5: Prioritize correction of high-risk words and sentences based on correction priorities.
[0065] Specifically, after obtaining the anomaly assessment information and correction priority information, high-risk words and high-risk sentences are first sorted according to the score and correction priority of each anomaly item. High-risk words are usually keywords that may cause semantic deviations, grammatical errors or inconsistent information, which may affect the accuracy and reliability of the entire text. High-risk sentences are sentences that contain obvious grammatical errors and obvious semantic contradictions, which may cause serious misunderstandings or hallucinations. On this basis, according to the correction priority sorting, high-risk words and sentences are corrected first. For high-risk words, context information is first obtained through a dynamic window mechanism, and candidate words are generated using a large language model. Candidate words are screened based on indicators such as semantic consistency, context fit, and generation probability, and the most appropriate words are finally selected for replacement. If some high-risk words have a high anomaly score, these words will be corrected first to ensure that their impact on the semantics and grammar of the text is minimized. For the correction of high-risk sentences, appropriate reconstruction prompts are generated to reconstruct the sentences by calling sequence-to-sequence models (such as T5 or GPT). During the reconstruction process, context information is referenced, anomaly detection results and correction targets are integrated, and new candidate sentences are generated. The reconstructed sentences are scored based on semantic and grammatical consistency, and the sentences with the highest scores are selected for replacement to ensure that the corrected text is more logical and grammatical.
[0066] During the entire correction process, high-risk words and sentences with higher correction priorities are given priority to effectively eliminate potential hallucinations. By prioritizing the correction of these problems, the accuracy, rationality and overall quality of the text can be improved, thereby achieving better hallucination correction effects. At the same time, if there are still unresolved high-risk issues after correction, subsequent corrections will continue to be made according to the correction priority until the expected correction effect is achieved.
[0067] More specifically, the process includes the following: S51: Reconstruct abnormal sentences based on the correction priority ranking.
[0068] Specifically, abnormal sentences marked as high-risk are processed first. Abnormal sentence reconstruction is automatically generated through a large language model, and prompts are used to guide the model to correct sentences. After generating candidate sentences, the candidate sentences are evaluated based on multiple dimensions such as semantic relevance and grammatical consistency, and the sentence with the highest comprehensive score is selected as the replacement result. If there are many abnormal sentences, they are corrected in order from high to low according to the abnormal proportion and abnormal score, gradually reducing the overall abnormality and ensuring the global optimization of text quality.
[0069] More specifically, in order to improve the generation effect, this embodiment extracts the relevant context information of the target sentence through the dynamic context window, and builds local dependency nodes in combination with the dependency tree to ensure that only necessary context content is processed. The prompt text clearly defines the task goal (such as "correct the sentence grammar and maintain semantic consistency"), and integrates the anomaly detection information, context content and output requirements to automatically generate an adaptive prompt text. For example: Context: Users need to file tax forms in 2022 to avoid tax late penalties; Unusual sentences: Penalties for filing tax returns early to earn extra bonuses; Anomaly detection information: There is a semantic conflict between "reward" and "punishment" in the original sentence; Generation goal: Correct grammatical and semantic problems to make the sentence consistent with the context logic; Revised sentence: Filing your tax return early can earn you extra bonuses and avoid penalties.
[0070] Dynamic context windows improve correction quality and computational efficiency by filtering the most relevant information and ensuring that only necessary context is included.
[0071] S52: Correct the abnormal words based on the correction priority ranking.
[0072] Specifically, after completing the correction of abnormal sentences, the dynamic window mechanism is used to capture the context information of the remaining high-risk words. The dynamic window is dynamically adjusted according to the context length and the distribution of abnormal words to ensure that sufficient semantic information is captured while controlling the computational efficiency. After calling the large language model to generate a list of candidate correction words, the candidate words with the highest scores are selected from the candidate word list through semantic and syntactic consistency evaluation to ensure the rationality of the correction and context consistency. If there are a large number of abnormal words in the text to be corrected, a batch correction strategy can be adopted to correct the abnormal words in stages according to priority, gradually optimize the text quality, and avoid frequent context adjustments. Through the incremental update mechanism, only the affected context is recalculated to ensure correction efficiency and global consistency.
[0073] S6: Evaluate the revised content, and if it meets the termination condition, output the revised text and record the revision log; Specifically, after each round of correction, the corrected text is re-evaluated and the global anomaly score is calculated to ensure that it gradually decreases. The global anomaly score is calculated by comprehensively considering multi-dimensional indicators such as grammatical errors, semantic deviations, and generation probability anomalies in the text. The changes in the anomaly score are continuously monitored to ensure that the degree of anomaly in the text is reduced after each round of correction.
[0074] According to the preset empirical value, set the iteration termination condition. Common termination conditions include: 1) the anomaly score is lower than the preset threshold (for example, 0.1), indicating that the text has achieved sufficient correction effect; 2) the correction rounds reach the set maximum number (for example, 10 rounds) to avoid an endless correction cycle.
[0075] When any termination condition is met, the iteration stops and the final corrected text is output. After each round of correction, the correction log is recorded, including the specific steps of each correction, the corrected vocabulary or sentences, the comparison of anomaly scores before and after correction, and whether the termination condition is met. These logs help track the correction process, verify the correction effect, and provide data support for subsequent optimization and analysis. Finally, after the termination condition is met, the corrected text is output and the correction log is archived for subsequent quality analysis and optimization.
[0076] More specifically, after the correction is completed, the text is re-evaluated to determine whether the termination condition is met. The evaluation includes recalculating the global anomaly score and analyzing the range of the remaining anomalies in combination with the dependency tree; if the global consistency of the dependency tree is significantly improved after the correction, and the remaining anomalies are concentrated in the low-risk area, the final result is output in advance; otherwise, the remaining anomalies are marked and the next round of correction iteration is entered; to avoid infinite loops, the maximum number of iterations is set (such as 10 times); when the number of iterations reaches the upper limit and the anomaly score is still not fully met, the current correction result will be output as a suboptimal solution, and the remaining problems will be marked for manual intervention or further optimization.
[0077] Embodiment 2: like Figure 3 As shown, this implementation provides a fine-grained large model hallucination processing system based on a zero-resource framework, including: The text preprocessing unit is configured to: obtain the text to be detected and perform preprocessing, wherein the preprocessing includes: performing syntactic analysis and generating a syntactic dependency tree; The multi-dimensional anomaly detection unit is configured to: perform multi-dimensional anomaly detection on the pre-processed text content through the large language model to obtain a multi-dimensional anomaly detection result; The anomaly correction priority sorting unit is configured to: sort the anomaly correction priorities according to the multi-dimensional anomaly detection results; The context window dynamic adjustment unit is configured to: dynamically adjust the context window range according to the syntactic analysis result and the generated syntactic dependency tree; The multi-round iterative correction unit is configured to: combine the adjusted context window range, and perform priority correction of high-risk words and sentences according to the abnormal correction priority sorting result; The correction evaluation unit is configured to: evaluate the corrected content and obtain the corrected final text when the termination condition is met.
[0078] It is understandable that the above-mentioned units can be separately or completely combined into one or several other units to constitute, or one (some) of the units can be further divided into multiple smaller units in function to constitute, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions. In practical applications, the functions of one unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present application, the system may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.
[0079] According to another embodiment of the present application, the system described in this embodiment can be constructed, and the method of Example 1 of the present application can be implemented by running a computer program (including program code) capable of executing the steps involved in the corresponding method described in Example 1 on a general-purpose computing device such as a computer, which includes processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM). The computer program can be recorded on, for example, a computer-readable recording medium, and loaded into the above-mentioned computing device through the computer-readable recording medium and run therein.
[0080] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A fine-grained large model hallucination processing method based on a zero-resource framework, characterized in that: The process includes: Acquire the text to be detected and perform preprocessing, wherein the preprocessing includes: performing syntactic analysis to generate a syntactic dependency tree; Perform multi-dimensional anomaly detection on the pre-processed text using a large language model to obtain multi-dimensional anomaly detection results; Prioritize anomaly correction based on multi-dimensional anomaly detection results; Dynamically adjust the context window range based on the syntactic analysis results and the generated syntactic dependency tree; Combined with the adjusted context window range, the results of the abnormal correction priority ranking are used to prioritize the correction of high-risk words and sentences; The revised content is evaluated and the revised final text is obtained when the termination conditions are met.
2. The fine-grained large model hallucination processing method based on the zero-resource framework as claimed in claim 1 is characterized in that: The text content to be tested is segmented, punctuation is removed, and capitalization is unified. A syntactic analysis tool is used to generate a syntactic dependency tree. Through syntactic analysis, a syntactic role is assigned to each word, and the syntactic relationship and its depth information are recorded.
3. The fine-grained large model hallucination processing method based on zero resource framework as claimed in claim 1 is characterized in that: The multi-dimensional anomaly detection of the pre-processed text content by the large language model is used to obtain the multi-dimensional anomaly detection results, including: Generate a candidate word list through a large language model, calculate the generation probability of each word to be tested and the candidate word, and evaluate whether there is a generation probability anomaly based on the difference in generation probability between the word to be tested and the candidate word. When the difference is greater than the set threshold, it is marked as an anomaly and the anomaly score is calculated; The enhanced embedding vectors of each word to be detected and the context are obtained through the large language model, and semantic similarity anomaly detection is performed. When the semantic similarity is lower than the set threshold, it is marked as an anomaly and the anomaly score is calculated; Through the syntactic dependency tree and the recorded lexical and grammatical roles, grammatical consistency detection is performed. When the grammatical consistency is lower than the set threshold, it is marked as abnormal and the abnormality score is calculated; Check the rationality of the part-of-speech role, the legitimacy of the dependency relationship, and the integrity of the syntactic dependency tree structure of each word to be tested. If it does not conform to the regular syntactic pattern, it will be marked as abnormal and the abnormality score will be calculated; The obtained anomaly scores of different dimensions are weighted and summed as the comprehensive anomaly score corresponding to each word to be detected.
4. The fine-grained large model hallucination processing method based on a zero-resource framework as described in any one of claims 1 to 3, characterized in that: Prioritize anomaly correction based on multi-dimensional anomaly detection results, including: According to the multi-dimensional anomaly detection results, the comprehensive anomaly score of each word to be detected and the proportion of abnormal words in each sentence are calculated; For each abnormal sentence, the correction priority is sorted based on the abnormal proportion; For the abnormal words that are not covered, the correction priorities are sorted according to their comprehensive scores.
5. The fine-grained large model hallucination processing method based on zero resource framework as claimed in claim 4 is characterized in that: Dynamically adjust the anomaly correction priority, including: recalculating the anomaly score of each word to be detected according to the adjusted context window range, adjusting the priority sorting, and giving priority to the parts that have a significant impact on the global quality.
6. The method for processing hallucinations of a fine-grained large model based on a zero-resource framework according to any one of claims 1 to 3, characterized in that: Dynamically adjust the context window range based on the syntactic analysis results and the generated syntactic dependency tree, including: Based on the recorded syntactic analysis results, the context window size is preliminarily allocated according to the part-of-speech role of each word to be tested; Through the syntactic dependency tree, the syntactic distance between each word to be detected and other words in the context is calculated, and the dependency strength is calculated; Calculate semantic similarity based on the semantic association between each word to be detected and the context words; By combining dependency strength and semantic similarity, the window range is dynamically adjusted to generate an adaptable MASK matrix. The generated MASK matrix is combined with the multi-head attention mechanism of the large language model to dynamically adjust the attention weight distribution and focus on the contextual information of highly correlated areas.
7. The fine-grained large model hallucination processing method based on zero resource framework as claimed in claim 6 is characterized in that: The first window range is determined according to the dependency strength, the second window range is determined according to the semantic similarity, and the intersection of the first window range and the second window range is used as the dynamically adjusted context window range to generate a highly adaptable MASK matrix; Combine the generated MASK matrix with the multi-head attention mechanism of the large language model, including: ,in, are query vector, key vector and value vector respectively, is the dimension of the key vector, is the normalized exponential function, is the attention mask.
8. The method for processing fine-grained large model hallucinations based on a zero-resource framework according to any one of claims 1 to 3, characterized in that: Prioritize abnormal sentences marked as high-risk, use prompts to guide the model to generate reconstruction prompts, generate candidate sentences based on the reconstruction prompts through the large language model, evaluate the candidate sentences, and select the sentence with the highest comprehensive score as the replacement result. If the number of abnormal sentences is greater than the set threshold, they are corrected in descending order according to the abnormal proportion and abnormal score; After completing the correction of abnormal sentences, for the remaining high-risk words, use the adjusted context window to capture their context information, generate a candidate word list through the large language model, and select the candidate words with the highest scores from the candidate word list for replacement. If the number of abnormal words in the text to be corrected is greater than the set threshold, a batch correction strategy is adopted to correct the abnormal words in stages according to priority, and only the affected context is recalculated through the incremental update mechanism.
9. The method for processing fine-grained large model hallucinations based on a zero-resource framework according to any one of claims 1 to 3, characterized in that: Evaluate the revised content and obtain the revised final text when the termination conditions are met, including: After the correction is completed, the global anomaly score of the text is recalculated, and the scope of the remaining anomalies is analyzed in combination with the syntactic dependency tree; If the global consistency of the corrected syntactic dependency tree is greater than the set threshold, and the remaining anomalies are concentrated in the low-risk area, the final result is output in advance; otherwise, the remaining anomalies are marked and the next round of correction iteration is entered; Set the maximum number of iterations. When the number of iterations reaches the upper limit and the anomaly score is still not fully up to standard, the current correction result will be output as a suboptimal solution, and the remaining problems will be marked for manual intervention or further optimization.
10. A fine-grained large model hallucination processing system based on a zero-resource framework, characterized in that: include: The text preprocessing unit is configured to: obtain the text to be detected and perform preprocessing, wherein the preprocessing includes: performing syntactic analysis and generating a syntactic dependency tree; The multi-dimensional anomaly detection unit is configured to: perform multi-dimensional anomaly detection on the pre-processed text content through the large language model to obtain a multi-dimensional anomaly detection result; The anomaly correction priority sorting unit is configured to: sort the anomaly correction priorities according to the multi-dimensional anomaly detection results; The context window dynamic adjustment unit is configured to: dynamically adjust the context window range according to the syntactic analysis result and the generated syntactic dependency tree; The multi-round iterative correction unit is configured to: combine the adjusted context window range, and perform priority correction of high-risk words and sentences according to the abnormal correction priority sorting result; The correction evaluation unit is configured to: evaluate the corrected content and obtain the corrected final text when the termination condition is met.
Citation Information
Patent Citations
Consensus graph representation reasoning-based positioning natural image subtitle generation method and device
CN111741236A
Error correction method and device for voice text
CN113012705A
Fine-grained large language model illusion detection method and device, and storage medium
CN118364065A
Adverse drug reaction questioning method
CN118675768A
Large model self-checking-based method for relieving large language model illusion by RAG system
CN118940839A
Cited By
Letter text analysis method driven by multilayer dynamic aggregation large language model
CN120387459A
A multi-layer dynamic aggregated large language model driven letter text analysis method
CN120387459B
Zero-knowledge scene-oriented large model output content illusion detection method and system
CN120723907A
Cboth modification method and device, terminal and storage medium
CN120781806A
Large language model illusion detection method based on causal double chains and intelligent question and answer method
CN120892928A