CN-122019758-A - AI model illusion suppression method and system based on search enhancement generation and prompt word engineering cooperation
Abstract
The invention discloses an AI model illusion suppression method and system based on search enhancement generation and prompt word engineering cooperation, and aims to solve the problems of the conventional large language model illusion and the defects of high cost, low search content utilization rate, common knowledge conflict, strong generation randomness and the like of the conventional scheme. Through constructing a high-precision domain vector index library, similarity retrieval and noise filtering are carried out on user inquiry, multi-level structured prompt words including role definition, thinking chain constraint and the like are generated, universal knowledge shielding or fusion modes are dynamically switched based on recall quality, and a final result is output through multipath reasoning sampling and consistency verification. The invention has the advantages of no need of modifying the parameters of the bottom model, obviously reduced illusion rate, accurate generated content facts, consistent logic, traceability, flexible deployment and low cost, and is suitable for multi-field factual question-answering scenes such as medical treatment, industry, legal consultation and the like.
Inventors
- Cai Daiju
Assignees
- 深圳市跨赚科技有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260202
Claims (10)
- 1. The AI model illusion suppression method based on search enhancement generation and prompt word engineering cooperation is characterized by comprising the following steps: (1) The method comprises the steps of constructing a high-precision domain vector index library, namely slicing a domain knowledge base document according to preset slicing parameters, converting slices into high-dimensional dense vectors through Embedding models, constructing vector indexes by adopting a specified index algorithm, and storing the vector indexes in a vector database; (2) After receiving the user query, calculating the semantic similarity between the query vector and the document vector in the index library, searching Top-K related document fragments, and only retaining the document fragments with the similarity score higher than a first threshold as effective contexts; (3) The generation of the structured prompting word, namely, constructing the structured prompting word comprising role definition, context injection, thinking chain constraint, negative constraint and traceability requirement based on a preset template, and dynamically filling the effective context screened in the step (2) into a context injection area of the prompting word; (4) The method comprises the steps of calculating the highest similarity score of an effective context, comparing the highest similarity score with a second threshold, switching a generation mode according to a comparison result, injecting a corresponding instruction, starting a strong recall mode and a general knowledge masking instruction if the highest similarity score is more than or equal to the second threshold, prohibiting a model from invoking pre-training general knowledge, starting a weak recall mode if the highest similarity score is lower than the second threshold and higher than the first threshold, allowing the model to combine the effective context and the general knowledge to generate content and mark uncertainty; (5) The self-consistency decoding and illusion filtering comprises the steps of carrying out independent reasoning sampling on the structured prompt words generated in the step (3) for N times to obtain N candidate answers, removing illegal answers which violate negative constraint or general knowledge masking instructions, carrying out semantic clustering or keyword matching on the rest candidate answers, counting the conclusion with highest occurrence frequency, taking the conclusion as final output if the occurrence frequency of the highest-frequency conclusion is more than or equal to a preset voting threshold, and otherwise triggering a retry mechanism or outputting uncertainty.
- 2. The method of claim 1, wherein the preset slice parameters in step (1) are ChunkSize =512 tokens, overlap =50 tokens, the Embedding model is bge-large-zh-v1.5 or OpenAItext-embedding-ada-002, and the generated high-dimensional dense vector dimension is 1024 dimensions.
- 3. The method of claim 1, wherein the specified index algorithm in the step (1) is HNSW algorithm, algorithm parameters are set to ef_ construction =200, m=16, and the vector database is FAISS or Pinecone.
- 4. The method of claim 1, wherein the Top-K in step (2) has a value of 5, the first threshold is 0.75, and the semantic similarity is calculated by a cosine similarity algorithm.
- 5. The method according to claim 1, wherein the specific structure of the structured prompt word in the step (3) is: character definition, "you are a strict intelligent assistant, your task is to answer based on the provided known information, and the organization is forbidden; Context injection, wrapping the valid context with a < context_info > tag in the format "< context_info > \n { Doc1} \n { Doc2} \n. </context_info >"; The thinking chain constraint is that please think according to the following steps of 1, analyzing key information in < context_info >, 2, associating identification information with a problem, 3, carrying out step logic reasoning, and 4, obtaining a conclusion; Negative constraint that if < context_info > does not contain an answer, please answer directly 'cannot answer according to known information', you cannot guess with your training data "; the traceability requirement is that the cited document number is marked with the source ID after each statement in the answer.
- 6. The method of claim 1, wherein the second threshold in step (4) is 0.85, and the general knowledge masking instruction is "System alarm: high correlation search results (similarity > 85%) are detected. [ general knowledge masking has been enabled ]. The current answer must be strict and only dependent on the offer [ context information ]. Absolutely prohibit invoking or mixing your model pre-training knowledge. Any details that do not appear in this context are considered 'unknown', prohibiting deduction.
- 7. The method of claim 1, wherein the Temperature parameter of the inferred sample in the step (5) is set to 0.7, the value of n is 5, and the preset voting threshold is 3.
- 8. The method of claim 1, wherein the semantic clustering in the step (5) uses a clustering algorithm based on cosine similarity, and the keyword matching uses TF-IDF keyword extraction followed by similarity comparison.
- 9. The method of any of claims 1-8, wherein the AI model is a large language model based on a transducer architecture, including GPT-4, lalama series models.
- 10. An AI model illusion suppression system based on search enhancement generation and prompt word engineering collaboration, comprising: The vector index construction module is used for executing the step (1) of the method of any one of claims 1-9 to finish slicing, vector embedding and index construction of the domain knowledge base; The retrieval filtering module is used for executing the step (2) of the method of any one of claims 1-9 to realize similarity retrieval and noise filtering of user inquiry; a prompt word generation module for performing step (3) of the method of any one of claims 1-9, constructing a structured prompt word and populating a valid context; a knowledge masking module for executing the step (4) of the method of any one of claims 1-9, switching generation modes based on recall quality assessment results and injecting corresponding instructions; The decoding and checking module is used for executing the step (5) of the method of any one of claims 1-9 to realize multipath sampling, candidate answer screening and consistency checking; And the output module is used for outputting a final result obtained by the decoding and checking module or recalling the flow of the retrieval and filtering module to the decoding and checking module when the retry mechanism is triggered. The system also comprises a storage module, wherein the storage module is used for storing the domain knowledge base document, the constructed vector index, the search log and the generated result, and the generated result comprises the marked source ID and the generated mode information.
Description
AI model illusion suppression method and system based on search enhancement generation and prompt word engineering cooperation Technical Field The invention relates to the technical field of natural language processing, in particular to a technology for controlling reliability of generated content of a large-scale language model, and especially relates to a method and a system for realizing accurate suppression of AI model illusion by combining a general knowledge masking mechanism and self-consistency verification through deep collaboration of a retrieval enhancement generation (RAG) architecture and a prompt word engineering. Background Along with the rapid evolution of the deep learning technology, a Large Language Model (LLM) based on a transducer architecture, such as GPT-4, llama series and the like, shows strong semantic understanding and content generating capability in natural language processing tasks such as text generation, question-answering systems, intelligent conversations and the like, and promotes the large-scale application of the artificial intelligence technology in various industries. However, such models are essentially "next word prediction" systems based on probability statistics, lack explicit knowledge of real world facts, are susceptible to training data bias, noise, and are subject to the phenomenon of "illusion", which is generated by smooth text grammar, but contains false information inconsistent with objective facts, logical paradox or non-basis, which severely limits the application reliability of large language models in sensitive fields such as medical, legal, industrial, etc. where information accuracy requirements are extremely high. In order to solve the model illusion problem, a plurality of technical schemes are proposed in the industry, but all have the obvious defects that firstly, a Reinforcement Learning Human Feedback (RLHF) scheme is used for optimizing a model by aligning human preference, but a great amount of manpower and material resources are needed in the training process, the cost is high, illusion is still difficult to completely eliminate, secondly, a rule-based post-processing filter scheme can only check specific types of fact errors, the adaptation capability of complex semantic logic is lacking, the flexibility is insufficient, thirdly, a retrieval enhancement generation (RAG) technology provides a fact basis for the model by introducing an external knowledge base, the fact errors are relieved to a certain extent, but the traditional RAG technology has a plurality of bottlenecks that the retrieval content utilization rate is low, the model tends to depend on internal pre-training parameters rather than input retrieval context, a simple mode of 'retrieval+splicing' is not used, when the retrieval result contains noise or is not completely matched with the query intention, the generation result is greatly influenced by randomness, even if the random sampling characteristic of the LLM has the fact errors, the fact error is easy to be generated, the error is easily offset from the general knowledge interpretation logic is generated, and the error is excessively due to the fact error is avoided, and the internal knowledge is excessively generated by using the general knowledge. In addition, the existing close technical scheme such as a question-answering system based on vector retrieval has the defects that the design of prompt words is crude, the model step-by-step reasoning cannot be forced, the anti-interference capability is weak, and a consistency verification link is lacking, so that the illusion problem is further aggravated. Therefore, a technical scheme capable of deeply coupling search information and a generation process and solving the problems of insufficient utilization of search content, logic constraint loss, general knowledge interference, randomness generation and the like through a refined control means is needed, so that accurate and efficient suppression of the illusion of an AI model is realized. Disclosure of Invention The invention aims to overcome the defects of the prior art, provides an AI model illusion suppression method and system based on the cooperation of search enhancement generation and prompt word engineering, and specifically solves the following technical problems: 1. generating "illusion" problems of fact errors, logic contradictions and the like of the content by using the large language model; 2. the existing RLHF scheme has the problems of high cost and poor flexibility of the rule filter; 3. the conventional RAG technology has the problems of low retrieval content utilization rate, lack of fine logic constraint and strong randomness of the generated result; 4. the conflict between the general knowledge and the field facts causes the problem that the model ignores the retrieval information or excessively interprets; 5. the existing scheme lacks traceability, and the generated result is difficult to verify. In or