Intelligent question answering method based on structured semantic index and double-layer memory enhancement

By employing a structured semantic indexing and dual-layer memory-enhanced intelligent question-answering method, the existing system addresses issues such as code semantic fragmentation, insufficient multimodal processing capabilities, and low retrieval accuracy in unstructured data processing. This approach enables efficient personalized interaction and self-optimization, improves code retrieval accuracy and context utilization, and reduces operational costs.

CN122019738AActive Publication Date: 2026-05-12TURING AI INST NANJING CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TURING AI INST NANJING CO LTD
Filing Date
2026-04-16
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Existing intelligent question-answering systems suffer from problems such as semantic breaks in code, insufficient multimodal processing capabilities, low retrieval accuracy, and lack of long-term memory mechanisms when processing unstructured data, resulting in low interaction efficiency and difficulties in system self-optimization.

Method used

By employing structured semantic indexing and dual-layer memory enhancement, and through query preprocessing, multi-tool dynamic routing, structured and semantically enhanced index construction, adaptive context assembly, and data closed-loop self-evolution, differentiated segmentation, accurate retrieval, and personalized interaction are achieved.

Benefits of technology

It improves the accuracy of code retrieval, enhances context utilization, possesses personalized learning capabilities, reduces operation and maintenance costs, and enables the system to self-iterate and improve interaction efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122019738A_ABST
    Figure CN122019738A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of natural language processing and information retrieval, and relates to an intelligent question answering method based on structured semantic indexing and double-layer memory enhancement. The method comprises six steps of query preprocessing, Agent-based multi-tool dynamic routing, structured and semantic enhanced index construction, self-adaptive context assembly, double-layer memory management, and data closed loop and self-evolution, a differential segmentation strategy is adopted for texts, codes and multi-modal data, query optimization, intelligent tool routing and a mixed retrieval algorithm are combined, and the multi-modal data are subjected to self-adaptive context assembly. The technical defects of semantic rupture, low retrieval accuracy, no long-term memory and lack of self-optimization of an existing RAG system are overcome. According to the method, the code retrieval accuracy and the context utilization rate are improved, personalized long-term service and automatic operation and maintenance are achieved, and the method is suitable for scenes such as technology research and development, code library maintenance and intelligent question and answer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of natural language processing and information retrieval technology, and relates to an intelligent question answering method based on structured semantic indexing and two-layer memory enhancement. Background Technology

[0002] With the development of Large Language Models (LLMs), Retrieval Augmentation (RAG) has become the mainstream paradigm for intelligent question answering systems. However, existing RAG systems suffer from the following technical shortcomings: Unstructured data segmentation is unreasonable: Traditional fixed character / token segmentation leads to semantic breaks in code and logical fragmentation in long texts, and cannot adapt to the semantic features of different types of data; Insufficient multimodal processing capabilities: low conversion efficiency for non-text files such as PDF and PPT, and difficulty in effectively extracting semantic information from non-text elements such as tables and charts; Limited search accuracy: The modal gap between user queries and code / professional documents leads to low relevant information recall, and a single search algorithm cannot take into account both semantic matching and keyword matching. No long-term memory mechanism: Context is lost after the session ends, and users need to repeatedly provide background information, resulting in low interaction efficiency; Lack of self-optimization loop: Relying on manual parameter adjustment, user feedback is not effectively utilized for system iteration.

[0003] Comparative document 1 (CN120337898B) focuses on the scenario of tender document plagiarism detection. Although it involves multimodal information processing and semantic segmentation, it does not solve problems such as code retrieval, long-term memory, and system self-evolution, and cannot meet the needs of scenarios such as technology research and development and code maintenance. Therefore, there is an urgent need for an unstructured document processing solution that takes into account differentiated segmentation, accurate retrieval, personalized interaction, and self-evolution. Summary of the Invention

[0004] The purpose of this invention is to overcome the shortcomings of the prior art and provide an intelligent question answering method based on structured semantic indexing and dual-layer memory enhancement.

[0005] To achieve the objectives of this invention, the following technical solutions are adopted.

[0006] An intelligent question answering method based on structured semantic indexing and two-layer memory enhancement includes: (1) Query preprocessing: rewrite the user query, extract key entities and set search filtering conditions; if the query is found to involve code retrieval, generate hypothetical pseudocode for code retrieval; (2)Agent-based Multi-tool Dynamic Routing: Deploy a central routing Agent to analyze the user's query intent and select a retrieval tool from a preset retrieval tool set based on the semantic matching degree. Among them, the retrieval tool set includes a document retrieval tool, a code library retrieval tool, a FAQ retrieval tool, and an online retrieval tool; (3)Structured and Semantic-enhanced Index Construction: Text Data Processing: First, perform segmentation according to the document title hierarchy. When there is no clear title or the text length exceeds the preset threshold, perform segmentation according to the maximum character length. Non-text format files are converted to text format through a multi-modal parsing tool and then segmented; Code Data Processing: Use the Tree-sitter parser to convert the code file into an Abstract Syntax Tree (AST), regard the identified high-level semantic nodes as segmentation units, and extract code meta-information at the same time. Call a large language model to generate a functional description summary for each code segmentation block; Hybrid Index Construction: Adopt a hybrid retrieval mechanism that combines vector cosine similarity and the BM25 algorithm to calculate the retrieval score; (4)Adaptive Context Assembly: Set a length threshold Tmax. When the length L of the retrieval result is less than Tmax, return the full text. When L ≥ Tmax, use a large language model to refine the core information of the long text and extract the skeleton of the long code, retaining the key logical structure; (5)Double-layer Memory Management: Build a short-term scenario buffer for storing structured interaction logs, an asynchronous memory solidification module for regularly extracting long-term information, and a long-term semantic knowledge base for realizing persistent storage and retrieval of knowledge; (6)Data Closed-loop and Self-evolution: Record the complete link of each interaction and the user feedback, generate positive and negative sample test data sets, and verify the answer consistency through regression testing during system update to achieve data-driven self-optimization.

[0007] Furthermore, the key entities include programming languages, device models, date ranges, and technical terms; the retrieval filtering conditions are metadata filtering conditions, which are implemented through the metadata filtering expression of the vector library.

[0008] Furthermore, the multi-modal parsing tools include mineru and paddleocr-vl; the non-text format files include PDF and PPT, and after conversion, a docx format file is generated for title parsing.

[0009] Furthermore, the high-level semantic nodes include function definitions and class definitions; the code meta-information includes file path, file type, module name, method name, start line number, end line number, and keywords; the code segmentation uses regular expression capture function comments and syntax structures.

[0010] Furthermore, the preset text length threshold is obtained by dynamically adjusting the capacity of the large model context window.

[0011] Furthermore, the structured interaction log includes the fields session_id, turn_index, timestamp, and interaction_data; wherein: the interaction_data field contains the user's original query, the rewritten query, the agent's thought process, the tool name, the tool output summary, and the final response.

[0012] Furthermore, the triggering conditions for the asynchronous memory solidification are the end of the session, the system idle time exceeding a preset threshold, or archiving across days; the long-term information includes user technology stack preferences, core requirement characteristics, and key facts of historical interactions.

[0013] Furthermore, the positive samples are user likes and interaction records, from which the query and retrieval content and final answers are extracted and rewritten to construct the dataset; the negative samples are user dislikes and interaction records, which are supplemented into the dataset after being manually labeled with error types.

[0014] Furthermore, the retrieval toolset is extended through a tool registry, which contains tool names, function descriptions, and parameter lists, and supports custom configurations according to business scenarios.

[0015] Furthermore, the code skeleton extraction retains the function signatures, parameter lists, and main control flow structures, while the specific implementation details are replaced with comment placeholders.

[0016] Compared with the prior art, the present invention has the following beneficial effects: 1. Code retrieval accuracy is significantly improved. By introducing AST parsing and LLM-generated semantic summaries, the problem of traditional RAGs being unable to understand the functional semantics of code is solved. Even if the user's question does not match the variable names in the code, accurate matching can be achieved through the generated Chinese summary and pseudocode.

[0017] 2. High context utilization and more accurate answers: Through an adaptive strategy of segmenting / summarizing long content and returning the full text of short content, context window overflow is avoided, while irrelevant information is reduced to prevent interference with LLM inference and the signal-to-noise ratio of the answer is improved.

[0018] 3. Possesses personalization and continuous learning capabilities. The dual-layer memory architecture enables the system to remember the user's technology stack and preferences. As usage time increases, the system becomes more and more familiar with the user, providing more customized assistance.

[0019] 4. Automated operation and maintenance and evaluation: The integrated log and test data generation loop transforms users' daily usage into system test assets, greatly reducing the maintenance cost and optimization difficulty of the RAG system and enabling the system to self-iterate. Attached Figure Description

[0020] Figure 1 This is a framework diagram of the method. Figure 2 This is a schematic diagram of the structured and semantically enhanced index; Figure 3 This is an architecture diagram of the dual-layer memory management. Detailed Implementation

[0021] The present invention will be further described in conjunction with the accompanying drawings and embodiments.

[0022] As an embodiment 1 of the present invention, such as Figures 1 to 3 As shown, an intelligent question-answering method based on structured semantic indexing and dual-layer memory enhancement includes the following process: (1) Query preprocessing: In the RAG system, the quality of question processing directly determines the upper limit of search results. Simple question rewriting typically only involves resolving semantic references and removing meaningless words. In this method, the question rewriting part also allows the large model to extract key entities E = {e1, e2,...} (such as programming language, device model, date range, etc.). The entities extracted will vary depending on the business scenario. These extracted entities will serve as metadata filtering conditions for subsequent vector retrieval. If a user asks "pointers in C language", the system will automatically generate the filtering condition language: 'c'. Later, during vector library retrieval, the filtering expression metadata['language'] == 'c' will be used, thus excluding all Java or Python code snippets from the search scope. This significantly reduces the vector search space and improves recall accuracy.

[0023] Secondly, in highly specialized tasks such as code retrieval, a modal gap exists between natural language and programming languages. The similarity between a user's natural language question and specific code is low, making accurate retrieval difficult. When a user's question is identified as relevant to the retrieved code, in addition to rewriting the question, the system generates hypothetical pseudocode, which is then used for the retrieval. This "code-to-code" retrieval method has a higher recall rate than "text-to-code" methods.

[0024] (2) Agent-based multi-tool dynamic routing This invention deploys a central routing agent to analyze user intent and determine whether and which tools to invoke. If the user's question is casual or a common knowledge-based question, an answer can be generated directly without invoking any tools. If the question involves specific knowledge, the appropriate tool is invoked, the results are compiled, and an answer is provided. The system pre-configures various retrieval tools, such as document retrieval for unstructured documents; code repository retrieval for project code repositories; FAQ retrieval for high-frequency question-and-answer pairs; and network retrieval for real-time information. The agent selects the most suitable tool based on semantic matching.

[0025] / / Tool registry definition (taking IC field as an example) { "tools": [ { "name": "code_search", "description": "Search for the software development kit (SDK) or hardware code library that comes with the chip. Used to find API functions, driver implementations, sample code, macro definitions, etc." "parameters": {"query": "string", "language": "string", "part_number": "string"} }, { "name": "document_search", "description": "Search chip-related technical documents (datasheets, manuals, specifications). Used to find information such as hardware parameters, electrical characteristics, register mappings, and physical dimensions." "parameters": {"keywords": "string", "part_number": "string"} }, ...... ] } (3) Structured and semantically enhanced indexes: In the knowledge base construction section, general RAG systems often use the same standard to segment all data. This method, however, employs differentiated processing strategies for different data types, such as... Figure 2 As shown.

[0026] For text data, the principle of minimizing segmentation is adopted. Currently, large models support long contexts, and technical documents have strong internal connections. Segmentation is only permissible when there are explicit chapter titles. For non-text files such as PDFs and PPTs, they can be converted into text documents (e.g., docx) first using multimodal document parsing tools (e.g., Mineru, Paddleocr-VL), and then segmented by parsing the titles in the Word document using the `document.paragraphs` method. When there are no specific titles or the text content under the same title is too long, a maximum length is limited (e.g., 5000 characters, which can be adjusted according to the actual scenario) to prevent multiple search results from being merged and exceeding the model context limit.

[0027] For code data, a Tree-sitter parser is used to transform the code file into an Abstract Syntax Tree (AST). The system traverses the AST, identifying high-level semantic nodes such as function definitions and class definitions, treating them as independent chunks to avoid truncating a function and ensuring the integrity of the code syntax. Besides the code content, the data also includes elements such as file path, file type, module, number of methods, method name, start line, end line, and keywords. The following example uses the IC domain, primarily C language code. First, the regular expression `r'( / \*\*[\s\S]*?\* / \s*)?^(?!static\s+inline)([\w\s\*]+?)\s+(\w+)\s*\(([^)]*)\)\s*\{'` is used to identify the function's return type, function name, parameter list, and can capture Doxygen-style comments above the function. Then, the end of the function is located by counting brackets.

[0028] def _find_function_end(self, content: str, start_pos: int) -> int: brace_count = 0 in_function = False # ... Traverse characters... if char == '{': brace_count += 1 elif char == '}': brace_count -= 1 # When the count reaches zero, it means the function has ended. if in_function and brace_count == 0: return i + 1 The complete logical flow is as follows: graph TD A[Start: main()] --> B{Check input path}; B -- Invalid --> Z [Exit]; B -- Valid --> C [Initialize CCodeParser]; C --> D[process_directory: Traverse SDK directories]; D --> E{file type?}; %% C Source File Processing E -- .c source file --> F[parse_c_file]; F --> F1 [Read content & Calculate line count]; F1 --> F2 [Extract all function information (regular expression + bracket matching)]; F2 --> F3 {Number of lines <= 500?}; F3 -- Yes (small file) --> F4 [Generate a single FileChunk]; F3 -- No (Large Files) --> F5 [Aggregate by Function Boundaries]; F5 --> F6 {current block + new function > line 500?}; F6 -- Yes --> F7 [Pack the current code chunk -> Reset the count]; F6 -- No --> F8 [Add to current block]; F7 --> F5; F8 --> F5; %% Header File Processing E -- .h header file --> G[parse_header_file]; G --> G1 [Regular expression matching Struct / Enum / Macro]; G --> G2[Generate HeaderDefinition Chunks]; %% Documentation Processing E -- .md document --> H[parse_markdown_file]; H --> H1[Split chapters by Markdown headings]; H --> H2[Generate DocumentChunks]; %% Aggregation F4 & F7 & G2 & H2 --> I[Collect all Chunks]; I --> J{Output format?}; J -- JSONL --> K[Write to .jsonl line by line]; J -- JSON --> L[Write as a whole to .json]; K & L --> M[Print statistical summary]; M --> N[End]; In addition, to solve the problem of mismatch between code and natural language queries, for each segmented code block, the system further calls the large model to generate a summary of the functional description in natural language.

[0029] During retrieval, improve the retrieval accuracy through the "code-code" and "text-text" methods, that is, match the user's question with the code keywords and code summaries, and match the pseudo-code in the question rewriting with the code. Users can accurately retrieve relevant code information in any way of asking questions. And use hybrid retrieval, specifically as follows: ;

[0030] Among them: is the vector cosine similarity, is the BM25 score, is the dynamic weight coefficient.

[0031] (4)Adaptive context assembly: To solve the problem of window overflow in long contexts, the system implements a dynamic processing strategy in the retrieval return stage. First, set the length threshold Tmax. When the length L of the retrieved content < Tmax, directly return the full text to ensure that the large model can know all the details. When the length L of the retrieved content >= Tmax, trigger real-time summarization, summarize and refine the long text through the large model, refine the core content, and retain the logic related to the user's question. Extract the skeleton of the long code through the large model, retain the function signature and the main control flow structure, and replace the specific implementation details with comment placeholders.

[0032] The retrieval results should also include the exact content source, such as the chapters of the document, the files and lines of the code, etc. These information have been processed accordingly during segmentation to ensure that accurate reference sources are included in the final answer.

[0033] (5) Dual-layer memory management: This invention designs a two-layer memory architecture that simulates human cognition to address the forgetting problem in long-term interactions. This architecture consists of three parts: a short-term context buffer, an asynchronous memory solidification module, and a long-term semantic knowledge base, as follows: Figure 3 As shown.

[0034] Unlike traditional dialogue systems that only store the plain text history of user questions and system responses, the structured metadata log of short-term episodic memory in this system is a high-dimensional structured metadata log. The system maintains a structured object for each session that allows for tracing back the reasoning process. Each round of interaction includes the following fields: { "session_id": "sess_20260211_001", "turn_index": 5, "timestamp": 1707645600, "interaction_data": { "user_query_raw": "...", "user_query_rewritten": "...", "agent_thought_trace": "...", "tool_name": "code_search", "tool_output_summary": "...", "final_response": "..." } } The system sets a maximum token threshold. When the log length exceeds the threshold, the earliest round is no longer simply discarded. Instead, the earliest k rounds of dialogue are compressed into a natural language summary, retaining key states while releasing context space.

[0035] The formation of asynchronous memory solidification is a process of extracting static knowledge from streaming logs. This system periodically scans short-term logs through a background asynchronous process. Memory retrieval is triggered in three situations: session end; idle time exceeds a set threshold; and archiving spans multiple days. During retrieval, a large model is used to analyze the short-term logs, distinguishing between facts, preferences, and noise. Facts or preferences with long-term value are extracted, while trivial chatter or temporary debugging instructions are discarded, thus forming a user profile (e.g., this user is a student who frequently uses Python programming).

[0036] Long-term memory is stored in a vector database, achieving knowledge persistence decoupled from specific time points. The extracted long-term memory is transformed into vector storage. At the start of each new future session, the user's memory partition is locked based on their user ID. The top-k relevant facts are retrieved from the long-term memory database based on the current user's question and used as part of the system prompt, thus achieving a personalized and consistent long-term service experience.

[0037] (6) Data closed loop and self-evolution To address the challenges of evaluating and optimizing RAG systems, this invention constructs an automated data pipeline. The system meticulously records the entire chain of each interaction and captures user feedback (likes / dislikes), transforming this feedback into a test dataset through a large model. Positive samples are user like interactions, from which Qrewrite, Cretrieved, and Answer are extracted to construct the dataset. Negative samples are user dislike interactions, which are subsequently manually labeled to form the dataset.

[0038] Whenever the system code is updated, a regression test library is run. The system compares the newly generated answers with those in the historical records, using a large model to determine whether the new answers maintain key consistency with the original answers. This mechanism effectively ensures that the RAG system can automatically accumulate knowledge and continuously improve its stability as usage increases, forming a data flywheel.

[0039] As an embodiment 2 of the present invention, such as Figures 1 to 3 As shown, a specific application example of an intelligent question answering method based on structured semantic indexing and two-layer memory enhancement is presented: The entire process of a certain device model N****5 (the data has been desensitized here) is demonstrated.

[0040] Data processing section: This model has a datasheet, a 209-page PDF file. First, Mineru was used to parse it into a docx document, containing text, images, and headings. Then, the `document.paragraphs` method was used to parse and segment the headings in the docx file, resulting in 50 chunks. This model also has a codebase with 421 code files. Using the same code parsing method, these were segmented into 515 chunks. Finally, a large model was used to generate a functional summary of these chunks.

[0041] Q&A section: Question: The N****5 supports a maximum operating frequency of 200MHz. After performing DMA data transfer on the SRAM, why does the CPU sometimes fail to read the latest data? How can this be resolved? Step (1) The problem has been rewritten and expanded to: Analysis of why the CPU cannot read the latest data after DMA transfer of SRAM data in N****5 and solutions, including cache consistency, L1-Cache refresh strategy, memory barrier usage and DMA cache synchronization mechanism.

[0042] Step (2) A memory retrieval was performed, but since this is the user's first time asking a question, the memory retrieval result is empty.

[0043] Step (3) The agent module automatically identifies and calls the tool.

[0044] Agent R1: Code retrieval revealed the main.c file under the DMA module. This file contains three complete functions: main, DMA_sramtosram, and DMA1_INT_0_handler. The model-generated functional description is as follows: Configure the DMA1 channel to implement block data transfer between SRAM and SRAM; bind a fixed source signal via DMAMUX; enable a transfer completion interrupt; in the main loop, LEDs flash to indicate the running status; the interrupt service routine verifies the integrity of the transferred data; upon success, outputs a verification pass message; otherwise, it indicates a data error, achieving efficient memory copying and automatic verification without CPU intervention.

[0045] agent r2: Document retrieval retrieved the device's architecture features from the datasheet: 32KB L1-Cache (16KB data cache + 16KB instruction cache), 128KB SRAM2 (with ECC check) + 64KB ITCM + 64KB DTCM.

[0046] agent r3: Summary of answer: The CPU's L1 data cache (16KB) caches data in SRAM. When DMA modifies the SRAM, if the CPU reads the same address again, it will directly read the old data from the cache instead of reading the latest data from SRAM. A solution is provided: use the `SCB_InvalidateDCache_by_Addr` method in `DMA1_INT_0_handler` to invalidate the data cache, forcing a reread from SRAM and ensuring the CPU reads the latest data.

[0047] Step (4) The model extracts user memories to generate a user profile: User is an Embedded Systems Engineer, which is then stored in a vector library.

[0048] As a verification example 3 of the present invention, the recall rate, accuracy, context utilization, interaction efficiency, and operation and maintenance cost are verified.

[0049] (1) Code retrieval accuracy and overall question answering performance have been greatly improved. In retrieval tests targeting SDK source code, underlying driver implementations, and complex system code, traditional RAG systems based on fixed token segmentation typically achieve a Top-5 recall rate of only around 65% for complex code. However, after adopting the structured and semantically enhanced indexing of this invention, the Top-5 retrieval recall rate for complex code fragments increases to 88%. In a closed test set containing 176 complex business questions, the overall accuracy of the system's generated answers reached 91%.

[0050] (2) Context utilization polarization and token consumption optimization For lengthy technical documents and source files with thousands of lines, the adaptive context assembly strategy employed in this invention significantly improves the signal-to-noise ratio of the context window. While maintaining the accuracy of responses, the average token consumption per interaction is reduced by approximately 35%, greatly alleviating the computational pressure on model inference and avoiding logic truncation issues caused by long context overflows.

[0051] (3) The leap in interaction efficiency and long-term memory coherence In testing, when troubleshooting complex hardware and software integration issues, the average number of interaction rounds decreased from the traditional 4.8 rounds to 2.2 rounds. Because the system can automatically complete the problem background using long-term memory, the frequency of users repeatedly inputting background information also decreased, resulting in significant improvements in interaction efficiency and immersive experience.

[0052] (4) Reduced operation and maintenance costs and self-evolution of system data This invention constructs a data closed-loop and self-evaluation mechanism, transforming manual-driven processes into data-driven ones. By capturing structured metadata and like / dislike feedback during user interactions, the system can automatically generate the dataset required for regression testing. This approach replaces most of the manual data annotation workload (over 70%), significantly shortening the knowledge base maintenance cycle and substantially reducing overall operation and maintenance time costs.

[0053] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.

Claims

1. An intelligent question-answering method based on structured semantic indexing and dual-layer memory enhancement, characterized in that: It includes: (1) Query preprocessing: Rewrite the user's original query, and extract key entities to form metadata filtering conditions; If it is recognized that the query involves code retrieval, generate hypothetical pseudo-code for code-code pattern retrieval; (2) Agent-based multi-tool dynamic routing: Deploy a central routing Agent, analyze the user's query intention, and select a retrieval tool from a preset retrieval tool set according to the semantic matching degree; where: the retrieval tool set includes a document retrieval tool, a code library retrieval tool, an FAQ retrieval tool, and an online retrieval tool; (3) Structured and semantic-enhanced index construction: Text data processing: First, split according to the document title hierarchy. When there is no clear title or the text length exceeds the preset threshold, split by the maximum character length; non-text format files are converted to text format by a multi-modal parsing tool and then split; Code data processing: Use the Tree-sitter parser to convert the code file into an abstract syntax tree (AST), use the identified high-level semantic nodes as split units, extract code meta-information at the same time, and call a large language model to generate a functional description summary for each code split block; Hybrid index construction: Use a hybrid retrieval mechanism that combines vector cosine similarity and the BM25 algorithm to calculate retrieval scores; (4) Adaptive context assembly: Set a length threshold Tmax. When the length L of the retrieval result is L < Tmax, return the full text; when L ≥ Tmax, use a large language model to refine the core information of the long text and extract the skeleton of the long code, retaining the key logical structure; (5) Double-layer memory management: Build a short-term scenario buffer for storing structured interaction logs, an asynchronous memory solidification module for periodically extracting long-term information, and a long-term semantic knowledge base for realizing persistent storage and retrieval of knowledge; (6) Data closed-loop and self-evolution: Record the complete link of each interaction and user feedback, generate positive and negative sample test data sets, and verify the answer consistency through regression testing during system update to achieve data-driven self-optimization.

2. The intelligent question-answering method based on structured semantic indexing and dual-layer memory enhancement according to claim 1, characterized in that: The key entities include programming languages, device models, date ranges, and technical terms; the metadata filtering conditions are implemented through the metadata filtering expressions of the vector library.

3. The intelligent question-answering method based on structured semantic indexing and dual-layer memory enhancement according to claim 1, characterized in that: The multi-modal parsing tools include mineru and paddleocr-vl; the non-text format files include PDF and PPT, and after conversion, a docx format file is generated for title parsing.

4. The intelligent question-answering method based on structured semantic indexing and dual-layer memory enhancement according to claim 1, characterized in that: The code meta-information includes file path, file type, module name, method name, start line number, end line number, and keywords; the code splitting uses a regular expression to capture function comments and syntax structures.

5. The intelligent question-answering method based on structured semantic indexing and dual-layer memory enhancement according to claim 1, characterized in that: The preset character length threshold is 5000 characters, which can be dynamically adjusted according to the context window capacity of the large model.

6. The intelligent question answering method based on structured semantic indexing and dual-layer memory enhancement according to claim 1, characterized in that: The structured interaction log includes the fields session_id, turn_index, timestamp, and interaction_data; wherein, the interaction_data field contains the user's original query, the rewritten query, the agent's thought process, the tool name, the tool output summary, and the final response.

7. The intelligent question-answering method based on structured semantic indexing and dual-layer memory enhancement according to claim 1, characterized in that: The triggering conditions for asynchronous memory solidification are the end of the session, the system idle time exceeding a preset threshold, or archiving across days; the long-term information includes user technology stack preferences, core requirement characteristics, and key facts of historical interactions.

8. The intelligent question answering method based on structured semantic indexing and dual-layer memory enhancement according to claim 1, characterized in that: The positive samples are user likes and dislikes interaction records, which are extracted, rewritten, queried, retrieved, and finally answered to construct the dataset; the negative samples are user dislikes and dislikes interaction records, which are manually labeled with error types and then added to the dataset.

9. The intelligent question-answering method based on structured semantic indexing and dual-layer memory enhancement according to claim 1, characterized in that: The retrieval toolset is extended through a tool registry, which contains tool names, function descriptions, and parameter lists, and supports custom configurations according to business scenarios.

10. The intelligent question-answering method based on structured semantic indexing and dual-layer memory enhancement according to claim 1, characterized in that: The code skeleton extract retains the function signatures, parameter lists, and main control flow structures, while the specific implementation details are replaced with comment placeholders.