A domain knowledge enhanced large model fine-tuning method, system, device and storage medium

CN123014206APending Publication Date: 2026-10-30HARBIN INST OF TECH +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611336467.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-31
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0007]本发明的目的是解决针对现有领域大模型微调中存在的领域文档切分破坏语义完整性、自动生成指令数据复杂度不足、合成数据质量不可控以及全量微调成本高的问题,提出一种领域知识增强的大模型微调方法

Benefits of technology

[0105]第一,本申请通过基于嵌入模型的动态语义切分方式替代传统固定长度切分方式,能够根据句间或段间语义连续性自适应确定切分边界,从而避免专业实体被截断、业务规则被割裂和逻辑链条不完整的问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123014206A_ABST
    Figure CN123014206A_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of artificial intelligence, and particularly relates to a domain knowledge enhanced large model fine-tuning method, system, device and storage medium. The application aims to solve the problems of semantic integrity damage caused by domain document segmentation, insufficient complexity of automatically generated instruction data, uncontrollable quality of synthetic data and high cost of full-scale fine-tuning in the existing domain large model fine-tuning, and proposes a domain knowledge enhanced large model fine-tuning method. The dynamic semantic segmentation method based on the embedding model is used to replace the traditional fixed length segmentation method, which can adaptively determine the segmentation boundary according to the semantic continuity between sentences or paragraphs, thereby avoiding the problems of professional entities being truncated, business rules being fragmented and logic chains being incomplete. The parameter efficient fine-tuning method is used for domain adaptation of the base large language model, which reduces the memory occupation and training cost under the condition of limited computing power, so that the domain knowledge injection process is more suitable for actual engineering deployment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of artificial intelligence technology, specifically relating to a method, system, device, and storage medium for fine-tuning large models with domain knowledge enhancement. Background Technology

[0002] In recent years, large language models have made significant progress in tasks such as natural language understanding, text generation, code generation, and complex reasoning, and have been widely applied in scenarios such as intelligent question answering, text summarization, assisted writing, knowledge retrieval, and business decision-making. However, when general-purpose large language models are directly applied to knowledge-intensive vertical fields such as finance, law, healthcare, and engineering, problems still exist, including insufficient coverage of professional knowledge, unstable terminology understanding, incomplete reasoning chains, factual illusions, and response styles that do not conform to domain norms.

[0003] Existing domain knowledge augmentation methods mainly fall into two categories: one is retrieval-enhanced generation methods, which retrieve relevant document fragments from external knowledge bases during the inference phase and concatenate them into the model's context to guide the model in generating responses; the other is fine-tuning methods, which train the model using domain data, enabling the model to internalize professional knowledge and domain task patterns in the parameter space. Retrieval-enhanced generation methods offer advantages such as flexible knowledge updates and traceable results, but their effectiveness depends on retrieval quality, document segmentation strategies, and context integration capabilities. When retrieval results contain noise, incomplete recall, or excessively long contexts, the model may still fail to accurately utilize external information. Fine-tuning methods are advantageous in high-frequency, stable, and low-latency application scenarios, but their core bottleneck lies in the scarcity of high-quality domain training data.

[0004] Knowledge within a vertical domain typically resides in unstructured or semi-structured documents such as PDFs, Word reports, HTML web pages, industry manuals, legal provisions, financial announcements, business rules documents, and technical specifications. These documents are complex in format, dense in terminology, and have long logical chains, often containing multi-level headings, tables, lists, headers and footers, footnotes, and page breaks. Directly processing these domain documents using fixed-length segmentation methods can easily lead to entity truncation, paragraph fragmentation, and disruption of professional logic, thereby affecting the factual integrity of subsequent synthesized instruction data.

[0005] Furthermore, existing automated instruction data generation methods typically generate question-and-answer samples based on single text fragments, tending to focus on shallow tasks such as fact extraction and concept interpretation, and failing to cover complex tasks common in vertical domains, such as comparative analysis, conditional judgment, causal reasoning, and comprehensive decision-making. At the same time, automatically generated synthetic data inevitably contains problems such as formatting errors, duplicate samples, insufficient factual basis, low-quality answers, and incomplete reasoning. Directly using these low-quality samples for model fine-tuning may lead to the injection of false knowledge, illusion enhancement, or a decrease in generalizability.

[0006] Therefore, there is an urgent need for a method that can automatically construct semantically complete knowledge units from heterogeneous domain documents, generate highly complex and reliable synthetic instruction data, and then complete domain model adaptation in an efficient manner through parameters. Summary of the Invention

[0007] The purpose of this invention is to address the problems existing in fine-tuning of large domain models, such as domain document segmentation disrupting semantic integrity, insufficient complexity of automatically generated instruction data, uncontrollable quality of synthesized data, and high cost of full-scale fine-tuning. This invention proposes a domain knowledge-enhanced large-scale model fine-tuning method. Specifically, it includes:

[0008] Step 1: Parse the original domain document set to obtain parsed documents; clean the parsed documents to obtain normalized domain text;

[0009] Receive the original domain document collection for the domain to be adapted, including vertical domains such as law, finance, medicine, and engineering;

[0010] The original domain document collection includes PDF documents, Word documents, HTML documents, industry manuals, legal provisions, financial announcements, business reports, or structured text data;

[0011] Furthermore, step 1, which involves parsing and cleaning the original domain document set to obtain normalized domain text, includes heterogeneous document parsing, format normalization, structure preservation, and noise filtering.

[0012] Heterogeneous document parsing is handled by the parsing module, while format normalization, structure preservation, and noise filtering are handled by the cleaning module.

[0013] The specific process of parsing heterogeneous documents is as follows:

[0014] For PDF documents, the parsing module extracts the main text, headings, page ranges, and table content. For digitized PDFs from which text can be directly extracted, the parsing and cleaning module identifies the main text and headings based on text block location, font size, heading numbering, and paragraph structure. For table content, the parsing and cleaning module converts the tables into Markdown tables or key-value pair formats. The resulting parsed PDF document is then obtained.

[0015] For Word documents, the parsing module reads paragraph, heading, table, and list numbering and style information, and retains the heading and list levels. The parsed Word document is then obtained.

[0016] For HTML documents, the parsing module parses the DOM tree, extracts body paragraphs, heading tags, list tags, and table tags, and filters out irrelevant content such as navigation bars, advertisements, scripts, and footers. The result is the parsed HTML document.

[0017] After parsing the original domain document collection, the cleaning module performs the following cleaning operations in sequence:

[0018] First cleaning process: Format standardization, used to merge redundant whitespace characters in the parsed document, fix abnormal line breaks within sentences, unify the format of Chinese and English punctuation, and delete invalid control characters; resulting in the document after the first cleaning process.

[0019] Second cleaning process: Structure preservation, used to retain chapter titles, multilevel numbering, list hierarchy, table fields and chart descriptions in the document after the first cleaning process; resulting in the document after the second cleaning process.

[0020] The third cleaning process involves noise filtering to remove headers and footers, isolated page numbers, table of contents fragments, copyright notices, garbled text snippets, and decorative symbols from the document after the second cleaning process. This yields normalized domain text.

[0021] After this step, the original heterogeneous domain documents are converted into normalized domain text, providing a foundation for subsequent dynamic semantic segmentation;

[0022] Step 2: Perform dynamic semantic segmentation on the standardized domain text to obtain N structured knowledge blocks; N is a positive integer;

[0023] Step 3: Generate a candidate synthesis instruction dataset based on N structured knowledge blocks;

[0024] Step 4: Perform multi-stage quality control on the candidate synthetic instruction dataset to obtain a high-quality domain instruction dataset;

[0025] Step 5: Based on the high-quality domain instruction dataset, perform efficient parameter fine-tuning on the base large language model to obtain a domain knowledge-enhanced large language model.

[0026] The base language model is one of the following: Qwen series, DeepSeek series, Llama series, Mistral series, or GPT series models;

[0027] The fields to be adapted can be finance, law, healthcare, engineering, or other knowledge-intensive vertical fields;

[0028] In step 2, the standardized domain text is dynamically semantically segmented to obtain N structured knowledge blocks. The specific process is as follows:

[0029] Step 2.1: Divide the normalized domain text into I basic text units; I is a positive integer;

[0030] The basic text unit can be a sentence, a paragraph, or the smallest semantic unit composed of multiple short sentences.

[0031] Step 2.2: Convert each basic text unit into a semantic vector using a text embedding model, and calculate the semantic similarity between adjacent basic text units. The specific process is as follows:

[0032] For the i-th basic text unit The semantic vector is obtained using an embedding model:

[0033]

[0034] For adjacent basic text units and Calculate semantic similarity:

[0035]

[0036] Here, cos(·) represents the cosine similarity.

[0037] Step 2.3: Determine the segmentation boundaries of structured knowledge blocks based on the semantic similarity between adjacent basic text units; the specific process is as follows:

[0038] When the semantic similarity between adjacent basic text units is lower than a preset threshold, or when a local semantic similarity trough occurs, and the current text length meets the preset length constraint, the position is determined as the segmentation boundary.

[0039] Candidate segmentation boundaries are determined based on semantic similarity. Below the preset threshold, or When a local trough occurs and the length of the current text block is greater than the minimum length threshold, the system determines the position between the i-th basic text unit and the (i+1)-th basic text unit as the candidate segmentation boundary.

[0040] Meanwhile, the embedding module corrects the candidate segmentation boundaries using the following four rules:

[0041] When the current position is the title switching position, increase its priority as a dividing boundary;

[0042] When the current position is inside a table or list, its priority as a dividing boundary is reduced;

[0043] When the length of the current text block exceeds the maximum length threshold, force a split at the nearest candidate split boundary;

[0044] When the length of a segmented text block is lower than the minimum length threshold, it is merged with an adjacent text block.

[0045] Step 2.4: Based on the segmentation boundaries of the structured knowledge blocks, the normalized domain text is segmented into N structured knowledge blocks;

[0046] Furthermore, the structured knowledge block includes at least: a unique knowledge block number, a source document number, a title path, cleaned text content, a source page range, content type, and additional structural information.

[0047] The content types include text, tables, lists, or charts.

[0048] The resulting structured knowledge blocks maintain thematic consistency and professional logical integrity as much as possible. Finally, the system outputs structured knowledge blocks. Each structured knowledge block includes the fields `chunk_id`, `doc_id`, `title_path`, `content`, `page_range`, `element_type`, and `metadata`. This dynamic semantic segmentation method can control the length of text blocks while maintaining the integrity of domain knowledge units as much as possible.

[0049] In step 3, a candidate synthesis instruction dataset is generated based on N structured knowledge blocks. The specific process is as follows:

[0050] Step 3.1: Generate instructions based on N structured knowledge blocks and the teacher's large model to obtain a basic instruction sample set;

[0051] Step 3.2: Based on the basic instruction sample set and the teacher's large model, perform instruction evolution to obtain the evolved instruction sample set;

[0052] Step 3.3: Based on the semantic relevance between the structured knowledge blocks and the teacher big model, construct a cross-knowledge block joint reasoning sample set;

[0053] Step 3.4: Use the basic instruction samples, evolutionary instruction samples, and cross-knowledge block joint reasoning samples as candidate synthetic instruction datasets.

[0054] The teacher's large model can be one of the Qwen series, DeepSeek series, GPT series, or other large language models with instruction generation capabilities;

[0055] In step 4, multi-stage quality control is performed on the candidate synthetic instruction dataset to obtain a high-quality domain instruction dataset; the specific process is as follows:

[0056] Step 4.1: Perform the first filtering on the candidate synthesis instruction dataset based on the first filtering rule to obtain the candidate synthesis instruction dataset after the first filtering;

[0057] The first filtering rule is heuristic filtering. The system checks whether each candidate synthesis instruction contains complete fields, whether the question and answer lengths are within a reasonable range, whether the answer is empty, and whether it contains obvious template residue, garbled characters, meaningless repetitions, or content unrelated to the knowledge block. Samples that do not meet the rules are directly rejected by the system.

[0058] Step 4.2: Perform a second filtering on the candidate synthetic instruction dataset after the first filtering based on the second filtering rule to obtain the candidate synthetic instruction dataset after the second filtering;

[0059] The second filtering rule is for duplicate sample filtering. The system calculates the text overlap and semantic similarity between samples. Text overlap can be expressed as n-gram overlap rate, Jaccard similarity, or edit distance; semantic similarity can be calculated using an embedding model. When the text overlap or semantic similarity between two samples exceeds a preset threshold, the system determines them as duplicate samples and retains the sample with the higher quality score or more complex task type.

[0060] Step 4.3: Perform a third filtering on the candidate synthetic instruction dataset after the second filtering based on the third filtering rule to obtain a high-quality domain instruction dataset;

[0061] The third filtering rule is the large-scale model's scoring. The system inputs candidate samples and their source knowledge blocks into the large-scale model, which scores them based on four dimensions: factual accuracy, question-answer relevance, cognitive complexity, and answer completeness. The overall quality score is expressed as:

[0062]

[0063] in, The score represents the accuracy of the facts. This represents the question-answer relevance score. Represents the cognitive complexity score. The answer completeness score is represented by α, β, γ, and δ, which are the corresponding weights. When the overall quality score of a sample is lower than a preset overall threshold, or any individual score is lower than a preset individual threshold, the system removes the sample. After multi-stage filtering, a high-quality domain instruction dataset is obtained.

[0064] The large-scale model for the judges can be one of the Qwen series, DeepSeek series, GPT series, or other large-scale language models with instruction generation capabilities.

[0065] In step 5, based on the high-quality domain instruction dataset, the parameters of the base large language model are efficiently fine-tuned to obtain a domain knowledge-enhanced large language model. The specific process is as follows:

[0066] Based on the aforementioned high-quality domain instruction dataset, the QLoRA parameter efficient fine-tuning method is used to adapt the base large language model to the domain, resulting in a domain-enhanced large language model. Specifically, the QLoRA parameter efficient fine-tuning method is used to adapt the base large language model to the domain. The specific process is as follows:

[0067] Step 5.1: Perform 4-bit quantization on the base large language model to reduce the model's memory usage.

[0068] Step 5.2: Freeze the original parameters of the base large language model and insert low-rank adaptation matrices into the attention layer and / or feedforward network layer of the base large language model. For the original weight matrix W, the weights after low-rank adaptation are expressed as:

[0069]

[0070] in:

[0071]

[0072] A and B are trainable low-rank matrices, and the rank of the low-rank matrix is ​​less than the dimension of the original weight matrix.

[0073] During training, the training module only updates the parameters of the low-rank adaptation matrix, without updating the original parameters of the base large language model. The training objective uses an autoregressive language modeling loss.

[0074]

[0075] in, Let x represent the t-th target token and x represent the input text. This represents the probability that the model predicts the target token given the input and the preceding tokens. The loss mask represents the number of tokens involved in training. This loss mask is used to mask the prompt words, calculating the loss only for the answer or the target output that needs to be learned. After training, the system obtains a domain-knowledge-enhanced large language model or a domain adapter that can be loaded onto a base large language model.

[0076] A domain knowledge-enhanced large model fine-tuning system, characterized in that it includes:

[0077] The parsing module is used to parse the original domain document collection to obtain the parsed documents;

[0078] The cleaning module is used to clean the parsed documents to obtain normalized domain text;

[0079] An embedding module is used to dynamically semantically segment the standardized domain text to obtain N structured knowledge blocks;

[0080] The teacher big model module is used to construct a candidate synthetic instruction dataset based on N structured knowledge blocks generated by the embedded module;

[0081] The multi-stage data quality control module is used to perform multi-stage filtering on candidate synthetic instruction datasets to obtain high-quality domain instruction datasets.

[0082] The training module is used to efficiently fine-tune the parameters of the base large language model based on a high-quality domain instruction dataset, resulting in a domain knowledge-enhanced large language model.

[0083] A medical information analysis method, comprising:

[0084] Identify the medical information to be analyzed;

[0085] The medical information is input into the target large model to generate medical feedback information;

[0086] The target large model is a large model that has been fine-tuned using a domain knowledge-enhanced large model fine-tuning method.

[0087] An engineering information analysis method, comprising:

[0088] Determine the engineering information to be analyzed;

[0089] The engineering information is input into the target large model to generate engineering feedback information;

[0090] The target large model is a large model that has been fine-tuned using a domain knowledge-enhanced large model fine-tuning method.

[0091] A financial information analysis method, comprising:

[0092] Identify the financial information to be analyzed;

[0093] The financial information is input into the target large model to generate financial feedback information;

[0094] The target large model is a large model that has been fine-tuned using a domain knowledge-enhanced large model fine-tuning method.

[0095] Taking the financial sector as an example, the system first receives documents such as financial policy documents, credit approval rules, corporate financial reports, financial announcements, and risk control manuals. The system parses, cleans, and dynamically segments these documents semantically to obtain multiple structured knowledge blocks. Subsequently, the system generates basic question-answering samples, evolutionary question-answering samples, and cross-knowledge-block joint reasoning samples based on these knowledge blocks. For example, the system can generate a comprehensive analysis sample to determine whether a loan application should be approved based on a company's cash flow, industry risk, and credit policy.

[0096] After multi-stage quality control, the system obtains a high-quality dataset of financial instructions. Finally, based on this dataset, the system performs QLoRA fine-tuning on base models such as Qwen, DeepSeek, or Llama, enabling the models to more accurately understand financial terminology, business rules, and risk assessment logic.

[0097] A legal information analysis method, comprising:

[0098] Identify the legal information to be analyzed;

[0099] The legal information is input into the target large model to generate legal feedback information;

[0100] The target large model is a large model that has been fine-tuned using a domain knowledge-enhanced large model fine-tuning method.

[0101] Taking the legal field as an example, the system can receive documents such as legal provisions, judicial interpretations, case facts, and judgments, and generate sample instructions for legal application, liability determination, clause interpretation, and case comparison. After fine-tuning, the model can better perform tasks such as legal Q&A, clause interpretation, and case analysis.

[0102] A computer storage medium storing at least one instruction, the at least one instruction being loaded and executed by a processor, as described in the method for fine-tuning a large model with enhanced domain knowledge.

[0103] A large model fine-tuning device based on domain knowledge enhancement, the device comprising a processor and a memory, the memory storing at least one instruction, the at least one instruction being loaded and executed by the processor to implement a large model fine-tuning method based on domain knowledge enhancement.

[0104] The beneficial effects of this invention are as follows:

[0105] First, this application replaces the traditional fixed-length segmentation method with a dynamic semantic segmentation method based on an embedding model. This method can adaptively determine the segmentation boundary based on the semantic continuity between sentences or paragraphs, thereby avoiding the problems of professional entities being truncated, business rules being fragmented, and logical chains being incomplete.

[0106] Second, this application uses a hybrid instruction generation method that combines basic instruction generation, instruction evolution, and cross-knowledge block joint reasoning. This method can generate not only fact extraction and concept explanation samples, but also comparative analysis, conditional judgment, causal reasoning, and comprehensive decision-making samples, thereby improving the cognitive complexity and task coverage of the synthesized instruction data.

[0107] Third, this application employs a multi-stage quality control pipeline consisting of heuristic rule filtering, duplicate sample filtering, and large model judge scoring. This pipeline can gradually eliminate low-quality samples with format errors, duplication, insufficient factual basis, and incomplete logic, thereby improving the reliability, diversity, and usability of the final training data.

[0108] Fourth, this application adopts a parameter-efficient fine-tuning method to adapt the base large language model to the domain, reducing memory usage and training costs under limited computing power, making the domain knowledge injection process more suitable for actual engineering deployment.

[0109] Fifth, this application integrates domain document processing, synthesis instruction generation, data quality control, and efficient parameter fine-tuning into a unified process, which can provide a low-cost, high-efficiency, and transferable professional adaptation solution for large language models in knowledge-intensive fields such as finance, law, medicine, and engineering. Attached Figure Description

[0110] Figure 1 A schematic diagram illustrating the overall process of fine-tuning instructions and injecting domain knowledge in this application;

[0111] Figure 2 This is a schematic diagram illustrating the efficient fine-tuning of parameters in this application;

[0112] Figure 3 This is a comparative diagram of the dynamic semantic segmentation effect of this application;

[0113] Figure 4 This is a schematic diagram of the instruction evolution prompt template based on reflection in this application;

[0114] Figure 5 This is a schematic diagram of the cross-knowledge block joint reasoning synthesis prompt template for this application;

[0115] Figure 6 A comparison chart of data quality generated by different instruction generation strategies in this application;

[0116] Figure 7 This is a comparison chart of experimental results for model fine-tuning in this application field;

[0117] Figure 8 This is an ablation result diagram of the teacher model source and quality control module in this application. Detailed Implementation

[0118] Specific Implementation Method 1: A method for fine-tuning a large model with domain knowledge enhancement, including:

[0119] Step 1: Parse the original domain document set to obtain parsed documents; clean the parsed documents to obtain normalized domain text;

[0120] Receive the original domain document collection for the domain to be adapted, including vertical domains such as law, finance, medicine, and engineering;

[0121] The original domain document collection includes PDF documents, Word documents, HTML documents, industry manuals, legal provisions, financial announcements, business reports, or structured text data;

[0122] Furthermore, step 1, which involves parsing and cleaning the original domain document set to obtain normalized domain text, includes heterogeneous document parsing, format normalization, structure preservation, and noise filtering.

[0123] Heterogeneous document parsing is handled by the parsing module, while format normalization, structure preservation, and noise filtering are handled by the cleaning module.

[0124] The specific process of parsing heterogeneous documents is as follows:

[0125] For PDF documents, the parsing module extracts the main text, headings, page ranges, and table content. For digitized PDFs from which text can be directly extracted, the parsing and cleaning module identifies the main text and headings based on text block location, font size, heading numbering, and paragraph structure. For table content, the parsing and cleaning module converts the tables into Markdown tables or key-value pair formats. The resulting parsed PDF document is then obtained.

[0126] For Word documents, the parsing module reads paragraph, heading, table, and list numbering and style information, and retains the heading and list levels. The parsed Word document is then obtained.

[0127] For HTML documents, the parsing module parses the DOM tree, extracts body paragraphs, heading tags, list tags, and table tags, and filters out irrelevant content such as navigation bars, advertisements, scripts, and footers. The result is the parsed HTML document.

[0128] After parsing the original domain document collection, the cleaning module performs the following cleaning operations in sequence:

[0129] First cleaning process: Format standardization, used to merge redundant whitespace characters in the parsed document, fix abnormal line breaks within sentences, unify the format of Chinese and English punctuation, and delete invalid control characters; resulting in the document after the first cleaning process.

[0130] Second cleaning process: Structure preservation, used to retain chapter titles, multilevel numbering, list hierarchy, table fields and chart descriptions in the document after the first cleaning process; resulting in the document after the second cleaning process.

[0131] The third cleaning process involves noise filtering to remove headers and footers, isolated page numbers, table of contents fragments, copyright notices, garbled text snippets, and decorative symbols from the document after the second cleaning process. This yields normalized domain text.

[0132] After this step, the original heterogeneous domain documents are converted into normalized domain text, providing a foundation for subsequent dynamic semantic segmentation;

[0133] Step 2: Perform dynamic semantic segmentation on the standardized domain text to obtain N structured knowledge blocks; N is a positive integer;

[0134] Step 3: Generate a candidate synthesis instruction dataset based on N structured knowledge blocks;

[0135] Step 4: Perform multi-stage quality control on the candidate synthetic instruction dataset to obtain a high-quality domain instruction dataset;

[0136] Step 5: Based on the high-quality domain instruction dataset, perform efficient parameter fine-tuning on the base large language model to obtain a domain knowledge-enhanced large language model.

[0137] The base language model is one of the following: Qwen series, DeepSeek series, Llama series, Mistral series, or GPT series models;

[0138] The target application areas can be finance, law, healthcare, engineering, or other knowledge-intensive vertical fields.

[0139] Specific Implementation Method Two: The difference between this implementation method and Specific Implementation Method One is that:

[0140] In step 2, the standardized domain text is dynamically semantically segmented to obtain N structured knowledge blocks. The specific process is as follows:

[0141] Step 2.1: Divide the normalized domain text into I basic text units; I is a positive integer;

[0142] The basic text unit can be a sentence, a paragraph, or the smallest semantic unit composed of multiple short sentences.

[0143] Step 2.2: Convert each basic text unit into a semantic vector using a text embedding model, and calculate the semantic similarity between adjacent basic text units. The specific process is as follows:

[0144] For the i-th basic text unit The semantic vector is obtained using an embedding model:

[0145]

[0146] For adjacent basic text units and Calculate semantic similarity:

[0147]

[0148] Here, cos(·) represents the cosine similarity.

[0149] Step 2.3: Determine the segmentation boundaries of structured knowledge blocks based on the semantic similarity between adjacent basic text units; the specific process is as follows:

[0150] When the semantic similarity between adjacent basic text units is lower than a preset threshold, or when a local semantic similarity trough occurs, and the current text length meets the preset length constraint, the position is determined as the segmentation boundary.

[0151] Candidate segmentation boundaries are determined based on semantic similarity. Below the preset threshold, or When a local trough occurs and the length of the current text block is greater than the minimum length threshold, the system determines the position between the i-th basic text unit and the (i+1)-th basic text unit as the candidate segmentation boundary.

[0152] Meanwhile, the embedding module corrects the candidate segmentation boundaries using the following four rules:

[0153] When the current position is the title switching position, increase its priority as a dividing boundary;

[0154] When the current position is inside a table or list, its priority as a dividing boundary is reduced;

[0155] When the length of the current text block exceeds the maximum length threshold, force a split at the nearest candidate split boundary;

[0156] When the length of a segmented text block is lower than the minimum length threshold, it is merged with an adjacent text block.

[0157] Step 2.4: Based on the segmentation boundaries of the structured knowledge blocks, the normalized domain text is segmented into N structured knowledge blocks;

[0158] Furthermore, the structured knowledge block includes at least: a unique knowledge block number, a source document number, a title path, cleaned text content, a source page range, content type, and additional structural information.

[0159] The content types include text, tables, lists, or charts.

[0160] The resulting structured knowledge blocks maintain thematic consistency and professional logical integrity as much as possible. Finally, the system outputs structured knowledge blocks. Each structured knowledge block includes the fields `chunk_id`, `doc_id`, `title_path`, `content`, `page_range`, `element_type`, and `metadata`. This dynamic semantic segmentation method can control the length of text blocks while maintaining the integrity of domain knowledge units as much as possible.

[0161] In step 3, a candidate synthesis instruction dataset is generated based on N structured knowledge blocks. The specific process is as follows:

[0162] Step 3.1: Generate instructions based on N structured knowledge blocks and the teacher's large model to obtain a basic instruction sample set;

[0163] Step 3.2: Based on the basic instruction sample set and the teacher's large model, perform instruction evolution to obtain the evolved instruction sample set;

[0164] Step 3.3: Based on the semantic relevance between the structured knowledge blocks and the teacher big model, construct a cross-knowledge block joint reasoning sample set;

[0165] Step 3.4: Use the basic instruction samples, evolutionary instruction samples, and cross-knowledge block joint reasoning samples as candidate synthetic instruction datasets;

[0166] The teacher's large model can be one of the Qwen series, DeepSeek series, GPT series, or other large language models with instruction generation capabilities;

[0167] In step 4, multi-stage quality control is performed on the candidate synthetic instruction dataset to obtain a high-quality domain instruction dataset; the specific process is as follows:

[0168] Step 4.1: Perform the first filtering on the candidate synthesis instruction dataset based on the first filtering rule to obtain the candidate synthesis instruction dataset after the first filtering.

[0169] The first filtering rule is heuristic filtering. The system checks whether each candidate synthesis instruction contains complete fields, whether the question and answer lengths are within a reasonable range, whether the answer is empty, and whether it contains obvious template residue, garbled characters, meaningless repetitions, or content unrelated to the knowledge block. Samples that do not meet the rules are directly rejected by the system.

[0170] Step 4.2: Perform a second filtering on the candidate synthetic instruction dataset after the first filtering based on the second filtering rule to obtain the candidate synthetic instruction dataset after the second filtering.

[0171] The second filtering rule is for duplicate sample filtering. The system calculates the text overlap and semantic similarity between samples. Text overlap can be expressed as n-gram overlap rate, Jaccard similarity, or edit distance; semantic similarity can be calculated using an embedding model. When the text overlap or semantic similarity between two samples exceeds a preset threshold, the system determines them as duplicate samples and retains the sample with the higher quality score or more complex task type.

[0172] Step 4.3: Perform a third filtering on the candidate synthetic instruction dataset after the second filtering based on the third filtering rule to obtain a high-quality domain instruction dataset;

[0173] The third stage involves large-scale model judging. The system inputs candidate samples and their source knowledge blocks into the large-scale judging model, which then scores them based on four dimensions: factual accuracy, question-answer relevance, cognitive complexity, and answer completeness. The overall quality score is expressed as:

[0174]

[0175] in, The score represents the accuracy of the facts. This represents the question-answer relevance score. Represents the cognitive complexity score. The answer completeness score is represented by α, β, γ, and δ, which are the corresponding weights. When the overall quality score of a sample is lower than a preset overall threshold, or any individual score is lower than a preset individual threshold, the system removes the sample. After multi-stage filtering, a high-quality domain instruction dataset is obtained.

[0176] The large-scale model for the judges can be one of the Qwen series, DeepSeek series, GPT series, or other large-scale language models with instruction generation capabilities.

[0177] In step 5, based on the high-quality domain instruction dataset, the parameters of the base large language model are efficiently fine-tuned to obtain a domain knowledge-enhanced large language model. The specific process is as follows:

[0178] Based on the aforementioned high-quality domain instruction dataset, the QLoRA parameter efficient fine-tuning method is used to adapt the base large language model to the domain, resulting in a domain-enhanced large language model. Specifically, the QLoRA parameter efficient fine-tuning method is used to adapt the base large language model to the domain. The specific process is as follows:

[0179] Step 5.1: Perform 4-bit quantization on the base large language model to reduce the model's memory usage.

[0180] Step 5.2: Freeze the original parameters of the base large language model and insert low-rank adaptation matrices into the attention layer and / or feedforward network layer of the base large language model. For the original weight matrix W, the weights after low-rank adaptation are expressed as:

[0181]

[0182] in:

[0183]

[0184] A and B are trainable low-rank matrices, and the rank of the low-rank matrix is ​​less than the dimension of the original weight matrix.

[0185] During training, the training module only updates the parameters of the low-rank adaptation matrix, without updating the original parameters of the base large language model. The training objective uses an autoregressive language modeling loss.

[0186]

[0187] in, Let x represent the t-th target token and x represent the input text. This represents the probability that the model predicts the target token given the input and the preceding tokens. The loss mask represents the number of tokens participating in training. This loss mask is used to mask the prompt word portion, calculating the loss only for the answer portion or the target output portion that needs to be learned. After training, the system obtains a domain-knowledge-enhanced large language model or a domain adapter that can be loaded onto a base large language model. Other steps and parameters are the same as in Specific Implementation Method 1.

[0188] Specific Implementation Method Three: The difference between this implementation method and Specific Implementation Methods One and Two is that:

[0189] In step 3.1, instructions are generated based on N structured knowledge blocks and the teacher's large model to obtain a basic instruction sample set. The specific process is as follows:

[0190] Input N structured knowledge blocks into the teacher's big model, and the teacher's big model will generate N basic instruction samples respectively;

[0191] N structured knowledge blocks correspond to N basic instruction samples, which together form a basic instruction sample set;

[0192] Each basic instruction sample includes: instruction field, input field, output field, and evidence field.

[0193] Here, instruction represents the task requirements, input represents optional input information, output represents the standard answer, and evidence represents the knowledge block content or knowledge block number on which the answer is based.

[0194] The task types corresponding to any basic instruction sample in the basic instruction sample set include: fact extraction task, concept explanation task, simple induction task, and rule explanation task.

[0195] In step 3.2, instruction evolution is performed based on the basic instruction sample set and the teacher large model to obtain the evolved instruction sample set; the specific process is as follows:

[0196] Step 3.2.1: Construct the first prompt word requirement text;

[0197] Furthermore, the first prompt word requires the text to be a reflective prompt word;

[0198] Reflective prompts require teachers to add domain constraints, reasoning steps, comparison objects, conditional limitations, or distracting information to the basic model, transforming simple factual problems into complex problems with analytical and reasoning aspects.

[0199] Reflective instruction evolution. This invention re-inputs basic instruction samples into a large teacher model and uses reflective prompts to request the model to enhance the original instructions. Enhancement methods include:

[0200] By adding domain constraints, requiring answers to involve multi-step reasoning, introducing comparison objects, adding conditional restrictions, adding distracting information, and requiring outputs such as approval recommendations, risk assessments, legal application analyses, or engineering decision conclusions, the original simple problem is transformed into a more analytical and reasoning-based complex problem.

[0201] Step 3.2.2: Input the basic instruction sample set and the first prompt word requirement text into the teacher big model, and the teacher big model will generate the evolutionary instruction sample set;

[0202] In step 3.3, a cross-knowledge block joint reasoning sample set is constructed based on the semantic relevance between the structured knowledge blocks and the teacher big model; the specific process is as follows:

[0203] Step 3.3.1: Use a text embedding model to convert N structured knowledge blocks into N knowledge block semantic vectors;

[0204] Step 3.3.2: Calculate the semantic similarity between the semantic vectors of the N knowledge blocks;

[0205] Furthermore, the semantic similarity between the semantic vectors of knowledge blocks is calculated using cosine similarity.

[0206] Step 3.3.3: Based on the semantic similarity between the semantic vectors of N knowledge blocks, determine the associated knowledge blocks for each structured knowledge block; the specific process is as follows: the structured knowledge blocks with semantic similarity higher than the threshold are taken as associated knowledge blocks;

[0207] Step 3.3.4: Input a structured knowledge block and its corresponding related knowledge blocks into the teacher's large model to construct a cross-knowledge block joint reasoning sample.

[0208] When all N structured knowledge blocks are input into the teacher's big model, N cross-knowledge block joint reasoning samples are obtained, which serve as the cross-knowledge block joint reasoning sample set.

[0209] A vector index is constructed based on the semantic vectors of structured knowledge blocks. For the current input structured knowledge block, at least one related knowledge block with semantic relevance is retrieved. Subsequently, the current input structured knowledge block and related knowledge blocks are input together into the teacher's big model, which is then required to generate a question that requires the integration of multiple knowledge blocks to answer.

[0210] Cross-knowledge block joint reasoning samples include task types such as comparative analysis, causal explanation, conditional judgment, comprehensive decision-making, and multi-basis induction.

[0211] For example, in the financial sector, knowledge blocks of enterprise operating data can be combined with knowledge blocks of credit policy rules to generate a comprehensive decision sample that judges whether a loan should be approved based on the enterprise's operating conditions and credit policy.

[0212] In the legal field, legal provisions and case facts can be combined to generate legal analysis samples for determining liability in a case based on the provisions.

[0213] The other steps and parameters are the same as in one of the specific implementation methods one or two.

[0214] Specific Implementation Method Four: A domain knowledge-enhanced large model fine-tuning system, comprising:

[0215] The parsing module is used to parse the original domain document collection to obtain the parsed documents;

[0216] The cleaning module is used to clean the parsed documents to obtain normalized domain text;

[0217] An embedding module is used to dynamically semantically segment the standardized domain text to obtain N structured knowledge blocks;

[0218] The teacher big model module is used to construct a candidate synthetic instruction dataset based on N structured knowledge blocks generated by the embedded module;

[0219] The multi-stage data quality control module is used to perform multi-stage filtering on candidate synthetic instruction datasets to obtain high-quality domain instruction datasets.

[0220] The training module is used to efficiently fine-tune the parameters of the base large language model based on a high-quality domain instruction dataset, resulting in a domain knowledge-enhanced large language model.

[0221] Specific Implementation Method Five: A medical information analysis method, comprising:

[0222] Identify the medical information to be analyzed;

[0223] The medical information is input into the target large model to generate medical feedback information;

[0224] The target large model is the large model after fine-tuning using the domain knowledge enhancement large model fine-tuning method described in any one of the specific implementation methods 1 to 3.

[0225] Specific Implementation Method Six: An engineering information analysis method, comprising:

[0226] Determine the engineering information to be analyzed;

[0227] The engineering information is input into the target large model to generate engineering feedback information;

[0228] The target large model is the large model fine-tuned using the domain knowledge enhancement large model fine-tuning method described in any one of the specific implementation methods 1 to 3.

[0229] Specific Implementation Method Seven: A financial information analysis method, comprising:

[0230] Identify the financial information to be analyzed;

[0231] The financial information is input into the target large model to generate financial feedback information;

[0232] The target large model is the large model fine-tuned using the domain knowledge enhancement large model fine-tuning method described in any one of the specific implementation methods 1 to 3.

[0233] Taking the financial sector as an example, the system first receives documents such as financial policy documents, credit approval rules, corporate financial reports, financial announcements, and risk control manuals. The system parses, cleans, and dynamically segments these documents semantically to obtain multiple structured knowledge blocks. Subsequently, the system generates basic question-answering samples, evolutionary question-answering samples, and cross-knowledge-block joint reasoning samples based on these knowledge blocks. For example, the system can generate a comprehensive analysis sample to determine whether a loan application should be approved based on a company's cash flow, industry risk, and credit policy.

[0234] After multi-stage quality control, the system obtains a high-quality dataset of financial instructions. Finally, based on this dataset, the system performs QLoRA fine-tuning on base models such as Qwen, DeepSeek, or Llama, enabling the models to more accurately understand financial terminology, business rules, and risk assessment logic.

[0235] Specific Implementation Method Eight: A legal information analysis method, characterized in that it includes:

[0236] Identify the legal information to be analyzed;

[0237] The legal information is input into the target large model to generate legal feedback information;

[0238] The target large model is the large model fine-tuned using the domain knowledge enhancement large model fine-tuning method described in any one of the specific implementation methods 1 to 3.

[0239] Taking the legal field as an example, the system can receive documents such as legal provisions, judicial interpretations, case facts, and judgments, and generate sample instructions for legal application, liability determination, clause interpretation, and case comparison. After fine-tuning, the model can better perform tasks such as legal Q&A, clause interpretation, and case analysis.

[0240] Specific Implementation Method Nine: This implementation method is a computer storage medium that stores at least one instruction. The at least one instruction is loaded and executed by a processor to implement the large model fine-tuning method for domain knowledge enhancement.

[0241] It should be understood that the instructions include computer program products, software, or computerized methods corresponding to any method described in this invention; the instructions can be used to program computer systems or other electronic devices. Computer storage media may include readable media on which instructions are stored, and may include, but are not limited to, magnetic storage media, optical storage media; magneto-optical storage media include read-only memory (ROM), random access memory (RAM), erasable programmable memory (e.g., EPROM and EEPROM), and flash memory layers, or other types of media suitable for storing electronic instructions.

[0242] Specific Implementation Method Ten: This implementation method is a domain knowledge enhancement large model fine-tuning device, which includes a processor and a memory. It should be understood that the device may include any device with a processor and memory described in this invention, and may also include units or modules that perform operations such as display, interaction, processing, and control via signals or instructions;

[0243] The memory stores at least one instruction, which is loaded and executed by the processor to implement the large model fine-tuning method for domain knowledge enhancement.

[0244] The above description is merely of preferred embodiments of the present invention. It should be understood that the present invention is not limited to the specific embodiments described above. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent substitutions, and improvements made to the above embodiments without departing from the scope of the present invention, based on the technical essence of the present invention, and within the spirit and principles of the present invention, shall still fall within the protection scope of the present invention.

Claims

1. A method for fine-tuning a large model with domain knowledge enhancement, characterized in that, include: Step 1: Parse the original domain document set to obtain the parsed documents; The parsed document is cleaned to obtain normalized domain text; Step 2: Perform dynamic semantic segmentation on the standardized domain text to obtain N structured knowledge blocks; N is a positive integer; Step 3: Generate a candidate synthesis instruction dataset based on N structured knowledge blocks; Step 4: Perform multi-stage quality control on the candidate synthetic instruction dataset to obtain a high-quality domain instruction dataset; Step 5: Based on the high-quality domain instruction dataset, perform efficient parameter fine-tuning on the base large language model to obtain a domain knowledge-enhanced large language model.

2. The method for fine-tuning a large model with enhanced domain knowledge according to claim 1, characterized in that, In step 2, the standardized domain text is dynamically semantically segmented to obtain N structured knowledge blocks. The specific process is as follows: Step 2.1: Divide the normalized domain text into I basic text units; I is a positive integer; Step 2.2: Use a text embedding model to convert each basic text unit into a semantic vector and calculate the semantic similarity between adjacent basic text units; Step 2.3: Determine the segmentation boundaries of structured knowledge blocks based on the semantic similarity between adjacent basic text units; Step 2.4: Based on the segmentation boundaries of the structured knowledge blocks, the normalized domain text is segmented into N structured knowledge blocks; In step 3, a candidate synthesis instruction dataset is generated based on N structured knowledge blocks. The specific process is as follows: Step 3.1: Generate instructions based on N structured knowledge blocks and the teacher's large model to obtain a basic instruction sample set; Step 3.2: Based on the basic instruction sample set and the teacher's large model, perform instruction evolution to obtain the evolved instruction sample set; Step 3.3: Based on the semantic relevance between the structured knowledge blocks and the teacher big model, construct a cross-knowledge block joint reasoning sample set; Step 3.4: Use the basic instruction samples, evolutionary instruction samples, and cross-knowledge block joint reasoning samples as candidate synthetic instruction datasets; In step 4, multi-stage quality control is performed on the candidate synthetic instruction dataset to obtain a high-quality domain instruction dataset. The specific process is as follows: Step 4.1: Perform the first filtering on the candidate synthesis instruction dataset based on the first filtering rule to obtain the candidate synthesis instruction dataset after the first filtering; Step 4.2: Perform a second filtering on the candidate synthetic instruction dataset after the first filtering based on the second filtering rule to obtain the candidate synthetic instruction dataset after the second filtering; Step 4.3: Based on the third filtering rule, perform a third filtering on the candidate synthetic instruction dataset after the second filtering to obtain a high-quality domain instruction dataset; In step 5, based on the high-quality domain instruction dataset, the parameters of the base large language model are efficiently fine-tuned to obtain a domain knowledge-enhanced large language model. The specific process is as follows: Based on the high-quality domain instruction dataset, the QLoRA parameter efficient fine-tuning method is used to adapt the base large language model to the domain, resulting in a domain knowledge-enhanced large language model.

3. The method for fine-tuning a large model with enhanced domain knowledge according to claim 2, characterized in that, In step 3.1, instructions are generated based on N structured knowledge blocks and the teacher's large model to obtain a basic instruction sample set. The specific process is as follows: Input N structured knowledge blocks into the teacher's big model, and the teacher's big model will generate N basic instruction samples respectively; N structured knowledge blocks correspond to N basic instruction samples, which together form a basic instruction sample set; Each basic instruction sample includes: instruction field, input field, output field, and evidence field; In step 3.2, instruction evolution is performed based on the basic instruction sample set and the teacher large model to obtain the evolved instruction sample set; the specific process is as follows: Step 3.2.1: Construct the first prompt word requirement text; Step 3.2.2: Input the basic instruction sample set and the first prompt word requirement text into the teacher big model, and the teacher big model will generate the evolutionary instruction sample set; In step 3.3, a cross-knowledge block joint reasoning sample set is constructed based on the semantic relevance between the structured knowledge blocks and the teacher big model; the specific process is as follows: Step 3.3.1: Use a text embedding model to convert N structured knowledge blocks into N knowledge block semantic vectors; Step 3.3.2: Calculate the semantic similarity between the semantic vectors of the N knowledge blocks; Step 3.3.3: Based on the semantic similarity between the semantic vectors of N knowledge blocks, determine the associated knowledge blocks of each structured knowledge block; Step 3.3.4: Input a structured knowledge block and its corresponding related knowledge blocks into the teacher's large model to construct a cross-knowledge block joint reasoning sample. When all N structured knowledge blocks are input into the teacher's large model, N cross-knowledge block joint reasoning samples are obtained, which serve as the cross-knowledge block joint reasoning sample set.

4. A domain knowledge-enhanced large model fine-tuning system, characterized in that, include: The parsing module is used to parse the original domain document collection to obtain the parsed documents; The cleaning module is used to clean the parsed documents to obtain normalized domain text; An embedding module is used to dynamically semantically segment the standardized domain text to obtain N structured knowledge blocks; The teacher big model module is used to construct a candidate synthetic instruction dataset based on N structured knowledge blocks generated by the embedded module; The multi-stage data quality control module is used to perform multi-stage filtering on candidate synthetic instruction datasets to obtain high-quality domain instruction datasets. The training module is used to efficiently fine-tune the parameters of the base large language model based on a high-quality domain instruction dataset, resulting in a domain knowledge-enhanced large language model.

5. A medical information analysis method, characterized in that, include: Identify the medical information to be analyzed; The medical information is input into the target large model to generate medical feedback information; The target large model is the large model after fine-tuning using the domain knowledge enhancement large model fine-tuning method according to any one of claims 1 to 3.

6. An engineering information analysis method, characterized in that, include: Determine the engineering information to be analyzed; The engineering information is input into the target large model to generate engineering feedback information; The target large model is the large model after fine-tuning using the domain knowledge enhancement large model fine-tuning method according to any one of claims 1 to 3.

7. A financial information analysis method, characterized in that, include: Identify the financial information to be analyzed; The financial information is input into the target large model to generate financial feedback information; The target large model is the large model after fine-tuning using the domain knowledge enhancement large model fine-tuning method according to any one of claims 1 to 3.

8. A method for analyzing legal information, characterized in that, include: Identify the legal information to be analyzed; The legal information is input into the target large model to generate legal feedback information; The target large model is the large model fine-tuned using the domain knowledge enhancement large model fine-tuning method described in any one of claims 1 to 3.

9. A computer storage medium, characterized in that, The storage medium stores at least one instruction, which is loaded and executed by a processor to implement a large model fine-tuning method for domain knowledge enhancement as described in any one of claims 1 to 3.

10. A computer device, characterized in that, The device includes a processor and a memory, the memory storing at least one instruction, which is loaded and executed by the processor to implement a large model fine-tuning method for domain knowledge enhancement as described in any one of claims 1 to 3.