Lightweight model adaptive behavior optimization method for complex questions and answers

By employing a lightweight model and dynamic optimization strategy, combined with the Weaviate vector database and SQL database, the problems of knowledge updating and intent understanding in complex tasks of intelligent question answering systems are solved, achieving an efficient and interpretable intelligent question answering solution and improving the robustness and accuracy of the system.

CN121501940APending Publication Date: 2026-02-10TONGXIANG GENERAL ARTIFICIAL INTELLIGENCE RESEARCH INSTITUTE +1
View PDF -1 Cites 0 Cited by

Patent Information

Application Number
CN202511565730.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-30
Publication Date
2026-02-10

Smart Images

  • Figure CN121501940A_ABST
    Figure CN121501940A_ABST
Patent Text Reader

Abstract

The invention discloses a lightweight model adaptive behavior optimization method for complex questions and answers, which comprises the following steps of: 1, constructing a Weaviate vector database and an SQL (Structured Query Language) database, and automatically generating a teacher thinking template; 2, inputting questions and decomposing the questions to form a thinking path; 3, performing information retrieval and key step extraction on the thinking path; 4, performing chain reasoning to generate answers; 5, dialogue abstracts are extracted and stored in an SQL database, feedback is memorized and enhanced, the defects of the lightweight model in tasks such as complex significance analysis, context tracking and dynamic adaptation are overcome, and interaction quality and output accuracy are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of artificial intelligence technology, specifically relating to a lightweight model adaptive behavior optimization method for complex question answering. Background Technology

[0002] With the rapid development of artificial intelligence technology, intelligent question-answering systems have been widely used in various fields. However, existing systems still have significant shortcomings in handling complex, multi-turn interactive problems. Although large language models are powerful, their high deployment costs and potential data security risks limit large-scale application.

[0003] Existing technologies, such as intelligent question-answering systems based on Large Language Models (LLMs) and Retrieval Augmentation (RAG) techniques, have made significant progress in knowledge acquisition and content generation, but the following technical problems still exist:

[0004] (1) Due to its reliance on static parameterized memory, LLMs are difficult to update knowledge in real time, and when the training corpus is sparse or the data distribution is skewed, they are prone to “illusion” phenomena, which affect the accuracy of the output.

[0005] (2) In complex queries, single-round retrieval usually cannot provide enough information, requiring multiple retrievals, query rewriting and evidence integration, while traditional static hints are difficult to handle these engineering challenges efficiently.

[0006] (3) Under the constraints of localization and privacy compliance, edge and lightweight models face bottlenecks such as limited upper limit of capabilities, superficial understanding of intent, easy distortion of long-distance reference, and insufficient tool governance, which affect the effectiveness of multi-round retrieval and the consistency of answers.

[0007] Therefore, there is an urgent need for a new approach that combines prompt words, RAG mechanisms, and dynamic optimization strategies based on user feedback to address the performance bottleneck of lightweight models in complex tasks. This approach can effectively overcome the shortcomings of traditional systems in handling complex problems, improve the robustness and accuracy of the system, and provide solid technical support for building high-performance dialogue systems for future edge devices. Summary of the Invention

[0008] To address the aforementioned technical problems in existing technologies, the purpose of this invention is to utilize a locally deployed lightweight model as its core. By combining prompt word engineering, the RAG mechanism, and a dynamic optimization strategy based on user feedback, this invention solves the performance bottleneck of lightweight models in complex tasks, proposing an intelligent question-answering solution that combines efficiency, interpretability, and practical feasibility. The technical solution is as follows:

[0009] A lightweight adaptive behavior optimization method for complex question answering models is proposed. This method employs an adaptive behavior optimization algorithm to implement template construction, entity-aware reasoning, and dynamic memory-enhanced feedback. Specifically, it includes the following steps:

[0010] Step 1: Build a Weaviate vector database and an SQL database to automatically generate teacher thinking templates;

[0011] Step 2: Input the problem and break it down to form a complete thinking path.

[0012] The automatically generated teacher thinking template is used as a reasoning blueprint. The thinking chain technology is used to perform deep semantic analysis on the user input question. Through the reasoning of the lightweight large language model, the complex problem is decomposed into a structured thinking path and a set of key entities. The user's original input question, the demonstration question and the thinking path are input into the lightweight large language model. The lightweight large language model will decompose the original input question hierarchically to form a complete thinking path.

[0013] Step 3: Retrieve information and extract key steps from the complete thought process.

[0014] The system extracts key entities with strong relevance to the problem from the complete thinking path, introduces an intelligent semantic slicing mechanism to vectorize the thinking path, generates high-precision semantic vectors, and stores them in the Weaviate vector database in combination with metadata information. Combining entity and semantic vector hybrid retrieval strategy, candidate text blocks are recalled. A reordering model is used to refine text blocks that are highly relevant to the problem based on the semantic relevance between the original problem and each candidate text block, forming a refined retrieval set. At the same time, based on the key steps in the teacher's thinking template, the key step sequence is extracted and parsed from the thinking path.

[0015] Step 4: Chain reasoning to generate the answer

[0016] By combining the original question, the refined retrieval set, and the key step sequence, a complete hint is constructed. The lightweight large language model performs chain reasoning based on the key step sequence to accurately locate the core intent of the question. It compares, summarizes, and synthesizes the evidence in the refined retrieval set step by step. Key entities serve as semantic anchors throughout the process, constraining each step of reasoning to revolve around the essence of the question. The final answer is generated by fusing the intermediate conclusions of the structured steps with external evidence.

[0017] Step 5: Extract dialogue summaries and store them in an SQL database for memory enhancement feedback.

[0018] A dual-layer memory architecture is introduced, utilizing an SQL database to build a comprehensive dialogue context management system. A memory-enhanced continuous feedback mechanism is introduced to generate a structured summary in real time based on the current round of dialogue, refine the dialogue summary and compress historical content, retain the simplified question-and-answer pairs from the most recent three rounds and store them in the SQL database. When a new question is input, the global summary is read first to complete the dialogue main line. When a semantic relationship across rounds is detected, the enhanced question-and-answer pairs in the SQL database are sequentially concatenated, and relevant memories are integrated into the prompt words and merged with the current question to generate extended prompts.

[0019] Furthermore, in step 1, the automated generation of the teacher's thinking template includes the following stages:

[0020] (1) Planning phase: Generate an executable set of key steps S plan Specifically, it includes the following steps:

[0021] ① Select the development set S from the dataset dev The expression is as follows:

[0022] S dev ={(q1,r1,a1),(q2,r2,a2),...,(q j ,r j ,a j )},(j=1,...,n)

[0023] Where, q j To indicate the problem, r j Indicates the search results, a j Indicates the correct answer;

[0024] ②From the development set S dev The problem set Q is extracted, and the expression is as follows:

[0025] Q = {q1, q2, ..., q} i}, (i = 1, ..., k);

[0026] ③ Generate thought path S for each task using a lightweight large language model. path Its expression is as follows:

[0027] S path ={h1,h2,...,h i};

[0028] ④ The lightweight large language model further extracts the key steps for each thinking path and plans the solution based on the data and steps required by the lightweight large language model to solve the problem;

[0029] ⑤ Output the extracted key steps in the specified JSON format to obtain the key step set S. plan It is represented as follows:

[0030] S plan ={p1,p2,...,p i}

[0031] Where, p i The form is: {"<Key Step1> ":"","<Key Step2> ":"",...};

[0032] (2) Collection phase: Select key steps with strong general applicability and build high-quality demonstration examples. * Specifically, it includes the following steps:

[0033] ① The key steps set S obtained during the planning phase plan Each key step p in i traverse the development set S dev Question q k and its search results r k The execution result e with the following structure is generated. ij It is represented as follows:

[0034] {" <keystep1> ":" <execution1> "," <keystep2> ":" <execution2>",...}

[0035] ② Quantify the execution result of each key step. Output 1 if the result is true, and output 0 otherwise. The quantization function expression is:

[0036]

[0037] Where f ext For heuristic functions, For the indicator function, y j To develop answers to each question in a focused manner;

[0038] ③ Calculate the scores for all key steps and select the one with the highest score as the best demonstration example. The expression is as follows:

[0039] d * =(q i ,h i ,p i )

[0040] This example serves as the optimal teacher thinking template to guide lightweight large language models in problem reasoning and solution generation.

[0041] Furthermore, in step 3, the intelligent semantic slicing mechanism is based on an adaptive slicing strategy for document semantic boundaries, dividing the original document D into a series of semantically complete slices C1, C2, ..., C6. n Each slice C i Each slice represents an independent semantic unit, and together they constitute the complete content of the document.

[0042] Furthermore, in step 3, the Weaviate vector database storage introduces a strict data isolation mechanism based on ID to perform strict isolation control throughout the entire chain from data storage to query retrieval.

[0043] Furthermore, the ID-based strict data isolation mechanism utilizes the schema extension capabilities and high-performance filtering mechanism of the Weaviate vector database to achieve unified storage and isolated access to multi-tenant data, specifically including the following stages:

[0044] (1) Data Injection Phase

[0045] Add an ID field to each document block and assign it a unique session identifier, so that each vector has a clear ownership tag. At the same time, construct metadata related to the text block in a uniform format and store it in the vector database.

[0046] (2) Search and query stage

[0047] The system utilizes the native filtering capabilities of the Weaviate vector database to dynamically construct queries containing WHERE clauses, strictly limiting the search scope to a specified session domain.

[0048] Furthermore, in step 3, the vectorization process uses the bge-m3 multilingual embedding model to generate high-quality vector representations, and each semantic slice C... i Mapped to a high-dimensional dense vector Batch processing optimization and parallel computing are introduced during vectorization processing.

[0049] Furthermore, the batch processing optimization and parallel computing techniques involve dividing multiple slices... Form a batch, and use GPU or multi-core CPU for parallel inference to calculate the vector of all slices in the batch at once, as shown in the following expression:

[0050]

[0051] Furthermore, in step 3, the hybrid retrieval adopts a hybrid retrieval strategy combining BM25 keyword retrieval and semantic vector retrieval. By calculating the relevance score between the query terms and documents, the search results are ranked, placing the most relevant documents at the top. Combining term frequency (TF), inverse document frequency (IDF), and document length normalization, the weight formula is dynamically adjusted to appropriately enhance the importance of high-frequency words in the document. The BM25 score calculation expression for text block d for query q is as follows:

[0052]

[0053] Where f(q) i ,d) represents q i The word frequency in text block d, |d| is the length of the text block, avgdl is the average length of text blocks in the knowledge base, k1 and b are hyperparameters. Semantic search is performed using vector similarity. Both the query and the text block are encoded as dense vectors, and semantic similarity is measured by cosine similarity.

[0054] Furthermore, in step 3, the re-ranking model obtains the candidate document set D through the retrieval phase. candidate The Reranker(q,d) model calculates a more accurate relevance score for each document d in the candidate set. rerank The expression is as follows:

[0055]

[0056] The documents are sorted in descending order based on the calculated new scores to obtain the final search results list D. final .

[0057] Furthermore, in step 5, the dual-layer memory architecture includes the following levels:

[0058] (1) Short-term memory

[0059] Maintain the dialogue history of the last three rounds after enhancement. When the user inputs a new question, use a lightweight large language model to rewrite the original question-answer pair with existing information, and transform the ambiguous referential question into a semantically clear expression containing complete contextual information.

[0060] (2) Long-term memory

[0061] Record a summary of the entire conversation, and add new information generated in each round of conversation to the summary in real time. Each time a new user enters, it uses both the enhanced conversation history in short-term memory and the conversation summary in long-term memory to build a complete prompt that contains both the latest details and a global perspective.

[0062] Beneficial effects: (1) Accurate capture of user intent, enhancing the ability to deeply understand complex or implicit intent. (2) Maintaining the coherence of semantic trajectory in multi-turn interactions, effectively avoiding contextual fragmentation and cumulative semantic distortion. (3) Reasoning reconstruction based on user feedback, improving the long-term adaptability and reliability of the system. Attached Figure Description

[0063] Figure 1 This is a flowchart illustrating the database construction process of the present invention.

[0064] Figure 2 This is a flowchart of the database retrieval process of the present invention;

[0065] Figure 3 This is a flowchart of the AdBOP algorithm of the present invention;

[0066] Figure 4 This is a template diagram of the thought path planning prompts for the present invention;

[0067] Figure 5 This is a diagram illustrating the thought process planning structure of the present invention;

[0068] Figure 6 Generate prompt word template diagram for the closing step of the present invention;

[0069] Figure 7 This is an example diagram of the teacher's thinking template for the present invention;

[0070] Figure 8 This is an overall framework diagram of the present invention. Detailed Implementation

[0071] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0072] This invention presents a lightweight model adaptive behavior optimization method for complex question answering. It employs a lightweight large language model and adaptive behavior optimization algorithm to achieve accurate reasoning, dynamic optimization, and semantic coherence. It constructs an enterprise-level retrieval enhancement module based on a Weaviate vector database. Through deep integration of State-of-the-Art (SOTA) semantic understanding technology and engineering deployment practices, it achieves end-to-end optimization from knowledge injection to intelligent generation. The specific implementation steps in vector database construction and retrieval, intelligent semantic slicing, data isolation, vectorization processing, hybrid retrieval, and dialogue memory management are as follows:

[0073] (1) Vector database construction and retrieval

[0074] During the construction phase, text semantic coherence is ensured through semantic chunking. A multilingual embedding model (e.g., bge-m3) is used to generate high-precision semantic vectors, which are then stored in the Weaviate vector database along with detailed metadata, laying a solid foundation for efficient retrieval. In the retrieval phase, complex problems are decomposed into controllable subtasks using chain-of-consciousness technology. Key entities are extracted, and a hybrid entity and vector retrieval strategy is employed. A re-ranking model (e.g., bge-reranker-v2-m3) is used to filter text chunks highly relevant to the problem, maximizing knowledge coverage and matching accuracy. Furthermore, the system introduces a strict ID-based data isolation mechanism to ensure data security and privacy protection in a multi-tenant environment. This module provides a highly controllable and scalable external knowledge interface for lightweight large language models, effectively compensating for their shortcomings in domain knowledge coverage, such as... Figure 1 and Figure 2 The diagrams shown are the vector database construction diagram and the database retrieval flowchart, respectively.

[0075] (2) Intelligent semantic slicing

[0076] To ensure efficient retrieval and high-precision matching of information stored in the database, an intelligent slicing mechanism is introduced. Based on an adaptive slicing strategy that considers the semantic boundaries of documents, an original document D is divided into a series of semantically complete slices C1, C2, ..., C6. n Each slice C i Each slice represents an independent semantic unit, and these slices together constitute the complete content of the document. By performing deep analysis of the document's logical structure and semantic relationships to intelligently identify segmentation points, key information is avoided from being fragmented and context is lost, thus improving retrieval hit rate and accuracy.

[0077] (3) Data isolation

[0078] Data isolation employs an ID-based enterprise-grade data isolation architecture to achieve strict isolation control across the entire chain from data storage to query retrieval. It leverages the schema extension capabilities and high-performance filtering mechanisms of the Weaviate vector database to achieve unified storage and isolated access to multi-tenant data. During the data injection phase, the system adds an ID field to each document block and assigns it a unique session identifier, giving each vector a clear ownership marker. Simultaneously, the system constructs metadata related to the text block in a unified format and stores it in the vector database. The metadata format is as follows:

[0079] {"chunkUniqueId":["string"],"content":["text"],

[0080] "interactionId":["string"],"chunkIndex":["int"],

[0081] "sourceIndex":["int"],"pageName":["string"],

[0082] "pageUrl":["string"],"pageLastModified":["string"]

[0083] During the retrieval and query phase, the system utilizes Weaviate's native filtering capabilities to dynamically construct queries containing WHERE clauses, strictly limiting the search scope to a specified session domain to ensure the absolute isolation of retrieval results. This enables efficient and secure multi-tenant service capabilities through a unified data management framework.

[0084] (3) Vectorization processing

[0085] A bge-m3 multilingual embedding model is used to generate high-quality vector representations. This model is a function Embed(·) that embeds each semantic slice C... i Mapped to a high-dimensional dense vector Where d is the embedding dimension. Its expression is:

[0086] v i =Embed(C i )

[0087] Batch processing optimization and parallel computing techniques are introduced during the vectorization process to divide multiple slices. Form a batch and use GPU or multi-core CPU for parallel inference, that is, calculate the vector of all slices in the batch at once:

[0088]

[0089] It improves the processing efficiency of large-scale documents, enabling the system to support real-time knowledge injection and incremental updates.

[0090] (4) Hybrid retrieval

[0091] A hybrid retrieval strategy combining BM25 keyword retrieval and semantic vector retrieval is employed. BM25 is a keyword ranking algorithm. Search results are ranked by calculating the relevance score between the query terms and documents, aiming to prioritize documents most relevant to the query. The algorithm combines term frequency (TF), inverse document frequency (IDF), and document length normalization, dynamically adjusting weights through a formula to moderately increase the importance of high-frequency words within documents, while simultaneously penalizing them based on document length and global term frequency, preventing long documents or common words from excessively influencing the results. The BM25 score of text block d for query q is calculated as follows:

[0092]

[0093] Where f(q) i ,d) represents q i The term frequencies in text block d, |d| is the length of the text block, avgdl is the average length of text blocks in the knowledge base, k1 and b are hyperparameters, typically (k1 = 1.2, b = 0.75). Semantic search is performed using vector similarity; both the query and the text block are encoded as dense vectors, and semantic similarity is measured using cosine similarity.

[0094]

[0095] In the formula, q and d are the vectorized representations of the query and the text block, respectively. q·d calculates the dot product of the two, and ||q||·||d|| is the Euclidean norm, also known as the L2 norm, which normalizes the vectors so that their length does not affect the similarity calculation, focusing only on the angle between the two vectors. Through the above two-step hybrid retrieval, complete information relevant to the question is finally obtained. To address the problem that the text information retrieved by BM25 and vector similarity is too long and contains a lot of redundant information, a re-ranking process is performed to ensure the accuracy and completeness of the retrieval results. A re-ranking model is used to perform more precise filtering and sorting of the retrieval results, ensuring a high degree of information concentration. The candidate document set D is obtained through the retrieval stage. candidate The following expression is used to perform fine-grained scoring and reordering of each document in the collection:

[0096]

[0097] The Reranker(q,d) model calculates a more accurate relevance score for each document d in the candidate set. rerank The system sorts the documents in descending order based on the new scores calculated by the re-ranking model, resulting in the final search results list D. final This will improve sorting accuracy and user experience.

[0098] (5) Dialogue Memory Management

[0099] A two-tiered memory architecture is introduced, utilizing the SQLite relational database to construct a robust dialogue context management system, ensuring contextual coherence and consistency across multiple turns of interaction. The core lies in maintaining two levels of dialogue memory: short-term memory and long-term memory.

[0100] Short-term memory maintains the dialogue history of the last three rounds, which have undergone enhancement processing. When a user asks a new question, the system uses a large language model to rewrite the original question-and-answer pair with existing information, transforming ambiguous referential questions into semantically clear statements containing complete contextual information.

[0101] Long-term memory serves as a summary of the entire conversation, synchronously adding new information generated in each round of dialogue to the summary to ensure the integrity of the dialogue history. With each new user input, the system simultaneously utilizes the enhanced dialogue history in short-term memory and the dialogue summary in long-term memory to construct a complete prompt that includes both the latest details and a global perspective.

[0102] The lightweight adaptive behavior optimization method for complex question-answering models employs the Adaptive Behavior Optimization Algorithm (AdBOP), a highly efficient three-stage closed-loop architecture. Its aim is to empower lightweight large language models to achieve accurate reasoning, dynamic optimization, and semantic coherence in complex open-domain tasks. This architecture includes template construction, entity-aware reasoning, and dynamic memory enhancement. To ensure semantic consistency and coherence in multi-turn dialogues, the AdBOP algorithm introduces a dynamic memory enhancement mechanism. During the dialogue, the system extracts and compresses historical content in real time, retaining only the most recent three refined question-answer pairs. When cross-turn semantic associations are detected, the system intelligently integrates relevant memories into prompt words to optimize the continuity of intent understanding and contextual coherence. The specific process is as follows: Figure 3 As shown, the left side illustrates the process of generating the teacher's thinking template, while the right side shows the overall execution process of the AdBOP algorithm.

[0103] The following sections will provide a detailed explanation of the specific processes involved in template construction, entity perception reasoning, and memory enhancement feedback.

[0104] (1) Automated generation of teacher thinking templates

[0105] To better guide the model's thinking and planning, an automated teacher thinking template generation algorithm is proposed, which constructs high-quality task-solving teacher thinking templates from a general dataset. First, a development set S is randomly selected from the dataset. dev ={(q1,r1,a1),(q2,r2,a2),...,(q j ,r j ,a j )}, (j=1,...,n), where q j To indicate the problem, r j Indicates the search results, a j This indicates the correct answer. The development set will serve as the foundational data for template construction, guiding subsequent task-solving pattern refinement and validation.

[0106] The process of constructing a teacher's thinking template is divided into two stages: the planning stage and the collection stage.

[0107] The planning phase aims to generate a set of executable key steps, S. plan This guides the model in conducting systematic reasoning. First, starting with the development set S... dev Extract the problem set Q = {q1, q2, ..., q} i }, (i = 1, ..., k). Then, a lightweight large language model is used to generate a thought path S for each task. path ={h1,h2,...,h i The generation of its thought process depends on specific prompt templates, such as... Figure 4 As shown, this guides the model to produce reasoning steps that conform to the task logic, and the path planning results are as follows: Figure 5 As shown, the model further extracts key steps for each thought process, and plans the steps based on the data and procedures required to solve the problem. The extracted key steps are output in a specified JSON format, as shown in the template below. Figure 6 As shown, the final set of key steps S is obtained. plan ={p1,p2,...,p i }, where p i The expression is:

[0108] {"<Key Step1> ":"","<Key Step2> ":"",...}

[0109] Obtain the key step set S plan Next, the collection phase begins, with the aim of selecting key steps with strong general applicability to build high-quality demonstration examples. * , for S plan Each key step p in i Facilitate the development of S dev Question q k and its search results r k The execution result e with the following structure is generated. ij Its expression is:

[0110] {" <keystep1> ":" <execution1> "," <keystep2> ":" <execution2>",...}

[0111] Subsequently, the execution results of each key step are quantitatively evaluated. Where f ext This is a heuristic function used to extract information from e. ij Extract the final result from it. For the indicator function, y j To develop the answer to each question in the set, outputting 1 if the result is true and 0 otherwise, the quantization function expression is:

[0112]

[0113] Finally, scores are calculated for all key steps, and the highest score is selected as the best demonstration example. * =(q i ,h i ,p i This example will serve as a template for optimal teacher thinking, such as... Figure 7 As shown, this guides the model in reasoning about problems and generating solutions.

[0114] (2) Entity perception

[0115] To improve computational efficiency and enhance the interpretability and credibility of answers, a thought chain execution mechanism based on entity perception is proposed. Through three stages—guided thinking planning, entity-anchored hybrid retrieval, and structured reasoning execution—semantic anchoring, knowledge retrieval, and step-by-step reasoning are deeply integrated to improve the accuracy of intent understanding and the credibility of answer generation.

[0116] In the guided thinking planning phase, an automatically generated teacher thinking template is used as a reasoning blueprint. The user's original query, sample question, and thought process are input into the model, guiding the user to generate a customized thinking path for the current problem. During this process, the model references and aligns with the reasoning framework of the teacher thinking template to effectively constrain divergent thinking, focus on the core intent of the problem, and establish a semantic foundation for subsequent entity extraction and retrieval strategies.

[0117] After obtaining the thought process path, the system performs entity extraction and key step parsing in parallel. On one hand, it extracts a core entity set E = {e1, e2, ..., e...} from the thought process path. m The system vectorizes the thought process and combines precise keyword matching with dense vector semantic retrieval to perform a hybrid search of the Weaviate knowledge base. First, the system recalls 20 candidate text blocks. Then, using a reordering model, it refines the top-5 text blocks based on the semantic relevance between the original question and each candidate text block, forming a concise search set. On the other hand, the system uses the key steps in the teacher's thinking template to extract and parse the sequence of key steps from the thinking path.

[0118] During the structured reasoning execution phase, the original question, key step sequence, and refined retrieval set are jointly used to construct a complete hint. The model strictly follows the key step sequence to conduct chain-like reasoning: first, the core intent of the question is accurately located, and then the evidence in the refined retrieval set is compared, summarized, and synthesized step by step. Throughout this process, key entities serve as semantic anchors, constraining each step of reasoning to revolve around the essence of the question, thereby effectively suppressing semantic drift. The final answer is generated by fusing the intermediate conclusions of the structured steps with external evidence.

[0119] (3) Memory enhancement feedback

[0120] A memory-enhanced continuous feedback mechanism is introduced, combined with dynamic semantic compression and a dual-caching architecture, to improve the lightweight model's context awareness and referential resolution capabilities in long-term interaction scenarios. This mechanism operates simultaneously in the output and input stages, forming a closed-loop incremental cycle of "write-read-rewrite," continuously optimizing semantic understanding and context management at the system level.

[0121] During the output phase, a structured summary is generated in real-time based on the current round of dialogue. High information density is maintained through incremental merging and redundancy pruning: newly generated content is semantically aligned with existing summaries, retaining only the core fact chain, and time and event states are updated synchronously to ensure accurate memory updates as the dialogue progresses. To reduce the risk of cross-round referencing, the system also maintains semantically enhanced question-and-answer pairs from the three most recent rounds of interaction, resolving colloquial ambiguities and supplementing implicit information. The structured summary and enhanced question-and-answer pairs together constitute a dual-channel memory bank, providing compact and complete contextual support for subsequent reasoning.

[0122] During the input phase, a user's new question triggers memory retrieval. The system first reads a global summary to complete the main dialogue thread, then sequentially concatenates three enhanced question-answer pairs, merging them with the current question to generate extended hints. Through dynamically updating the summary, standardizing key questions and answers, and efficient retrieval injection, the dialogue history is transformed into precisely referable "semantic landmarks." < / keystep2> < / execution1> < / keystep1> < / keystep2> < / execution1> < / keystep1>

Claims

1. A lightweight adaptive behavior optimization method for complex question answering models, characterized in that, An adaptive behavior optimization algorithm is used to implement template construction, entity perception reasoning, and dynamic memory-enhanced feedback, specifically including the following steps: Step 1: Build a Weaviate vector database and an SQL database to automatically generate teacher thinking templates; Step 2: Input the problem and break it down to form a complete thinking path. The automatically generated teacher thinking template is used as a reasoning blueprint. The thinking chain technology is used to perform deep semantic analysis on the user input question. Through the reasoning of the lightweight large language model, the complex problem is decomposed into a structured thinking path and a set of key entities. The user's original input question, the demonstration question and the thinking path are input into the lightweight large language model. The lightweight large language model will decompose the original input question hierarchically to form a complete thinking path. Step 3: Retrieve information and extract key steps from the complete thought process. The system extracts key entities with strong relevance to the problem from the complete thinking path, introduces an intelligent semantic slicing mechanism to vectorize the complete thinking path, generates high-precision semantic vectors, and stores them in the Weaviate vector database in combination with metadata information. Combining entity and semantic vector hybrid retrieval strategy, candidate text blocks are recalled. A reordering model is used to refine text blocks that are highly relevant to the problem based on the semantic relevance between the original problem and the candidate text blocks, forming a refined retrieval set. At the same time, based on the key steps in the teacher's thinking template, the key step sequence is extracted and parsed from the thinking path. Step 4: Chain reasoning to generate the answer By combining the original question, the refined retrieval set, and the key step sequence, a complete hint is constructed. The lightweight large language model performs chain reasoning based on the key step sequence to accurately locate the core intent of the question. It compares, summarizes, and synthesizes the evidence in the refined retrieval set step by step. Key entities serve as semantic anchors throughout the process, constraining each step of reasoning to revolve around the essence of the question. The final answer is generated by fusing the intermediate conclusions of the structured steps with external evidence. Step 5: Extract dialogue summaries and store them in an SQL database for memory enhancement and feedback. A dual-layer memory architecture is introduced, utilizing an SQL database to build a comprehensive dialogue context management system. A memory-enhanced continuous feedback mechanism is introduced to generate a structured summary in real time based on the current round of dialogue, refine the dialogue summary and compress historical content, retain the simplified question-and-answer pairs from the last three rounds and store them in the SQL database. When a new question is input, the global summary is read first to complete the dialogue main line. When a semantic relationship across rounds is detected, the enhanced question-and-answer pairs in the SQL database are sequentially concatenated, and relevant memories are integrated into prompt words and fused with the current question to generate extended prompts.

2. The lightweight model adaptive behavior optimization method for complex question answering according to claim 1, characterized in that, Step 1, which involves automatically generating a teacher's thinking template, includes the following stages: (1) Planning phase: Generate an executable set of key steps S plan Specifically, it includes the following steps: ① Select the development set S from the dataset dev The expression is as follows: S dev ={(q1,r1,a1),(q2,r2,a2),...,(q j ,r j ,a j )},(j=1,...,n) Where, q j To indicate the problem, r j Indicates the search results, a j Indicates the correct answer; ②From the development set S dev The problem set Q is extracted, and the expression is as follows: Q={q1,q2,...,q i },(i=1,...,k); ③ Generate thought path S for each task using a lightweight large language model. path Its expression is as follows: S path ={h1,h2,...,h i }; ④ The lightweight large language model further extracts the key steps for each thinking path and plans the data and steps required to solve the problem based on the lightweight large language model; ⑤ Output the extracted key steps in the specified JSON format to obtain the key step set S. plan , It is expressed as follows: S plan ={p1,p2,...,p i } Where, p i The form is: {"<Key Step1> ":"","<Key Step2> ":"",...}; (2) Collection phase: Select key steps with strong general applicability and build high-quality demonstration examples. * Specifically, it includes the following steps: ① The key steps set S obtained during the planning phase plan Each key step p in i traverse the development set S dev Question q k and its search results r k The execution result e with the following structure is generated. ij It is represented as follows: {" <keystep1> ":" <execution11> "," <keystep2> ":" <exectution2> ",...}< / exectution2> < / keystep2> < / execution11> < / keystep1> ② Quantify the execution result of each key step. Output 1 if the result is true, and output 0 otherwise. The quantization function expression is: Where f ext For heuristic functions, For the indicator function, y j To develop answers to each question in a focused manner; ③ Calculate the scores for all key steps and select the one with the highest score as the best demonstration example. The expression is as follows: d * =(q i ,h i ,p i ) This example serves as the optimal teacher thinking template to guide lightweight large language models in problem reasoning and solution generation.

3. The lightweight model adaptive behavior optimization method for complex question answering according to claim 1, characterized in that, In step 3, the intelligent semantic slicing mechanism is based on an adaptive slicing strategy for document semantic boundaries, which divides the original document D into a series of semantically complete slices C1, C2, ..., C6. n Each slice C i Each slice represents an independent semantic unit, and together they constitute the complete content of the document.

4. The lightweight model adaptive behavior optimization method for complex question answering according to claim 1, characterized in that, In step 3, the Weaviate vector database introduces a strict data isolation mechanism based on ID to perform strict isolation control throughout the entire chain from data storage to query retrieval.

5. The lightweight model adaptive behavior optimization method for complex question answering according to claim 4, characterized in that, The ID-based strict data isolation mechanism utilizes the schema extension capabilities and high-performance filtering mechanism of the Weaviate vector database to achieve unified storage and isolated access to multi-tenant data, specifically including the following stages: (1) Data Injection Phase Add an ID field to each document block and assign it a unique session identifier, so that each vector has a clear ownership tag. At the same time, construct metadata related to the text block in a uniform format and store it in the vector database. (2) Search and query stage The system utilizes the native filtering capabilities of the Weaviate vector database to dynamically construct queries containing WHERE clauses, strictly limiting the search scope to a specified session domain.

6. The lightweight model adaptive behavior optimization method for complex question answering according to claim 1, characterized in that, In step 3, the vectorization process uses the bge-m3 multilingual embedding model to generate high-quality vector representations, and each semantic slice C... i Mapped to a high-dimensional dense vector Batch processing optimization and parallel computing are introduced during vectorization processing.

7. The lightweight model adaptive behavior optimization method for complex question answering according to claim 6, characterized in that, The batch processing optimization and parallel computing techniques involve dividing multiple slices... Form a batch, and use GPU or multi-core CPU for parallel inference to calculate the vector of all slices in the batch at once, as shown in the following expression:

8. The lightweight model adaptive behavior optimization method for complex question answering according to claim 1, characterized in that, In step 3, the hybrid retrieval adopts a hybrid retrieval strategy that combines BM25 keyword retrieval and semantic vector retrieval. By calculating the relevance score between the query terms and documents, the search results are sorted, with the most relevant documents appearing first. Combining term frequency (TF), inverse document frequency (IDF), and document length normalization, the weight formula is dynamically adjusted to appropriately enhance the importance of high-frequency words in the documents. The BM25 score calculation expression for text block d with respect to query q is as follows: Where f(q) i ,d) represents q i The word frequency in text block d, |d| is the length of the text block, avgdl is the average length of text blocks in the knowledge base, k1 and b are hyperparameters. Semantic search is performed using vector similarity. Both the query and the text block are encoded as dense vectors, and semantic similarity is measured by cosine similarity.

9. The lightweight model adaptive behavior optimization method for complex question answering according to claim 1, characterized in that, In step 3, the re-ranking model obtains the candidate document set D through the retrieval phase. candidate The Reranker(q,d) model calculates a more accurate relevance score for each document d in the candidate set. rerank The expression is as follows: The documents are sorted in descending order based on the calculated new scores to obtain the final search results list D. final .

10. The lightweight model adaptive behavior optimization method for complex question answering according to claim 1, characterized in that, In step 5, the dual-layer memory architecture includes the following levels: (1) Short-term memory Maintain the dialogue history of the last three rounds after enhancement. When the user inputs a new question, use a lightweight large language model to rewrite the original question-answer pair with existing information, and transform the ambiguous referential question into a semantically clear expression containing complete contextual information. (2) Long-term memory Record a summary of the entire conversation, and add new information generated in each round of conversation to the summary in real time. Each time a new user enters, it uses both the enhanced conversation history in short-term memory and the conversation summary in long-term memory to build a complete prompt that contains both the latest details and a global perspective.