A medical institution name governance method based on contrastive learning
Through the combination of comparative learning and single tower BERT model, the problem of inconsistent medical institution names in the medical sales link data is solved, efficient data cleaning and unified expression are achieved, and the automation and accuracy of data governance are improved.
Patent Information
- Application Number
- CN202411830825.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2044-12-12
AI Technical Summary
The inconsistent naming of medical institutions in the data of the pharmaceutical sales link is caused by low data quality, which affects the internal digital transformation and data governance of enterprises.
The encoder model based on comparison learning is used to vectorize medical institution names, combine the single tower BERT model for reordering and matching, and the text similarity recall is used to recall the text similarity, and the cleaning accuracy is improved through the historical alias library and data quality inspection mechanism.
It improves the accuracy and automation of data cleaning, reduces the cost of manual intervention, and ensures the unity and reliability of data.
Smart Images

Figure CN119761311B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data governance technology, and in particular to a medical institution name governance method based on comparative learning. Background Art
[0002] The data generated throughout the entire process of pharmaceutical products from manufacturers through distributors (which may involve multiple levels of distributors) to sales outlets (such as hospitals and pharmacies) and finally to consumer purchase is known as pharmaceutical sales chain data (flow data). However, this flow data is inconsistent in quality and lacks standards. Competitive product data largely comes from different distributors or service providers, and different data sources have different naming conventions. This lack of unified standards, low quality, and poor sharing of this data complicates the cleaning of flow data, severely hindering enterprises' internal digital transformation and data governance efforts. Summary of the Invention
[0003] In view of the shortcomings of the existing technology, the present invention aims to provide a medical institution name management method based on comparative learning.
[0004] In order to achieve the above object, the present invention adopts the following technical solutions:
[0005] A medical institution name governance method based on contrastive learning includes the following steps:
[0006] S1. Vectorizing the names of medical institutions in the pharmaceutical sales chain data to be cleaned using an encoder model; the encoder model is an encoder model based on contrastive learning;
[0007] S2. Perform text matching of medical institution names in the medical institution standard database and recall semantic and character similarities;
[0008] S3. Reorder the data recalled in step S2 using a single-tower BERT model, output the standard name of the medical institution with the highest score, and project the unknown medical institution name into the unified code corresponding to the standard name of the medical institution with the highest score;
[0009] The fields of the medical institution standard library include a unified code, a medical institution standard name, a medical institution's former name, and a business organization name; the unified code is used to uniquely identify a medical institution; the medical institution standard name represents a standard expression of the medical institution and is the currently recognized name of the medical institution; the medical institution's former name represents the medical institution's former standard name. As the relevant business changes, the standard name is modified and the former standard name becomes the former name; the business organization name is some names that appear in the actual business process of the medical institution; the medical institution standard name, medical institution's former name, and business organization name are all vectorized through the encoder model;
[0010] In step S2, the text character similarity recall is completed by the character similarity algorithm, which is implemented using the BM25 algorithm. The specific formula is as follows:
[0011]
[0012] bm25(W,D) represents the similarity score between the name of the medical institution to be queried W and the standard name of the medical institution D, w i Indicates the i-th element after the word W, n(w i ) means including element w i The number of all standard names, N represents the number of standard names of all medical institutions, f(w i ,D) represents the element w i The frequency in D, |D| represents the length of the standard name D, avgdl represents the average length of the standard names of all medical institutions, k1, b represent hyperparameters, which respectively control the rising speed of the word frequency results in the word frequency saturation and the role played by controlling the field length normalization value;
[0013] In step S2, text semantic similarity recall is completed by the vector similarity algorithm of the medical institution names. The semantic similarity of the medical institution names is defined based on the cosine distance algorithm. The specific formula is as follows:
[0014]
[0015] Where, vec1=encode(W), vec2=encode(D), encode(·) represents the encoder model, which is used to convert the text of the medical institution name into a vector, W represents the name of the medical institution to be queried, D represents the standard name of the medical institution, vec1 represents the vector of W, and vec2 represents the vector of D;
[0016] In step S3, the single-tower BERT scoring model is used to re-rank the recall data obtained in step S2.
[0017] Furthermore, the encoder model is an encoder model based on contrastive learning, and its acquisition includes sample construction and model training;
[0018] A1. Sample set construction: Use either semantic similarity or text distance similarity to construct samples;
[0019] A11. Semantic similarity:
[0020] A111. Read data: read the collected medical institution name dataset from the specified file path;
[0021] A112. Data preprocessing: cleaning and formatting the text data in the dataset obtained in step A111;
[0022] A113. Encode text data: Use the pre-trained model to encode the text data cleaned and formatted in step A112 into an embedding vector;
[0023] A114. Construct a similarity matrix; calculate the cosine similarity between the embedding vectors obtained in step A113 to construct a similarity matrix;
[0024] A115. Generate positive samples. For each text, find other texts with the same unified code zk_code as the positive samples.
[0025] A116. Generate negative samples. For each text, find the text with the largest approximation value and different from its unified code zk_code from the similarity matrix as a negative sample.
[0026] A117. Save the constructed sample set; write the generated sample set to a CSV file;
[0027] A12. Text distance similarity:
[0028] A121. Indexing synonym sets: Based on the medical institution standard library, a set of medical institution names with the same unified code is defined as a synonym set. The elements of the synonym set are constructed in the data format of (zk_code, medical institution name) and indexed into the full-text search database.
[0029] A122. Generate positive samples: Traverse the medical institution standard library and, for each text, find other texts with the same unified code zk_code as positive samples;
[0030] A123. Generate negative samples: For each text, find the text with the largest matching value and different zk_code from the full-text search database as a negative sample;
[0031] A124. Save sample set: Write the generated sample set to a CSV file;
[0032] In the sample set obtained in step A11 or step A12, an ID is assigned to each text data to establish a mapping relationship between the ID and the text data, so as to facilitate the establishment of a relationship between each text data and the unified code; a set of medical institution names with the same unified code is defined as a synonym set; in the sample set, for any element in the synonym set, no other element in the synonym set appears in the context domain with a distance N from it; in the sample set, for any element, its context is similar to that element in N nearest neighbors;
[0033] A2. Encoder model training:
[0034] The encoder model is built using the SimCSE model based on the contrastive learning method. The specific training process is divided into three steps: forward calculation, definition of loss function, and reverse calculation:
[0035] Step A21, forward calculation; for any sample x i ∈X, X represents the sample set; sample x i The two elements in are calculated by the base encoder respectively, using Chinese BERT as the base encoder, expressed as:
[0036] base_vec1,base_vec2=encode_base(x i,1 ,t1),encode_base(x i,2 ,t2)
[0037] Where encode_base(·) represents the base encoder function, using Chinese BERT, t1, t2 represent the parameters of the Dropout layer in the base encoder, the larger t1, t2 are, the more invalid neural network elements are output by the neural network, x i,1 ,x i,2 Represents sample x respectively i The first and second elements of ;
[0038] Step A22, define the loss function: For a given batch B of training data, the loss function is defined as:
[0039]
[0040] Among them, the similarity sim(·,·) is calculated using cosine;
[0041] Step A23, reverse calculation: First, calculate the gradient of the loss function Loss with respect to the model parameters through the back propagation algorithm. Then, use these gradients to iteratively update the parameters through the gradient descent method or its variants to reduce the value of the loss function. The specific update formula is:
[0042] θ new =θ old -ηΔ θ Loss
[0043] Among them, θ represents the model parameters, η represents the learning rate, Δ θ Loss represents the gradient of the loss function with respect to the parameter θ;
[0044] With multiple iterations, the model is gradually optimized, the loss function value continues to decrease, and the model performance is improved; finally, this process completes the learning of the encoder model. *(·)=encode_base(·,0).
[0045] Furthermore, the single-tower BERT model is mainly divided into two stages: training and prediction;
[0046] B1. Training phase: Collect samples and format them into “[CLS] Medical institution name 1 [SEP] Medical institution name 2 [SEP]”;
[0047] B2. The specific steps of the prediction stage are:
[0048] B21. Sort the standard names of medical institutions obtained by recalling text character similarity and recalling text semantic similarity in descending order respectively;
[0049] B22. Select the top N candidate elements of the medical institution standard names obtained by recalling text character similarity and text semantic similarity, respectively, and encapsulate them into the format of [CLS]Medical Institution 1[SEP]Medical Institution 2[SEP] as the input of the single-tower BERT model, where Medical Institution 1 is the name of the medical institution to be queried and Medical Institution 2 is the recalled medical institution standard name;
[0050] B23. Obtain the standard name of the medical institution with the highest output score from the single-tower BERT model, complete the mapping of the same code, and finally output the unified code of the medical institution.
[0051] Furthermore, before managing the field names in the flow data to be cleaned, the field names in the flow data to be cleaned are first subjected to text preprocessing and historical alias library cleaning;
[0052] Text preprocessing uses any of the following methods:
[0053] (1) Direct text replacement: Direct text replacement is applicable to distributors with special internal names, and directly replaces the designated special name with the recognizable medical institution name text;
[0054] (2) Regularization replacement: Regularization replacement is used to uniformly convert a type of data that meets the regularization conditions into identifiable medical institution name text;
[0055] The specific process of cleaning the historical alias library is as follows:
[0056] The historical alias library includes the original upstream medical institution name, the original downstream medical institution name and the successfully cleaned downstream medical institution name; when cleaning the historical alias library, the pre-processed medical institution name text is first accurately queried in the historical alias library, and the query fields are the original upstream institution name and the original downstream institution name. If the query has results, the cleaning process is terminated directly, and no subsequent cleaning process is performed. The accurate query result of the historical alias library is returned, and the cleaning similarity in the returned result is 100%. If the query has no results, the cleaning process of steps S1-S2 is continued.
[0057] Furthermore, while performing the cleaning in steps S1-S2, model cleaning is added as a supplement to improve the probability of data being cleaned out; the specific process of the model cleaning is as follows:
[0058] C1. Pre-cleaning operation
[0059] After text preprocessing, if there are no accurate search results in the historical alias library, the preprocessed medical institution name text is used in real time to retrieve the encoder model to obtain vectorized text. Vector search operations are performed in the standard library using the inner product algorithm. After obtaining the vector result, the similarity value between the retrieved vector result and the vectorized array is calculated and sorted in descending order. The top M results are taken and returned.
[0060] C2. Rules and threshold determination
[0061] After obtaining the M vector search results with the highest similarity in step B1, the M vector search results are subjected to rule and threshold determination. The threshold is the minimum similarity value set by the user to determine whether the data cleaning is successful. The specific process of rule and threshold determination is as follows:
[0062] (1) If there is only one vector with a similarity of 100% in the TOP10 vector search results, the vector with 100% similarity is considered to be cleaned successfully;
[0063] (2) In the TOP10 vector search results, if there are two or more results with the same similarity above the threshold, and only one of the results has a medical institution with an operating status of "existing", it is considered to be cleaned successfully;
[0064] (3) In the TOP10 vector search results, if there is only one result with a similarity higher than the threshold, it is considered to be cleaned successfully;
[0065] (4) In the TOP10 vector search results, if there are multiple results with values above the threshold, they are considered to be cleaned and awaiting confirmation, and are marked as requiring manual intervention for confirmation;
[0066] (5) Except for the above four situations, the rest are judged as cleaning failures.
[0067] Furthermore, after the cleaning in steps S1-S2 or after the model cleaning, the cleaning results are quality-checked according to the set specifications;
[0068] After data quality inspection, the data is given different credibility levels based on the quality inspection results. The credibility is divided into three levels, from high to low credibility: credibility A, credibility B, credibility C. The credibility granting rules are as follows:
[0069] When the data quality inspection results are normal and the name of the medical institution in the cleansed results is exactly the same as the downstream institution name of the original data, the credibility level A is granted;
[0070] If the cleaning result has been cleaned by the historical alias database or confirmed by manual intervention, it will be given a credibility of A;
[0071] When the data quality inspection results are normal and the similarity of the data cleaning results is 100%, the credibility B is granted;
[0072] When the data quality inspection results are normal and the similarity of the data cleaning results is less than 100%, the credibility C is granted.
[0073] The beneficial effects of the present invention are:
[0074] 1. This paper proposes a hybrid contrastive learning scheme that combines unsupervised learning with partially supervised prior data. By introducing the SimCSE model for modeling, the process of vectorizing medical institution names is optimized. This hybrid learning approach not only leverages the advantages of unsupervised learning to improve the model's generalization capabilities, but also, by incorporating prior knowledge from supervised learning, makes the model more aligned with business needs and improves data cleaning accuracy.
[0075] 2. Innovative Application of the Single-Tower BERT Model. This paper uses a single-tower BERT model to re-rank recall results. Through two phases, training and prediction, the single-tower BERT model optimizes the sorting of recall data, further improving the accuracy of data cleaning. This model enables the system to more accurately identify and sort relevant medical institution names when faced with large amounts of recall data.
[0076] 3. The present invention adopts processes such as text preprocessing and historical alias library cleaning, which not only ensures the validity of data input, but also greatly improves the accuracy of data through the data quality inspection process, effectively reducing the cost of manual intervention.
[0077] 4. Innovative data quality inspection and credibility assessment mechanism. To improve the automation level of data cleaning, this invention innovatively proposes a data quality inspection process, assigning different credibility levels to data based on the quality inspection results. The application of this mechanism reduces the need for manual judgment, improves the automation level of the cleaning process, and also ensures the consistency and reliability of the cleaning results. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] Figure 1 This is an example of the sample data format for encoder model training in an embodiment of the present invention;
[0079] Figure 2 This is a flowchart of cleaning the historical alias library in an embodiment of the present invention. DETAILED DESCRIPTION
[0080] The present invention will be further described below in conjunction with the accompanying drawings. It should be noted that this embodiment is based on the technical solution and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to this embodiment.
[0081] This embodiment provides a medical institution name governance method based on contrastive learning, which implements medical institution name governance through contrastive learning models and text matching. The semantic expression of medical institution names is primarily achieved through the vectors output by the contrastive learning model. Furthermore, text matching of medical institution names is primarily performed using BM25. After recalling semantic and character similarity, a unified scoring model is used to achieve the goal of medical institution name governance. The goal of medical institution name governance is to project unknown medical institution names into an abstract unified code, achieving a unified semantic representation of medical institutions.
[0082] A medical institution name governance method based on contrastive learning includes the following steps:
[0083] S1. Vectorize the names of medical institutions in the pharmaceutical sales chain data to be cleaned using the encoder model;
[0084] S2. Perform text matching of medical institution names in the medical institution standard database and recall semantic and character similarities;
[0085] S3. Use the single-tower BERT model to reorder the data recalled in step S2, output the standard name of the medical institution with the largest score, and project the unknown medical institution name into the unified code corresponding to the standard name of the medical institution with the largest score.
[0086] In this embodiment, the medical institution standard library is constructed by manually sorting and reviewing the medical institution data accumulated by the company's internal business system and the external Internet. The fields of the standard library include four fields: unified code (zk_code), medical institution standard name (registered_name), medical institution formerly used name (use_name_set) and business organization name (customer_naem_set). The unified code abstractly describes the abstract concept of the medical institution, represents the objectively existing medical institution, and is used to uniquely identify the medical institution; the medical institution standard name represents the standard expression of the medical institution, which is the currently recognized name of the medical institution and facilitates relevant exchanges between medical institutions; the medical institution formerly used name represents the standard name of the medical institution. With the changes in related businesses, the standard name is modified, and the former standard name becomes the former used name; the business organization name is some names that appear in the actual business process of the medical institution, which may be the abbreviation of the medical institution, may be a less-worded or more-worded expression of the standard name, or may be a typo expression of the standard name. The medical institution’s standard name (registered_name), medical institution’s former name (use_name_set), and business organization’s name (customer_naem_set) are all vectorized through the encoder model.
[0087] In this embodiment, in step S1, the encoder model is based on contrastive learning. Contrastive learning is an unsupervised learning method whose core concept is to learn a meaningful representation by bringing similar pairs of samples closer together and dissimilar pairs apart. Based on the unsupervised learning of contrastive learning, this embodiment introduces partially supervised prior data to better meet business needs and proposes a hybrid contrastive learning scheme. Obtaining the encoder model includes sample construction and model training.
[0088] A1. Sample set construction
[0089] In this embodiment, the construction of the sample set is implemented according to the principle of In-batch negatives. In the process, some supervised prior data are introduced. The specific data format is as follows: Figure 1 As shown in Figure 2, samples are constructed using either semantic similarity or text distance similarity.
[0090] A11. Semantic similarity:
[0091] A111. Read data. Read the collected medical institution name dataset from the specified file path.
[0092] A112. Data preprocessing: Clean and format the text data in the dataset obtained in step A111.
[0093] A113. Encode text data. Use the pre-trained model to encode the text data cleaned and formatted in step A112 into an embedding vector.
[0094] A114. Construct a similarity matrix. Calculate the cosine similarity between the embedding vectors obtained in step A113 to construct a similarity matrix.
[0095] A115. Generate positive samples. For each text, find other texts with the same unified encoding zk_code as the positive samples.
[0096] A116. Generate negative samples. For each text, find the text with the largest approximation value from the similarity matrix and different from its unified code zk_code as a negative sample.
[0097] A117. Save the constructed sample set and write the generated sample set to a CSV file.
[0098] A12. Text distance similarity:
[0099] A121. Indexing synonym sets. Based on the medical institution standard library, a set of medical institution names with the same unified code is defined as a synonym set. The elements of the synonym set are constructed in the data format of (zk_code, medical institution name) and indexed into a full-text search database, such as Elasticsearch.
[0100] A122. Generate positive samples. Traverse the medical institution standard library and, for each text, find other texts with the same unified code zk_code as the positive sample.
[0101] A123. Generate negative samples. For each text, find the text with the largest matching value and different from its zk_code from the full-text retrieval database as a negative sample.
[0102] A124. Save the sample set. Write the generated sample set to a CSV file.
[0103] It should be noted that in the sample set obtained in step A11 or step A12, an ID is assigned to each text data to construct a mapping relationship between the ID and the text data, which facilitates the establishment of a relationship between each text data and the unified code. The set of medical institution names with the same unified code is defined as a synonym set. For example, for a unified code, there are multiple name character expressions such as {'Sun Yat-sen University Cancer Center', 'Sun Yat-sen University Affiliated Cancer Hospital', 'Sun Yat-sen University Cancer Hospital', 'Sun Yat-sen University Cancer Research Institute', 'Sun Yat-sen University Cancer Center Internet Hospital'}, and the expressions of these medical institution names are constructed into a synonym set. When there is only one element in a synonym set, the element is independently constructed into a sample, which is expressed in styles such as "<Sun Yat-sen University Cancer Center, Sun Yat-sen University Cancer Center>", "<Sun Yat-sen University Affiliated Cancer Hospital, Sun Yat-sen University Affiliated Cancer Hospital>".
[0104] like Figure 1 As shown in the sample set, for any element in the synonym set, no other elements of the synonym set will appear in the context field with a distance N from it. Suppose there is a synonym set as a represents the standard name of the medical institution, The m+1 synonyms of element a are multiple name character expressions in the unified code (zk_code). In the context field with a distance N from element a in the sample set, no synonyms will appear. Elements (i=0, 1, ...m). For example, for 'Sun Yat-sen University Cancer Center', in the context domain with a distance N from it, there will not be elements in the synonym set such as 'Sun Yat-sen University Affiliated Cancer Hospital' or 'Zhongda Cancer Hospital'.
[0105] In the sample set, for any element, its context is similar to that of the element’s N nearest neighbors. Figure 1 As shown, a, b, c, etc. are the most similar elements, such as {('Sun Yat-sen University Cancer Center', 'Sun Yat-sen University Cancer Center', 1), ('Hainan Cancer Center', 'Hainan Cancer Center', 1), ('Yunnan Cancer Hospital', 'The Third Affiliated Hospital of Kunming Medical College', 1), ('Huxiang Traditional Chinese Medicine Cancer Hospital', 'Changsha Yuelu District People's Hospital', 1), ('Affiliated Cancer Hospital of Guangzhou Medical University', 'Guangzhou Cancer Center', 1), ...}.
[0106] A2. Encoder model training:
[0107] In this embodiment, the encoder model is modeled using the SimCSE model based on the contrastive learning method. The SimCSE model uses the twin-tower model as a semantic framework, that is, encoding the text of the two medical institution names separately and then calculating their similarity. The specific training process is divided into three steps: forward calculation, definition of loss function, and reverse calculation:
[0108] Step A21, forward calculation. For any sample x i ∈X, X represents the sample set. Sample x i The two elements in are calculated by the base encoder respectively. In this embodiment, Chinese BERT is selected as the base encoder, which can be expressed as:
[0109] base_vec1,base_vec2=encode_base(x i,1 ,t1),encode_base(x i,2 ,t2)
[0110] Where encode_base(·) represents the base encoder function, using Chinese BERT, t1, t2 represent the parameters of the Dropout layer in the base encoder, the larger t1, t2 are, the more invalid neural network elements are output by the neural network, x i,1 ,x i,2 Represents sample x respectively i The first and second elements of .
[0111] Step A22: Define the loss function. For a given batch B of training data, the loss function is defined as:
[0112]
[0113] Among them, the similarity sim(·,·) is calculated using cosine.
[0114] Step A23, reverse calculation. First, calculate the gradient of the loss function Loss with respect to the model parameters through the back propagation algorithm. Then, use these gradients to iteratively update the parameters through the gradient descent method or its variants to reduce the value of the loss function. The specific update formula is:
[0115] θ new =θ old -ηΔ θ Loss
[0116] Among them, θ represents the model parameters, η represents the learning rate, Δ θ Loss represents the gradient of the loss function with respect to the parameter θ.
[0117] With multiple iterations, the model is gradually optimized, the loss function value continues to decrease, and the model performance is improved. Finally, this process completes the learning of the encoder model. * (·)=encode_base(·,0).
[0118] In this embodiment, in step S2, the text character similarity recall is mainly completed by a character similarity algorithm, such as edit distance, BM25 algorithm, etc. This embodiment adopts the BM25 algorithm, and the specific formula is as follows:
[0119]
[0120] bm25(W,D) represents the similarity score between the name of the medical institution to be queried W and the standard name of the medical institution D, w i Indicates the i-th element after the word W, n(w i ) means including element w i The number of all standard names, N represents the number of standard names of all medical institutions, f(w i ,D) represents the element w i The frequency in D, |D| represents the length of the standard name D, avgdl represents the average length of the standard names of all medical institutions, k1 and b represent hyperparameters, which respectively control the rising speed of the word frequency results in the word frequency saturation and the role played by the field length normalization value. The default values are 1.2 and 0.75, respectively.
[0121] In this embodiment, the character matching service system is Elasticsearch. Elasticsearch is an open-source, distributed, RESTful search and analysis engine built on Apache Lucene. It allows for rapid storage, search, and analysis of large amounts of data, implements full-text search capabilities, and is well-suited for processing a wide range of search queries.
[0122] In this embodiment, in step S2, text semantic similarity recall is completed using a vector similarity algorithm for medical institution names. The vector similarity algorithm can be an algorithm such as Euclidean distance, Manhattan distance, and cosine distance. This embodiment specifically defines the semantic similarity of medical institution names based on the cosine distance algorithm. The specific formula is as follows:
[0123]
[0124] Wherein, vec1=encode(W), vec2=encode(D), encode(·) represents the encoder model, which is used to convert the text of the medical institution name into a vector, W represents the name of the medical institution to be queried, D represents the standard name of the medical institution, vec1 represents the vector of W, and vec2 represents the vector of D.
[0125] In this embodiment, in step S3, a single-tower BERT scoring model is used to reorder the recall data obtained in step S2.
[0126] The single-tower BERT model is mainly divided into two stages: training and prediction.
[0127] B1. Training: Collect samples and format them as "[CLS]Medical Institution Name 1[SEP]Medical Institution Name 2[SEP]," for example, "[CLS]XX Pharmacy, Shuangliu District, Chengdu (Sichuan Province)[SEP]XX Pharmacy, Shuangliu District, Chengdu[SEP]." During training, [CLS] is used as the output of the single-tower BERT model. When the elements are relevant, the sample is labeled 1; otherwise, it is labeled 0.
[0128] B2. The specific steps of the prediction stage are:
[0129] B21. Sort the standard names of medical institutions obtained by recalling text character similarity and recalling text semantic similarity in descending order respectively;
[0130] B22. Select the top N candidate elements for the standard medical institution names obtained from the text character similarity recall and text semantic similarity recall, and encapsulate them into the format of [CLS]Medical Institution 1[SEP]Medical Institution 2[SEP] as the input to the single-tower BERT model, where Medical Institution 1 is the name of the medical institution to be queried and Medical Institution 2 is the recalled standard medical institution name. For example, "[CLS]Shuangliu District XX Pharmacy[SEP]Chengdu Shuangliu District XX Pharmacy[SEP]"
[0131] B23. Obtain the standard name of the medical institution with the highest output score from the single-tower BERT model, complete the mapping of the same code, and finally output the unified code of the medical institution.
[0132] Furthermore, in this embodiment, before the field names in the flow data to be cleaned are managed, the field names in the flow data to be cleaned are first subjected to text preprocessing and historical alias library cleaning, which can ensure the validity and certainty of the input data. Specifically, the specific process of text preprocessing is as follows:
[0133] In the actual pharmaceutical sales business, the names of upstream and downstream medical institutions in the sales chain have their own independent names in the ERP systems of major distributors. For example, the name of the upstream medical institution may be the name of the distributor, not the real name. In another example, the names of upstream and downstream medical institutions may be abbreviations, symbols, codes, and other irregular names. Before text cleaning, these medical institution names need to be preprocessed. Preprocessing can be done in any of the following ways:
[0134] (1) Direct text replacement: Direct text replacement is applicable to distributors with special internal names, and directly replaces the designated special name with the recognizable medical institution name text;
[0135] (2) Regular replacement: Regular replacement is suitable for converting a type of data that meets the regular conditions into recognizable medical institution name text.
[0136] Specifically, a preprocessing rule group can be used to support sequential preprocessing replacements. This has been verified in real-world scenarios, and the text preprocessing process significantly improves the final cleaning accuracy. Table 1 lists some preprocessing rules.
[0137] Table 1
[0138]
[0139] The specific process of cleaning the historical alias library is as follows:
[0140] The historical alias library is an accumulation of historical cleaning data. The data that has been cleaned and confirmed to be successfully cleaned is valuable cleaning experience. By effectively storing this data, not only can the cleaning efficiency be improved and the cleaning time be reduced, but the cleaning accuracy can also be improved through experience.
[0141] like Figure 2 As shown, the historical alias database includes the original upstream medical institution names, the original downstream medical institution names, and the successfully cleaned downstream medical institution names. When cleaning the historical alias database, the pre-processed medical institution name text is first accurately queried in the historical alias database, with the query fields being the original upstream institution names and the original downstream institution names. If the query yields a result, the cleaning process is terminated without further cleaning. The accurate query result of the historical alias database is returned, with a cleaned similarity of 100%. If the query yields no result, the cleaning process continues with steps S1-S2.
[0142] In this embodiment, while performing the cleaning of steps S1-S2, model cleaning is added as a supplement to improve the probability of data cleaning. If the cleaning of steps S1-S2 fails, model cleaning can be further used. The specific process of the model cleaning is as follows:
[0143] C1. Pre-cleaning operation
[0144] After text preprocessing, if there are no accurate query results in the historical alias library, the preprocessed medical institution name text is retrieved in real time from the encoder model to obtain vectorized text, and a vector search operation is performed in the standard library. The vector search uses the IP (inner product) algorithm. After obtaining the vector result, the similarity value between the retrieved vector result and the vectorized array is calculated and sorted in descending order. The top 10 results are taken and returned.
[0145] The inner product calculation formula is:
[0146] For two vectors a = (a1, a2, ..., an) and b = (b1, b2, ..., bn), their inner product is defined as:
[0147]
[0148] The core parameters of MILVUS vector retrieval are:
[0149] {"topK::10,"metricType":"IP","nprobe":8}
[0150] C2. Rules and threshold determination
[0151] After obtaining the 10 most similar vector search results in step B1, the 10 vector search results are subjected to rule and threshold determination. The threshold is the minimum similarity value set by the user to determine whether the data cleaning is successful. The specific process of rule and threshold determination is as follows:
[0152] (1) If there is only one vector with a similarity of 100% in the TOP10 vector search results, the vector with 100% similarity is considered to be cleaned successfully;
[0153] (2) In the TOP10 vector search results, if there are two or more results with the same similarity above the threshold, and only one of the results has a medical institution with an operating status of "existing", it is considered to be cleaned successfully;
[0154] (3) In the TOP10 vector search results, if there is only one result with a similarity higher than the threshold, it is considered to be cleaned successfully;
[0155] (4) In the TOP10 vector search results, if there are multiple results with values above the threshold, they are considered to be cleaned and awaiting confirmation, and are marked as requiring manual intervention for confirmation;
[0156] (5) Except for the above four situations, the rest are judged as cleaning failures.
[0157] In this embodiment, after completing data cleaning, further data quality inspection can greatly improve the accuracy of the data and effectively reduce the cost of manual intervention. The specific process of data quality inspection is as follows:
[0158] After the cleaning process of steps S1-S2 or model cleaning, the data cleaning results are often uncertain and unreliable. To help users intuitively and efficiently quality check the data results after the cleaning process, this embodiment defines the specifications for machine quality inspection based on a large amount of experience in actual business scenarios, as shown in Table 2.
[0159] Table 2
[0160]
[0161] Among them, the four specifications are defined as:
[0162] (1) Entity type: common medical institution entities such as clinics, hospitals, pharmacies, and branches.
[0163] (2) Chain brand: a large-scale chain brand that sells pharmaceuticals.
[0164] (3) Region: Provinces, cities, districts, sub-districts, etc. as defined in the Administrative Regional Planning of the People’s Republic of China.
[0165] (4) Names: Names extracted by the open source NLP framework HanLP.
[0166] After data quality inspection, the data is given different credibility levels based on the quality inspection results. The credibility is divided into three levels, from high to low credibility: credibility A, credibility B, credibility C. The credibility granting rules are as follows:
[0167] When the data quality inspection results are normal and the name of the medical institution in the cleansed results is exactly the same as the downstream institution name of the original data, the credibility level A is granted;
[0168] If the cleaning result has been cleaned by the historical alias database or confirmed by manual intervention, it will be given a credibility of A;
[0169] When the data quality inspection results are normal and the similarity of the data cleaning results is 100%, the credibility B is granted;
[0170] When the data quality inspection results are normal and the similarity of the data cleaning results is less than 100%, the credibility C is granted.
[0171] Those skilled in the art can make various corresponding changes and modifications based on the above technical solutions and concepts, and all of these changes and modifications should be included in the scope of protection of the claims of the present invention.
Claims
1. A medical institution name management method based on contrastive learning, characterized by: The steps include: S1. Vectorize the names of medical institutions in the pharmaceutical sales chain data to be cleaned using the encoder model; the encoder model is modeled using the SimCSE model based on the contrastive learning method; S2. Perform text matching of medical institution names in the medical institution standard database and recall semantic and character similarities; S3. Reorder the data recalled in step S2 using a single-tower BERT model, output the standard name of the medical institution with the highest score, and project the unknown medical institution name into the unified code corresponding to the standard name of the medical institution with the highest score; The fields of the medical institution standard library include a unified code, a medical institution standard name, a medical institution's former name, and a business organization name; the unified code is used to uniquely identify a medical institution; the medical institution standard name represents a standard expression of the medical institution and is the currently recognized name of the medical institution; the medical institution's former name represents the medical institution's former standard name. As the relevant business changes, the standard name is modified and the former standard name becomes the former name; the business organization name is some names that appear in the actual business process of the medical institution; the medical institution standard name, medical institution's former name, and business organization name are all vectorized through the encoder model; In step S2, text character similarity recall is completed through a character similarity algorithm, which is implemented using the BM25 algorithm. The specific formula is as follows: bm25(W,D) represents the similarity score between the name of the medical institution to be queried W and the standard name of the medical institution D, w i Indicates the i-th element after the W segmentation, n(w i ) means including element w i The number of all standard names, N represents the number of standard names of all medical institutions, f(w i ,D) represents the element w i The frequency in D, |D| represents the length of the standard name D, avgdl represents the average length of the standard names of all medical institutions, k1, b represent hyperparameters, which respectively control the rising speed of the word frequency results in the word frequency saturation and the role played by controlling the field length normalization value; In step S2, text semantic similarity recall is completed by the vector similarity algorithm of the medical institution names. The semantic similarity of the medical institution names is defined based on the cosine distance algorithm. The specific formula is as follows: Where, vec1=encode(W), vec2=encode(D), encode(·) represents the encoder model, which is used to convert the text of the medical institution name into a vector, W represents the name of the medical institution to be queried, D represents the standard name of the medical institution, vec1 represents the vector of W, and vec2 represents the vector of D; In step S3, the single-tower BERT scoring model is used to re-rank the recall data obtained in step S2.
2. The method according to claim 1, characterized in that The encoder model is an encoder model based on contrastive learning, and its acquisition includes sample construction and model training; A1. Sample set construction: Use either semantic similarity or text distance similarity to construct samples; A11. Semantic similarity: A111. Read data: read the collected medical institution name dataset from the specified file path; A112. Data preprocessing: cleaning and formatting the text data in the dataset obtained in step A111; A113. Encode text data: Use the pre-trained model to encode the text data cleaned and formatted in step A112 into an embedding vector; A114. Construct a similarity matrix; calculate the cosine similarity between the embedding vectors obtained in step A113 to construct a similarity matrix; A115. Generate positive samples. For each text, find other texts with the same unified code zk_code as the positive samples. A116. Generate negative samples. For each text, find the text with the largest approximation value and different from its unified code zk_code from the similarity matrix as a negative sample. A117. Save the constructed sample set; write the generated sample set to a CSV file; A12. Text distance similarity: A121. Indexing synonym sets: Based on the medical institution standard library, a set of medical institution names with the same unified code is defined as a synonym set. The elements of the synonym set are constructed in the data format of (zk_code, medical institution name) and indexed into the full-text search database. A122. Generate positive samples: Traverse the medical institution standard library and, for each text, find other texts with the same unified code zk_code as positive samples; A123. Generate negative samples: For each text, find the text with the largest matching value and different zk_code from the full-text search database as a negative sample; A124. Save sample set: Write the generated sample set to a CSV file; In the sample set obtained in step A11 or step A12, an ID is assigned to each text data to establish a mapping relationship between the ID and the text data, so as to facilitate the establishment of a relationship between each text data and the unified code; a set of medical institution names with the same unified code is defined as a synonym set; in the sample set, for any element in the synonym set, no other element in the synonym set appears in the context domain with a distance N from it; in the sample set, for any element, its context is similar to that element in N nearest neighbors; A2. Encoder model training: The specific training process of the encoder model is divided into three steps: forward calculation, definition of loss function, and reverse calculation: Step A21, forward calculation; for any sample x i ∈X, X represents the sample set; sample x i The two elements in are calculated by the base encoder respectively, using Chinese BERT as the base encoder, expressed as: base_vec i,1 ,base_vec i,2 =encode_base(x i,1 ,t1),encode_base(x i,2 ,t2) Among them, encode_base(·) represents the base encoder function, using Chinese BERT, t1, t2 represent the parameters of the Dropout layer in the base encoder, the larger t1, t2 are, the more invalid neural network elements are output by the neural network, x i,1 ,x i,2 Represents sample x respectively i The first and second elements of ; Step A22, define the loss function: For a given batch B of training data, the loss function is defined as: Among them, the similarity sim(·,·) is calculated using cosine; Step A23, reverse calculation: First, calculate the gradient of the loss function Loss with respect to the model parameters through the back propagation algorithm. Then, use these gradients to iteratively update the parameters through the gradient descent method or its variants to reduce the value of the loss function. The specific update formula is: i new =θ old -ηD θ Loss Among them, θ represents the model parameters, θ old and θ new Represent the model parameters before and after update respectively; η represents the learning rate, Δ θ Loss represents the gradient of the loss function with respect to the parameter θ; With multiple iterations, the model is gradually optimized, the loss function value continues to decrease, and the model performance is improved; finally, this process completes the learning of the encoder model. * (·)=encode_base(·,0).
3. The method according to claim 1, characterized in that The single-tower BERT model is divided into two stages: training and prediction; B1. Training phase: Collect samples and format them into "[CLS] Medical institution name 1 [SEP] Medical institution name 2 [SEP]"; B2. The specific steps of the prediction stage are: B21. Sort the standard names of medical institutions obtained by recalling text character similarity and recalling text semantic similarity in descending order respectively; B22. Select the top N candidate elements of the medical institution standard names obtained by recalling text character similarity and text semantic similarity, respectively, and encapsulate them into the format of [CLS]Medical Institution 1[SEP]Medical Institution 2[SEP] as the input of the single-tower BERT model, where Medical Institution 1 is the name of the medical institution to be queried and Medical Institution 2 is the recalled medical institution standard name; B23. Obtain the standard name of the medical institution with the highest output score from the single-tower BERT model, complete the mapping of the unified code, and finally output the unified code of the medical institution.
4. The method according to claim 1, wherein Before managing the field names in the flow data to be cleaned, perform text preprocessing and historical alias library cleaning on the field names in the flow data to be cleaned; Text preprocessing uses any of the following methods: (1) Direct text replacement: Direct text replacement is applicable to distributors with special internal names, and directly replaces the designated special name with the recognizable medical institution name text; (2) Regularization replacement: Regularization replacement is used to uniformly convert a type of data that meets the regularization conditions into identifiable medical institution name text; The specific process of cleaning the historical alias library is as follows: The historical alias library includes the original upstream medical institution name, the original downstream medical institution name, and the downstream medical institution name that has been successfully cleaned; when cleaning the historical alias library, the pre-processed medical institution name text is first accurately queried in the historical alias library, and the query fields are the original upstream institution name and the original downstream institution name. If the query has results, the cleaning process is directly terminated, and no subsequent cleaning process is performed. The accurate query result of the historical alias library is returned, and the cleaning similarity in the returned result is 100%. If the query has no results, the cleaning process of steps S1-S2 is continued.
5. The method according to claim 4, characterized in that While performing the cleaning in steps S1-S2, model cleaning is performed as a supplement to improve the probability of data being cleaned out. The specific process of the model cleaning is as follows: C1. Pre-cleaning operation After text preprocessing, if there are no accurate search results in the historical alias library, the preprocessed medical institution name text is used in real time to retrieve the encoder model to obtain vectorized text. Vector search operations are performed in the standard library using the inner product algorithm. After obtaining the vector result, the similarity value between the retrieved vector result and the vectorized array is calculated and sorted in descending order. The top M results are taken and returned. C2. Rules and threshold determination After obtaining the M vector search results with the highest similarity in step C1, the M vector search results are subjected to rule and threshold determination. The threshold is the minimum similarity value set by the user to determine that the data cleaning is successful. The specific process of rule and threshold determination is as follows: (1) If there is only one vector with a similarity of 100% in the TOP10 vector search results, the vector with 100% similarity is considered to be cleaned successfully; (2) In the TOP10 vector search results, if there are two or more results with the same similarity above the threshold, and only one of the results has a medical institution with an operating status of "existing", it is considered to be cleaned successfully; (3) In the TOP10 vector search results, if there is only one result with a similarity higher than the threshold, it is considered to be cleaned successfully; (4) In the TOP10 vector search results, if there are multiple results with values above the threshold, they are considered to be cleaned and awaiting confirmation, and are marked as requiring manual intervention for confirmation; (5) Except for the above four situations, the rest are judged as cleaning failures.
6. The method according to claim 5, characterized in that After the cleaning in steps S1-S2 or after the model is cleaned, the cleaning results are quality inspected according to the set specifications; After data quality inspection, different credibility levels are assigned to the data based on the quality inspection results. The credibility is divided into three levels, from high to low: credibility A, credibility B, and credibility C. The credibility granting rules are as follows: When the data quality inspection results are normal and the name of the medical institution in the cleansed results is exactly the same as the downstream institution name of the original data, the credibility level A is granted; If the cleaning result has been cleaned by the historical alias database or confirmed by manual intervention, it will be given a credibility of A; When the data quality inspection results are normal and the similarity of the data cleaning results is 100%, the credibility B is granted; When the data quality inspection results have no anomalies and the similarity of the data cleaning results is less than 100%, the credibility C is granted.
Citation Information
Patent Citations
Medical examination item standardization system and method based on medical knowledge graph and pre-training model
CN113191156A
Medical term standardization method based on deep learning
CN116975201A