Fine-tuning method for real estate field large model
By constructing a corpus quality scoring matrix and gradient sensitivity analysis in the real estate field, and performing quantitative configuration and multi-card parallel fine-tuning of large-scale language models, the problems of insufficient professional knowledge adaptation and high resource threshold of large-scale language models in the real estate field are solved, and the model can provide efficient and accurate professional consulting support in real estate business.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SUZHOU ZHONGDIHANG INFORMATION TECH CO LTD
- Filing Date
- 2026-05-14
- Publication Date
- 2026-07-21
AI Technical Summary
Large-scale language models are not adequately adapted to the professional knowledge in the real estate field, and the threshold for fine-tuning resources is too high. This causes the models to give answers that deviate from industry practices in professional consultations, affecting customer experience and the quality of business decisions.
By acquiring raw corpus data in the real estate field, a set of domain knowledge triples is constructed, a corpus quality score matrix is generated, hierarchical screening and truncation alignment are performed, quantitative configuration is carried out based on gradient sensitivity analysis, multi-card parallel fine-tuning training is adopted, the learning rate and LoRA weights are dynamically adjusted, and an interactive question-and-answer interface adapted to real estate business is generated.
It enhances the model's ability to understand and express complex knowledge structures in the real estate field, reduces computational complexity, ensures the accuracy and generalization ability of professional knowledge, suppresses overfitting trends, and guarantees the numerical stability of the reasoning process.
Smart Images

Figure CN122432331A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing technology, and more specifically, to a method for fine-tuning large models in the real estate sector. Background Technology
[0002] Large-scale language models face deep-seated technical bottlenecks and adaptation barriers when fine-tuned for specialized fields such as real estate. The most pressing issue is insufficient adaptation to specific domain knowledge—while existing models excel in general knowledge, they often fall short when dealing with the complex legal framework, intricate network of terminology, and multi-layered transaction structures of the real estate sector. In practical applications, when users consult on professional issues, models often provide superficially reasonable but substantively detached answers from industry practice, even confusing policies and regulations across different regions, leading to a serious crisis of professional trust. Simultaneously, the high resource threshold for fine-tuning also poses a significant obstacle to industry application—traditional full-parameter fine-tuning methods require massive computing clusters and specialized teams, making it unaffordable for small and medium-sized institutions such as real estate agencies, legal consulting firms, or regional developers to customize specialized models. Although these institutions possess a wealth of valuable first-hand business data, they cannot translate this into improved model capabilities, ultimately resorting to general-purpose large models to handle specialized inquiries, frequently resulting in biased professional judgments in real-world business scenarios, impacting customer experience and the quality of business decisions.
[0003] In view of this, the present invention proposes a large model fine-tuning method for the real estate field to solve the above problems. Summary of the Invention
[0004] To overcome the aforementioned deficiencies of the prior art and to achieve the above objectives, the present invention provides the following technical solution: a method for fine-tuning large models in the real estate field, comprising: Acquire raw corpus data in the real estate field, extract entity terms, clause structure and question-answer pairs, and construct a set of domain knowledge triples; Based on the domain knowledge triple set, the domain coverage frequency and semantic association density of each triple are statistically analyzed to generate a corpus quality score matrix. Based on the corpus quality score matrix, the original corpus data is hierarchically filtered and truncated and aligned to construct a fine-tuning training dataset that adapts to the input length of the base model. Obtain the parameter gradient sensitivity distribution of each Transformer layer in the base model, and determine the QLoRA quantization layer adaptation strategy based on the parameter gradient sensitivity distribution; Based on the hierarchical adaptation strategy, the quantization bit width and low-rank matrix rank value are configured for different layers of the base model to generate differentiated quantization configuration schemes. Based on the differentiated quantization configuration scheme and the fine-tuning training dataset, multi-GPU parallel fine-tuning training was initiated, and the training loss curve and gradient distribution characteristics were collected in real time through Swanlab. Based on the training loss curve and gradient distribution characteristics, identify the overfitting risk zone and dynamically adjust the learning rate decay strategy and LoRA weight update frequency. The fine-tuned model weights and differentiated quantization configuration scheme are merged and exported, converted to an Ollama-compatible format, and a model service configuration file is generated. Based on the model service configuration file, the model inference service is deployed through Docker containers and connected to Open WebUI to build an interactive question-and-answer interface for real estate business.
[0005] Compared to existing technologies, this invention enhances the ability of large-scale language models to understand and express complex knowledge structures in the real estate field through precise mapping and deep integration of professional domain knowledge systems. This enables the model to accurately identify and apply the inherent logical connections between professional terms, providing domain ontology-based reasoning support for complex consultations. A multi-level parameter optimization strategy based on gradient sensitivity analysis effectively overcomes computational resource limitations, significantly reducing computational complexity while maintaining key semantic representation capabilities, thus breaking through the hardware bottleneck of customized professional models. Through semantic integrity-driven structured processing of training data, this invention ensures that the model learns a coherent and complete professional knowledge system rather than fragmented information. A real-time dynamic parameter adjustment mechanism effectively suppresses the overfitting tendency of the model in the professional domain, maintaining a balance between the accuracy of professional knowledge and generalization ability. This invention also ensures the numerical stability of the inference process through automatic detection and correction of abnormal weight distribution. Attached Figure Description
[0006] Figure 1 This is a schematic diagram of a large model fine-tuning method for the real estate field according to the present invention. Detailed Implementation
[0007] 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.
[0008] Please see Figure 1 In this embodiment of the invention, a specific implementation process of a large model fine-tuning method for the real estate field includes: We acquire raw corpus data in the real estate field, extract entity terms, clause structures, and question-and-answer pairs, and construct a set of domain knowledge triples. The raw corpus data includes key information such as real estate regulations, transaction contract templates, property ownership documents, and professional consultation Q&A records, acquired in batches through a multi-source data acquisition interface. Entity terms cover basic concepts such as property rights holders, property types, and legal responsibilities; clause structures reflect the contract framework, division of rights and responsibilities, and transaction processes; and question-and-answer pairs record professional consultations and answers in actual business scenarios. This structured information is organized into subject-relationship-object triples using knowledge graph technology, such as "commercial housing - belongs to - real estate rights" and "land use rights - term is - 70 years," forming the basic units of domain knowledge and providing a high-quality professional knowledge foundation for subsequent fine-tuning.
[0009] Based on the set of domain knowledge triples, the domain coverage frequency and semantic association density of each triple are statistically analyzed to generate a corpus quality score matrix. Domain coverage frequency reflects the frequency of triple occurrences in real estate literature, while semantic association density quantifies the degree of connection between the triple and related knowledge points. The score matrix uses entity terminology categories (e.g., property rights, transactions, taxes, etc.) as row indexes and clause structure categories (e.g., definition clauses, rights and responsibilities clauses, breach of contract clauses, etc.) as column indexes. Each cross-cell contains the quality score of the corresponding category of triples. This structured scoring method ensures the relevance and balance of subsequent data selection, avoiding the bias of the training data in the specific domain.
[0010] Based on the corpus quality scoring matrix, the original corpus data underwent hierarchical screening and truncation alignment to construct a fine-tuned training dataset adapted to the input length of the base model. The hierarchical screening process divided the corpus into high-quality, medium-quality, and low-quality layers, employing different processing strategies for each. High-quality corpus data retained complete text to ensure the coherence of key knowledge; medium-quality corpus data was truncated using a sliding window technique to retain main information; low-quality corpus data was directly discarded to avoid introducing noise. The truncation process paid special attention to semantic integrity, ensuring that the segmentation points did not disrupt the logical structure of professional knowledge through semantic checks at the beginning and end. The final training dataset was organized in a three-part structure of instruction-input-output, such as "Explain the title restriction clause" (instruction) - "The following are the title restriction clauses of a certain commercial housing sales contract" (input) - "This clause restricts the owner's right to transfer the property within a specific period..." (output), providing the model with clear learning objectives and professional examples.
[0011] The parameter gradient sensitivity distribution of each Transformer layer in the base model is obtained, and the layer adaptation strategy for QLoRA quantization is determined based on this distribution. Parameter gradient sensitivity reflects the responsiveness of each layer to fine-tuning and is a key basis for formulating differentiated quantization strategies. The measurement process involves backpropagating gradients on randomly sampled training batches to record the sensitivity of each layer's parameters to the loss function. High-sensitivity layers (such as typical shallow attention mechanisms and deep semantic integration layers) have a greater impact on fine-tuning and require more quantization accuracy to be preserved; while low-sensitivity layers can employ more aggressive compression strategies to save computational resources. This sensitivity-based adaptive quantization method achieves an optimal balance between model performance and training resource consumption.
[0012] Based on a hierarchical adaptation strategy, different layers of the base model are configured with varying quantization bit widths and low-rank matrix rank values, generating differentiated quantization configuration schemes. This differentiated quantization configuration scheme is a core technological innovation of QLoRA fine-tuning, achieving efficient resource utilization through precise control of the quantization parameters of each layer. High-sensitivity layers are configured with higher quantization bit widths (e.g., 6-8 bits) and larger low-rank matrix rank values (e.g., 16-32) to ensure the expressive power of critical layers; low-sensitivity layers use lower quantization bit widths (e.g., 3-4 bits) and smaller rank values (e.g., 4-8), significantly reducing memory consumption. The configuration scheme also considers inter-layer dependencies and information flow paths, ensuring the overall coordination and expressive power of the quantized model. This refined quantization strategy achieves better fine-tuning results under the same resource conditions compared to a uniform quantization scheme.
[0013] Based on the differentiated quantization configuration scheme and the fine-tuning training dataset, multi-GPU parallel fine-tuning training was initiated, with Swanlab used to collect training loss curves and gradient distribution characteristics in real time. Multi-GPU parallel training employs a strategy combining data parallelism and model parallelism, distributing the model across multiple computing devices to process different batches of training samples simultaneously. Swanlab, as a lightweight training monitoring tool, collects key metrics in real time, including training loss values for each batch, validation set performance metrics, gradient norm distribution, and parameter update amounts. This real-time data is presented through a visual interface, facilitating dynamic monitoring and timely intervention during the training process, and serving as a crucial basis for subsequent training strategy adjustments.
[0014] Based on the training loss curve and gradient distribution characteristics, overfitting risk intervals are identified, and the learning rate decay strategy and LoRA weight update frequency are dynamically adjusted. The overfitting risk interval refers to the period when the gap between the training set loss and the validation set loss continuously widens, indicating that the model begins to memorize training data rather than learn general rules. The identification method is based on sliding window analysis of the loss difference sequence. When the difference continuously increases beyond a preset number of steps, the system automatically enters the anti-overfitting adjustment phase. Adjustment measures include reducing the learning rate (usually to 0.1-0.5 times the original value) and reducing the LoRA weight update frequency (e.g., from updating every step to updating every 3-5 steps). These measures effectively suppress the model's overfitting to the training data and improve the final model's generalization ability in real-world business scenarios.
[0015] The fine-tuned model weights and differentiated quantization configuration scheme are merged and exported, converted to an Ollam-compatible format, and a model service configuration file is generated. Model export is a crucial step in transforming training results into deployable outputs. The merging process calculates and fuses the LoRA weight matrix with the original weights of the base model, while applying a differentiated quantization scheme for accuracy conversion. For layers exhibiting abnormal distributions after merging (such as layers with significant deviations in mean or variance), the system automatically performs weighting correction to ensure the numerical stability of the quantized model. The final model is converted to GGUF format, the standard model format within the Ollam framework, supporting efficient inference computation and flexible deployment configuration. The service configuration file defines the model's operating parameters, including inference temperature (controlling output diversity), maximum generation length (controlling response comprehensiveness), and context window size (controlling the depth of historical information utilization). These parameters are specifically optimized based on the characteristics of real estate business.
[0016] Based on the model service configuration file, the model inference service is deployed via Docker containers and integrated with Open WebUI to build an interactive question-and-answer interface for real estate businesses. Docker containers provide an isolated and portable runtime environment, ensuring consistent performance of the model service across different infrastructures. The deployment process first involves pre-testing with a standard question set to evaluate the service's response time and output quality; then, based on the test results, inference parameters are fine-tuned to optimize service performance; finally, the adjusted service is integrated with the Open WebUI open-source front-end interface, configuring real estate-specific prompt word templates and session management strategies. This complete deployment process ensures that the fine-tuned model can be easily applied to real-world business scenarios, providing intelligent support for professional consulting, contract review, risk assessment, and other applications in the real estate field.
[0017] In this embodiment of the invention, the detailed implementation steps for generating the corpus quality score matrix include: The frequency of each triple in the original corpus within the statistical domain knowledge triple set is denoted as the domain coverage frequency. The statistical process employs entity linking and relation extraction techniques, using deep semantic matching to identify triple expressions in the original text, ensuring accurate statistics even with variations in expression. For example, "The property rights belong to the developer" and "The property rights holder is the construction unit" are different expressions, but they both refer to the same triple: "House-Property Ownership-Developer". The statistical results are visualized as frequency distribution plots, reflecting the importance and prevalence of different knowledge points in domain literature, providing a quantitative basis for subsequent quality scoring.
[0018] The semantic similarity between each triple and other triples of the same type is calculated and denoted as the semantic association density. Semantic association density reflects the connectivity and centrality of knowledge points within a knowledge network. The calculation process first maps the triples to a vector space using knowledge embedding techniques (such as TransE or ComplEx); then, it calculates the cosine similarity between the target triple and other triples of the same type (same domain or same topic); finally, the average value is taken as the semantic association density of that triple. Triples with high association density are usually key nodes in the knowledge network, connecting multiple related concepts and are of significant value for the model's understanding of the domain's knowledge architecture. The semantic similarity is calculated using the following formula: ; in, It is a triplet and semantic similarity, and These are their vector representations. and It is a vector norm.
[0019] The domain coverage frequency and semantic association density are normalized and then weighted and summed to generate a quality score for each triple. Normalization eliminates the dimensional differences between the two metrics, allowing them to be compared and integrated on the same scale. Log-normalization is used to handle the long-tail effect of the frequency distribution for domain coverage frequency, while semantic association density is mapped to the [0,1] interval using the Min-Max method. The weighted summation formula is: ; in, It is the final quality score of the triple $t$. It is the normalized domain coverage frequency. It is the normalized semantic association density. These are weighting coefficients, typically set between 0.4 and 0.6, and can be optimized using the validation set. This weighting method balances the popularity and structural importance of knowledge points, and the generated quality score comprehensively reflects the overall value of the triples in the real estate field.
[0020] A corpus quality score matrix is constructed using the quality scores of each triple as elements, with entity term categories as row indices and clause structure categories as column indices. The matrix construction process first classifies the triples in two dimensions, assigning each triple to a corresponding cell in the matrix based on its main entity category and applicable clause category. Then, the average score of all triples within the same cell is calculated as the representative value for that cell. Finally, a complete score matrix is generated, visually displaying the distribution quality of knowledge points across different domains. The matrix typically reveals obvious hotspot areas, such as property rights-definition clauses and taxes-liability clauses; corpora from these areas will be prioritized for retention in subsequent screening. The score matrix is not only used for corpus screening but also provides a structured perspective for the completeness analysis of domain knowledge, helping to identify and supplement knowledge blind spots.
[0021] In this embodiment of the invention, the detailed implementation steps for constructing a fine-tuned training dataset that adapts to the input length of the pedestal model include: Based on the corpus quality score matrix, the original corpus was divided into high-quality, medium-quality, and low-quality layers. The division process was based on the statistical distribution of the quality scores, with thresholds determined using percentile methods. Specifically, corpora with scores in the top 30% were assigned to the high-quality layer, those with scores between 30% and 70% were assigned to the medium-quality layer, and those with scores below the bottom 30% were assigned to the low-quality layer. This quality-based three-layer division strategy ensures the overall quality of the training data while preserving sufficient diversity, preventing the model from overemphasizing certain specific patterns. The division results are visualized using a confusion matrix, intuitively presenting the quality distribution of each category and providing a basis for subsequent differentiated processing.
[0022] For high-quality corpora, complete text is preserved; for medium-quality corpora, a sliding window is used to truncate them according to the maximum input length; and low-quality corpora are filtered out. This differentiated processing strategy employs different methods based on the corpus quality level to maximize the retention of high-value information. High-quality corpora, due to their importance, retain their original integrity, with only extremely long documents exceeding the absolute upper limit of the base model (e.g., 32k) undergoing necessary segmentation. Medium-quality corpora are processed using a sliding window technique, with the window size set to the maximum input length of the base model (typically 2048-4096), and a sliding step size of 50%-75% of the window size, ensuring sufficient overlap between adjacent windows to maintain contextual coherence. Low-quality corpora are directly discarded to avoid introducing noise and redundant information. This hierarchical processing method significantly improves the overall quality and information density of the training data.
[0023] The system performs semantic integrity checks on truncated segments, prioritizing merging incomplete segments with adjacent segments before re-truncating. Semantic integrity checks are a crucial step in ensuring that truncating does not disrupt the semantic structure. The checks are based on sentence boundary detection and semantic coherence assessment in natural language processing. Specifically, the system extracts the first and last sentences of each truncated segment, calculates their cosine similarity to the semantic vector of the segment's main body, and determines segments as semantically incomplete when the similarity is below a preset threshold (typically 0.7). For incomplete segments, the system prioritizes merging with semantically relevant adjacent segments, then re-truncates at semantic boundary points, ensuring the semantic self-sufficiency and integrity of each training sample. This semantically aware truncating method significantly improves the quality of training data and the efficiency of model learning.
[0024] The filtered and truncated corpora were uniformly formatted into an instruction-input-output ternary structure to generate a fine-tuning training dataset. Formatting transforms the processed corpora into a standard form that the model can learn, ensuring training consistency. In the ternary structure, the instruction part describes the task objective, such as "explain the concept of down payment in real estate transactions"; the input part provides task-related context or question descriptions, such as "When purchasing a commercial house, the developer requires a 30% down payment of the total price. Is this reasonable?"; the output part is the expected professional answer generated by the model, such as a detailed explanation of the legal basis and practical standards for down payment ratios. The formatting process uses a template-based approach, applying appropriate structural templates according to different types of corpora (such as legal interpretation, contract analysis, and consultation answers) to ensure format consistency. The final training dataset is stored in JSON Lines format, with each line containing a complete training sample, facilitating batch loading and out-of-order training. The dataset also includes metadata fields recording the sample source, quality level, and knowledge coverage category, facilitating subsequent training monitoring and evaluation analysis.
[0025] In this embodiment of the invention, the detailed implementation steps for determining the hierarchical adaptation strategy for QLoRA quantization include: The base model is propagated forward and backward using randomly sampled batches of the fine-tuned training dataset, and the gradient norm of each Transformer layer is recorded. The gradient norm reflects the sensitivity of the model parameters to the loss function and is a key indicator for evaluating the importance of a layer. The measurement process first randomly samples multiple small batches (usually 8-16) from the training dataset to ensure the representativeness of the samples; then, forward computation and backpropagation of the loss are performed on each batch, without updating the parameters, only recording the gradients; finally, the L2 norm is calculated for the gradient tensor of each layer to obtain the scalarized gradient strength. To improve stability, the measurement is usually repeated multiple times and the average value is taken to eliminate random fluctuations from a single sampling. The distribution of gradient norms usually exhibits a clear hierarchical structure, with shallow and deep layers of the model often having larger gradient values, while the middle layers have relatively smaller ones, reflecting the differentiated roles of different layers in the model's functionality.
[0026] Normalize the gradient norms of each layer and calculate the parameter gradient sensitivity values for each layer. Normalization is a necessary step to eliminate the influence of differences in parameter scales across different layers, making the sensitivity comparable. The normalization method is based on global distribution statistics. First, the mean and standard deviation of the gradient norms of all layers are calculated. Then, the original gradient norms of each layer are standardized using Z-scores, converting them into standardized values relative to the global distribution. For ease of intuitive understanding and application, the standardized values are mapped to the (0,1) interval using the Sigmoid function, forming the final sensitivity values. The formula for calculating parameter gradient sensitivity is as follows: ; in, It is a layer The parameter gradient sensitivity value, It is a layer The original gradient norm, and These are the mean and standard deviation of the gradient norms of all layers, respectively. It is the Sigmoid function. Layers with sensitivity values close to 1 have a greater impact on model performance and need to retain higher computational accuracy; layers with sensitivity values close to 0 can adopt a more aggressive compression strategy.
[0027] Layers with parameter gradient sensitivity values higher than a preset sensitivity threshold are labeled as high-sensitivity layers, and the rest are labeled as low-sensitivity layers. Layer labeling is a fundamental step in developing a differentiated quantization strategy. The sensitivity threshold is typically set based on the statistical characteristics of the sensitivity distribution, such as 0.7 or the upper quartile of the sensitivity distribution. Layering results usually reveal that the input embedding layer, shallow self-attention mechanisms, deep feedforward networks, and output prediction layers are typically high-sensitivity layers, while some attention heads and feedforward connections in the middle layers are relatively insensitive. This sensitivity-based functional layering aligns with the information processing flow of neural networks: the lower layers are responsible for feature extraction, the deeper layers for decision output, and the middle layers for feature transformation and information transmission; the differences in sensitivity reflect the different functional importance.
[0028] A layer-wise adaptation strategy is adopted, configuring higher quantization bit widths and larger low-rank matrix rank values for high-sensitivity layers and lower quantization bit widths and smaller rank values for low-sensitivity layers. Layer-wise adaptation is the core innovation of QLoRA technology, optimizing resource utilization through differentiated configuration. The configuration process follows the principle of "fine-grained quantization for important layers and coarse-grained quantization for minor layers." Specifically, high-sensitivity layers are typically configured with 6-8 bits of quantization bit width and 16-32 low-rank matrix rank values to maintain high expressive power; while low-sensitivity layers are configured with 3-4 bits of quantization bit width and 4-8 low-rank matrix rank values, significantly reducing memory consumption and computational load. This differentiated configuration scheme achieves better performance under the same resource conditions compared to a uniform configuration because it concentrates limited resources on the key layers that have the greatest impact on model performance, while using a more aggressive compression strategy for layers with less impact. The configuration results are output in the form of a configuration mapping table, explicitly specifying the quantization parameters for each layer, providing detailed guidance for subsequent model conversion and training.
[0029] In this embodiment of the invention, the detailed implementation steps for dynamically adjusting the learning rate decay strategy and the LoRA weight update frequency include: A moving average is applied to the training loss curve to calculate the difference sequence between the training set loss and the validation set loss. Moving average is a preprocessing step that eliminates random fluctuations in the loss curve and highlights trend changes. This is achieved by applying a moving average filter with a window size of k (typically 10-20) to the original loss value sequence to obtain a smoothed loss curve. The difference sequence represents the point-to-point difference between the training set loss and the validation set loss, directly reflecting the performance gap of the model on the two types of data and serving as a key indicator for detecting overfitting. The formula for calculating the difference is: ; in, Steps The difference in loss, and The steps are respectively The validation set loss and training set loss are calculated. The difference sequence is usually small in the early stages of training and gradually increases as training progresses. When the growth rate accelerates or the difference exceeds a threshold, it often means that the model has begun to overfit the training data.
[0030] When the difference sequence monotonically increases within a preset number of consecutive training steps, the corresponding training step interval is marked as an overfitting risk interval. Monotonically increasing is a typical characteristic of the early stage of overfitting, and early identification can prevent model performance degradation. The identification method is to examine the trend of the difference sequence within n consecutive steps (usually 50-100). When the difference continues to increase and the rate of increase does not decrease (i.e., the first derivative is always positive and the second derivative is non-negative), the system determines that it has entered the overfitting risk interval. The starting point of the risk interval is recorded as the overfitting trigger point. At this time, the model still has a certain generalization ability, which is the best time to take intervention measures. The identification of the risk interval adopts a sliding window strategy, which monitors the changing trend of the loss difference in real time. Once the condition is met, the adjustment process is triggered immediately to ensure timely intervention and prevent further development of overfitting.
[0031] Within the overfitting risk range, the learning rate is reduced by a preset ratio, and the frequency of LoRA weight updates is decreased. Learning rate adjustment is the primary means of suppressing overfitting by slowing down the parameter update step size, thus reducing the model's memory of the training data. Specifically, the current learning rate is multiplied by a decay factor β (typically 0.1-0.5), significantly reducing the magnitude of parameter updates. Simultaneously, the LoRA weight update frequency is adjusted from per step to once every m steps (m is typically 3-5), further reducing the model's adaptation speed to the training data. The combined effect of these two measures is to slow down further optimization of the model on the training data, giving validation performance more room for recovery, thereby suppressing the overfitting trend. The adjustment process is achieved through dynamic modification of optimizer parameters, without restarting the training process, ensuring the continuity and efficiency of training.
[0032] After the overfitting risk interval ends, the learning rate and LoRA weight update frequency are restored to their initial configuration. The end of the risk interval is determined based on the trend change of the loss difference sequence. When the difference no longer increases monotonically or the rate of increase slows significantly, the system determines that the overfitting risk is under control and the normal training rhythm can be resumed. The recovery process adopts a gradual strategy, instead of jumping directly back to the initial value, it gradually increases according to a preset step size (such as 25% of the initial value) to avoid drastic fluctuations in the training state. This dynamic adjustment strategy of "suppression first, recovery later" effectively controls the overfitting risk while maintaining training efficiency, enabling the model to achieve a better balance between training data and generalization ability, ultimately resulting in a more practical professional model for the real estate field.
[0033] In this embodiment of the invention, the detailed implementation steps for generating the model service configuration file include: The fine-tuned LoRA weight matrix is merged with the original weights of the base model according to a differentiated quantization configuration scheme to obtain a merged weight file. Weight merging is a key step in integrating the incremental training results back into the original model. The merging process first loads the original weights of the base model and the low-rank matrix obtained from LoRA training; then, based on the mathematical principles of LoRA, the low-rank decomposition (product of low-rank matrices) is converted into incremental updates of the original weights; finally, the increments are applied to the original weights to generate a complete merged model. For cases where different quantization strategies are used for different layers, the merging process requires special handling of the quantization bit width conversion to ensure consistency of numerical accuracy. The core formula for the merging calculation is: ; in, This is the merged weight matrix. This is the original weight matrix of the base model. and These are the low-rank matrices obtained from LoRA training. The merged result is a complete model weight file, containing the general capabilities of the base model and the real estate domain expertise gained from fine-tuning.
[0034] The numerical distribution offset of weights in each layer of the merged weight file is statistically analyzed, and layers with offsets exceeding a preset threshold are subjected to weighting correction. Distribution offset detection is a safety measure to ensure the stability of model quantization. The detection process first calculates the statistical characteristics (such as mean, standard deviation, kurtosis, etc.) of the weights of each layer, and then compares them with the baseline distribution before fine-tuning to calculate the deviation value of each statistic. When the mean deviation or kurtosis deviation of a certain layer exceeds a preset threshold (usually 30% of the original value), that layer is marked as a distribution anomalous layer and requires special handling. The correction method is to recalculate the quantization parameters of that layer, especially the scaling factor, to make it more suitable for the new distribution characteristics. The calculation of the adaptive scaling factor is based on the principle of minimizing quantization error. The optimal scaling value is obtained by solving an optimization problem, which significantly improves quantization accuracy and model stability. This distribution-aware weighting correction effectively prevents the amplification of quantization error caused by changes in weight distribution after fine-tuning, ensuring the accuracy of model inference.
[0035] The corrected merged weights file is converted to GGUF format to generate an Ollam-compatible model file. GGUF (GPT-Generated Unified Format) is an efficient model storage format designed for inference optimization of large language models and is the standard model format for the Ollam framework. The conversion process first reorganizes the model architecture information, vocabulary, and weight matrix according to the GGUF specification; then, it applies a specified quantization scheme to convert the weights from their original precision (usually FP16 or BF16) to a target precision (such as INT4 or INT8); finally, it adds metadata information, such as model version, training data description, and usage license. The conversion tool typically uses the open-source llama.cpp or Ollam's built-in conversion tool to ensure format compatibility and runtime efficiency. The converted model file is significantly smaller than the original file (usually compressed to 25%-50% of the original size) while maintaining key inference performance, facilitating deployment and application in resource-constrained environments.
[0036] Configure inference temperature, maximum generation length, and context window parameters according to the needs of real estate business scenarios to generate a model service configuration file. Service configuration is the final step in optimizing model behavior, adapting key parameters to specific application scenarios. Inference temperature controls the randomness and creativity of output; in the real estate field, a lower temperature (0.1-0.4) is typically set to emphasize the accuracy and consistency of answers. Maximum generation length limits the number of words in a single answer, set to an appropriate value based on the complexity of the consultation, typically 1024-4096. The context window parameter determines the length of historical dialogues the model can reference; for complex consultations requiring multi-round inference, a larger window is typically set (e.g., 8192-16384). These parameters combine to form a complete service configuration file, usually saved in YAML or JSON format, containing information such as model path, runtime parameters, and resource limitations. The configuration file directly affects the model's inference behavior and user experience, and is a key link in transforming technical capabilities into business value.
[0037] In this embodiment of the invention, the detailed implementation steps for performing semantic integrity verification on the beginning and end of the truncated segment include: The first and last sentences of each truncated segment are extracted, and their cosine similarity to the semantic vector of the segment's main body is calculated. Semantic vector calculation is fundamental to evaluating semantic coherence, judging their coherence by comparing the positional relationships of text segments in the semantic space. The implementation method first uses a pre-trained semantic encoder (such as BERT or Universal Sentence Encoder) to convert the text segments into high-dimensional vector representations; then, the first sentence, last sentence, and main body (intermediate content excluding the first and last sentences) of the truncated segment are extracted; finally, the cosine similarity between the first sentence vector and the main body vector, and the cosine similarity between the last sentence vector and the main body vector, are calculated. These two similarity values reflect the semantic consistency between the beginning and end of the segment and the main content, respectively, and are important indicators for judging the rationality of the truncation point.
[0038] When the cosine similarity of the first or last sentence is lower than a preset integrity threshold, the segment is determined to be semantically incomplete. The integrity threshold is a key parameter for distinguishing between normal semantic transitions and anomalous semantic breaks, typically set to 0.6-0.7. The determination process compares the similarity values of the first and last sentences with the threshold; when either value is below the threshold, it indicates that the truncation at that point may have disrupted the original semantic structure and requires adjustment. This semantic similarity-based determination method, compared to simple syntactic rules, is better at capturing deep semantic relationships and effectively identifies truncation points that appear coherent but exhibit semantic jumps.
[0039] For semantically incomplete segments, priority is given to merging them with adjacent segments and then re-truncating them according to the maximum input length. Segment merging is the main strategy for restoring semantic integrity by expanding the truncation window to include more context. The merging process first determines whether the first or last sentence has lower similarity to determine the merging direction; then it merges with adjacent segments in the corresponding direction to form a longer temporary segment; finally, according to the maximum input length constraint of the base model, the merged segment is re-truncated. During re-truncation, a semantic boundary-aware strategy is adopted, prioritizing segmentation at natural semantic boundaries such as paragraph breaks and topic transitions to avoid further compromising semantic integrity.
[0040] If the merged length still exceeds the limit, the text is re-segmented using semantic boundaries as truncation points, retaining the segment with the highest semantic integrity score. This is an alternative strategy for handling long texts, used when simple merging fails to meet the length limit. The implementation first identifies potential semantic boundary points in the merged segments, such as paragraph breaks, transition markers, or topic changes; then, it calculates the semantic integrity score of the segment with each boundary point as a truncation point, taking into account both beginning-end coherence and content integrity; finally, it selects the segment with the highest score and retains it, discarding the rest or allocating them to other training samples. This intelligent truncation strategy based on semantic boundaries maximizes the preservation of the integrity and coherence of professional knowledge, significantly improving the quality of training data and providing a better demonstration for model learning.
[0041] In this embodiment of the invention, the detailed implementation steps for calculating the gradient sensitivity values of parameters in each layer include: The mean and standard deviation of the gradient norms of all Transformer layers are calculated to construct a global baseline for the gradient norm distribution. This global baseline serves as a reference standard for evaluating the sensitivity of individual layers, describing the overall gradient distribution of the model through statistical properties. The construction process first calculates the raw values of the gradient norms for each layer, forming a sequence encompassing all layers; then, the arithmetic mean and sample standard deviation of this sequence are calculated to obtain the central tendency and dispersion of the global distribution; finally, these two statistics are used as a standardized reference baseline for subsequent calculations of relative sensitivity. The use of a global baseline makes sensitivity assessment adaptive, adaptable to models of different sizes and structures, and also ensures comparability of sensitivity results between different models.
[0042] The standardized gradient norm is obtained by subtracting the mean of the global distribution baseline from the gradient norm of each layer and then dividing by the standard deviation. Standardization is a necessary step to eliminate differences in parameter scale and gradient magnitude between different layers, providing a unified metric for sensitivity. The standardization calculation uses the Z-score method to convert the original gradient norm into units of standard deviation relative to the global distribution. The formula is as follows: ; in, It is a layer The standardized gradient norm, It is the original gradient norm. and These are the mean and standard deviation of the global distribution, respectively. After standardization, a positive value indicates that the gradient of that layer is above average, and a negative value indicates that it is below average; the absolute value reflects the degree of deviation. This relative metric method eliminates the influence of model size and training batch size, making the sensitivity analysis results more generalizable.
[0043] A sigmoid transformation is applied to the standardized gradient norm, mapping it to the interval between 0 and 1 to obtain the parameter gradient sensitivity value. The sigmoid transformation is a common method for converting theoretically unbounded standardized values into bounded probability values, facilitating threshold setting and layer partitioning. The transformation uses the standard sigmoid function, mapping the Z-score value to the (0,1) interval. After the transformation, layers with sensitivity values close to 1 indicate that their gradients are significantly higher than the average level, having a greater impact on model performance; layers with sensitivity values close to 0 indicate that their gradients are significantly lower than the average level, having a relatively smaller impact on performance. The median value of 0.5 corresponds to layers comparable to the average level. This probabilistic representation intuitively reflects the relative importance of layers, facilitating subsequent quantization strategy formulation.
[0044] For layers whose sensitivity values fluctuate beyond a preset fluctuation threshold, the moving average of their sensitivity values is used as the final sensitivity value. This is a stability optimization measure that addresses the issue of large sensitivity fluctuations for certain layers across different training batches. The implementation first calculates the standard deviation of the sensitivity values for each layer across multiple measurements to measure its volatility; then, it compares the standard deviation with a preset fluctuation threshold (typically 0.15-0.2) to identify high-fluctuation layers; finally, it applies a moving average filter with a window size of k (typically 5-10) to these layers to smooth the sensitivity curve and obtain a more stable final value. This fluctuation handling mechanism ensures the reliability of sensitivity evaluation, avoids erroneous decisions caused by fluctuations in a single measurement, and improves the robustness of the layer adaptation strategy.
[0045] In this embodiment of the invention, the detailed implementation steps for weighting correction of layers with offsets exceeding a preset threshold include: The mean and kurtosis of each layer's weights in the merged weight file are calculated and compared with the baseline distribution of the corresponding layer before fine-tuning. Comparison of distribution characteristics is a crucial step in identifying quantization risks, capturing abnormal changes in the weight distribution through changes in statistical measures. The calculation process first extracts statistical features from the weight tensor of each layer, including the first moment (mean), second moment (variance), third moment (skewness), and fourth moment (kurtosis); then, it compares these with pre-stored baseline values before fine-tuning, calculating the relative rate of change; finally, it focuses on changes in the mean and kurtosis, as these two indicators have the greatest impact on the quantization effect. Changes in the mean reflect the overall shift of the weight center, while changes in kurtosis reflect changes in the sharpness of the distribution shape; both directly affect the accuracy and numerical stability of the quantized representation.
[0046] Layers with mean deviation or kurtosis deviation exceeding preset thresholds are marked as distribution anomaly layers. Anomaly detection is a necessary step in screening layers requiring special handling. The detection criteria are based on the relative magnitude of statistical deviations; typically, a distribution anomaly is determined when the mean deviation exceeds 25% of its original value or the kurtosis deviation exceeds 40% of its original value. The formula for calculating mean deviation is: ; in, It is a layer The mean deviation, This is the slightly adjusted mean. This is the baseline mean. Kurtosis bias is calculated using a similar method. Distribution anomalies typically occur in the model's adaptation and output layers, which undergo the largest adjustments and show the most significant distribution changes during fine-tuning. Timely identification and handling of these anomalous layers is crucial for ensuring the performance of quantization models.
[0047] For the distribution anomaly layer, an adaptive scaling factor based on minimizing quantization error is used to replace the original scaling factor. The scaling factor is a key parameter in the quantization process, determining the mapping relationship from the original value to the quantized value, and directly affecting the quantization accuracy. For the distribution anomaly layer, the original simple scaling method based on statistics may no longer be applicable, requiring a more refined optimization strategy. The adaptive scaling factor calculation process first defines the quantization error objective function, typically using mean squared error or absolute error; then, the scaling factor is used as the optimization variable, and the optimal value that minimizes the error is found through methods such as gradient descent or grid search; finally, the optimized scaling factor replaces the original value. This adaptive method based on minimizing error can better adapt to the characteristics of the fine-tuned weight distribution, significantly improving quantization accuracy.
[0048] The weights of the outlier layers are requantized using the replaced scaling factor, and the results are written back to the merged weights file. Weighting is the final step in the correction process, improving model performance by updating the quantization parameters. The process first calculates the quantized values of the weights using the new scaling factor, typically employing linear or logarithmic quantization methods. Then, the quantized values are converted to integer representations of the target precision (e.g., INT8 or INT4). Finally, the corrected quantized weights are written back to the model file, replacing the original values. To verify the correction effect, inference results before and after correction are typically compared on a small test set to ensure that the correction effectively improves model performance. This targeted weighting correction strategy significantly improves the representational precision of key layers while maintaining the overall model size, effectively solving the quantization bias problem after fine-tuning.
[0049] In this embodiment of the invention, the detailed implementation steps for constructing an interactive question-and-answer interface for real estate business include: Based on the model service configuration file, a Docker container startup script is built, containing the model file path, inference parameters, and resource limits. Containerized deployment is a key technology for ensuring the stability and portability of the model service. The script build process first determines the base image, typically a lightweight Linux distribution with CUDA support; then, environment variables are configured, including the model path, number of threads, GPU device ID, and memory limits; finally, the startup command is set, specifying the listening port and log level for the Ollam service. The complete startup script uses YAML or Shell format, containing all necessary configuration items and resource constraints to ensure consistent container performance across different environments. The advantages of containerization lie in environment isolation and rapid deployment, eliminating concerns about differences in the underlying system and greatly simplifying the management and expansion of the model service.
[0050] After starting the Docker container, a pre-test was conducted on the inference service using a standard set of questions from the real estate sector to evaluate inference latency and output quality. Pre-testing is a necessary step in optimizing service performance by simulating real query loads to preload and optimize the model. The testing process used a pre-prepared set of standard questions covering typical real estate scenarios such as property rights determination, transaction processes, tax calculation, and risk assessment. The response time and output results for each question were recorded. Finally, key metrics such as average latency, P95 latency, and output quality score were calculated. Pre-testing not only populated the GPU cache and model weight cache, optimizing the response speed of the first query, but also provided baseline data for service performance, offering a reference for subsequent parameter tuning.
[0051] Based on the preheating test results, the inference temperature and context window parameters are fine-tuned, and the model service configuration file is updated. Parameter fine-tuning is a key step in optimizing user experience, balancing response quality and performance by adjusting key parameters. The tuning process is based on quantitative analysis of test results, focusing on the professional accuracy of model output, the completeness of answers, and inference latency. Inference temperature adjustments are typically based on output quality scores; when answers are too vague or deviate from professional standards, the temperature is lowered to enhance certainty. Context window parameters are adjusted based on multi-turn dialogue test results, minimizing the window size as much as possible while ensuring contextual understanding, thus reducing memory usage and computational burden. The adjusted parameters are updated to the service configuration file, and the service process is reloaded to make the changes effective. This parameter fine-tuning based on real-world test results ensures optimal service performance under specific hardware environments and business scenarios.
[0052] The adjusted inference service interface was registered with Open WebUI, and real estate-specific prompt word templates and session context management strategies were configured to build an interactive question-and-answer interface. Front-end integration is the final step in enhancing the user experience, combining the optimized model service with an intuitive interface. The integration process first registers the Ollam service with the Open WebUI platform, configuring the service address and authentication information; then, it creates a real estate-specific model configuration, including icons, descriptions, and default parameters; finally, it configures professional prompt word templates and session management strategies. The prompt word templates pre-set common real estate consultation scenarios, such as "analyze the legal risks of this house sale contract" or "explain the renewal regulations for land use rights," which users can directly select or modify, simplifying the expression of professional consultations. The session context management strategy optimizes the information retention and forgetting mechanisms in multi-turn dialogues, ensuring that context-relevant information is retained while irrelevant information is promptly removed, improving the model's multi-turn interaction capabilities. These specialized configurations together construct an efficient interactive question-and-answer interface for real estate business, providing intelligent support for scenarios such as real estate transactions, legal consultation, and risk assessment.
[0053] This invention achieves efficient fine-tuning of large-scale models for the real estate sector through domain knowledge triple construction, corpus quality assessment, differentiated quantization configuration, and dynamic training adjustments. The QLoRA quantization fine-tuning method of this invention can accurately adapt to professional domain knowledge under limited computing power, effectively improving the model's performance in real estate business scenarios and providing a systematic solution for digital real estate services.
[0054] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
[0055] It should be noted that all formulas in this manual are calculated by removing dimensions and taking their numerical values. The formulas are derived from software simulations based on a large amount of collected data to obtain the most recent real-world results. The preset parameters and thresholds in the formulas are set by those skilled in the art according to the actual situation.
[0056] Although embodiments of the invention have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.
Claims
1. A method for fine-tuning large models in the real estate sector, characterized in that, include: Acquire raw corpus data in the real estate field, extract entity terms, clause structure and question-answer pairs, and construct a set of domain knowledge triples; Based on the domain knowledge triple set, the domain coverage frequency and semantic association density of each triple are statistically analyzed to generate a corpus quality score matrix. Based on the corpus quality score matrix, the original corpus data is subjected to hierarchical filtering and truncation alignment to construct a fine-tuning training dataset that adapts to the input length of the base model. Obtain the parameter gradient sensitivity distribution of each Transformer layer in the base model, and determine the QLoRA quantization layer adaptation strategy based on the parameter gradient sensitivity distribution; Based on the aforementioned hierarchical adaptation strategy, the quantization bit width and low-rank matrix rank value are configured for different layers of the base model to generate differentiated quantization configuration schemes. Based on the differentiated quantization configuration scheme and the fine-tuning training dataset, multi-GPU parallel fine-tuning training is initiated, and the training loss curve and gradient distribution characteristics are collected in real time through Swanlab. Based on the training loss curve and the gradient distribution characteristics, identify the overfitting risk zone and dynamically adjust the learning rate decay strategy and LoRA weight update frequency. The fine-tuned model weights are merged and exported with the differentiated quantization configuration scheme, converted to an Ollama-compatible format, and a model service configuration file is generated. Based on the model service configuration file, the model inference service is deployed through a Docker container and connected to the Open WebUI to build an interactive question-and-answer interface for real estate business.
2. The method according to claim 1, characterized in that, The generated corpus quality score matrix includes: The frequency of each triplet in the domain knowledge triplet set in the original corpus is counted and denoted as the domain coverage frequency. Calculate the mean semantic similarity between each triplet and triplets of the same type, and denote it as the semantic association density. The domain coverage frequency and the semantic association density are normalized and then weighted and summed to generate a quality score for each triple. The corpus quality score matrix is constructed using the quality score of each triple as an element, with entity term category as the row index and clause structure category as the column index.
3. The method according to claim 1, characterized in that, The fine-tuning training dataset for constructing the adaptive pedestal model input length includes: Based on the corpus quality scoring matrix, the original corpus is divided into a high-quality layer, a medium-quality layer, and a low-quality layer. For high-quality corpora, complete text is retained; for medium-quality corpora, sliding window truncation is performed according to the maximum input length; and for low-quality corpora, filtering and elimination are performed. Perform semantic integrity checks on the beginning and end of the truncated segments, and prioritize merging semantically incomplete segments with adjacent segments before re-truncating them; The filtered and truncated corpus is uniformly formatted into a command-input-output ternary structure to generate the fine-tuning training dataset.
4. The method according to claim 1, characterized in that, The hierarchical adaptation strategy for determining QLoRA quantization includes: The base model is propagated forward and backward using random sampling batches of the fine-tuned training dataset, and the gradient norm of each Transformer layer is recorded. Normalize the gradient norm of each layer and calculate the gradient sensitivity value of each layer parameter; Layers with parameter gradient sensitivity values higher than a preset sensitivity threshold are marked as high-sensitivity layers, and the rest are marked as low-sensitivity layers; The layer adaptation strategy is formed by configuring a higher quantization bit width and a larger low-rank matrix rank value for the high-sensitivity layer, and a lower quantization bit width and a smaller rank value for the low-sensitivity layer.
5. The method according to claim 1, characterized in that, The dynamic adjustment strategy for learning rate decay and LoRA weight update frequency includes: A moving average is applied to the training loss curve to calculate the sequence of differences between the training set loss and the validation set loss; When the difference sequence monotonically increases within a consecutive preset number of steps, the corresponding training step interval is marked as an overfitting risk interval. Within the overfitting risk range, the learning rate is reduced by a preset ratio and the LoRA weight update frequency is decreased. After the overfitting risk period ends, the learning rate and LoRA weight update frequency are restored to the initial configuration.
6. The method according to claim 1, characterized in that, The generated model service configuration file includes: The fine-tuned LoRA weight matrix is merged with the original weights of the base model according to the differentiated quantization configuration scheme to obtain the merged weight file; The numerical distribution offset of the weights of each layer in the merged weight file is statistically analyzed, and layers with offsets exceeding a preset threshold are corrected by weighting. Convert the corrected merged weight file to GGUF format to generate an Ollama-compatible model file; Configure inference temperature, maximum generation length, and context window parameters according to the needs of real estate business scenarios, and generate the model service configuration file.
7. The method according to claim 3, characterized in that, The step of performing semantic integrity verification on the truncated segment includes: Extract the first and last sentences of each truncated segment, and calculate their cosine similarity with the semantic vector of the segment's main body. When the cosine similarity of the first or last sentence is lower than the preset integrity threshold, the segment is determined to be a semantically incomplete segment. The semantically incomplete segments are preferentially merged with adjacent segments and then truncated again according to the maximum input length; If the length after merging still exceeds the limit, then re-segment the data at the semantic boundary, retaining the sub-segment with the highest semantic integrity score.
8. The method according to claim 4, characterized in that, The calculation of the gradient sensitivity values of each layer parameter includes: Calculate the mean and standard deviation of the gradient norm of all Transformer layers to construct a global baseline for the gradient norm distribution; The standardized gradient norm is obtained by subtracting the mean of the global distribution baseline from the gradient norm of each layer and then dividing by the standard deviation. The standardized gradient norm is subjected to a Sigmoid transformation and mapped to the interval of 0 to 1 to obtain the parameter gradient sensitivity value. For layers whose sensitivity values fluctuate beyond a preset fluctuation threshold, the moving average of their sensitivity values is used as the final sensitivity value.
9. The method according to claim 6, characterized in that, The step of weighting and correcting layers whose offset exceeds a preset threshold includes: Calculate the mean and kurtosis of the weights of each layer in the merged weight file and compare them with the baseline distribution of the corresponding layer before fine-tuning. Layers with mean deviation or kurtosis deviation exceeding a preset threshold are marked as distribution anomaly layers; The original scaling factor is replaced by an adaptive scaling factor based on minimizing quantization error for the distribution anomaly layer. The weights of the distribution anomaly layer are requantized using the replaced scaling factor, and the results are written back to the merged weight file.
10. The method according to claim 1, characterized in that, The construction of an interactive question-and-answer interface for real estate business includes: Based on the model service configuration file, construct a Docker container startup script that includes the model file path, inference parameters, and resource limits; After starting the Docker container, the inference service is preheated using a standard set of questions in the real estate field to evaluate inference latency and output quality. Based on the preheating test results, the inference temperature and context window parameters are fine-tuned, and the model service configuration file is updated. Register the adjusted inference service interface to Open WebUI, configure the real estate business-specific prompt word template and session context management strategy, and build the interactive question-and-answer interface.