Fuzzy font recognition method based on collaborative filtering algorithm and knowledge graph
By introducing collaborative filtering algorithm and knowledge graph into OCR technology, combined with BERT and Transformer models, the problem of insufficient accuracy of fuzzy font recognition is solved, and a more efficient fuzzy font recognition effect is achieved, which is suitable for the field of optical character recognition.
Patent Information
- Application Number
- CN202410877384.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-02
- Publication Date
- 2024-10-01
AI Technical Summary
Existing OCR technology has insufficient accuracy in blurry font recognition, especially when scanning quality is low, printing quality issues, image noise, and character overlap make it difficult to effectively identify blurry fonts.
Using a method based on the collaborative filtering algorithm and knowledge graph, the BERT model is used to vectorize the fuzzy font sentences, calculate the cosine similarity with the text library sentences, filter related entities, use the BFS algorithm to expand the knowledge graph, and apply collaborative filtering to analyze potential Correlation degree, combined with Transformer model to predict fuzzy fonts.
The accuracy and efficiency of fuzzy font recognition are improved, and the true content of fuzzy fonts can be accurately predicted in complex contexts. It has broad application prospects and commercial value.
Smart Images

Figure CN118736609A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of font recognition technology, and in particular to a fuzzy font recognition method based on a collaborative filtering algorithm and a knowledge graph. Background Art
[0002] Early OCR technology mainly relied on template matching technology, which requires pre-defining the shape template of the characters and then searching for matching patterns in the image. This method works well for standardized printed text, but not well for handwritten text or text with large font variations.
[0003] With the development of pattern recognition, artificial intelligence and machine learning technologies, OCR technology is also constantly improving; modern OCR usually adopts statistical learning methods to recognize characters by training a large amount of sample data. These methods include feature extraction, classifier design and deep learning.
[0004] For current OCR recognition technology, the recognition of blurred fonts is a major difficulty. Blurred fonts may be caused by a variety of reasons, such as poor scanning quality, print quality problems, image noise, character overlap, etc. These problems pose a challenge to the accurate recognition of characters. In order to solve these problems, researchers and developers are constantly exploring new technologies and methods.
[0005] Deep learning methods, such as the patent with publication number CN117474012A, use convolutional neural networks (CNN) and recurrent neural networks (RNN) for semantic recognition, but this model is not suitable for blurred font recognition; existing methods have made certain progress in improving the accuracy of blurred font recognition, and data enhancement technology and adversarial training are also used to improve the robustness of the model for blurred images; despite this, OCR recognition of blurred fonts is still an active research field that requires continuous technological innovation and algorithm optimization. Summary of the invention
[0006] In view of the shortcomings of the existing methods, the present invention utilizes collaborative filtering and knowledge graphs to perform fuzzy font recognition and improve the accuracy of fuzzy font recognition.
[0007] The technical solution adopted by the present invention is: a fuzzy font recognition method based on collaborative filtering algorithm and knowledge graph includes the following steps:
[0008] Step 1: vectorize the sentence A in fuzzy font;
[0009] As a preferred embodiment of the present invention, sentence A in ambiguous font is vectorized by using a BERT model.
[0010] Step 2: Calculate the vector V of sentence A in fuzzy font Aand the vector V of sentence B in the text library B The cosine similarity value between A With V B Construct a sentence set β based on the cosine similarity values between them; and filter out the related entity set contained in β;
[0011] As a preferred embodiment of the present invention, construct the sentence set β as V A With V B The cosine similarity value between them is greater than the first threshold.
[0012] As a preferred implementation of the present invention, the ExtractEntities function is used to filter out the related entity set contained in β.
[0013] Step 3: Use the BFS algorithm to expand the entity nodes to the first-order domain and obtain the expanded knowledge graph entity relationship set R;
[0014] As a preferred implementation of the present invention, the ExpandKnowledgeGraph function is used to expand the entity nodes to the first-order domain.
[0015] Step 4: Use collaborative filtering algorithm to analyze the entity relationship set R, obtain the potential correlation score with fuzzy words in the knowledge graph, and sort the scores in descending order. Entities exceeding the second threshold are selected as the recommendation list; the entities with the highest correlation with fuzzy words are composed of the entity set E. r ;
[0016] As a preferred implementation of the present invention, obtaining the recommendation list specifically includes:
[0017] Step 41: For m sentences and n entities, construct an m×n matrix M;
[0018] Step 42: For sentence s i In the fuzzy font, calculate the sentence s i With entity e j Similarity score of
[0019] Step 43: Calculate sentence s based on similarity score i The fuzzy font in the generated recommendation score Rec(s i , e j ).
[0020] Step 5: According to the entity set E r , the context information C of the fuzzy font, the predicted fuzzy font;
[0021] As a preferred implementation of the present invention, step five specifically includes:
[0022] Step 51: For entity set E r ={e1, e2, ...e i , e n Each entity e in i , using the entity embedding matrix W E To get the embedding vector
[0023] Step 52: For context information C = {c1, c2, ..c j ., c m Each word c in j , using the word embedding matrix W W To get its embedding vector
[0024] Step 53: Concatenate entity set features and context information features.
[0025] As a preferred implementation of the present invention, step five also includes: inputting the concatenated features into a Transformer model to predict blurred fonts.
[0026] As a preferred embodiment of the present invention, the Transformer model includes: setting the number of encoder layers to 6 layers, the number of decoder layers to 6 layers, the hidden layer size to 512, and the number of multi-head attention heads to 8.
[0027] As a preferred implementation of the present invention, the Transformer model is trained using a cross entropy loss function.
[0028] Beneficial effects of the present invention:
[0029] 1. Use collaborative filtering algorithm to find out external knowledge features related to fuzzy fonts and apply them to model reasoning to identify fuzzy fonts;
[0030] 2. The method of the present invention can be applied to optical character recognition and has certain commercial value;
[0031] 3. The present invention combines advanced natural language processing technology and knowledge graphs, and improves the accuracy and efficiency of fuzzy font recognition through a collaborative filtering algorithm; this method can not only process a single fuzzy font, but also accurately predict the true content of the fuzzy font in a complex context, and has broad application prospects. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 It is a logical block diagram of fuzzy font recognition based on collaborative filtering algorithm and knowledge graph of the present invention;
[0033] Figure 2It is a flow chart of fuzzy font recognition based on collaborative filtering algorithm and knowledge graph of the present invention. DETAILED DESCRIPTION
[0034] The present invention is further described below in conjunction with the accompanying drawings and embodiments. This figure is a simplified schematic diagram, which only illustrates the basic structure of the present invention in a schematic manner, and therefore it only shows the components related to the present invention.
[0035] like Figure 1 and 2 As shown, a fuzzy font recognition method based on collaborative filtering algorithm and knowledge graph includes the following steps:
[0036] Step 1: For a sentence A with blurred fonts, use the BERT model to vectorize sentence A into V A =BERT(A), V A is the vector representation of sentence A;
[0037] Step 2: Calculate the sentence vector V A And the vector representation V of sentence B in the text library B The cosine similarity between ;
[0038] The text library is a database for storing sentences, and the data sources include the Internet, books, magazines, etc. The sentences in the text library are used to perform similarity calculation with sentence A, but sentence A blocks ambiguous words during calculation.
[0039] The formula for cosine similarity is:
[0040]
[0041] Among them, V B is the vector representation of sentence B in the text library, Sim(V A ,V B ) is the sentence vector V A and V B The similarity between them, cos represents the cosine similarity, ||V A || and ||V B || are vectors V A and V B The Euclidean norm of .
[0042] The sentences with similarity greater than the first threshold are retained to form a similar sentence set β, where the first threshold is a predefined hyperparameter. The named entity recognizer is used to filter out the related entity set E={e1, e2, ..., e n}=ExtractEntities(B); where E is the entity set extracted from sentence B, n represents the number of entity nodes, and e nis the nth entity node, and ExtractEntities is the entity extraction function.
[0043] Step 3: Use the BFS algorithm to n Expand to the first-order domain, that is, the domain directly related to the entity, and obtain the expanded knowledge graph entity relationship set R, R = ExpandKnowledgeGraph(E), where ExpandKnowledgeGraph is the knowledge graph expansion function.
[0044] Step 4: Use collaborative filtering algorithm to analyze the entity relationship set R, obtain the potential correlation score with the fuzzy word in the knowledge graph, and sort the scores in descending order. The entities with the highest scores exceeding the second threshold are selected as the recommendation list. The second threshold n r >0.5; n in the entity relationship set R with the highest correlation with the fuzzy word r Entities form an entity set E r .
[0045] The recommended list includes:
[0046] Step 41: For m sentences and n entities, construct an m×n matrix M; where M ij represents the strength of association between sentence i and entity j; if sentence i contains entity j, then M ij Set to 1 if false, 0 otherwise.
[0047]
[0048] Step 42: For sentence s i In the fuzzy font, calculate the sentence s i With entity e j The similarity score Sim(s i , e j ), using the cosine similarity formula:
[0049]
[0050] in, It is a sentence i Medium Entity k The weight of It is a sentence B Medium Entity j The weight K is related to the sentence s i The number of the k most similar sentences.
[0051] Step 43: Calculate sentence s based on similarity score i The fuzzy font in the generated recommendation score Rec(s i , ej ); the calculation method is:
[0052]
[0053] Among them, Rec(s i , e j ) is the sentence s i For entity e j The recommendation score of the model predicts that entity e j As a sentence i The confidence of the possible answers to the ambiguous words in the i , e j ) is the sentence s i and entity e j Similarity score; For sentence s B The sum of the association strengths of all entities in R Bk Indicates sentence s B The association strength of the kth entity in s can be based on the frequency of the entity in the sentence or other relevance measures; K is the number of entities in the sentence s i Most similar sentences B The total number of entities in ; is the normalization factor, representing sentence s i With all similar entities e k The sum of similarity scores.
[0054] Formula (4) is the sentence s i Recommend the most likely related entity in the fuzzy word j ; By considering the similarity between sentences and entities and the association strength of entities in sentences, the model is able to assign a recommendation score to each possible answer and then generate a recommendation list based on these scores.
[0055] Step 5: According to the entity set E r , the context information C of the fuzzy font, the predicted fuzzy font is Among them, Transformer is a model used for prediction and classification.
[0056] Models for predictive classification include:
[0057] Step 51: For entity set E r ={e1, e2, ...e i , e n Each entity e in i , using the entity embedding matrix W E To get the embedding vector Among them, W E is the entity embedding matrix, ei As a one-hot encoding of the entity.
[0058] Step 52: For context information C = {c1, c2, ..c j ., c m Each word c in j , using the word embedding matrix W W To get its embedding vector The acquisition method is as follows: Among them, W W is the word embedding matrix, c j is the one-hot encoding of the word, and C is the information in the sentence that does not contain the ambiguous font.
[0059] Step 53: Concatenate the processed entity set features and context information features and input them into the Transformer model to predict the blurred font During training, the cross entropy loss function is used to calculate the predicted labels. The difference between the actual label y and the actual label y, the loss function is defined as follows:
[0060]
[0061] Where N is the number of categories, y i is the one-hot encoding of the i-th class in the true label y, is the probability of the i-th class predicted by the model.
[0062] The Transformer model includes: setting the number of encoder layers to 6, the number of decoder layers to 6, the hidden layer size to 512, and the number of multi-head attention heads to 8. The vocabulary size containing the entity names in the involved sentences and knowledge graphs is 15,000, and the maximum sequence length of sentences is set to 100; during the training process, the learning rate size is set to 0.001, the batch size is set to 64, the training cycle is set to 10, the Adam optimizer is used, and the dropout ratio is set to 0.1.
[0063] Based on the above ideal embodiments of the present invention, the relevant staff can make various changes and modifications without departing from the technical concept of the present invention through the above description. The technical scope of the present invention is not limited to the contents of the specification, and its technical scope must be determined according to the scope of the claims.
Claims
1. A fuzzy font recognition method based on collaborative filtering algorithm and knowledge graph, characterized by: The following steps are involved: Step 1: Vectorize sentence A in fuzzy font; Step 2: Calculate the vector V of sentence A in fuzzy font A and the vector V of sentence B in the text library B The cosine similarity value between them; and construct the sentence set β using the cosine similarity value; filter out the related entity set contained in β; Step 3: Use the BFS algorithm to expand the entity nodes to the first-order domain and obtain the expanded knowledge graph entity relationship set R; Step 4: Use the collaborative filtering algorithm to analyze the entity relationship set R, obtain the potential correlation score of the fuzzy word in the knowledge graph, and sort the scores in descending order. Entities exceeding the second threshold are selected as the recommendation list; The second threshold entities with the highest correlation with the fuzzy word are combined into the entity set E r ; Step 5: According to the entity set E r , the context information C of the fuzzy font, the predicted fuzzy font.
2. The fuzzy font recognition method based on collaborative filtering algorithm and knowledge graph according to claim 1 is characterized in that: The recommended list includes: Step 41: For m sentences and n entities, construct an m×n matrix M; Step 42: For sentence s i In the fuzzy font, calculate the sentence s i With entity e j Similarity score of Step 43: Calculate sentence s based on similarity score i Fuzzy font generation recommendation score Rec(s i ,e j ).
3. The fuzzy font recognition method based on collaborative filtering algorithm and knowledge graph according to claim 1 is characterized in that: Step 5 specifically includes: Step 51: For the entity set E r ={e1,e2,…e i ,e n Each entity e in i , using the entity embedding matrix W E To get the embedding vector Step 52: For context information C = {c1, c2, ..c j .,c m Each word c in j , using the word embedding matrix W w To get its embedding vector Step 53: Concatenate the entity set features and the context information features.
4. The fuzzy font recognition method based on collaborative filtering algorithm and knowledge graph according to claim 3 is characterized in that: Step five also includes: inputting the concatenated features into the Transformer model to predict blurred fonts.
5. The fuzzy font recognition method based on collaborative filtering algorithm and knowledge graph according to claim 4 is characterized in that: The Transformer model includes: setting the number of encoder layers to 6, the number of decoder layers to 6, the hidden layer size to 512, and the number of multi-head attention heads to 8.
6. The fuzzy font recognition method based on collaborative filtering algorithm and knowledge graph according to claim 5 is characterized in that: The Transformer model is trained using the cross entropy loss function.
7. The fuzzy font recognition method based on collaborative filtering algorithm and knowledge graph according to claim 1 is characterized in that: Sentence A in ambiguous font is vectorized using the BERT model.
8. The fuzzy font recognition method based on collaborative filtering algorithm and knowledge graph according to claim 1 is characterized in that: Construct sentence set β as V A With V B The cosine similarity value between them is greater than the first threshold.
9. The fuzzy font recognition method based on collaborative filtering algorithm and knowledge graph according to claim 1 is characterized in that: Use the ExtractEntities function to filter out the related entity set contained in β.
10. The fuzzy font recognition method based on collaborative filtering algorithm and knowledge graph according to claim 1 is characterized in that: Use the ExpandKnowledgeGraph function to expand entity nodes to the first-order domain.
