Cathode copper defect tracing method, system and program product based on rag retrieval
Patent Information
- Application Number
- CN202610902887.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-22
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2046-06-22
AI Technical Summary
然而,该类技术方案的核心仍主要集中在缺陷检出、尺寸测量或者合格与不合格的二元判断层面,尚未形成面向缺陷根因追溯的完整技术链路
[0042] This invention elevates the existing defect detection-oriented processing method to a defect tracing method oriented towards process cause analysis by constructing a complete technical chain of "diffusion-enhanced sample generation - multimodal feature extraction - RAG knowledge retrieval - expert closed-loop update". It can output corresponding inducing process causes and troubleshooting suggestions for cathode copper surface defects, thereby effectively solving the problem that existing technologies cannot support root cause tracing and process optimization.
Smart Images

Figure CN122473157B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electrolytic copper quality testing technology, and in particular to a method, system, and program product for tracing the source of cathode copper defects based on RAG retrieval. Background Technology
[0002] As downstream industries increasingly demand higher standards for the surface quality, consistency, and stability of cathode copper products, manufacturers are shifting their focus from simple defect detection to root cause analysis and process optimization. This means that companies not only need to know whether defects such as granules, pores, or deposits exist on the cathode copper plate surface, but also need to further determine the correlation between these defects and production process factors such as current density, electrolyte concentration, and electrode spacing, providing a basis for subsequent parameter adjustments and process optimization.
[0003] Current methods for detecting surface defects in cathode copper still heavily rely on manual inspection. Quality inspectors typically use visual observation to check both sides of the cathode copper plate one by one, and then make compliance judgments based on national standards and the company's internal quality specifications. While this method can achieve basic quality control, it suffers from problems such as low inspection efficiency, high labor costs, high labor intensity, and the judgment results being significantly affected by personnel experience and subjective factors.
[0004] With the application of machine vision technology in industrial inspection, some intelligent solutions have begun to be used for cathode copper defect detection. For example, existing technologies have disclosed various solutions based on area scan cameras, line scan cameras, infrared scan cameras, laser scanning, and 2D and 3D fusion detection. These solutions can, to a certain extent, detect, locate, measure the height of, or determine the conformity of local defects such as copper particles, and the detection efficiency is improved compared to manual methods. However, the core of these technical solutions is still mainly focused on defect detection, dimensional measurement, or binary judgment of conformity, and a complete technical chain for tracing the root cause of defects has not yet been formed.
[0005] Therefore, this invention proposes a method, system, and program product for tracing the source of cathode copper defects based on RAG retrieval. The information disclosed above in the background section is only used to enhance the understanding of the background of this disclosure, and therefore may contain prior art information that is not common knowledge to those skilled in the art. Summary of the Invention
[0006] The purpose of this invention is to address the shortcomings of existing technologies by providing a method, system, and program product for tracing the source of cathode copper defects based on RAG retrieval, thereby solving the technical problems mentioned in the background section.
[0007] To achieve the above objectives, the present invention provides the following technical solution:
[0008] The first part of this invention provides a method for tracing the source of cathode copper defects based on RAG retrieval, comprising the following steps:
[0009] S1. Construct a defect process RAG knowledge base, standardize and vectorize the defect feature descriptions and corresponding process causes in the historical defect records of cathode copper plates, and obtain a knowledge vector set.
[0010] S2. Construct a diffusion enhancement model to generate rare defect enhancement samples based on text prompts and defect region masks;
[0011] S3. Acquire two-dimensional color images and three-dimensional point cloud data of the cathode copper plate to be inspected, and spatially align the two-dimensional color images and three-dimensional point cloud data.
[0012] S4. Train a defect recognition model based on real defect samples and rare defect augmentation samples, extract two-dimensional semantic features and three-dimensional quantitative features of the cathode copper plate to be inspected and fuse them to form a standardized defect feature vector. Perform similarity retrieval and rule verification between the standardized defect feature vector and the knowledge vector set, and output standardized tracing results.
[0013] S5. Conduct expert closed-loop confirmation based on the standardized traceability results, and update the training samples and knowledge vector set based on the confirmation results.
[0014] S1 specifically includes: extracting the defect feature descriptions and corresponding process causes from the historical defect records of cathode copper plates in a structured manner to form a standardized set of knowledge items;
[0015] Standardized knowledge item sets are processed by unifying terminology, converting units, merging duplicates, and deleting ambiguous items.
[0016] The processed defect feature descriptions are vectorized and encoded, and the encoding results are associated with the corresponding process causes and stored in a lightweight vector database to obtain a knowledge vector set.
[0017] S2 specifically includes: an attention module that encodes text prompts into text feature vectors and inputs them into the U-Net feature extraction network, and adds a defect region mask input channel to the original three input channels to form a four-channel input structure;
[0018] The diffusion enhancement model was trained using images of defect-free cathode copper plates, corresponding text prompts, and defect region mask templates, and rare defect enhancement samples were generated after training.
[0019] After generating rare defect augmentation samples, the process also includes: screening the effectiveness of rare defect augmentation samples, specifically:
[0020] When the defective region in the generated image is within a preset range, the edge clarity of the defect meets the preset requirements, and the texture transition between the defective region and the defect-free substrate is continuous, the corresponding generated image is retained as an effective enhancement sample.
[0021] If the generated image contains defects whose locations exceed the defect area mask range, the overall texture of the board is distorted, or the defect edges are severely blurred, the corresponding generated image will be deleted.
[0022] S3 specifically includes:
[0023] Two-dimensional color images of the cathode copper plate under inspection are acquired using an area array color camera, and three-dimensional point cloud data of the cathode copper plate under inspection are acquired using a line laser scanner. A unified sample number is generated for the same acquisition through a synchronous triggering unit. Based on the extrinsic parameter calibration results between the area array color camera and the line laser scanner, the pixel positions in the two-dimensional color image are mapped to the spatial positions in the three-dimensional point cloud data.
[0024] S4 specifically includes:
[0025] The defect recognition model is trained using real defect samples and rare defect augmentation samples to obtain the defect category, category confidence, and defect area location results of the cathode copper plate under inspection.
[0026] Two-dimensional semantic features are extracted based on the defect area localization results, and three-dimensional quantization features are extracted by combining the spatially aligned three-dimensional point cloud data.
[0027] The two-dimensional semantic features and three-dimensional quantitative features are normalized and spliced to form a standardized defect feature vector.
[0028] The standardized defect feature vectors and knowledge vector sets are compared using similarity retrieval and rule validation to output standardized source tracing results, specifically including:
[0029] The standardized defect feature vector is used as the query vector and input into the lightweight vector database. The similarity between the query vector and each knowledge vector in the knowledge vector set is calculated to obtain candidate knowledge entries.
[0030] Next, rule validation is performed on the candidate knowledge entries. Candidate knowledge entries with inconsistent defect types or mismatched size ranges are deleted, and candidate knowledge entries with inconsistent defect locations or inconsistent surface colors are downgraded. The results are then sorted according to the comprehensive scores after validation, and standardized tracing results are output.
[0031] S5 specifically includes: retrieving the two-dimensional color images, three-dimensional point cloud data and historical process records corresponding to the standardized traceability results, and having process experts verify the reasons for the candidate processes;
[0032] When the actual process cause confirmed by process experts is consistent with the standardized traceability results, the corresponding sample is recorded as a positive feedback sample, and the retrieval weight of the corresponding knowledge item is increased.
[0033] When the actual process cause confirmed by process experts is inconsistent with the standardized traceability results, the corresponding sample is recorded as a correction sample, and the corresponding sample is added to the training sample. The defect feature description corresponding to the actual process cause is rewritten into the lightweight vector database to update the knowledge vector set.
[0034] The second part of this invention provides a cathode copper defect tracing system based on RAG retrieval, comprising:
[0035] The Defect Process RAG Knowledge Base Construction Module is used to extract, standardize, and vectorize the defect feature descriptions and corresponding process causes from the historical defect records of cathode copper plates, resulting in a knowledge vector set.
[0036] The diffusion enhancement module is used to build a diffusion enhancement model based on text prompts and defect region masks, and to generate rare defect enhancement samples using the diffusion enhancement model;
[0037] The multimodal data acquisition and alignment module is used to acquire two-dimensional color images and three-dimensional point cloud data of the cathode copper plate under inspection, and to perform spatial alignment of the two-dimensional color images and three-dimensional point cloud data.
[0038] The defect identification and tracing module is used to train a defect identification model based on real defect samples and rare defect enhancement samples, and to extract two-dimensional semantic features and three-dimensional quantitative features of the cathode copper plate under inspection using the defect identification model.
[0039] The closed-loop update module is used to perform expert closed-loop confirmation based on the standardized traceability results, and update the training samples and knowledge vector set based on the confirmation results.
[0040] The third part of this invention provides a computer program product, which includes computer program code. When the computer program code is run on a computer, the computer implements the above-described method for tracing the source of cathode copper defects based on RAG retrieval.
[0041] The beneficial effects of this invention are as follows:
[0042] This invention elevates the existing defect detection-oriented processing method to a defect tracing method oriented towards process cause analysis by constructing a complete technical chain of "diffusion-enhanced sample generation - multimodal feature extraction - RAG knowledge retrieval - expert closed-loop update". It can output corresponding inducing process causes and troubleshooting suggestions for cathode copper surface defects, thereby effectively solving the problem that existing technologies cannot support root cause tracing and process optimization.
[0043] This invention utilizes a diffusion enhancement model to generate enhanced samples for rare defects such as pores with special morphology and dense needle-like agglomerates. This completes the rare defect sample data system and alleviates the problem of insufficient model training, limited recognition accuracy, and limited generalization ability caused by insufficient samples in existing cathode copper defect detection, thereby improving the recognition ability of complex and low-frequency defects. By collaboratively acquiring two-dimensional color images and three-dimensional point cloud data using an area array color camera and a line laser scanner, and achieving spatial alignment through calibration, the two-dimensional semantic features are fused with the three-dimensional quantized features. This allows for the simultaneous characterization of defect morphology, texture, color, and geometric undulation information, improving the cross-modal matching accuracy and feature representation completeness of defect regions.
[0044] This invention structures and processes defect tracing manuals written by process engineers, extracting defect feature descriptions, inducing process causes, and process adjustment suggestions to construct a defect process RAG knowledge base. Combined with vector retrieval and rule validation, it outputs standardized tracing results, establishing a correlation between defect characterization results and production process parameters, thus improving the targeting and practicality of defect cause localization. By introducing process experts to conduct on-site verification of the system's tracing results and writing confirmed defect samples and actual process causes back into the training set and RAG knowledge base, continuous iterative updates of the defect identification model and knowledge entries can be achieved, thereby improving the accuracy of subsequent defect identification, the accuracy of process cause matching, and the long-term operational stability of the system. Attached Figure Description
[0045] Figure 1 This is a schematic diagram of the cathode copper defect tracing method based on RAG retrieval according to the present invention;
[0046] Figure 2 This is a schematic diagram of the framework of the cathode copper defect tracing system based on RAG retrieval according to the present invention. Detailed Implementation
[0047] 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.
[0048] Example 1: As Figure 1 As shown, this embodiment provides a method for tracing the source of cathode copper defects based on RAG retrieval, including the following steps:
[0049] S1. Construct a defect process RAG knowledge base, standardize and vectorize the defect feature descriptions and corresponding process causes in the historical defect records of cathode copper plates, and obtain a knowledge vector set.
[0050] S2. Construct a diffusion enhancement model to generate rare defect enhancement samples based on text prompts and defect region masks;
[0051] S3. Acquire two-dimensional color images and three-dimensional point cloud data of the cathode copper plate to be inspected, and spatially align the two-dimensional color images and three-dimensional point cloud data.
[0052] S4. Train a defect recognition model based on real defect samples and rare defect augmentation samples, extract two-dimensional semantic features and three-dimensional quantitative features of the cathode copper plate to be inspected and fuse them to form a standardized defect feature vector. Perform similarity retrieval and rule verification between the standardized defect feature vector and the knowledge vector set, and output standardized tracing results.
[0053] S5. Conduct expert closed-loop confirmation based on the standardized traceability results, and update the training samples and knowledge vector set based on the confirmation results.
[0054] S1 specifically includes the following:
[0055] Construct a defective process RAG knowledge base and complete the initialization of a searchable knowledge index;
[0056] First, we collected historical defect traceability manuals, process personnel investigation records, defect handling records, and team experience summaries from the cathode copper production process. Then, we extracted the content related to the root causes of defects in a structured manner to form a standardized set of knowledge items.
[0057] Each standardized knowledge entry includes at least the following fields: Defect Type, Defect Morphology, Defect Location, Surface Color, Size Range, Corresponding Process Reason, Process Adjustment Suggestion, Knowledge Source, and Credibility. Specifically, the Defect Type field records defect categories such as porosity, needle-like granules, pepper-like granules, and white deposits; the Defect Morphology field records the appearance characteristics of the defect, such as dot-like, strip-like, locally dense, or discretely distributed; the Defect Location field records whether the defect is located on the front, back, edge, center, or near the mounting lug of the cathode copper plate; and the Size Range field records the range of the defect's length, width, area, or height.
[0058] The corresponding process cause field records production factors associated with defects, including at least one or more of the following: current density, electrolyte concentration, electrode spacing, additive status, and circulating fluid stability. Subsequently, a cleaning process is performed on the standardized knowledge entry set, including terminology standardization, unit conversion, merging duplicates, and deleting ambiguous entries.
[0059] Terminology standardization refers to mapping synonymous defect names to unique standard names, such as unifying "needle-pierced granules" and "needle-shaped granules" into "needle-shaped granules"; unit conversion refers to converting concentration units, length units, and current units from different sources into unified measurement units; duplication merging refers to retaining only the entry with a clearer source and more complete fields when two entries have the same defect type, defect morphology, and process cause; and fuzzy entry deletion refers to deleting a record from the knowledge entry set when it lacks both the defect morphology field and the corresponding process cause field, or only records "surface anomaly" without specifying any identifiable features, to avoid interfering with subsequent searches.
[0060] After cleaning, a lightweight industrial semantic encoding model is used to encode the defect feature descriptions in the knowledge entries, resulting in knowledge vectors. In this embodiment, the lightweight industrial semantic encoding model preferably adopts an ALBERT (A LiteBERT) network architecture or a RoBERTa network architecture, with 4-6 layers and a hidden layer feature dimension of 512 to match the vector library requirements. This model is pre-trained and fine-tuned using a masked language model (MLM) on a corpus of historical defect inspection reports and process manuals in the metallurgical industry, thereby accurately capturing the contextual semantic features of industrial terms such as needle penetration, granulation, and current density.
[0061] Knowledge vectors are vectorized results that express the semantic features of defects in a multi-dimensional numerical form, and are used for subsequent similarity comparison with the feature vectors of the samples to be inspected.
[0062] ;
[0063] in, This is the knowledge vector corresponding to a single knowledge item; It provides standardized text descriptions for knowledge entries; the Encoder is a lightweight industrial semantic encoding model; the vector dimension is 512.
[0064] To quantify cleaning effectiveness and avoid the subjectivity of manual cleaning, a cleaning confidence formula is introduced to screen effective knowledge items:
[0065] ;
[0066] in, The confidence level for cleaning a single knowledge item (0-1); This is the field completeness coefficient (1 for all fields, minus 0.2 for each missing core field). Accuracy coefficient for units / terms (1 for no errors, 0.3 for each error); This is the terminology uniformity coefficient (1 if it conforms to standard terminology, 0 otherwise); , , As a weight, in this embodiment, in order to focus on ensuring the completeness of information of knowledge items, it is preferable to set the weight. =0.5, =0.3, =0.2. After calculating the score based on this formula, the system only retains... Entries with a value of ≥0.6 are considered valid entries.
[0067] In this embodiment, the knowledge vector, along with the corresponding process reason field, process adjustment suggestion field, and knowledge source field, is written into a lightweight vector database. To improve subsequent retrieval efficiency, a one-to-one mapping relationship between knowledge entry identifiers and knowledge vectors is established, and a knowledge vector index table is generated. The knowledge base management backend connects to the lightweight vector database for manually adding, modifying, deactivating, and restoring knowledge entries. After processing by S1, a standardized set of knowledge entries, a set of knowledge vectors, and a knowledge vector index table are output as the knowledge foundation for subsequent similarity retrieval.
[0068] S2 specifically includes the following:
[0069] Construct a diffusion enhancement model and generate rare defect enhancement samples that can be used for training;
[0070] After initializing the knowledge base, a mask-constrained diffusion generation model (DefFiller structure) is built to supplement rare defect samples. This invention draws on the DefFiller layout to image diffusion logic, adding mask constraint channels to the traditional latent space diffusion model to strictly limit the defect generation area and avoid irregular generation. At the same time, a new defect texture fitting constraint is added, which is different from the DefFiller basic model and improves the industrial adaptability of the generated samples.
[0071] ;
[0072] in, The clean cathode copper exhibits defect-free latent space characteristics; The noisy latent space features are defined for step t. This is the cumulative noise attenuation coefficient; It is Gaussian random noise.
[0073] The diffusion generation model retains the original text input channel, inputs the natural language text prompts into the text encoder, and converts the output into a text feature vector to represent semantic meaning. The text feature vector is a 512-dimensional feature vector, which is used in this embodiment. The 512-dimensional feature vector is input into the attention module of the U-Net feature extraction network, so that the model can perceive both image texture features and text description constraints during the denoising and generation process.
[0074] The U-Net feature extraction network here refers to a convolutional network with encoding and decoding paths. The encoding path is responsible for extracting image features at different scales, while the decoding path is responsible for restoring spatial resolution. The attention module is used to inject textual semantic information between different layers. Furthermore, the input structure of the diffusion generation model is improved by adding a defect region mask input channel to the original three input channels, forming a four-channel input structure.
[0075] The defect region mask is a binary image with the same size as the input image. Regions with a pixel value of 1 represent locations where defects are allowed to be generated, while regions with a pixel value of 0 represent locations where the base texture is preserved without defects. Therefore, the role of the defect region mask is not to replace the image, but to impose spatial constraints on the range of defect generation, preventing the generation results from spreading uncontrollably across the entire board.
[0076] ;
[0077] in, The fused image under mask constraints; Background image of defect-free cathode copper; Generate defect textures for the model; M is a binary defect mask; Pixel-level Hadamard layer; the original copper plate texture is forcibly preserved in the area outside the mask.
[0078] To ensure that the generated defects fit the surface texture of the cathode copper and avoid texture decoupling, a texture similarity constraint is introduced and incorporated into the diffusion loss function:
[0079] ;
[0080] In the formula: The similarity between the defect and the background texture (value 0-1); , These are the grayscale values of the defect area and the background area at pixel (I,j), respectively. At that time, the texture is deemed to be of acceptable quality.
[0081] In the basic training phase, surface images of the front and back sides of a defect-free cathode copper plate are collected as basic training data. Each defect-free image is then assigned a corresponding text prompt about the defect-free surface and a mask template for defect areas. The mask template can be generated manually by marking high-incidence areas on a historical defect statistics chart, or it can be automatically generated according to the distribution rules of the plate surface areas.
[0082] The specific generation rules are as follows: the annular area extending 5cm-10cm inward from the physical edge of the cathode copper plate is set as the edge area mask template; the area within 10cm-20cm below the extraction ear is set as the ear adjacent area mask template; and the central rectangular area other than the above areas is set as the central area mask template.
[0083] When automatically generating the mask, a connected region occupying 5%-15% of the total area of the template is randomly generated within the corresponding region template, and the pixel value in the connected region is set to 1 (i.e., the region where defects are allowed to be generated), while the pixel value of the remaining background region is set to 0. This completes the automatic construction of the preset mask template. For example, the edge region, the middle region, and the adjacent region of the ear are set to different preset mask templates.
[0084] After establishing the training dataset, the number of training epochs, batch size, learning rate, input image size, and diffusion steps are set, and model training is then initiated. In this embodiment, stable validation set loss means that the loss decrease over three consecutive validation epochs is less than a preset threshold, for example, less than two percent of the loss value from the previous epoch. At this point, the model is considered to have completed learning the mapping relationship between the defect-free substrate texture and positional constraints. The optimized diffusion model loss function is:
[0085] ;
[0086] in, The loss function for the diffusion model is... Predict noise for U-Net; M is the text feature vector; M is the binary defect mask; λ is the texture constraint weight; in this embodiment, the preferred value of λ is 0.1 to 0.3, for example, it can be 0.15, so as to ensure the accuracy of the generated defect semantics while avoiding the Gaussian noise from being effectively degraded due to excessively strong texture constraints; the loss constraint model fits the noise, text semantics, mask position and texture fit at the same time to improve the authenticity of the generated samples.
[0087] After completing the basic training, special text prompts are designed for rare defects such as special morphological pores and locally dense needle-like agglomerates. The special text prompts should include at least a description of the defect type, a description of the defect morphology, and a description of the distribution. For example, "Locally dense needle-like agglomerates on the cathode copper surface, distributed in the edge area, with fine and continuous protrusions."
[0088] Simultaneously, a corresponding defect region mask is matched for the specific text prompt and input into the trained diffusion generation model to generate rare defect enhancement samples. To prevent unstable quality of generated samples, an enhancement sample acceptance rule is also set: when the defect region coverage in the generated image is within a preset range, the edge sharpness reaches a preset value, and the defect region and the surrounding undefected substrate maintain continuity in texture transition, the generated image is judged as a valid enhancement sample;
[0089] If the edges of the defect area are severely blurred, the defect location exceeds the mask range, or the overall texture of the board is distorted, the generated image is deleted directly. The selected and retained effective enhanced samples, together with the corresponding defect labels, text prompts, and mask records, constitute the enhanced sample set, serving as a supplementary data source for training the defect recognition model in S4.
[0090] S3 specifically includes the following:
[0091] Collect multimodal defect data of cathode copper plates and complete the spatial alignment of two-dimensional images with three-dimensional point clouds;
[0092] A collaborative acquisition device is deployed at the post-cathode copper stripping station. This device includes at least an area array color camera, a line laser scanner, a synchronization triggering unit, and a data buffer unit. The area array color camera is used to acquire two-dimensional color images of the cathode copper plate surface to preserve the color, outline, texture, and distribution information of defects.
[0093] A line laser scanner is used to acquire 3D point cloud data of the area corresponding to the 2D image, preserving information such as defect height, indentation depth, surface undulation, and local roughness. A synchronous triggering unit simultaneously triggers 2D image acquisition and 3D point cloud acquisition when the cathode copper plate enters the predetermined sampling position, ensuring consistent acquisition time for the same plate area in both channels. A data caching unit generates a unique sample number for each trigger and writes this sample number into both the 2D image record and the 3D point cloud record, establishing a one-to-one correspondence. Each acquisition record includes at least a sample number field, an acquisition time field, a plate identification field, a 2D image file path field, and a 3D point cloud file path field. After the initial acquisition is completed, external parameter calibration is performed on the array color camera and the line laser scanner.
[0094] External parameter calibration refers to calculating the positional and attitude relationships between the camera coordinate system and the point cloud coordinate system, and outputting transformation parameters for coordinate transformation.
[0095] ;
[0096] In the formula: These are the pixel coordinates of the image. Let R be the corresponding 3D spatial coordinates; R be the rotation matrix; and T be the translation vector. To ensure that the alignment accuracy meets the requirements of subsequent feature extraction, an average projection error formula is introduced to verify the alignment effect:
[0097] ;
[0098] In the formula: The mean projection error is N; N is the number of feature points in the validation samples. , These are the three-dimensional coordinates and two-dimensional pixel coordinates of the i-th feature point, respectively; If the alignment is successful, it is deemed acceptable; otherwise, it is recalibrated.
[0099] In practice, a calibration board can be placed within the common field of view of the collaborative acquisition device. The position of the feature point of the calibration board in the two-dimensional image and the corresponding position of the point in the three-dimensional point cloud can be obtained respectively. Then, the transformation parameters from the camera coordinate system to the point cloud coordinate system can be obtained through the minimum error registration method.
[0100] After obtaining the transformation parameters, the pixel positions in the 2D image are converted to their spatial positions in the 3D point cloud, thereby achieving precise spatial alignment between the 2D image and the 3D point cloud data. To ensure alignment quality, an alignment error threshold can be set. When the average projection error of the calibrated verification samples exceeds the threshold, calibration is re-executed until the accuracy requirements for subsequent cross-modal feature matching are met. After processing in S3, the output is a set of 2D color images and a set of 3D point clouds with corresponding sample numbers and spatial alignment, providing input for defect mapping and geometric quantization feature extraction in S4.
[0101] S4 specifically includes the following:
[0102] A defect identification model is trained using real and augmented samples. Fusion features are extracted and similarity retrieval and rule verification are performed to output standardized source tracing results.
[0103] First, real defect samples collected during actual production are merged with enhanced samples generated by S2 and passed acceptance testing to form a defect training sample set. To avoid the model becoming biased towards synthetic textures due to an excessively high proportion of enhanced samples, in one feasible implementation, the number of real defect samples can be no less than 60% of the total training samples, and the number of enhanced samples can be no more than 40% of the total training samples.
[0104] Subsequently, the defect training sample set is divided into a training set, a validation set, and a test set according to a preset ratio, and a deep convolutional neural network is used to train the defect type recognition and localization module. The input of the defect type recognition and localization module is a two-dimensional color image, and the output includes at least a defect category field, a category confidence field, and a defect region localization result; the defect region localization result can be bounding box coordinates or a pixel-level segmentation mask.
[0105] In this embodiment, when the defect region localization result requires the output of a pixel-level segmentation mask, the deep convolutional neural network preferably adopts the Mask R-CNN instance segmentation model or the YOLOv8-Seg model. Taking the Mask R-CNN model as an example, its backbone feature extraction network can adopt ResNet-50 combined with a feature pyramid network (FPN). Through multi-scale feature fusion, this network can not only output defect categories and bounding boxes through classification and regression branches, but also output pixel-level accurate binary masks through the Mask branch, thereby providing extremely accurate coordinate localization basis for the spatial point set mapping of two-dimensional semantic features and three-dimensional point cloud data in subsequent steps.
[0106] After the model training is completed, the two-dimensional color image of the cathode copper plate to be inspected is input into the defect type identification and localization module to obtain the preliminary defect classification results and pixel-level localization coordinates.
[0107] Then, based on the coordinate transformation parameters obtained in S3, the defect region in the two-dimensional image is mapped to the corresponding point set in the three-dimensional point cloud. Specifically, the pixel set of the two-dimensional defect region is first determined based on the pixel-level positioning coordinates, and then the coordinate transformation parameters are used to find the point set in the three-dimensional point cloud corresponding to the pixel set, and three-dimensional quantization features are extracted within the range of the point set.
[0108] The three-dimensional quantization features include at least one or more of the following: average height of the defect region, maximum height, average indentation depth, surface roughness, region area, and local volume change. Simultaneously, two-dimensional semantic features are extracted from the two-dimensional color image. These two-dimensional semantic features include at least defect category, color variation features, contour shape features, texture distribution features, and region density features.
[0109] In order to combine two-dimensional semantic features and three-dimensional quantization features in the same numerical space, normalization is first performed on the two types of features respectively.
[0110] ;
[0111] in, is the normalized feature value, and x is the original feature value; These are historical extreme values for features of the same type; after normalization, all features are constrained to the 0-1 range. To address the source tracing bias caused by equal weights for two-dimensional semantic features and three-dimensional quantized features, weights are dynamically allocated based on defect type, unlike traditional fixed-weight fusion.
[0112] ;
[0113] in, , These are the fusion weights for two-dimensional and three-dimensional features, respectively. This is the merged query vector; It is a two-dimensional semantic feature vector; This is a three-dimensional quantized feature vector; for "appearance-driven" defects such as granulation and white deposits, For defects such as pores and depressions that are "geometry-dominated", ;
[0114] After feature fusion is completed, the standardized defect feature vector is used as the query vector and input into the lightweight vector database established by S1. Similarity retrieval is then performed on the knowledge vector set. The similarity retrieval uses cosine similarity calculation, which involves multiplying the query vector and the knowledge vector by their corresponding dimensions, summing the results, and then dividing by the product of their lengths to obtain the similarity value. The closer the similarity value is to 1, the closer the sample to be tested is to the knowledge item in terms of feature representation.
[0115] ;
[0116] The retrieval phase does not directly retrieve the single entry with the highest similarity. Instead, it first returns multiple candidate knowledge entries with the highest similarity, such as the top five, to avoid misjudgments caused by single-vector matching errors. Then, the rule engine performs validation on the candidate knowledge entries.
[0117] The rule engine is not an abstract judgment module, but a verification process based on field comparison, including at least the following rules: when the defect type field of a candidate knowledge entry is inconsistent with the defect category field output by the recognition module, the candidate knowledge entry is directly deleted; when the defect location field of a candidate knowledge entry is inconsistent with the actual defect location of the sample to be inspected, the comprehensive score of the candidate knowledge entry is reduced; when the size range field of a candidate knowledge entry does not match the size range reflected by the three-dimensional quantization features, the candidate knowledge entry is deleted; when the surface color field of a candidate knowledge entry is significantly inconsistent with the color change features reflected by the two-dimensional semantic features, the comprehensive score of the candidate knowledge entry is reduced again.
[0118] ;
[0119] in, Pre-set weights manually; The overall score after verification is represented by ; Sim is the cosine similarity score between the query vector and the knowledge vector. Score the location matching. Score for size matching; Score the color matching. The weighting factor is set at 0.5 for position / color mismatch and 1 for match, quantifying the weighting process. In a specific implementation, to highlight the dominant role of vector semantic similarity and core size dimension in the evaluation, it is preferable to set... =0.4、 =0.2、 =0.3、 =0.1.
[0120] After deletion and weight reduction, the remaining candidate knowledge items are re-sorted according to their comprehensive scores, and the one or more items with the highest scores are selected as the final source tracing results. The comprehensive score is jointly determined by vector similarity, position matching results, size matching results, and color matching results, thus avoiding conclusions based solely on a single similarity. The final standardized source tracing results output includes at least the sample number to be inspected, defect type, defect location, defect morphology, two-dimensional semantic feature summary, three-dimensional quantitative feature summary, candidate inducing process causes, recommended investigation order, and process adjustment suggestions to assist process personnel in conducting on-site investigations.
[0121] S5 specifically includes the following:
[0122] The system output results are verified by experts in a closed loop, and the training sample set, knowledge items and retrieval weights are updated accordingly.
[0123] After obtaining the standardized traceability results output by S4, the on-site process experts retrieved the two-dimensional color images, three-dimensional point cloud data, defect identification results, candidate inducing process causes, and historical process records under the corresponding sample number. They then verified the candidate inducing process causes given by the system in conjunction with the shift's production parameters, tank status, and on-site investigation results.
[0124] When experts confirm that the first candidate cause of the induced process given by the system is consistent with the actual investigation conclusion, the sample is recorded as a positive feedback sample; when the actual investigation conclusion is inconsistent with the first candidate cause of the induced process in the system, the sample is recorded as a correction sample, and the actual process cause is entered into the closed-loop management unit.
[0125] The closed-loop management unit should record at least the following fields: sample number, defect type, system output reason, expert confirmation reason, confirmation time, consistency, and handling opinion. For positive feedback samples, the credibility field and retrieval weight of their corresponding knowledge entries can be increased; for corrective samples, knowledge entries that the system incorrectly hit are marked as low-priority entries, and restrictions are added if necessary, or their default retrieval weight is directly reduced when significant deviations occur repeatedly.
[0126] Credibility Iterative Update Formula:
[0127] ;
[0128] In the formula: For the updated credibility; To maintain the original credibility; The historical retention factor is 0.8. The increment for expert verification is adjusted (0.1 for positive feedback and -0.2 for correction samples); the increment for positive feedback is positive and the increment for correction samples is negative, to ensure that the credibility update is consistent with the actual verification results.
[0129] By combining expert feedback loop results, the retrieval weights of knowledge items are dynamically updated to optimize subsequent retrieval accuracy, which differs from fixed-weight retrieval.
[0130] ;
[0131] In the formula: These are the retrieval weights of the knowledge entries before and after the update, respectively. This is the weighting adjustment factor; The feedback coefficient is set to 1 for positive feedback, -0.5 for corrective samples, and 0 for no feedback, enabling dynamic adaptive updating of the retrieval weight.
[0132] Meanwhile, defect sample images, pixel-level localization results, and real defect labels confirmed by experts are added to the defect training sample set; when the number of newly added valid confirmed samples for a certain defect category reaches a preset number, or when the recognition accuracy of the category in the most recent round of testing is lower than a preset threshold, the retraining and fine-tuning of the defect recognition model is triggered.
[0133] Valid confirmed samples here refer to samples that have completed expert verification, have complete labels, and whose image quality meets the requirements. Meeting the image quality requirements means that the image clarity, exposure level, and defect area integrity all meet the model training standards. For the knowledge base update part, the correspondence between "defect features - actual process causes" confirmed by experts is rewritten into standardized knowledge entries. After performing the same terminology standardization, unit conversion, and field completion processing as in S1, it is written into the RAG knowledge base, and the corresponding knowledge vectors are recalculated and updated to the lightweight vector database.
[0134] Specifically, on the one hand, the defect identification model gains support from new real samples, and on the other hand, the knowledge base also gains new real cause mappings, making subsequent similarity retrieval and rule verification more closely aligned with the actual production process. After processing by S5, the updated defect training sample set, the updated knowledge vector set, and the updated retrieval weight configuration are output, achieving synchronous iteration of defect identification capability and process cause matching capability.
[0135] Example 2: Figure 2 As shown, this embodiment provides a cathode copper defect tracing system based on RAG retrieval, including:
[0136] It includes: a defect process RAG knowledge base construction module, a diffusion enhancement module, a multimodal data acquisition and alignment module, a defect identification and tracing module, and a closed-loop update module; among which,
[0137] The Defect Process RAG Knowledge Base Construction Module is used to extract, standardize, and vectorize the defect feature descriptions and corresponding process causes from the historical defect records of cathode copper plates, resulting in a knowledge vector set.
[0138] The diffusion enhancement module is used to build a diffusion enhancement model based on text prompts and defect region masks, and to generate rare defect enhancement samples using the diffusion enhancement model;
[0139] The multimodal data acquisition and alignment module is used to acquire two-dimensional color images and three-dimensional point cloud data of the cathode copper plate under inspection, and to perform spatial alignment of the two-dimensional color images and three-dimensional point cloud data.
[0140] The defect identification and tracing module is used to train a defect identification model based on real defect samples and rare defect augmentation samples. The defect identification model is used to extract two-dimensional semantic features and three-dimensional quantitative features of the cathode copper plate to be inspected. The two-dimensional semantic features and three-dimensional quantitative features are fused to form a standardized defect feature vector. The standardized defect feature vector is compared with the knowledge vector set for similarity retrieval and rule verification, and the standardized tracing results are output.
[0141] The closed-loop update module is used to perform expert closed-loop confirmation based on the standardized traceability results, and update the training samples and knowledge vector set according to the confirmation results.
[0142] Example 3: This example provides a computer program product, which includes computer program code. When the computer program code is run on a computer, the computer implements a cathode copper defect tracing method based on RAG retrieval as described in Example 1.
[0143] All the above formulas are performed using dimensionless numerical calculations; the relevant formulas are based on empirical models that approximate the real situation, obtained through extensive data collection and software simulation fitting. The preset parameters and thresholds involved in the formulas can be conventionally set and adjusted by those skilled in the art according to the physical constraints of the actual application scenario.
[0144] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0145] In conclusion, the above are merely preferred embodiments of the present invention and are not intended to limit the present invention. 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.
Claims
1. A method for tracing the source of cathode copper defects based on RAG retrieval, characterized in that, Includes the following steps: S1. Construct a defect process RAG knowledge base, standardize and vectorize the defect feature descriptions and corresponding process causes in the historical defect records of cathode copper plates, and obtain a knowledge vector set. S2. Construct a diffusion enhancement model to generate rare defect enhancement samples based on text prompts and defect region masks; S3. Acquire two-dimensional color images and three-dimensional point cloud data of the cathode copper plate to be inspected, and spatially align the two-dimensional color images and three-dimensional point cloud data. S4. Train a defect recognition model based on real defect samples and rare defect augmentation samples, extract two-dimensional semantic features and three-dimensional quantitative features of the cathode copper plate to be inspected, and fuse them to form a standardized defect feature vector. The standardized defect feature vector and knowledge vector set are used for similarity retrieval and rule verification to output standardized source tracing results; specifically including: A defect recognition model is trained using real defect samples and rare defect augmentation samples to obtain the defect category, category confidence, and defect region localization results of the cathode copper plate under inspection. Two-dimensional semantic features are extracted based on the defect region localization results, and three-dimensional quantitative features are extracted by combining spatially aligned three-dimensional point cloud data. The two-dimensional semantic features and three-dimensional quantitative features are normalized and spliced to form a standardized defect feature vector. The standardized defect feature vector and knowledge vector set are subjected to similarity retrieval and rule verification to output standardized tracing results. This includes: inputting the standardized defect feature vector as a query vector into a lightweight vector database, calculating the similarity between the query vector and each knowledge vector in the knowledge vector set to obtain candidate knowledge entries; then performing rule verification on the candidate knowledge entries, deleting candidate knowledge entries with inconsistent defect types or mismatched size ranges, reducing the weight of candidate knowledge entries with inconsistent defect locations or inconsistent surface colors, and sorting them according to the comprehensive score after verification to output standardized tracing results. S5. Conduct expert closed-loop confirmation based on the standardized traceability results, and update the training samples and knowledge vector set based on the confirmation results.
2. The method for tracing the source of cathode copper defects based on RAG retrieval according to claim 1, characterized in that, S1 specifically includes: The defect feature descriptions and corresponding process causes in the historical defect records of cathode copper plates are extracted in a structured manner to form a standardized set of knowledge items; The standardized knowledge entry set is processed by standardizing terminology, converting units, merging duplicates, and deleting fuzzy entries. Fuzzy entry deletion refers to the deletion of a record from the knowledge entry set when a record is missing both the defect morphology field and the corresponding process cause field, or when it only records surface abnormalities without specifying any identifiable features. The processed defect feature descriptions are vectorized and encoded, and the encoding results are associated with the corresponding process causes and stored in a lightweight vector database to obtain a knowledge vector set.
3. The method for tracing the source of cathode copper defects based on RAG retrieval according to claim 1, characterized in that, S2 specifically includes: The text prompts are encoded into text feature vectors and input into the attention module of the U-Net feature extraction network. A defect region mask input channel is added to the original three input channels to form a four-channel input structure. The diffusion enhancement model was trained using images of defect-free cathode copper plates, corresponding text prompts, and defect region mask templates, and rare defect enhancement samples were generated after training.
4. The method for tracing the source of cathode copper defects based on RAG retrieval according to claim 3, characterized in that, After generating rare defect augmentation samples, the process also includes: screening the effectiveness of rare defect augmentation samples; When the defective region in the generated image is within a preset range, the edge clarity of the defect meets the preset requirements, and the texture transition between the defective region and the defect-free substrate is continuous, the corresponding generated image is retained as an effective enhancement sample. If the generated image contains defects whose locations exceed the defect area mask range, the overall texture of the board is distorted, or the defect edges are severely blurred, the corresponding generated image will be deleted.
5. The method for tracing the source of cathode copper defects based on RAG retrieval according to claim 1, characterized in that, S3 specifically includes: Two-dimensional color images of the cathode copper plate under inspection are acquired using an area array color camera, and three-dimensional point cloud data of the cathode copper plate under inspection are acquired using a line laser scanner. A unified sample number is generated for the same acquisition through a synchronous triggering unit. Based on the extrinsic parameter calibration results between the area array color camera and the line laser scanner, the pixel positions in the two-dimensional color image are mapped to the spatial positions in the three-dimensional point cloud data.
6. The method for tracing the source of cathode copper defects based on RAG retrieval according to claim 1, characterized in that, S5 specifically includes: Retrieve the two-dimensional color images, three-dimensional point cloud data and historical process records corresponding to the standardized traceability results, and have process experts verify the reasons for the candidate processes; When the actual process cause confirmed by process experts is consistent with the standardized traceability results, the corresponding sample is recorded as a positive feedback sample, and the retrieval weight of the corresponding knowledge item is increased. When the actual process cause confirmed by process experts is inconsistent with the standardized traceability results, the corresponding sample is recorded as a correction sample, and the corresponding sample is added to the training sample. The defect feature description corresponding to the actual process cause is rewritten into the lightweight vector database to update the knowledge vector set.
7. A cathode copper defect tracing system based on RAG retrieval, employing the cathode copper defect tracing method based on RAG retrieval as described in any one of claims 1 to 6, characterized in that, include: The Defect Process RAG Knowledge Base Construction Module is used to extract, standardize, and vectorize the defect feature descriptions and corresponding process causes from the historical defect records of cathode copper plates, resulting in a knowledge vector set. The diffusion enhancement module is used to construct a diffusion enhancement model based on text prompts and defect region masks, and to generate rare defect enhancement samples using the diffusion enhancement model; The multimodal data acquisition and alignment module is used to acquire two-dimensional color images and three-dimensional point cloud data of the cathode copper plate under inspection, and to spatially align the two-dimensional color images and the three-dimensional point cloud data. The defect identification and tracing module is used to train a defect identification model based on real defect samples and the rare defect enhancement samples, and to extract two-dimensional semantic features and three-dimensional quantitative features of the cathode copper plate to be inspected using the defect identification model. The closed-loop update module is used to perform expert closed-loop confirmation based on the standardized tracing results, and update the training samples and the knowledge vector set based on the confirmation results.
8. A computer program product, characterized in that, The computer program product includes computer program code, which, when run on a computer, enables the computer to implement a cathode copper defect tracing method based on RAG retrieval as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Method for detecting welding defects of steel pipe and copper pipe
CN120953261A
Copper stack side wall appearance defect detection method, computer program product and storage medium
CN121481944A