A near-infrared detection method for polysaccharide content of radix comphoric oral liquid

CN122889155APending Publication Date: 2026-10-09SHANDONG ACAD OF CHINESE MEDICINE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611391984.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-09
Publication Date
2026-10-09

AI Technical Summary

Technical Problem

当前行业内针对中药口服液有效成分定量,普遍采用偏最小二乘回归等线性建模方法,但潞党参口服液属于复杂水基体系,光谱易受水体强吸收、基线漂移、微量浊度散射及仪器随机噪声的叠加干扰,光谱信号与多糖含量之间存在显著的非线性映射关系,线性模型的特征拟合能力有限,无法充分挖掘光谱深层非线性信息,普遍存在预测精度偏低、抗干扰能力不足、泛化性能有限的问题

Benefits of technology

1、无需复杂化学前处理与试剂消耗,单样品全流程检测时长不超过1分钟,相比传统湿法检测效率提升数十倍,可实现大批量样品快速筛查与生产过程快速筛查,显著降低质控成本;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122889155A_ABST
    Figure CN122889155A_ABST
Patent Text Reader

Abstract

The application discloses a kind of near-infrared detection methods for polysaccharide content of Lu Dangshen oral liquid, and relates to the technical field of rapid detection of traditional Chinese medicine quality, including collecting the near-infrared spectrum of multiple batches of oral liquid and dividing data set;Through double strategy expansion training set, alleviate the overfitting risk under small sample scene;Construct multiscale residual CNN, bidirectional LSTM and waveband attention three-branch heterogeneous fusion network, with phased four-component joint loss function, fusion robust regression loss and trainable spectral chemical prior constraint complete model training;Introduce regression type Grad-CAM heat map to evaluate the consistency of model feature learning and preset spectral chemical prior.The method is fast and non-destructive, the results show that the model attention area is consistent with the preset carbohydrate absorption area, suitable for Lu Dangshen oral liquid production process quality detection, finished product sampling and batch stability evaluation, and provides reliable technical support for intelligent quality control of traditional Chinese medicine preparations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of rapid detection technology for the quality of traditional Chinese medicine, and in particular to a near-infrared method for detecting the polysaccharide content of Codonopsis pilosula oral liquid. Background Technology

[0002] Codonopsis pilosula oral liquid is a commonly used tonic traditional Chinese medicine preparation in clinical practice. Codonopsis pilosula polysaccharides are one of the important chemical components of this oral liquid, and their content can be used as one of the indicators for evaluating the quality of the preparation. It is a core indicator for enterprise internal control and drug quality evaluation. At present, enterprises routinely use the phenol-sulfuric acid colorimetric method to determine the polysaccharide content. This method has drawbacks such as cumbersome operation procedures, detection cycles of several hours, large consumption of chemical reagents, and destructive nature of samples. It cannot achieve real-time online detection during the production process and cannot meet the efficiency requirements of industrial batch quality control.

[0003] Near-infrared spectroscopy, with its advantages of being rapid, non-destructive, pollution-free, and requiring no complex pretreatment, has gradually become the mainstream technology for rapid quality testing of traditional Chinese medicine preparations. Currently, the industry generally uses linear modeling methods such as partial least squares regression for the quantification of effective components in oral liquids of traditional Chinese medicine. However, Codonopsis pilosula oral liquid is a complex water-based system, and its spectrum is easily affected by strong absorption in water, baseline drift, trace turbidity scattering, and the superposition of random instrument noise. There is a significant nonlinear mapping relationship between the spectral signal and the polysaccharide content. The feature fitting ability of linear models is limited, and they cannot fully explore the deep nonlinear information of the spectrum. They generally suffer from low prediction accuracy, insufficient anti-interference ability, and limited generalization performance.

[0004] In recent years, deep learning models such as convolutional neural networks and long short-term memory networks have begun to be applied to near-infrared spectroscopy quantitative analysis due to their powerful nonlinear fitting capabilities. However, in actual production and experimental scenarios, the preparation of high-quality calibration samples is costly and difficult to obtain. Small sample datasets can easily lead to problems such as overfitting and unstable parameter convergence in deep learning models. Moreover, existing spectral data enhancement methods often use indiscriminate random perturbation, lacking constraints on spectrochemical mechanisms, which can easily introduce invalid or even distorted samples, making it difficult to guarantee model robustness. At the same time, existing near-infrared deep learning methods usually only use data-driven approaches to learn spectral features, without jointly constraining the chemical correlation between the feature absorption regions and the prediction targets in the complex water-based system of traditional Chinese medicine liquids. This can lead to inconsistencies between the feature regions learned by the model and the actual chemical contribution regions, making it impossible to intuitively verify whether the model has effectively learned the spectral absorption feature information related to polysaccharide content. The detection results lack chemical mechanism support, making it difficult to meet the scientific and traceability supervision requirements of traditional Chinese medicine quality evaluation.

[0005] In summary, existing near-infrared detection technologies for polysaccharides in Codonopsis pilosula oral liquid suffer from multiple technical bottlenecks, including insufficient nonlinear fitting ability of linear models, poor robustness of models in small sample scenarios, and lack of interpretability and mechanism verification of model prediction results. There is an urgent need for a solution to address the problem that existing near-infrared deep learning models cannot simultaneously take into account local spectral absorption characteristics, global sequence relationships, and chemical prior constraints. Summary of the Invention

[0006] To address the aforementioned issues, this application proposes a near-infrared detection method for the polysaccharide content of Codonopsis pilosula oral liquid. This method aims to resolve the technical problems of strong absorption interference from water bodies, limited sample quantity, and the difficulty of effectively extracting polysaccharide-related spectral features using traditional models in near-infrared detection of Codonopsis pilosula oral liquid. The specific steps are as follows: S1. Collect the original near-infrared spectra of multiple batches of oral liquid samples, and simultaneously use standard methods to determine the true value of polysaccharide content of each sample to construct a raw dataset with paired spectra and content. S2. The original dataset is divided into training set, validation set and test set using a sample set partitioning algorithm. Under the condition that the test set does not participate in the selection of preprocessing schemes, the spectral preprocessing method is determined based on the training set and validation set, and the determined preprocessing method is used to process each dataset. S3. Perform dual data augmentation on the training set, based on spectral acquisition perturbation features and conditional generative spectral synthesis, to obtain the augmented training set. S4. Construct an improved 1D-CNN-LSTM hybrid deep learning quantitative model. The model adopts a three-branch heterogeneous fusion architecture that combines multi-scale residual convolution, bidirectional LSTM temporal modeling and spectral band attention. It adopts a joint loss function that includes a robust regression term, attention weights and spectral prior consistency constraints and a concentration-absorption consistency constraint, and adopts a training strategy that gradually introduces each loss component in stages. The attention weight and spectral prior consistency constraint term is constructed based on the consistency between the learnable band attention weight generated by the model and the preset spectrochemical prior weight. The concentration-absorption consistency constraint term is constructed based on the overall positive correlation direction between the model-predicted polysaccharide content and the sugar-related spectral response. The model training and optimization are completed based on the enhanced training set and validation set. Among them, the enhanced training set is used for model training, the validation set is used for model optimization, and the test set is used for model performance evaluation. It does not participate in model parameter training, hyperparameter optimization, or early stopping judgment. S5. After preprocessing the near-infrared spectrum of the oral liquid sample to be tested in the same way as the training set, input it into the trained improved 1D-CNN-LSTM hybrid deep learning quantitative model, and output the predicted detection results of polysaccharide content.

[0007] Preferably, the preprocessing in S2 uses the selected SG0_SNV preprocessing pipeline, which first removes spectral noise by smoothing with an 11-point window and a third-order polynomial Savitzky-Golay convolution, and then corrects baseline drift and optical path difference by standard normal variable transformation. The sample set partitioning algorithm is the SPXY joint distance partitioning algorithm, and the joint distance between samples is calculated using the following formula: ; in, For the sample p With sample q Euclidean distance in spectral space, For the sample p With sample q The distance in the content space; By normalizing the two spatial distances separately and then adding them together, we can ensure that each dataset has complete distribution coverage in both the spectral and content dimensions. After the partitioning is complete, the mean and standard deviation of each wavenumber point are calculated based only on the original training set, and Z-score normalization is performed on the entire dataset using the following formula: σ ; In the formula, The arithmetic mean of each wavenumber in the training set spectrum. σ The standard deviation of each wavenumber in the training set spectrum is used to avoid information leakage between the validation and test sets.

[0008] Preferably, the data augmentation based on spectral acquisition perturbation features described in S3 includes random polynomial baseline drift, Gaussian noise addition, and small wavenumber axis shift, expanding the training samples by a set factor, and using a small perturbation of the target value as a regression regularization method during model training. The conditional generative spectral synthesis employs a conditional Wasserstein generative adversarial network cWGAN-GP with gradient penalty, using polysaccharide content as a conditional input to generate synthetic samples that conform to the true spectral distribution. These synthetic samples are then merged with spectral perturbation enhancement samples to form the final enhanced training set.

[0009] Preferably, before model training, a Bayesian optimization algorithm is used to automatically optimize hyperparameters, with the optimization objective being to minimize the average root mean square error of 5-fold cross-validation. The objective function is calculated as follows: ; in, This represents the hyperparameter vector to be optimized. For the hyperparameter search space, For cross-validation folds, For the first The root mean square error on the validation set; The objective function is fitted based on a Gaussian process surrogate model. The expected improvement acquisition function is used to guide iterative sampling, and the optimal combination of hyperparameters, such as learning rate, number of convolutional channels, LSTM hidden layer dimension, Dropout ratio, and weight decay coefficient, is obtained through Bayesian optimization.

[0010] Preferably, in S4, the three-branch heterogeneous fusion architecture specifically includes: The multi-scale residual CNN branch uses multiple one-dimensional convolutional kernels of different sizes to extract local narrowband absorption features of the spectrum in parallel. After residual connection and global average pooling, these features are mapped to a unified feature vector in the first dimension. The bidirectional LSTM branch uses a multi-layer bidirectional long short-term memory network to capture the global sequence dependence and broadband absorption features of the entire spectrum, which are then mapped to a unified feature vector in the second dimension after layer normalization. The spectral band attention branch averages and aggregates the 64×778-dimensional feature map output from the CNN branch along the channel dimension, obtaining a 778-dimensional wavenumber position feature vector while retaining 778 wavenumber positions. This vector is then passed through a fully connected layer that maps from 778 dimensions to 97 dimensions to enhance the feature contribution of polysaccharide-related bands. After convolutional pooling, it is mapped to a unified feature vector in the third dimension. The feature vectors output from the three branches are fused by an adaptive fusion layer with learnable weights and then input into a multi-layer deep regression head, ultimately outputting the predicted polysaccharide content.

[0011] Preferably, the multi-scale residual CNN branch uses five convolutional kernels with sizes of 3, 5, 7, 11, and 15 to extract features in parallel, and the average of the multi-path convolutional outputs is connected to the input residual of the 1×1 convolution; the spectral band attention branch generates attention weights in the 0~1 range through two-level fully connected layers and a Sigmoid activation function, adaptively reducing the weight ratio of the water strong absorption band.

[0012] Preferably, in S4, the joint loss function is introduced in stages using a training strategy. The training process is divided into three stages, and the loss function for each stage is calculated using the following formula: First training phase (epoch 0~49): Only Huber loss is used. Complete the training of the model's basic regression capabilities; Second training phase (epochs 50-149): Introducing Cauchy loss. This improves the model's robustness to outliers; The third training phase (from epoch 150 until the end of model training, with a maximum of 1000 training epochs): fully utilizes all loss components and introduces trainable spectrochemical prior constraints. ,The guided model focuses on spectral feature regions related to polysaccharide content.

[0013] Preferably, the joint loss function comprises four components: Huber loss, Cauchy loss, band prior constraint, and concentration-absorption consistency constraint. Each component is calculated using the following formula: (1) Huber Loss: When the absolute value of the prediction error is less than the threshold δ, the squared error is used, and when it is greater than δ, the absolute error is used. It has good robustness to outliers. ; in, To predict the polysaccharide content for the i-th sample using the model, Let be the true value of the polysaccharide content of the i-th sample. The learnable error threshold (lower bound is 0.1). The number of samples; (2) Cauchy Loss: ; Where c is the learnable scale parameter, with a lower bound set to 0.01. For the number of samples, this loss has a gentler effect on extreme errors.

[0014] (3) Band prior constraints: Based on the consistency between the learnable band attention weights generated by the model and the preset spectrochemical prior weights, the preset spectrochemical prior weights are set according to the sugar-related absorption region and the water-strong absorption region, which are used to improve the feature contribution of the sugar-related absorption region and reduce the interference of the water-strong absorption region. ; in, The learnable band attention weights for the nth training sample at the i-th wavenumber point. The preset spectrochemical prior weights for the i-th wavenumber point, This represents the number of samples in the current training batch. Wavenumber points ( =778); the preset spectrochemical prior weights are 1.0 in the carbohydrate-related absorption region, 0.05 in the water-strong absorption region, and 0.5 in other regions; (4) Concentration-absorption consistency constraint: Based on the overall positive correlation trend between the polysaccharide content predicted by the model and the average spectral response of the sugar-related absorption region, it is used to constrain the consistency between the model prediction results and the polysaccharide-related spectral response in the overall positive correlation direction; M ; ; in, To predict the polysaccharide content for the i-th sample using the model, The average spectral response value of the i-th sample in the carbohydrate-related absorption band is taken from the model input spectrum after Z-score normalization. This represents the batch sample size. Preferably, after the model training is completed, an interpretability verification step is also included: Using the regression-based Grad-CAM method, the band attention heatmap is generated by calculating the following formula: First, calculate the gradient of the model's predicted value with respect to the k-th feature map output by the last parallel one-dimensional convolutional submodule with a kernel size of 15 in the multi-scale residual CNN branch: ; in, Indicates the first Each feature map at wavelength position The change in predicted content value when the activation value at a location changes by one unit is the "local contribution sensitivity" of that feature-location to the prediction. The model predicts the content value. This is the k-th feature map; Global average pooling is used to obtain the feature channel importance weights: ; In the formula, N is the number of wavelength points in the feature map; The final heatmap is obtained by weighted summation followed by ReLU activation: ; By comparing the degree of agreement between the highly activated regions of the heatmap and the spectral absorption characteristics related to polysaccharide content, we can assess whether the spectral regions on which the model predictions depend are consistent with the preset spectrochemical priors.

[0015] Preferably, the method is applied to rapid quality testing, batch sampling of finished products, and rapid evaluation of formulation stability in the production process of Codonopsis pilosula oral liquid; The model's coefficient of determination R on the independent test set 2 The error rate should be no less than 0.90, the predicted residual ratio (RPD) should be no less than 3.0, and the detection time for a single sample should not exceed 1 minute.

[0016] In summary, the near-infrared detection method for polysaccharide content in Codonopsis pilosula oral liquid of the present invention has the following advantages compared with traditional technologies: 1. No complex chemical pretreatment or reagent consumption is required. The entire process of single sample detection takes no more than 1 minute, which is dozens of times more efficient than traditional wet detection. It can realize rapid screening of large batches of samples and rapid screening of the production process, significantly reducing quality control costs. 2. By fully exploring the nonlinear mapping relationship between spectra and content through a three-branch heterogeneous fusion architecture, and combining it with a joint loss function that constrains the training direction using trainable spectrochemical prior constraints, the test set determination coefficient R0 is achieved. 2 The prediction error can reach 0.92, which is 48.5% lower than that of the traditional PLS linear model. The prediction residual ratio RPD reaches 3.54, indicating that the model has good quantitative prediction ability. 3. In the above model training process, spectral perturbation enhancement and conditional generative spectral synthesis are further adopted to improve the training stability under limited sample conditions. Combined with Bayesian hyperparameter automatic optimization, overfitting can be effectively suppressed in scenarios with limited calibration samples, ensuring stable convergence of model parameters and solving the pain point of high cost and small quantity of calibration samples in actual production. 4. The model incorporates a regression-based Grad-CAM heatmap and input gradient significance analysis for interpretability verification. The high-contribution spectral regions of the model show good consistency with carbohydrate-related absorption bands. The detection results are supported by spectrochemical priors, breaking through the limitations of the black box in traditional deep learning and meeting the scientific and traceability regulatory requirements for the quality evaluation of traditional Chinese medicine.

[0017] The technical method of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description

[0018] Figure 1 A technical flowchart of a near-infrared detection method for polysaccharide content in Codonopsis pilosula oral liquid; Figure 2 The image shows the near-infrared spectrum and polysaccharide content distribution of the sample. Figure 2 (a) in the diagram is a schematic diagram of the original near-infrared spectrum. Figure 2 (b) in the diagram is a schematic of the spectrum after preprocessing. Figure 2 (c) in the diagram is a schematic diagram of the polysaccharide content distribution. Figure 2 (d) in the diagram is a schematic of the average spectrum; Figure 3 This is a comparison of the synthetic spectrum of cWGAN-GP with the target value distribution, where, Figure 3 (a) in the diagram is a comparison of the synthesized spectra of cWGAN-GP. Figure 3 (b) in the diagram is a comparison of the distribution of target values; Figure 4 This is a comparison chart of the prediction results of five regression models, where... Figure 4 (a) shows the prediction results of the PLS model. Figure 4 Image (b) shows the prediction results of the 1D-CNN model. Figure 4 (c) shows the prediction results of the LSTM model. Figure 4 The middle (d) graph shows the prediction results of the MSE-Model. Figure 4 (e) shows the prediction results of the Patent-Full model; Figure 5 The image shows the attention heatmap for the Patent-Full model Grad-CAM, where... Figure 5 (a) in the figure is a schematic diagram of the spectrum of the test sample after preprocessing. Figure 5 (b) in the diagram is a schematic diagram of Grad-CAM attention heatmap; Figure 6 Input a gradient significance analysis comparison chart for samples of different concentrations, where, Figure 6 (a) in the diagram is a comparison of the significance of the input gradient for low-concentration samples. Figure 6 (b) in the diagram is a comparison of the significance of the input gradient for medium-concentration samples. Figure 6 (c) in the diagram is a comparison of the significance analysis of the input gradient for high-concentration samples. Detailed Implementation

[0019] The technical method of the present invention will be further described below with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values ​​of the components and steps described in these embodiments do not limit the scope of this application.

[0020] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the scope of this application and its application or use.

[0021] Techniques, systems, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, they should be considered part of the instruction manual.

[0022] In all the examples shown and discussed herein, any specific values ​​should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values.

[0023] Unless otherwise defined, the technical or scientific terms used in this invention shall have the ordinary meaning as understood by one of ordinary skill in the art to which this invention pertains.

[0024] Example 1 This embodiment constructs and verifies the performance of a near-infrared detection model for polysaccharide content in Codonopsis pilosula oral liquid. A technical flowchart of a near-infrared detection method for polysaccharide content in Codonopsis pilosula oral liquid is shown below. Figure 1 As shown.

[0025] 1. Experimental sample and spectral data acquisition.

[0026] This embodiment uses Codonopsis pilosula oral liquid as the research object, and collects a total of 143 samples of Codonopsis pilosula oral liquid from 15 production batches (batch numbers: 20220919, 20230127, 20230719, 20230912, 20230913, 20231203, 20231257, 20240120, 20240123, 20240247, 20240311, 20240430, 20240915, 20241012, 20241223). Each batch number contains 8 to 11 samples, covering the normal production content fluctuation range.

[0027] Diffuse transmission mode spectra were acquired using a Thermo Fisher Antaris II Fourier transform near-infrared spectrometer, with a spectral scanning range of 10000–4000 cm⁻¹. -1 Spectral resolution of 8cm -1 The scan was performed 32 times. Each sample was measured in triplicate, and the average spectrum was used as the original spectrum for that sample. Each spectrum contained 778 wavenumber sampling points. The polysaccharide content of each sample was simultaneously determined using the phenol-sulfuric acid colorimetric method, in mg / mL, and used as label data for model training.

[0028] The polysaccharide content of the 143 samples ranged from 64.12 to 82.34 mg / mL, with a mean of 74.87 mg / mL and a standard deviation of 3.90 mg / mL. The spectral distribution and target value distribution before and after SG0_SNV pretreatment are shown in the attached figure. Figure 2 As shown, the overall concentration range covers 64.12–82.34 mg / mL, and the sample distribution is representative of the model.

[0029] 2. Spectral preprocessing and dataset partitioning.

[0030] 2.1 Dataset partitioning.

[0031] The SPXY (Sample Set Partitioning based on joint XY distances) algorithm was used to partition the 143 samples, resulting in training, validation, and test sets at proportions of 65%, 15%, and 20%, respectively. The formula for calculating the joint distance between samples using the SPXY algorithm is as follows: ; in, For the sample p With sample q Euclidean distance in spectral space, For the sample p With sample qThe distance in the content space is considered. By normalizing the distances in the two spaces and then summing them, we avoid the single spatial distance from dominating sample selection. This ensures that each dataset has complete distribution coverage in both the spectral and content dimensions, and that each independent sample belongs to only one dataset in the training, validation, or test sets. There is no overlap between the training and test sets for the same sample and its derived data.

[0032] The partitioning results are as follows: 93 training sets, 22 validation sets, and 28 test sets. The concentration ranges from 64.1 to 81.7 mg / mL in the training set, 64.7 to 81.7 mg / mL in the validation set, and 64.8 to 82.3 mg / mL in the test set. The concentration ranges of the three sets are basically consistent, ensuring the reliability of the model's generalization performance evaluation.

[0033] 2.2 Screening of preprocessing methods.

[0034] To reduce interference from water scattering, baseline drift, and random instrument noise, this embodiment constructs six pretreatment pipelines for automated comparison and screening, namely SG0_SNV, SG1_SNV, SG1_MSC, SG2_SNV, SG1_SNV_Detrend, and SG1 without normalization.

[0035] Where SG represents Savitzky-Golay convolution smoothing, the number represents the derivative order, SNV is standard normal variable transformation, MSC is multivariate scattering correction, and Detrend is detrending correction.

[0036] The selection method is as follows: each candidate preprocessing pipeline processes the spectra of the training and validation sets respectively; a PLS model is built on the training set and its performance is evaluated on the validation set; the principal component number search range is 2~15; and the validation set determination coefficient R is used. 2 The highest-performing pipeline is the optimal pipeline. After screening, the SG0_SNV pipeline performed optimally, and the validation set R... 2 The value reached 0.564, corresponding to an optimal principal component count of 14. It should be noted that the validation set R in the preprocessing and screening stage... 2 =0.564 represents the initial screening result for each candidate preprocessing pipeline. After determining SG0_SNV, Z-score normalization based solely on training set parameters is further employed to rebuild the final PLS baseline model.

[0037] The specific process of the optimal pipeline is as follows: First, the SG smoothing algorithm with a window length of 11, a polynomial order of 3, and a 0th derivative is used to filter out high-frequency noise in the spectrum. Then, the optical path difference and baseline drift are corrected by the standard normal variable transformation (SNV) to obtain the purified standardized spectrum.

[0038] 2.3 Data normalization.

[0039] Calculate the arithmetic mean for each wavenumber point based on only 93 samples from the original training set. with standard deviation σ The validation set and test set adopt the above. and σ Z-score normalization was performed; for the subsequently generated spectral perturbation-enhanced samples and cWGAN-GP synthesized samples, the same set of parameters determined from the original training set was used. and σ Perform Z-score normalization: σ ; Normalization parameters do not incorporate any statistical information from the validation and test sets, thus avoiding inflated model performance due to data leakage.

[0040] 3. Dual data augmentation and expansion of the training set.

[0041] To address the overfitting issue in small-sample modeling, a dual augmentation strategy combining spectral perturbation enhancement and cWGAN-GP synthesis enhancement is adopted to expand the training sample size.

[0042] 3.1 Enhanced spectral perturbation.

[0043] An enhancement method was designed based on the actual interference mechanism during near-infrared spectral acquisition. Six additional perturbation-enhanced spectra were generated for each original training set spectrum, while retaining the original 93 training samples. The specific method is as follows: (1) Baseline drift enhancement: A random third-order polynomial baseline is superimposed on the spectrum, with the polynomial coefficients uniformly distributed in the range of [-0.08, 0.08] to simulate the baseline fluctuation interference in actual detection; (2) Random noise addition: Gaussian noise with a mean of 0 and a standard deviation of 0.8% of the original spectrum standard deviation is superimposed on the spectrum to simulate the random noise of the instrument; (3) Wavenumber shift: The spectrum is randomly shifted by ±1 wavenumber point with a 50% probability to simulate the systematic shift error of the wavenumber axis; (4) Slight perturbation of target value: Add random noise within ±2% to the true value of polysaccharide content of the corresponding sample as a regression regularization method to avoid mechanical overfitting of concentration and spectral features.

[0044] After the above enhancements, 93 original training samples and 558 perturbation-enhanced samples were obtained, for a total of 651 samples.

[0045] 3.2 Conditional spectral synthesis of cWGAN-GP.

[0046] A conditional Wasserstein generative adversarial network with gradient penalty (cWGAN-GP) is used to generate highly realistic synthetic spectra, further supplementing the training samples.

[0047] The generator network structure is as follows: the input consists of a 1-dimensional polysaccharide content conditional value and 128-dimensional random noise, which are concatenated to form a 129-dimensional input vector. This vector is then passed through four fully connected layers: the first layer maps from 129 dimensions to 512 dimensions, introduces nonlinearity through the ReLU activation function, and then uses BatchNorm for batch normalization to stabilize the training distribution; the second layer expands from 512 dimensions to 1024 dimensions, also using ReLU and BatchNorm; the third layer further expands to 2048 dimensions, which is the layer with the highest hidden dimension, giving the model sufficient capacity to learn the complex structure of the spectrum; the fourth layer compresses the 2048-dimensional features back to 778 dimensions, consistent with the wavenumber of the real near-infrared spectrum, and finally outputs a synthetic near-infrared spectrum.

[0048] The discriminator network structure is as follows: The input 778-dimensional spectrum and 1-dimensional content conditions are concatenated to form a 779-dimensional vector. The first fully connected layer performs matrix multiplication with this vector using a 512-row, 779-column weight matrix. The result is then added with a 512-dimensional bias to output a 512-dimensional vector. Subsequently, each element is passed through LeakyReLU, with positive values ​​preserved as is and negative values ​​multiplied by a very small constant (e.g., 0.01). Next, the second fully connected layer uses a 256-row, 512-column weight matrix and a 256-dimensional bias to transform it into a 256-dimensional vector, which is then passed through LeakyReLU again. The third fully connected layer uses a 128-row, 256-column weight matrix and a 128-dimensional bias to obtain a 128-dimensional vector, which is then passed through LeakyReLU a third time. Finally, the fourth fully connected layer uses a 1-row, 128-column weight matrix and a single scalar bias to output the spectral authenticity score.

[0049] The model training employs a gradient penalty mechanism with a gradient penalty coefficient λ=10, and the learning rate for both the generator and discriminator is 1×10. -4 The optimizer is Adam. In each training round, the discriminator is updated 5 times and the generator is updated once, for a total of 5000 training rounds. After training, 100 concentration values ​​are uniformly selected from the minimum to maximum range of the training set content as conditions to generate 100 corresponding synthetic spectra.

[0050] The 93 original training samples and 558 spectral perturbation-enhanced samples (a total of 651 samples) were merged with 100 samples synthesized by GAN, resulting in an enhanced training set of 751 samples. A comparison between the synthesized spectra generated by cWGAN-GP and the real spectra is attached. Figure 3 As shown, the overall profile and absorption peak positions of the synthesized spectrum are highly consistent with the real spectrum, and the concentration distribution matches the real training set, effectively supplementing the sample space.

[0051] 4. Hyperparameter Bayesian optimization.

[0052] A Bayesian optimization algorithm based on Gaussian processes is used to automatically optimize the key hyperparameters of the deep learning model. The objective function is to minimize the mean square error of 5-fold cross-validation. The objective function formula is as follows: ; in, This represents the hyperparameter vector to be optimized. For the hyperparameter search space, The cross-validation fold number is K=5 in this embodiment. For the first The root mean square error on the validation set is used. The 5-fold cross-validation is performed on 93 samples in the original training set. Each fold only performs spectral perturbation enhancement on the training samples of that fold, and the validation part does not participate in the enhancement to avoid information leakage.

[0053] The hyperparameters to be optimized and the search range are: learning rate 1×10⁻⁶ -5 ~1×10 -2 CNN convolutional layers have 16-128 channels, LSTM hidden layers have 32-256 dimensions, Dropout ratio is 0.05-0.5, and weight decay coefficient is 1×10⁻⁶. -6 ~1×10 -3 .

[0054] The optimization process is as follows: First, 10 sets of initial hyperparameters are randomly sampled within the search space for model evaluation. A Gaussian process surrogate model is used to fit the mapping relationship between the hyperparameters and the validation error. The expected improvement (EI) acquisition function guides the sampling of the next set of hyperparameters. The mean square error of the 5-fold cross-validation is used as the evaluation metric for each set of hyperparameters. A total of 50 iterations are performed to obtain the optimal hyperparameter combination obtained through Bayesian optimization: initial learning rate 8.15 × 10⁻⁶. -4 The CNN has 64 convolutional channels, the LSTM has 128 hidden layers, the Dropout ratio is 0.3, and the weight decay factor is 1.30 × 10⁻⁶. -4 .

[0055] 5. Compare with baseline model construction.

[0056] To verify the performance advantages of the present invention, four baseline models were simultaneously constructed for comparative experiments: (1) PLS regression model: trained on the preprocessed training set, with the principal component number optimally determined to be 14 as the baseline of the traditional linear method. The final PLS baseline model was re-established after SG0_SNV preprocessing and Z-score normalization, and its validation set R 2 It is 0.720; (2) 1D-CNN baseline model: A two-layer one-dimensional convolutional structure is adopted. The input is a normalized spectrum, which passes through the first one-dimensional convolutional layer. This layer has 64 convolutional kernels of size 5, with padding set to 2. Each convolutional kernel slides along the sequence to perform multiplication and addition operations, and outputs 64. Each of the 778-dimensional feature maps undergoes ReLU activation element-wise, retaining positive values ​​and truncating negative values ​​to 0. Then, each element is processed using BatchNorm, subtracting the mean of the feature map in the current batch, dividing by the standard deviation, multiplying by a learnable scaling parameter, and adding a learnable offset parameter. These feature maps then enter a second one-dimensional convolutional layer with 64 kernels, but with a kernel size increased to 7 and padding of 3. The convolution outputs 64 new 778-dimensional feature maps, which are again processed by ReLU and BatchNorm. Next, the average value of each feature map is taken at all 778 positions, compressing each of the 64 feature maps into a scalar. These scalars are then concatenated into a 64-dimensional global feature vector. Finally, a fully connected layer is passed through this layer. This layer performs matrix multiplication with the feature vector using a 1-row, 64-column weight matrix and adds a single scalar bias, outputting the final predicted content value. (3) LSTM baseline model: A 3-layer bidirectional LSTM structure is adopted, with a hidden layer dimension of 128. The predicted value is output after layer normalization and fully connected layer. (4) MSE-Model Ablation Model: The network structure is completely consistent with the model of this invention. Only a single MSE loss function is used for training to verify the gain effect of the joint loss function.

[0057] All deep learning baseline models use the same dataset partitioning, optimizer, learning rate scheduling, and early stopping principle; except for the structural parameters of each model, the other training settings are kept consistent.

[0058] 6. Construction and training of an improved 1D-CNN-LSTM hybrid model.

[0059] 6.1 Three-branch heterogeneous fusion network structure.

[0060] The Patent-Full model constructed in this invention adopts a heterogeneous fusion architecture of three branches: multi-scale residual CNN, bidirectional LSTM, and spectral band attention. The specific structure is as follows: (1) Multi-scale residual CNN branch: The normalized spectrum is transformed into (1,778) format input. Five parallel one-dimensional convolutions with kernel sizes of 3, 5, 7, 11 and 15 are used to extract multi-scale local features. The number of output channels of each channel is 64. After averaging the results of the five convolutions, they are added to the input features mapped by 1×1 convolution through residual connection. After ReLU activation and Dropout layer, the global average value of each feature map is taken over the entire sequence length to obtain a 64-dimensional global feature vector. Finally, it is passed through a fully connected layer that maps from 64 dimensions to 512 dimensions to output a 512-dimensional feature vector.

[0061] (2) Bidirectional LSTM branch: The normalized spectrum is transformed into (778,1) format input, processed by 3 layers of bidirectional LSTM, the hidden layer dimension is 128, and the inter-layer dropout is 0.3; after taking the mean in the time dimension, it is normalized by LayerNorm(256), and finally passed through a 256-dimensional fully connected layer to a 512-dimensional feature vector, outputting a 512-dimensional feature vector.

[0062] (3) Spectral Band Attention Branch: The 64×778-dimensional feature map output from the CNN branch is averaged and aggregated along the channel dimension to obtain a 778-dimensional wavenumber position feature vector while retaining 778 wavenumber positions. This vector is then passed through a fully connected layer that maps from 778-dimensional to 97-dimensional, and each element is activated by ReLU, retaining positive values ​​and truncating negative values ​​to 0. It is then passed through another fully connected layer that maps from 97-dimensional back to 778-dimensional, and each element is activated by Sigmoid, compressing the value of each element to between 0 and 1, generating a set of 778-dimensional attention weight vectors. The magnitude of each weight represents the importance of the corresponding wavenumber point in the prediction. This set of attention weights is multiplied element-wise by the 64×778-dimensional feature map output from the CNN branch, that is, the feature value of each feature channel at each wavenumber position is multiplied by the corresponding attention weight, achieving selective weighting of the spectrum. The weighted spectrum enters a one-dimensional convolutional layer with 64 kernels of size 3 and padding set to 1, outputting 64 feature maps with a length of 778. Then, each element is normalized by BatchNorm, the batch mean is subtracted, the result is divided by the standard deviation, multiplied by the scaling and offset parameters, and then activated by ReLU. The global average of each feature map is then taken over the entire sequence length, compressing the 64 feature maps into a 64-dimensional global feature vector. Finally, it passes through a fully connected layer that maps from 64 dimensions to 512 dimensions, outputting a 512-dimensional feature vector.

[0063] (4) Adaptive feature fusion layer: The 512-dimensional feature vectors output by the three branches are weighted and fused through learnable weights, with the initial weights being 1 / 3. The weighted sum is then added to the result of the three-way feature concatenation and a fully connected layer transformation from 1536-dimensional to 512-dimensional to obtain the final fused feature.

[0064] (5) Deep Regression Head: The fused features are normalized sequentially by BatchNorm, subtracted from the mean of the current batch, divided by the standard deviation, multiplied by the learnable scaling parameter, and then added with the learnable offset parameter. Next, they are activated element-wise by ReLU, with positive values ​​retained and negative values ​​truncated to 0. Then, they are passed through a Dropout layer, where some elements are randomly set to 0 with a probability of 0.3, and the remaining elements are scaled up proportionally to maintain the overall scale. The randomly deactivated feature vectors enter the first fully connected layer, which performs matrix multiplication with the feature vector using a 128-row, 512-column weight matrix and adds a 128-dimensional bias to output a 128-dimensional feature vector. This vector is then passed element-wise again by BatchNorm, ReLU, and Dropout, with the Dropout probability reduced to 0.15. Then, it enters the second fully connected layer, which uses a 64-row, 128-column weight matrix and a 64-dimensional bias to output a 64-dimensional feature vector. The vector passes through BatchNorm, ReLU, and Dropout element-wise for the third time. At this point, the Dropout probability is further reduced to 0.09. Finally, it enters the third fully connected layer, which uses a 1-row, 64-column weight matrix and a single scalar bias to compress it into a single scalar and output the final predicted polysaccharide content value.

[0065] 6.2 Staged four-component joint loss function.

[0066] A joint loss function combining four components—Huber loss, Cauchy loss, band prior constraint, and concentration-absorption consistency constraint—is adopted. Training is conducted through a three-stage progressively introduced strategy. The calculation formulas for each loss component are as follows: (1) Huber losses: ; in, To predict the polysaccharide content for the i-th sample using the model, Let be the true value of the polysaccharide content of the i-th sample. The learnable error threshold (lower bound is 0.1). This represents the number of samples.

[0067] (2) Cauchy loss: ; Where c is the learnable scale parameter, with a lower bound set to 0.01. For the number of samples, this loss has a gentler effect on extreme errors.

[0068] (3) Band Prior Constraints: Based on the consistency between the learnable band attention weights generated by the model and the preset spectrochemical prior weights, the preset spectrochemical prior weights are set according to the sugar-related absorption region and the water-intensive absorption region, which are used to improve the feature contribution of the sugar-related absorption region and reduce the interference of the water-intensive absorption region. The expression is as follows: ; in, The learnable band attention weights for the nth training sample at the i-th wavenumber point. The preset spectrochemical prior weights for the i-th wavenumber point, This represents the number of samples in the current training batch. Wavenumber points ( =778); the preset spectrochemical prior weights are 1.0 in the sugar-related absorption region, 0.05 in the water-strong absorption region, and 0.5 in the remaining regions.

[0069] In this embodiment, the carbohydrate-related absorption region is set to 4000-4500 cm⁻¹. -1 5500-6000 cm -1 and 6200-6500 cm -1 The water absorption zone is set at 5000-5300 cm. -1 and 6700-7100 cm -1 .

[0070] (4) Concentration-Absorption Consistency Constraint: Based on the overall positive correlation trend between the polysaccharide content predicted by the model and the average spectral response of the sugar-related absorption region, this constraint is constructed to ensure that the model prediction results and the polysaccharide-related spectral responses maintain the consistency of the overall positive correlation direction. Its expression is: M ; ; in, To predict the polysaccharide content for the i-th sample using the model, The average spectral response value of the i-th sample in the carbohydrate-related absorption band is taken from the model input spectrum after Z-score normalization. This represents the number of samples in the batch.

[0071] The phased training strategy is as follows: Phase 1 (epochs 0-49): Only Huber loss is enabled. Complete the basic regression capability training of the model; The second stage (epochs 50-149): Cauchy loss is introduced with a weight of 0.7:0.3. This enhances the model's ability to resist outlier interference. Phase 3 (epoch 150 and later): Utilize the full four-component joint loss, with weights of λHuber=0.45, λCauchy=0.35, λBand=0.12, and λMono=0.08. We introduce trainable spectrochemical prior constraints.

[0072] 6.3 Model training parameters.

[0073] The model was trained on a 751-part augmented training set, with 22 parts of the validation set used for early stopping and learning rate scheduling. The optimizer used was AdamW, with an initial learning rate of 8.15 × 10⁻⁶. -4 The weight decay coefficient is 1.30 × 10⁻⁶. -4 The learning rate scheduling strategy is to halve the learning rate if the validation set loss does not decrease for 20 consecutive rounds; the maximum number of training rounds is 1000, and the early stopping patience value is 80 rounds; the training process enables mixed precision training (AMP) and gradient clipping (maximum norm 5.0) to accelerate training and prevent gradient explosion.

[0074] 7. Model performance evaluation results.

[0075] Using the coefficient of determination R 2 The performance of each model was evaluated on an independent test set using three common metrics: Root Mean Square Error (RMSE), Predictive Residual Ratio (RPD), and Root Mean Square Error (RMSE). A scatter plot comparing the predicted and measured values ​​for each model is attached. Figure 4 The prediction performance of each model on the test set is compared in Table 1.

[0076] Table 1 Model performance evaluation results

[0077] The results show that the Patent-Full model test set R of this invention... 2 The RMSE was 1.41 mg / mL, and the RPD was 3.54, indicating that the model has good quantitative prediction ability. Compared with the traditional PLS model, the Patent-Full scheme reduced the RMSE by 48.5%; compared with the model with the same network structure but using only MSE loss, the RMSE was reduced by 37.0%, indicating that the joint loss and training strategy can further improve the prediction performance of the three-branch network.

[0078] 8. Verification by ablation experiment.

[0079] To verify the contributions of each component of the joint loss function and the dual data augmentation strategy to model performance, this embodiment further conducts ablation experiments. All ablation experiments used the same SPXY data partitioning, optimal hyperparameters, and training configuration as the Patent-Full model, changing only the single factor under investigation to ensure rigorous comparability of the experimental results. The results of the ablation experiments on the independent test set are shown in Tables 2 and 3.

[0080] Table 2 Results of combined loss ablation experiments

[0081] Table 2 shows that, based on Huber+Cauchy robust regression, the R² of the test set increased from 0.87 to 0.90 after introducing trainable spectrochemical prior constraints (band prior constraints); further introducing concentration-absorption consistency constraints increased the R² to 0.91; and after adopting a three-stage stepwise introduction strategy based on the four-component joint loss, the complete scheme achieved an R² of 0.92, an RMSE of 1.41 mg / mL, and an RPD of 3.54. The results indicate that both band prior constraints and concentration-absorption consistency constraints contribute to the model's predictive performance, and the complete scheme achieves the best predictive performance in this embodiment after adopting a stepwise introduction strategy.

[0082] Table 3 Results of Dual-Enhanced Ablation Experiments

[0083] Table 3 shows that without any data augmentation, the R² for the test set is only 0.78, and the RMSE is 2.35 mg / mL. With only spectral perturbation enhancement or only cWGAN-GP synthesis enhancement, the R² is 0.88 and 0.85, respectively. When both enhancement methods are used in combination, the R² reaches 0.92, and the RMSE decreases to 1.41 mg / mL. These results indicate that spectral perturbation enhancement and conditional generative spectral synthesis are complementary in improving the accuracy of small-sample modeling, and the dual enhancement strategy improves the predictive performance of independent test sets under small-sample conditions.

[0084] 9. Model interpretability verification.

[0085] To explain the predictive basis of the Patent-Full model, the regression-based Grad-CAM (Gradient-weighted Class Activation Mapping) method was used to visualize the model's attention regions on the test set samples. The spectral attention distribution of the model for a single test sample is shown in the attached figure. Figure 5 As shown.

[0086] The specific steps are as follows: The gradient of the output feature map of the last parallel one-dimensional convolutional submodule with a kernel size of 15 in the multi-scale residual CNN branch is calculated based on the predicted value of the calculation model. The importance weight of each channel is obtained by global average pooling. The weights are weighted and summed with the corresponding feature maps and then activated by ReLU to obtain the band attention heatmap. After upsampling to the original spectral resolution, it is superimposed with the average spectrum for display.

[0087] The core calculation formula is: Gradient calculation: ,in Indicates the first Each feature map at wavelength position The change in predicted content value when the activation value at a location changes by one unit is the "local contribution sensitivity" of that feature-location to the prediction. The model predicts the content value. This is the k-th feature map; Weight calculation: Where N is the number of wavelength points in the feature map; Heatmap generation: .

[0088] One sample each from the low-concentration (approximately 64.79 mg / mL), medium-concentration (approximately 75.67 mg / mL), and high-concentration (approximately 82.34 mg / mL) samples in the test set were selected. The absolute values ​​of the gradients of the predicted values ​​output by the model with respect to each wavenumber point in the input spectrum were calculated. The magnitude of the gradient value reflects the importance of that wavenumber point in the prediction process. The attention comparison results for the low, medium, and high concentration samples are attached. Figure 6 .

[0089] Validation results show that the model's high attention region is concentrated in the 4000~4500cm range. -1 (CH combination absorption band), 5500~6000cm -1 (CH first-order harmonic absorption band), 6200~6500cm -1 The characteristic absorption bands of carbohydrates, such as the OH bending and CH stretching combination band, are present in the 6700~7100cm range. -1 5000~5300cm -1 The attention weight of the water-intensity absorption band is relatively low, and it generally shows good consistency with the preset spectrochemical priors. This indicates that the high-contribution spectral regions on which the model predictions depend correspond to the sugar-related absorption regions, providing spectrochemical prior explanations for the model prediction results.

[0090] 10. Applications for detecting unknown samples.

[0091] For the sample of Codonopsis pilosula oral liquid to be tested, its raw near-infrared spectrum is directly acquired. After SG smoothing, SNV preprocessing and Z-score normalization consistent with the training set, it is input into the trained Patent-Full model to output the polysaccharide content prediction result. The total time from spectrum acquisition to result output for a single sample is less than 1 minute, which is much faster than the several hours of traditional wet detection. It meets the needs of scenarios such as rapid quality inspection in the production process, batch sampling inspection of finished products, and rapid evaluation of batch stability.

[0092] Finally, it should be noted that the above embodiments are only used to illustrate the technical methods of the present invention and not to limit them. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the technical methods of the present invention, and these modifications or equivalent substitutions cannot cause the modified technical methods to deviate from the spirit and scope of the technical methods of the present invention.

Claims

1. A near-infrared detection method for the polysaccharide content of Codonopsis pilosula oral liquid, characterized in that, Includes the following steps: S1. Collect the original near-infrared spectra of multiple batches of oral liquid samples, and simultaneously use standard methods to determine the true value of polysaccharide content of each sample to construct a raw dataset with paired spectra and content. S2. The original dataset is divided into training set, validation set and test set using a sample set partitioning algorithm. Under the condition that the test set does not participate in the selection of preprocessing schemes, the spectral preprocessing method is determined based on the training set and validation set, and the determined preprocessing method is used to process each dataset. S3. Perform dual data augmentation on the training set, based on spectral acquisition perturbation features and conditional generative spectral synthesis, to obtain the augmented training set. S4. Construct an improved 1D-CNN-LSTM hybrid deep learning quantitative model. The model adopts a three-branch heterogeneous fusion architecture that combines multi-scale residual convolution, bidirectional LSTM temporal modeling and spectral band attention. It adopts a joint loss function that includes a robust regression term, attention weights and spectral prior consistency constraints and a concentration-absorption consistency constraint, and adopts a training strategy that gradually introduces each loss component in stages. The attention weight and spectral prior consistency constraint term is constructed based on the consistency between the learnable band attention weight generated by the model and the preset spectrochemical prior weight. The concentration-absorption consistency constraint term is constructed based on the overall positive correlation direction between the model-predicted polysaccharide content and the sugar-related spectral response. Model training and optimization are completed based on enhanced training and validation sets; Among them, the enhanced training set is used for model training, the validation set is used for model optimization, and the test set is used for model performance evaluation. It does not participate in model parameter training, hyperparameter optimization, or early stopping judgment. S5. After preprocessing the near-infrared spectrum of the oral liquid sample to be tested in the same way as the training set, input it into the trained improved 1D-CNN-LSTM hybrid deep learning quantitative model, and output the predicted detection result of polysaccharide content.

2. The near-infrared detection method for polysaccharide content in Codonopsis pilosula oral liquid according to claim 1, characterized in that, In S2, the preprocessing uses the selected SG0_SNV preprocessing pipeline. First, spectral noise is removed by smoothing through 11-point window and third-order polynomial Savitzky-Golay convolution. Then, baseline drift and optical path difference are corrected by standard normal variable transformation. The sample set partitioning algorithm is the SPXY joint distance partitioning algorithm, and the expression for the joint distance between samples is: ; in, For the sample p With sample q Euclidean distance in spectral space, For the sample p With sample q The distance in the content space; After the partitioning is completed, the mean and standard deviation of each wavenumber point are calculated based on the original training set, and Z-score normalization is performed on the entire dataset.

3. The near-infrared detection method for polysaccharide content in Codonopsis pilosula oral liquid according to claim 1, characterized in that, Data augmentation based on spectral acquisition perturbation features in S3 includes random polynomial baseline drift, Gaussian noise addition, and small wavenumber axis shift. Training samples are expanded by a set factor. During model training, a small perturbation of the target value is also used as a regression regularization method. The conditional generative spectral synthesis employs a conditional Wasserstein generative adversarial network cWGAN-GP with gradient penalty, using polysaccharide content as a conditional input to generate synthetic samples that conform to the true spectral distribution. These synthetic samples are then merged with spectral perturbation enhancement samples to form the final enhanced training set.

4. The near-infrared detection method for polysaccharide content in Codonopsis pilosula oral liquid according to claim 1, characterized in that, Before model training, Bayesian optimization algorithm is used for automatic hyperparameter optimization, with the goal of minimizing the mean root square error of 5-fold cross-validation. The expression for the objective function is: ; in, This represents the hyperparameter vector to be optimized. For the hyperparameter search space, For cross-validation folds, For the first The root mean square error on the validation set; The objective function is fitted based on a Gaussian process surrogate model. The expected improvement acquisition function is used to guide iterative sampling, and the optimal combination of hyperparameters, such as learning rate, number of convolutional channels, LSTM hidden layer dimension, Dropout ratio, and weight decay coefficient, is obtained through Bayesian optimization.

5. The near-infrared detection method for polysaccharide content in Codonopsis pilosula oral liquid according to claim 1, characterized in that, The three-branch heterogeneous convergence architecture in S4 specifically includes: The multi-scale residual CNN branch uses multiple one-dimensional convolutional kernels of different sizes to extract local narrowband absorption features of the spectrum in parallel. After residual connection and global average pooling, these features are mapped to a unified feature vector in the first dimension. The bidirectional LSTM branch uses a multi-layer bidirectional long short-term memory network to capture the global sequence dependence and broadband absorption features of the entire spectrum, which are then mapped to a unified feature vector in the second dimension after layer normalization. The spectral band attention branch averages and aggregates the 64×778-dimensional feature map output from the CNN branch along the channel dimension, obtaining a 778-dimensional wavenumber position feature vector while retaining 778 wavenumber positions. This vector is then passed through a fully connected layer that maps from 778 dimensions to 97 dimensions to enhance the feature contribution of polysaccharide-related bands. After convolutional pooling, it is mapped to a unified feature vector in the third dimension. The feature vectors output from the three branches are fused by an adaptive fusion layer with learnable weights and then input into a multi-layer deep regression head, ultimately outputting the predicted polysaccharide content.

6. The near-infrared detection method for polysaccharide content in Codonopsis pilosula oral liquid according to claim 5, characterized in that, The multi-scale residual CNN branch uses five convolutional kernels with sizes of 3, 5, 7, 11 and 15 to extract features in parallel. The average of the multi-path convolutional outputs is then connected to the input residual of the 1×1 convolution. The spectral band attention branch generates attention weights in the 0~1 range through a two-level fully connected layer and a Sigmoid activation function.

7. The near-infrared detection method for polysaccharide content in Codonopsis pilosula oral liquid according to claim 6, characterized in that, In S4, the joint loss function is introduced in stages using a training strategy. The training process is divided into three stages, and the expression for the loss function in each stage is as follows: Epochs 0-49 constitute the first training phase: only Huber loss is used. Complete the training of the model's basic regression capabilities; Epochs 50-149 constitute the second training phase: Cauchy loss is introduced. This improves the model's robustness to outliers; The third training phase begins at epoch 150 and continues until the model training ends, with a maximum of 1000 training epochs: all loss components are fully utilized. We introduce trainable spectrochemical prior constraints to guide the model to focus on spectral feature regions related to polysaccharide content.

8. The near-infrared detection method for polysaccharide content in Codonopsis pilosula oral liquid according to claim 7, characterized in that, The joint loss function comprises four components: Huber loss, Cauchy loss, band prior constraint, and concentration-absorption consistency constraint. The expressions for each component are as follows: (1) Huber losses: ; in, To predict the polysaccharide content for the i-th sample using the model, Let be the true value of the polysaccharide content of the i-th sample. The learnable error threshold, The number of samples; (2) Cauchy loss: ; Where c is the learnable scale parameter, with a lower bound set to 0.

01. For the number of samples, this loss has a gentler effect on extreme errors; (3) Band Prior Constraints: Based on the consistency between the learnable band attention weights generated by the model and the preset spectrochemical prior weights, the preset spectrochemical prior weights are set according to the sugar-related absorption region and the water-intensive absorption region, which are used to improve the feature contribution of the sugar-related absorption region and reduce the interference of the water-intensive absorption region. The expression is as follows: ; in, The learnable band attention weights for the nth training sample at the i-th wavenumber point. The preset spectrochemical prior weights for the i-th wavenumber point, This represents the number of samples in the current training batch. The number of wavenumber points; the preset spectrochemical prior weights are 1.0 in the carbohydrate-related absorption region, 0.05 in the water-strong absorption region, and 0.5 in other regions; (4) Concentration-Absorption Consistency Constraint: Based on the overall positive correlation trend between the polysaccharide content predicted by the model and the average spectral response of the sugar-related absorption region, this constraint is constructed to ensure that the model prediction results and the polysaccharide-related spectral responses maintain the consistency of the overall positive correlation direction. Its expression is: M ; ; in, To predict the polysaccharide content for the i-th sample using the model, Let be the average spectral response value of the i-th sample in the carbohydrate-related absorption band. This represents the number of samples in the batch.

9. The near-infrared detection method for polysaccharide content in Codonopsis pilosula oral liquid according to claim 1, characterized in that, After model training is complete, an interpretability verification step is also included: Using the regression-based Grad-CAM method, the band attention heatmap is generated by calculating the following formula: First, calculate the gradient of the model's predicted value with respect to the k-th feature map output by the last parallel one-dimensional convolutional submodule with a kernel size of 15 in the multi-scale residual CNN branch: ; in, Indicates the first Each feature map at wavelength position The change in predicted content value when the activation value at a location changes by one unit is the "local contribution sensitivity" of that feature-location to the prediction. The model predicts the content value. This is the k-th feature map; Global average pooling is used to obtain the feature channel importance weights: ; In the formula, N is the number of wavelength points in the feature map; the final heatmap is obtained by weighted summation and ReLU activation: ; By comparing the degree of agreement between the highly activated regions of the heatmap and the spectral absorption characteristics related to polysaccharide content, we can assess whether the spectral regions on which the model predictions depend are consistent with the preset spectrochemical priors.