A knowledge base construction and multi-domain retrieval method and system based on small model decision
By using a lightweight language model for intelligent cleaning and structured segmentation in the offline stage, combined with domain-specific retrieval of multi-dimensional metadata, the problems of low data quality and cross-domain noise in enterprise-level knowledge bases are solved, achieving efficient and reliable multi-domain knowledge retrieval and answer generation.
Patent Information
- Application Number
- CN202611269072.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-20
- Publication Date
- 2026-11-24
AI Technical Summary
Existing technologies in the fields of enterprise-level intelligent question answering and knowledge retrieval suffer from problems such as low quality of offline data construction, coarse-grained segmentation strategies, single metadata dimensions, single retrieval strategies, inability to balance localized deployment with high-performance data governance, and difficulty in verifying the credibility of answers.
A lightweight language model is used to perform intelligent cleaning, structured segmentation, and automatic annotation of multi-dimensional metadata in the offline stage to build a multi-domain knowledge index. In the online retrieval stage, multi-dimensional metadata is used to achieve domain-specific retrieval. Finally, the local large model generates answers with traceability information.
It improves the data quality and retrieval accuracy of the knowledge base, reduces hardware costs, enhances the credibility and compliance of answers, and supports efficient retrieval across multiple business domains.
Smart Images

Figure CN123159484A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of artificial intelligence and natural language processing technology, and in particular relates to a knowledge base construction and multi-domain retrieval method and system based on small model decision-making. Background Technology
[0002] Currently, in the field of enterprise-level intelligent question answering and knowledge retrieval, the mainstream technical solutions mainly include Retrieval Augmentation Generation (RAG) technology based on Large Language Model (LLM), traditional keyword-based retrieval technology, and question answering systems based on knowledge graphs.
[0003] Standard technical content: The standard RAG workflow typically involves: receiving user questions → converting the questions into vectors → performing global semantic similarity retrieval in a vector database → retrieving the Top-K text blocks → concatenating the text blocks with the question to form a Prompt → inputting the Prompt into a large language model to generate the answer.
[0004] Data processing flow: The document is cleaned simply (e.g., using regular expressions to remove headers and footers, and deduplication), split into segments with a fixed number of characters (e.g., 500 / 1000 characters), and then vectorized using a general Embedding model and stored in a vector library.
[0005] Multi-model collaboration: Some solutions utilize a large-scale model collaboration mechanism, deciding whether to use a lightweight model (small model) or a large model (large model) to answer the question based on its difficulty, in order to balance cost and effectiveness.
[0006] The shortcomings and deficiencies of existing technologies: Offline data construction suffers from low quality and a lack of intelligent governance: Existing technologies (such as some "large and small model collaboration" patents) mainly focus on model scheduling in the online phase, neglecting data processing in the offline phase. They typically rely on simple rule scripts or general preprocessing models for cleaning, failing to identify complex semantic noise (such as complex disclaimers, footer decorations, and specific formatting interference), resulting in a large amount of low-quality text entering the knowledge base.
[0007] Coarse-grained segmentation strategies: These strategies often use a fixed number of characters for segmentation, lacking a deep understanding of the document structure (chapter titles, paragraph logic), which can easily disrupt the integrity of the context and cause the same complete meaning to be scattered in different fragments, affecting the retrieval effect.
[0008] Metadata dimensions are limited and extraction is difficult: Existing technologies mostly rely on manual annotation or simple keyword extraction (such as CN120780916A, a resource recommendation method and system based on hybrid retrieval RAG), lacking a deep understanding of the semantics of documents (such as short summaries, topic tags, entities, and content types), and cannot support subsequent refined retrieval and multi-dimensional filtering.
[0009] The retrieval strategies are simplistic and lack refined control (domain-specific) for business domains: Existing RAG systems mostly use a global retrieval mode, i.e., a unified retrieval across all vector blocks. Although some patents propose "tag library filtering" (e.g., CN120780916A) or "problem difficulty routing" (e.g., CN119740554A, a decision-making method, computer system, and computer-readable storage medium based on collaborative optimization of large and small language models), the former focuses on SQL rule filtering, while the latter focuses on computational cost (L-LLM vs S-LLM).
[0010] In enterprise environments, knowledge bases often encompass multiple business areas (such as water conservancy, legal affairs, and equipment maintenance). The terminology, expressions, and knowledge structures differ significantly across these areas. Global searches are prone to "cross-domain noise interference" (e.g., searching for water conservancy regulations but finding personnel management systems), and cannot employ differentiated search strategies based on the specific characteristics of knowledge in particular areas (e.g., regulations vs. case studies). Existing technologies lack a "multi-expert" physical or logical database sharding search mechanism based on multi-dimensional metadata.
[0011] The inability to balance localized deployment with high-performance data governance: To achieve better data governance (such as cleaning and labeling), existing solutions often rely on large cloud models (GPT-4, etc.) or high-performance computing power, resulting in high costs and failing to meet compliance requirements for data not leaving the domain. On the other hand, if small models are used solely for localized deployment (such as CN120874999A, a knowledge base enhancement generation method and system based on hybrid retrieval and fact verification, mentioned in the portable device scenario), they can often only perform simple question-and-answer tasks and cannot handle complex data cleaning, structured segmentation, and intelligent labeling tasks, resulting in limited data quality in the database and consequently affecting the accuracy of the final answer.
[0012] Weak contextual relevance makes it difficult to verify the credibility of answers: Existing technologies often directly splice fragments to generate answers after retrieval, lacking in-depth source tracing based on metadata (such as precise page numbers and document titles). The lack of factual consistency verification of search results (such as deduplication clustering and conflict detection) easily introduces duplicate or contradictory information into large models, increasing the risk of illusion. Summary of the Invention
[0013] This invention provides a knowledge base construction and multi-domain retrieval method and system based on small model decision-making. It utilizes a lightweight language model (small model) as the core decision-maker. In the offline stage, it performs intelligent cleaning, structured segmentation, and automatic annotation of multi-dimensional metadata on unstructured documents, and establishes a multi-domain knowledge index in a vector database based on the multi-dimensional metadata. In the online retrieval stage, it identifies the business intent and target domain according to the user's question, achieves multi-expert domain-based retrieval through metadata filtering, and finally generates answers with traceability information from a local large model after re-sorting.
[0014] To achieve the above-mentioned objectives, the first objective of this invention is to provide a knowledge base construction and multi-domain retrieval method based on small model decision-making, including an offline construction phase and an online retrieval phase; wherein: The offline build phase includes: S1. Obtain the original document, parse and extract the text content, page numbers and document structure information; S2. Use the first lightweight language model to perform semantic judgment on the parsed text blocks, identify and filter semantic noise, and retain valid content. S3. Based on document structure information and the first lightweight language model, perform semantic integrity segmentation on effective content to obtain knowledge blocks; S4. Use the first lightweight language model to automatically annotate each knowledge block with multidimensional metadata. The multidimensional metadata includes at least text summary, topic tags, entity list, content type and business domain. S5. Vectorize the knowledge block text and bind and store the semantic vector, original text and multidimensional metadata to the local vector database. The online search phase includes: S6. Receive user queries and use the second lightweight language model to identify the intent category and target business area of the query. S7. Based on the target business domain, determine the corresponding target sub-knowledge base in the local vector database, and perform a hybrid search within the target sub-knowledge base to obtain a set of candidate knowledge fragments; S8. Use the reordering model to score and filter the candidate knowledge fragment set for relevance, and obtain the target knowledge fragment. S9. Input the target knowledge fragment into the local large language model to generate the answer, and generate traceability information based on multidimensional metadata.
[0015] Preferably, in S2, the first lightweight language model determines whether a text block belongs to at least one of header, footer, table of contents, disclaimer, or garbled text by using preset cleaning prompts.
[0016] Preferably, in S3, the semantic integrity segmentation includes: preferentially segmenting at chapter boundaries; for chapters exceeding a preset length threshold, using a first lightweight language model to calculate the semantic coherence between paragraphs, and segmenting at positions where the semantic coherence is lower than the preset threshold.
[0017] Preferably, in S4, the multidimensional metadata also includes the document title and file path, which are used to provide a basis for tracing the source when generating the answer.
[0018] Preferably, in S7, the hybrid retrieval includes parallel vector retrieval and keyword retrieval; the vector retrieval uses cosine similarity calculation, and the keyword retrieval uses the BM25 algorithm; the retrieval results are fused using a reciprocal sorting fusion algorithm.
[0019] Preferably, in S9, the source information includes the document title, page number, and file path; the answer generated by the local large language model includes a reference identifier associated with the source information.
[0020] A second objective of this invention is to provide a knowledge base construction and multi-domain retrieval system based on small model decision-making, comprising: An offline data intelligent construction unit is used to execute the steps of the offline construction phase. The online retrieval and generation unit is used to perform the steps of the online retrieval phase.
[0021] Preferably, the offline data intelligent construction unit includes: The document parsing module is used to parse the original document; The small model decision cleaning module is equipped with the first lightweight language model to filter semantic noise; The segmentation and annotation module for small model decision-making is configured with the first lightweight language model for semantic integrity segmentation and multidimensional metadata annotation. The vectorization and storage module is used for vectorization encoding and writing to the local vector database; The online retrieval and generation unit includes: The intent recognition and routing module is configured with the second lightweight language model for recognizing intents and target business domains; The multi-domain retrieval and fusion module is used to perform hybrid retrieval within the scope of the target sub-knowledge base; The reordering module is configured with the reordering model for scoring and filtering candidate segments. The generation and tracing module is configured with the local large language model to generate answers and tracing information.
[0022] A third objective of the present invention is to provide an electronic device, characterized in that it comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the aforementioned knowledge base construction and multi-domain retrieval method based on small model decision-making.
[0023] A fourth objective of this invention is to provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned knowledge base construction and multi-domain retrieval method based on small model decision-making.
[0024] The advantages and positive effects of this application are: This invention utilizes a lightweight, small model to perform deep, intelligent data governance (cleaning, segmentation, and annotation) on the knowledge base offline, constructing a vector knowledge base with rich multi-dimensional metadata. In the online phase, it enables multi-expert-based domain-specific retrieval and intelligent routing based on the multi-dimensional metadata. This leverages the low cost and low computational power of the small model to achieve high-quality data governance and intent recognition, while also addressing cross-domain noise issues through domain-specific retrieval, significantly improving the accuracy, reliability, and response speed of enterprise local knowledge base question answering. Specifically: This invention effectively eliminates semantic noise such as headers, footers, and disclaimers through intelligent cleaning and structured segmentation driven by small models, preventing noisy content from entering the vector database. The segmentation strategy based on semantic integrity ensures the semantic coherence of knowledge blocks. High-quality data directly improves the recall accuracy and semantic relevance of subsequent searches.
[0025] This invention performs domain-based routing retrieval based on the "business domain" and "topic" in multidimensional metadata, limiting the query scope to the relevant expert sub-knowledge base, completely eliminating cross-domain noise, and making the retrieval results more focused and accurate.
[0026] This invention utilizes a small model for "one-time decision-making" (cleaning and labeling), avoiding complex incremental training processes and not relying on cloud APIs. The small model has far fewer parameters than the large model, resulting in faster inference speeds. It can run smoothly on ordinary enterprise servers and even portable devices, lowering the hardware barrier for local deployment.
[0027] This invention deeply binds multidimensional metadata (especially document titles, page numbers, and paths) to knowledge blocks and generated answers. The system-generated answers come with clear source citations (such as document name + page number), and users can click the link to directly jump to the original text for verification, effectively reducing the risk of "illusion" and enhancing the credibility and compliance of the system's output.
[0028] This invention utilizes a domain-based retrieval mechanism based on multidimensional metadata, resulting in excellent system scalability. When a new business domain (such as "Finance Department") is added, the system can automatically identify and route to the sub-knowledge base of that domain simply by annotating the corresponding domain during the offline construction phase, without requiring modification to the core retrieval code. The modular design allows each stage (cleaning, segmentation, annotation, retrieval, and generation) to be independently upgraded or replaced, facilitating system maintenance and iteration. Attached Figure Description
[0029] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0030] Figure 1 A flowchart of a preferred embodiment of the present invention; Figure 2 This is a system block diagram of a preferred embodiment of the present invention; Figure 3 This is a flowchart of the offline data intelligent construction stage in a preferred embodiment of the present invention; Figure 4 This is a flowchart of the online retrieval and generation stage in a preferred embodiment of the present invention; Figure 5 This is a schematic diagram of the multidimensional metadata storage structure in a preferred embodiment of the present invention; Figure 6 This is a flowchart of the user interface (UI) interaction in a preferred embodiment of the present invention. Detailed Implementation
[0031] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0032] Please see Figures 1 to 6 A knowledge base construction and multi-domain retrieval method based on small model decision-making mainly includes an offline construction stage and an online retrieval stage; wherein: The offline build phase includes the following steps: S1. Obtain the original document, parse and extract the text content, page numbers and document structure information; Retrieve the original document from the local file system or data source. Use a document parsing tool (such as Docling) to parse the original document and extract information such as text content, page numbers, heading levels (H1, H2, H3), and paragraph structure.
[0033] S2. Use the first lightweight language model to perform semantic judgment on the parsed text blocks, identify and filter semantic noise, and retain valid content. The first lightweight language model (small model) is used to identify and filter noise in the parsed text blocks.
[0034] The first lightweight language model uses preset cleaning prompts to determine whether a text block belongs to at least one of the following: header, footer, table of contents, disclaimer, or garbled text.
[0035] Specifically: Input a text block into the first lightweight language model. Using preset cleaning prompts, the model is asked to determine whether the text block belongs to semantic noise such as "header," "footer," "table of contents," "disclaimer," or "garbled text." If the model outputs "noise," the text block is filtered out; if it is "valid content," it is retained.
[0036] Compared to traditional regular expression filtering, this step can leverage the generalization ability of the first lightweight language model to identify semantic noise in complex patterns, significantly improving the quality of the data entering the database.
[0037] S3. Based on document structure information and the first lightweight language model, perform semantic integrity segmentation on effective content to obtain knowledge blocks; The semantic integrity segmentation includes: prioritizing segmentation at chapter boundaries; for chapters exceeding a preset length threshold, using a first lightweight language model to calculate semantic coherence between paragraphs, and segmenting at points where semantic coherence is below a preset threshold. Specifically: First, using the structural information (chapter titles) extracted by the document parsing tool, the text is segmented at the chapter boundaries to ensure the integrity of the semantic units.
[0038] Secondly, for excessively long chapters, the first lightweight language model is used to calculate the semantic coherence or similarity between paragraphs. The chapters are then segmented at positions where the semantic coherence is below a preset threshold to ensure that the segmented knowledge blocks are relatively independent semantically.
[0039] S4. Use the first lightweight language model to automatically annotate each knowledge block with multidimensional metadata. The multidimensional metadata includes at least text summary, topic tags, entity list, content type and business domain. The multidimensional metadata also includes document titles and file paths, which are used to provide a basis for tracing the source when generating answers.
[0040] Each segmented knowledge block is automatically labeled using a first-level lightweight language model to generate multidimensional metadata. The multidimensional metadata includes at least: Short summary: A one-sentence summary of the main idea of the knowledge block; Topic Tags: Extract 3-5 topic keywords; Entity list: Identifies entities such as person names, place names, project names, and equipment models; Content type: Determine if it belongs to definition, specification, case study, FAQ, or other; Business Area: Determine the relevant business area (e.g., water conservancy projects, equipment management, legal contracts, etc.).
[0041] S5. Vectorize the knowledge block text and bind and store the semantic vector, original text and multidimensional metadata to the local vector database. The knowledge block text is vectorized using a semantic embedding model (such as Qwen3-Embedding) to generate a high-dimensional semantic vector. The semantic vector, the original knowledge block text, and its corresponding multi-dimensional metadata are then bound together and written to a local vector database (such as Qdrant) as a payload.
[0042] At the same time, a fingerprint mechanism (based on file size, modification time, and header hash) is used to record processed files to support incremental updates.
[0043] The online search phase includes the following steps: S6. Receive user queries and use the second lightweight language model to identify the intent category and target business area of the query. First, receive natural language input from the user.
[0044] Then, a second lightweight language model or classification model is used to process the user's question, identify the category of their query intent (such as fact query, comparative analysis, process description) and the target business domain to which it belongs.
[0045] Subsequently, based on the identified target business domain (such as "water conservancy"), metadata filtering is performed through the domain field in the multidimensional metadata to route the retrieval request to the corresponding "expert sub-knowledge base" or "logical subset".
[0046] This step transforms the global search into a multi-expert (MoE) domain-specific search, ensuring that knowledge from different business domains does not interfere with each other, thus greatly reducing cross-domain noise.
[0047] S7. Based on the target business domain, determine the corresponding target sub-knowledge base in the local vector database, and perform a hybrid search within the target sub-knowledge base to obtain a set of candidate knowledge fragments; The hybrid retrieval includes parallel vector retrieval and keyword retrieval; the vector retrieval uses cosine similarity calculation, and the keyword retrieval uses the BM25 algorithm; the retrieval results are fused using a reciprocal sorting fusion algorithm.
[0048] Within the selected target sub-knowledge base, perform the following operations in parallel: Vector retrieval: Calculates semantic similarity (such as cosine similarity) between user questions (or their vectors) and vectors in the sub-knowledge base.
[0049] Keyword retrieval: The BM25 algorithm is used to perform precise keyword matching in the sub-knowledge base.
[0050] The search results from both methods are fused (e.g., Reciprocal Rank Fusion, RRF) to obtain a preliminary set of candidate knowledge fragments.
[0051] S8. Use the reordering model to score and filter the candidate knowledge fragment set for relevance, and obtain the target knowledge fragment. The candidate fragments are re-ranked using a re-ranking model (such as BGE-Reranker) to score their relevance, and then the Top-K (such as Top 10) target knowledge fragments with the highest relevance are selected.
[0052] S9. Input the target knowledge fragment into the local large language model to generate the answer, and generate traceability information based on multidimensional metadata.
[0053] The source information includes the document title, page number, and file path; the answer generated by the local large language model contains a reference identifier associated with the source information.
[0054] The target knowledge fragments are sorted by relevance score and then concatenated as context input.
[0055] The "document title", "page number", and "path" from the multidimensional metadata are embedded in the context as reference information.
[0056] Input the context into the local large language model to generate an initial answer.
[0057] Analyze the preliminary answer, identify the key information points that contain factual claims, and associate them with the corresponding citation information. Add traceable citation markers to the answer (e.g., [Source: XXX Specification, Page Y]).
[0058] The answers undergo post-processing, including removing invalid statements, standardizing terminology style, deduplicating and categorizing, and finally outputting resource recommendation answers with highlighted reference links on the user interface.
[0059] Please see Figure 2A knowledge base construction and multi-domain retrieval system based on small model decision-making includes: Offline data-intelligent building units for performing offline build phase steps. The offline data intelligent construction unit includes: The document parsing module is used to parse the original document; The small model decision cleaning module is equipped with the first lightweight language model to filter semantic noise; The segmentation and annotation module for small model decision-making is configured with the first lightweight language model for semantic integrity segmentation and multidimensional metadata annotation. The vectorization and storage module is used for vectorization encoding and writing to the local vector database; An online retrieval and generation unit for performing the online retrieval stage steps, the online retrieval and generation unit comprising: The intent recognition and routing module is configured with the second lightweight language model for recognizing intents and target business domains; The multi-domain retrieval and fusion module is used to perform hybrid retrieval within the scope of the target sub-knowledge base; The reordering module is configured with the reordering model for scoring and filtering candidate segments. The generation and tracing module is configured with the local large language model to generate answers and tracing information.
[0060] To better understand the technical solution of the present invention, the following non-limiting explanation is provided: Offline data intelligent building blocks are used to process raw documents and generate high-quality vector knowledge bases.
[0061] Document parsing module: Connects to the data source and is used to parse raw documents in various formats such as PDF, Word, and PPT, extracting text content, page numbers, heading levels, and structural information. It is preferably implemented using the Docling tool or in combination with an OCR engine.
[0062] The cleaning module for the small model decision-making process is connected to the document parsing module and is configured with a first lightweight language model (small model). This module utilizes the generative understanding capabilities of the first lightweight language model to perform semantic judgment on the parsed text blocks, identifying and filtering semantic noise such as headers, footers, tables of contents, disclaimers, and garbled characters.
[0063] The small model decision-making segmentation and annotation module connects the document parsing and cleaning modules and is equipped with a first lightweight language model. This module uses the first lightweight language model in conjunction with document structure information (such as chapter titles) to perform semantic integrity segmentation; at the same time, it uses the first lightweight language model to automatically annotate each segmented knowledge block with multi-dimensional metadata, generating multi-dimensional metadata including summary, topic tags, entity list, content type, and business domain.
[0064] Vectorization and Storage Module: Connects to the segmentation and annotation modules and is configured with a semantic embedding model (such as Qwen3-Embedding). This module is used to vectorize knowledge block text and bind the vectors, original text, and multi-dimensional metadata to a local vector database.
[0065] Online retrieval and generation unit: Used to respond to user queries and generate answers.
[0066] Intent Recognition and Routing Module: Configured with a second lightweight language model or lightweight classification model. This module receives user questions, uses the model to identify the intent category of the question and its target business domain (such as water conservancy, equipment, legal affairs), and determines the target sub-knowledge base to be retrieved based on the target business domain.
[0067] Multi-domain retrieval and fusion module: Connects the vector database and the intent recognition and routing module. This module is used to perform vector retrieval and keyword matching retrieval (BM25) in parallel within the target sub-knowledge base, and to deduplicate and fuse the initially recalled candidate fragments.
[0068] The re-ranking module connects the multi-domain retrieval and fusion modules and is configured with a re-ranking model (such as BGE-Reranker or Cross-Encoder). This module is used to perform deep relevance scoring on the fused candidate fragments and select the Top-K target knowledge fragments.
[0069] Generation and Source Tracing Module: This module is configured with a local large language model (such as Qwen3-32B). It is used to concatenate target knowledge fragments into a contextual input to the local large model, generate answers, and generate corresponding source tracing information (document title, page number, path) based on multidimensional metadata, which is then displayed in the user interface.
[0070] This invention differs from existing technologies that rely on simple rule-based cleaning or general processing. Instead, it utilizes a lightweight language model (SLM) to autonomously decide on data cleaning strategies (identifying complex semantic noise), structured segmentation strategies (based on semantic boundaries), and automatic annotation of multi-dimensional metadata (generating summaries, topics, entities, and domains) offline. This "small model decision-making" data governance model significantly improves the quality and retrieval value of the data entering the database, and is the core innovation of this invention.
[0071] This invention presents a multi-domain routing retrieval mechanism based on a MoE-like architecture using multidimensional metadata. Unlike existing technologies that rely on model routing based on "question difficulty" (CN119740554A) or tag filtering based on "SQL rules" (CN120780916A), this invention proposes physical or logical domain-based retrieval based on "business domain / topic." Utilizing automatically labeled business domains, topics, and content types from small models as routing criteria, queries are precisely routed to the corresponding expert sub-knowledge base. This mechanism effectively solves the cross-domain noise problem and significantly improves the retrieval accuracy for enterprises across multiple business scenarios.
[0072] This invention not only utilizes multidimensional metadata (summaries, entities, domains, etc.) for retrieval filtering, but also applies it to intelligent decision-making (segmentation boundary judgment) during the offline construction phase and to traceability display during the online generation phase. Metadata is no longer static tags, but rather a core index that runs through the entire chain of data governance, retrieval routing, and generation traceability, forming a structured knowledge representation network.
[0073] This invention employs a hierarchical collaborative architecture where a small model handles intelligent decision-making, while a large model handles content generation. Low-cost small models handle cost-sensitive but highly intelligent tasks such as cleaning, segmentation, annotation, intent recognition, and routing; the large local model is used only in the final generation stage. This architecture significantly reduces the hardware computing power requirements while maintaining the system's intelligence level, making it more suitable for local deployment.
[0074] This invention employs a hybrid retrieval mechanism of "vector retrieval + keyword retrieval" within the target sub-knowledge base, combined with a re-ranking model for fine-grained ranking. Compared to simple vector retrieval or SQL filtering, this mechanism takes into account both semantic relevance and precise matching, further ensuring the quality and relevance of the retrieved results.
[0075] As a preferred embodiment, based on the above preferred embodiment, the following technical features may also be adopted: In addition to using small models for cleaning decisions, a hybrid approach of "rule-based pre-cleaning + small model fine-tuning" can be adopted. That is, first use regular expressions or dictionaries to filter out obvious noise (such as pure numeric page numbers), and then use small models to process complex semantic noise.
[0076] The small model can be replaced with other text classification models or deep learning models that have sequence labeling capabilities, as long as they can determine whether a text block is noise.
[0077] Alternatives to the segmentation strategy: In scenarios lacking document structure information (such as headings), a segmentation scheme based on "semantic similarity" can be adopted. This involves using an embedding model to calculate the vector similarity between adjacent sentences or paragraphs, and segmenting the document when the similarity is below a threshold.
[0078] You can combine "semantic segmentation" and "fixed-length segmentation" to first divide the data into large blocks according to semantics, and then truncate the excessively long blocks to a fixed length to ensure data consistency.
[0079] Alternatives to metadata dimensions: The dimensions of metadata can be added or removed according to business needs. For example, labels such as "applicable scenarios", "risk level", and "priority" can be added.
[0080] Metadata extraction methods can be replaced by using Named Entity Recognition (NER) models to extract entities or using text classification models to identify content types, instead of necessarily using generative small models.
[0081] Alternatives to routing mechanisms: The routing logic can employ either "soft routing" or "probabilistic routing." That is, instead of routing to a single target sub-base, it routes in parallel to multiple related sub-knowledge bases (such as "water conservancy" and "equipment") based on relevance scores, and then performs weighted fusion of the results.
[0082] Routing can be based on additional information such as "user profile" and "access control". For example, if different users can only access specific sub-databases, permissions will be checked first during routing.
[0083] Alternatives to retrieval and sorting: The re-ranking model can use a rule-based scoring formula that combines vector similarity scores, keyword matching scores (BM25), and metadata weight scores (such as document authority) for weighted calculation.
[0084] Hybrid retrieval can add a "knowledge graph retrieval" path, which converts queries into graph database query statements to query entity relationships in the graph database, and then converts them into text for fusion.
[0085] Alternatives to system deployment: The system can be deployed on a single machine, a multi-machine cluster, or a containerized environment. Modules can communicate with each other through local function calls, inter-process communication, or microservice interfaces.
[0086] Vector databases can be replaced with Elasticsearch, Milvus, or FaISS; large language models can be replaced with other open-source or closed-source models.
[0087] An electronic device is characterized by comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the aforementioned knowledge base construction and multi-domain retrieval method based on small model decision-making.
[0088] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned knowledge base construction and multi-domain retrieval method based on small model decision-making.
[0089] The above description is only a preferred embodiment of the present invention. It should be noted that, for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A knowledge base construction and multi-domain retrieval method based on small model decision-making, characterized in that, It includes an offline construction phase and an online retrieval phase; among which: The offline build phase includes: S1. Obtain the original document, parse and extract the text content, page numbers and document structure information; S2. Use the first lightweight language model to perform semantic judgment on the parsed text blocks, identify and filter semantic noise, and retain valid content. S3. Based on document structure information and the first lightweight language model, perform semantic integrity segmentation on effective content to obtain knowledge blocks; S4. Use the first lightweight language model to automatically annotate each knowledge block with multidimensional metadata. The multidimensional metadata includes at least text summary, topic tags, entity list, content type and business domain. S5. Vectorize the knowledge block text and bind and store the semantic vector, original text and multidimensional metadata to the local vector database. The online search phase includes: S6. Receive user queries and use the second lightweight language model to identify the intent category and target business area of the query. S7. Based on the target business domain, determine the corresponding target sub-knowledge base in the local vector database, and perform a hybrid search within the target sub-knowledge base to obtain a set of candidate knowledge fragments; S8. Use the reordering model to score and filter the candidate knowledge fragment set for relevance, and obtain the target knowledge fragment. S9. Input the target knowledge fragment into the local large language model to generate the answer, and generate traceability information based on multidimensional metadata.
2. The knowledge base construction and multi-domain retrieval method based on small model decision-making according to claim 1, characterized in that, In S2, the first lightweight language model uses preset cleaning prompts to determine whether a text block belongs to at least one of the following: header, footer, table of contents, disclaimer, or garbled text.
3. The knowledge base construction and multi-domain retrieval method based on small model decision-making according to claim 1, characterized in that, In S3, the semantic integrity segmentation includes: prioritizing segmentation at chapter boundaries; for chapters exceeding a preset length threshold, using a first lightweight language model to calculate semantic coherence between paragraphs, and segmenting at positions where semantic coherence is below a preset threshold.
4. The knowledge base construction and multi-domain retrieval method based on small model decision-making according to claim 1, characterized in that, In S4, the multidimensional metadata also includes document title and file path, which are used to provide a basis for tracing when generating answers.
5. The knowledge base construction and multi-domain retrieval method based on small model decision-making according to claim 1, characterized in that, In S7, the hybrid retrieval includes parallel vector retrieval and keyword retrieval; the vector retrieval uses cosine similarity calculation, and the keyword retrieval uses the BM25 algorithm; the retrieval results are fused using a reciprocal sorting fusion algorithm.
6. The knowledge base construction and multi-domain retrieval method based on small model decision-making according to claim 1, characterized in that, In S9, the source information includes the document title, page number, and file path; the answer generated by the local large language model contains a reference identifier associated with the source information.
7. A knowledge base construction and multi-domain retrieval system based on small model decision-making, characterized in that, include: An offline data intelligent construction unit is used to perform the steps of the offline construction phase as described in any one of claims 1 to 6; An online retrieval and generation unit is used to perform the steps of the online retrieval stage as described in any one of claims 1 to 6.
8. The knowledge base construction and multi-domain retrieval system based on small model decision-making according to claim 7, characterized in that: The offline data intelligent construction unit includes: The document parsing module is used to parse the original document; The small model decision cleaning module is equipped with the first lightweight language model to filter semantic noise; The segmentation and annotation module for small model decision-making is configured with the first lightweight language model for semantic integrity segmentation and multidimensional metadata annotation. The vectorization and storage module is used for vectorization encoding and writing to the local vector database; The online retrieval and generation unit includes: The intent recognition and routing module is configured with the second lightweight language model for recognizing intents and target business domains; The multi-domain retrieval and fusion module is used to perform hybrid retrieval within the scope of the target sub-knowledge base; The reordering module is configured with the reordering model for scoring and filtering candidate segments. The generation and tracing module is configured with the local large language model to generate answers and tracing information.
9. An electronic device, characterized in that, include: At least one processor; The at least one processor is also connected in communication with a memory, wherein the memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the knowledge base construction and multi-domain retrieval method based on small model decision-making as described in any one of claims 1-6.
10. A computer-readable storage medium storing a computer program, characterized in that, When executed by a processor, the program implements the knowledge base construction and multi-domain retrieval method based on small model decision-making as described in any one of claims 1-6.
Citation Information
Patent Citations
Decision-making method based on collaborative optimization of big and small language models, computer system and computer readable storage medium
CN119740554A
Resource recommendation method and system based on hybrid retrieval RAG
CN120780916A
Knowledge base enhancement generation method and system based on hybrid retrieval and fact verification
CN120874999A
