Text recognition method, electronic equipment and storage medium
By first determining whether the text to be recognized contains sensitive information in the text recognition method, and using the preset knowledge base and semantic analysis model for identification, the problems of limited model capabilities and high rejection rate in the existing technology are solved, and a better solution is achieved. Safe and efficient text recognition results.
Patent Information
- Application Number
- CN202410656570.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2024-10-11
AI Technical Summary
Existing text recognition methods adopt strict security filtering strategies, resulting in limited model capabilities and high rejection rates, affecting user experience.
By obtaining the text to be recognized, first determine whether it contains sensitive information. If it does, obtain the preset text recognition result. Otherwise, enter the text recognition model for recognition, and use the preset knowledge base, semantic analysis model and sensitive word vector library for matching, reducing The probability of mismatching improves security and user experience.
Conducting security screening before text recognition improves the security of text recognition, reduces the rejection rate of the model, and improves user experience.
Smart Images

Figure CN118761399A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of text recognition, and specifically provides a text recognition method, an electronic device and a storage medium. Background Art
[0002] Artificial intelligence is a discipline that studies how to use computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.). It includes both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing. Artificial intelligence software technologies mainly include computer vision technology, speech recognition technology, natural language processing technology, machine learning / deep learning, big data processing technology, knowledge graph technology, and other major directions. With the development of Internet technology, text recognition and text data desensitization technology have become particularly important for various reasons such as file review and user privacy protection.
[0003] Existing text recognition methods adopt strict security filtering strategies, such as the currently commonly used sensitive word filtering method, to fully ensure the security of model-generated content. However, this method will limit model capabilities and have a high model rejection rate, seriously affecting user experience.
[0004] Accordingly, the art needs a new text recognition solution to solve the above problems.
[0005] Application Contents
[0006] In order to overcome the above defects, the present application is proposed to provide a solution or at least partially solve the above technical problems. The present application provides a text recognition method, an electronic device and a storage medium.
[0007] In a first aspect, the present application provides a text recognition method, which includes: obtaining a text to be recognized; determining whether the text to be recognized contains sensitive information; if so, obtaining a first text recognition result based on the text to be recognized, wherein the first text recognition result is a preset text recognition result; if not, inputting the text to be recognized into a text recognition model to obtain a second text recognition result.
[0008] In one embodiment of the present application, determining whether the text to be recognized contains sensitive information includes: obtaining a first preset knowledge base; segmenting the text to be recognized to obtain a segmentation result; matching the segmentation result with the first preset knowledge base to obtain a first matching result; and determining whether the text to be recognized contains first sensitive information based on the first matching result.
[0009] In one embodiment of the present application, when the text to be recognized does not contain the first sensitive information, determining whether the text to be recognized contains sensitive information includes: inputting the text to be recognized into a semantic analysis model, and outputting a result of whether the text to be recognized contains the second sensitive information.
[0010] In one embodiment of the present application, when the text to be recognized does not contain the second sensitive information, determining whether the text to be recognized contains sensitive information further includes: obtaining a second preset knowledge base and a third preset knowledge base, wherein the second preset knowledge base includes multiple sensitive topics, and the third preset knowledge base includes multiple preset sensitive word vector libraries, and one sensitive topic corresponds to one preset sensitive word vector library; matching the text to be recognized with the second preset knowledge base to obtain a second matching result; obtaining at least one preset sensitive word vector library corresponding to the second matching result; matching the text to be recognized with the at least one preset sensitive word vector library to obtain a third matching result; and determining whether the text to be recognized contains the third sensitive information based on the third matching result.
[0011] In one embodiment of the present application, matching the text to be recognized with the at least one preset sensitive word vector library includes: obtaining a text feature vector of the text to be recognized; determining a similarity score between the text feature vector and a word vector in the at least one preset sensitive word vector library; obtaining a maximum similarity score among all similarity scores; and determining a third matching result based on the maximum similarity score.
[0012] In one embodiment of the present application, the similarity score is the inner product between the text feature vector and the word vector.
[0013] In one embodiment of the present application, the third matching result includes that the text to be recognized hits the preset sensitive word vector library and the text to be recognized does not hit the preset sensitive word vector library; determining the third matching result based on the maximum similarity score includes: judging whether the maximum similarity score is greater than a preset threshold; if so, determining that the text to be recognized hits the preset sensitive word vector library; otherwise, determining that the text to be recognized does not hit the preset sensitive word vector library.
[0014] In one embodiment of the present application, the method further includes: performing a post-processing operation on the second text recognition result to determine whether the second text recognition result contains sensitive information.
[0015] In a second aspect, the present application provides an electronic device, comprising at least one processor and at least one memory, wherein the memory is suitable for storing a plurality of program codes, and the program codes are suitable for being loaded and run by the processor to execute any of the aforementioned text recognition methods.
[0016] In a fourth aspect, a computer-readable storage medium is provided, wherein a plurality of program codes are stored in the computer-readable storage medium, wherein the program codes are suitable for being loaded and run by a processor to execute any of the aforementioned text recognition methods.
[0017] The above one or more technical solutions of the present application have at least one or more of the following beneficial effects:
[0018] The text recognition method provided in this application first obtains the text to be recognized; determines whether the text to be recognized contains sensitive information; if so, obtains a first text recognition result based on the text to be recognized, and the first text recognition result is a preset text recognition result; if not, inputs the text to be recognized into an entity recognition model to obtain a second text recognition result. In this way, sensitive information in the text to be recognized can be pre-screened for security before text recognition, thereby improving the security of the text to be recognized, obtaining a safer text recognition result, reducing the rejection rate of the model, and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The disclosure of the present application will become more easily understood with reference to the accompanying drawings. It is easy for those skilled in the art to understand that these drawings are only for illustrative purposes and are not intended to limit the scope of protection of the present application. In addition, similar numbers in the drawings are used to represent similar components, among which:
[0020] Figure 1 is a flowchart of the main steps of a text recognition method according to an embodiment of the present application;
[0021] Figure 2 is a structural schematic diagram of a text recognition system according to an embodiment of the present application;
[0022] Figure 3 is a schematic diagram of the main structural block diagram of a text recognition device according to an embodiment of the present application;
[0023] Figure 4 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0024] Some embodiments of the present application are described below with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are only used to explain the technical principles of the present application and are not intended to limit the protection scope of the present application.
[0025] In the description of the present application, "module" and "processor" may include hardware, software or a combination of the two. A module may include hardware circuits, various suitable sensors, communication ports, memory, and may also include software parts, such as program code, or a combination of software and hardware. The processor may be a central processing unit, a microprocessor, an image processor, a digital signal processor or any other suitable processor. The processor has data and / or signal processing functions. The processor may be implemented in software, hardware or a combination of the two. Non-temporary computer-readable storage media include any suitable medium that can store program code, such as a disk, a hard disk, an optical disk, a flash memory, a read-only memory, a random access memory, etc. The term "A and / or B" means all possible combinations of A and B, such as only A, only B or A and B. The term "at least one A or B" or "at least one of A and B" has a similar meaning to "A and / or B" and may include only A, only B or A and B. The singular terms "one" and "the" may also include plural forms.
[0026] At present, traditional text recognition methods adopt strict security filtering strategies, such as the currently commonly used sensitive word filtering method, to fully ensure the security of model-generated content. However, this method will limit the model's capabilities and have a high model rejection rate, seriously affecting the user experience.
[0027] To this end, the present application proposes a text recognition method, an electronic device and a storage medium.
[0028] See attached Figure 1 , Figure 1 It is a flowchart of the main steps of a text recognition method according to an embodiment of the present application.
[0029] like Figure 1 As shown, the text recognition method in the embodiment of the present application mainly includes the following steps S101 to S104.
[0030] Step S101: Obtain text to be recognized.
[0031] The text to be recognized may be relevant text information input by a user.
[0032] Step S102: Determine whether the text to be identified contains sensitive information.
[0033] Sensitive information includes harmful words and sensitive words.
[0034] Step S103: when the text to be recognized contains sensitive information, obtaining a first text recognition result based on the text to be recognized, wherein the first text recognition result is a preset text recognition result.
[0035] The preset text recognition results include standard answer content that can be answered and refusal to answer content, wherein the standard answer content that can be answered refers to the preset relevant standard answer content that matches the text to be recognized, and the refusal to answer content can be content related to refusal to answer.
[0036] Step S104: When the text to be recognized does not contain sensitive information, the text to be recognized is input into a text recognition model to obtain a second text recognition result.
[0037] The text recognition model is able to identify specific entities in the text, such as names, places, organizations, etc., and sometimes also sensitive words or harmful words, and give text recognition results related to the text to be recognized based on the identified specific entities.
[0038] The text recognition model may be a conventional language model, etc., and is not limited to this.
[0039] Based on the above steps S101 to S104, first obtain the text to be recognized; determine whether the text to be recognized contains sensitive information; if so, obtain a first text recognition result based on the text to be recognized, and the first text recognition result is a preset text recognition result; if not, input the text to be recognized into the entity recognition model to obtain a second text recognition result. In this way, sensitive information in the text to be recognized can be pre-screened for security before text recognition, which improves the security of the text to be recognized, obtains a safer text recognition result, reduces the rejection rate of the model, and improves the user experience.
[0040] The above step S102 is further explained below.
[0041] With respect to the above-mentioned step S102, in a specific implementation of the present application, determining whether the text to be recognized contains sensitive information includes: obtaining a first preset knowledge base; performing word segmentation on the text to be recognized to obtain a word segmentation result; matching the word segmentation result with the first preset knowledge base to obtain a first matching result; and determining whether the text to be recognized contains first sensitive information based on the first matching result.
[0042] The first preset knowledge base may be a harmful word group library, which contains all harmful words and harmful word groups, and may be obtained in advance through construction.
[0043] The first sensitive information may be a harmful word.
[0044] Specifically, the text to be recognized is first divided into single sentences and redundant spaces and symbols are removed, and the single sentences are divided into words using conventional word segmentation technology to obtain word segmentation results. Then, the word segmentation results are matched with harmful words or harmful phrases in the first preset knowledge base by keyword filtering, so as to determine whether the first preset knowledge base contains harmful words.
[0045] By matching with the first preset knowledge base, it is determined whether the text to be recognized contains harmful words or harmful phrases to implement security review of the text to be recognized, thereby ensuring that the generated content of the text recognition model is more secure.
[0046] In the case that the text to be recognized does not contain the first sensitive information, determining whether the text to be recognized contains sensitive information includes: inputting the text to be recognized into a semantic analysis model, and outputting a result of whether the text to be recognized contains the second sensitive information.
[0047] The second sensitive information may be harmful words or input that may induce attack on the large model.
[0048] The semantic analysis model is a pre-trained sentence binary classification model, whose output includes either of the two labels "harmful" and "harmless". The semantic analysis model can be obtained based on the bert-base-chinese open source pre-trained model.
[0049] Specifically, the semantic analysis model is used to understand the input text to be identified, thereby filtering out input that contains toxic and harmful content or content that induces attacks on the large model. The input model of the semantic analysis model can be a text paragraph, and the output can be a binary classification label, such as "harmful" or "harmless".
[0050] The semantic analysis model is used to determine whether the text to be recognized contains harmful words to achieve security review of the text to be recognized, ensuring that the content generated by the text recognition model is more secure.
[0051] In the case that the text to be recognized does not contain the second sensitive information, the determination of whether the text to be recognized contains sensitive information can be achieved through the following steps S1021-S1025.
[0052] Step S1021: Obtain a second preset knowledge base and a third preset knowledge base, wherein the second preset knowledge base includes multiple sensitive topics, and the third preset knowledge base includes multiple preset sensitive word vector libraries, one sensitive topic corresponds to one preset sensitive word vector library, and each preset sensitive word vector library contains multiple questions related to the corresponding sensitive topic and answers corresponding to the questions.
[0053] The second preset knowledge base and the third preset knowledge base may be manually constructed in advance.
[0054] Step S1022: Match the text to be recognized with the second preset knowledge base to obtain a second matching result.
[0055] Specifically, at least one sensitive topic corresponding to the text to be identified can be obtained from the second preset knowledge base through a keyword matching algorithm.
[0056] Step S1023: Obtain at least one preset sensitive word vector library corresponding to the second matching result.
[0057] At least one sensitive topic knowledge base corresponding to at least one sensitive topic is obtained from the third preset knowledge base.
[0058] Step S1024: Match the text to be recognized with the at least one preset sensitive word vector library to obtain a third matching result.
[0059] In a specific embodiment of the present application, the matching of the text to be recognized with the at least one preset sensitive word vector library includes: obtaining a text feature vector of the text to be recognized; determining a similarity score between the text feature vector and a word vector in the at least one preset sensitive word vector library; obtaining a maximum similarity score among all similarity scores; and determining a third matching result based on the maximum similarity score. The similarity score is the inner product between the text feature vector and the word vector.
[0060] In a specific embodiment of the present application, the third matching result includes that the text to be recognized hits the preset sensitive word vector library and the text to be recognized does not hit the preset sensitive word vector library; determining the third matching result based on the maximum similarity score includes: judging whether the maximum similarity score is greater than a preset threshold; if so, determining that the text to be recognized hits the preset sensitive word vector library; otherwise, determining that the text to be recognized does not hit the preset sensitive word vector library.
[0061] The preset threshold may be a value obtained in advance through experiments, and may be adaptively modified or adjusted according to different implementation scenarios.
[0062] Specifically, a text feature extraction model is used to obtain a text feature vector of the text to be identified, and a similarity score between the text feature vector and each word vector in at least one preset sensitive word vector library is calculated, wherein the inner product between the text feature vector and the word vector can be used as an example of a similarity score, but is not limited thereto. Then, the maximum similarity score is obtained from all similarity scores. It is determined whether the maximum similarity score is greater than a preset threshold value. If so, it is determined that the text to be identified hits the preset sensitive word vector library, otherwise, it is determined that the text to be identified does not hit the preset sensitive word vector library.
[0063] Step S1025: Determine whether the text to be identified contains third sensitive information based on the third matching result.
[0064] The third sensitive information is sensitive words corresponding to sensitive topics related to the text to be identified.
[0065] Specifically, when the text to be recognized hits the preset sensitive word vector library, it means that the text to be recognized contains the third sensitive information. When the text to be recognized does not hit the preset sensitive word vector library, it means that the text to be recognized does not contain the third sensitive information.
[0066] By adding a sensitive topic library (the second preset knowledge base) and a topic knowledge base corresponding to each topic (the third preset knowledge base), the entire sensitive topic knowledge base is divided into small libraries. After the keyword matching algorithm is used to accurately hit the sensitive topic in the second preset knowledge base, the corresponding sensitive topic knowledge small library will be used for matching, thereby greatly reducing the probability of mismatching, improving matching efficiency, and enhancing user experience.
[0067] The second preset knowledge base and the third preset knowledge base are used to preset standard answers to sensitive questions that are sensitive to questions or have complex answers. This greatly reduces the rejection rate of the model while ensuring the security of the content generated by the model.
[0068] The above describes three methods for determining whether the text to be identified contains sensitive information, namely, a method of matching with a first preset knowledge base, a method of identifying using a semantic analysis model, and a method of matching through a second preset knowledge base. Those skilled in the art should understand that it is also possible to determine whether the text to be identified contains sensitive information by combining at least any two of the above three determination methods.
[0069] The above is a further description of step S102.
[0070] In a specific implementation of the present application, the method further includes: performing a post-processing operation on the second text recognition result to determine whether the second text recognition result contains sensitive information.
[0071] Specifically, the text processing result may be subjected to post-processing operations to determine whether the second text recognition result contains sensitive information. The post-processing operation may be at least one of the aforementioned method of matching with the first preset knowledge base, the method of identifying using a semantic analysis model, and the method of matching through the second preset knowledge base, which will not be described in detail.
[0072] By further determining whether the model-generated content contains sensitive information, it is helpful to improve the security of the generated content.
[0073] In one embodiment of the present application, the specific implementation of the text recognition method of the present application is further explained in a systematic manner.
[0074] Specific as Figure 2 As shown, the system includes a pre-processing module, a generative large model (corresponding to the text recognition model in the aforementioned embodiment) and a post-processing module, wherein the pre-processing module includes a harmful word module, a semantic review module and a sensitive topic module, and the post-processing module includes a harmful word module and a semantic analysis model.
[0075] The harmful word library module is mainly composed of harmful word libraries, which ensure that the content does not contain harmful information through keyword filtering; the harmful word library includes harmful words and harmful phrases.
[0076] The semantic review module consists of a semantic review model, which filters inputs containing toxic and harmful content or content that induces attacks on the large model by understanding the semantics of the input content. The input of the semantic review model is paragraph text, and the output is a binary classification label, such as "harmful" or "harmless".
[0077] The semantic review model (the semantic analysis model in the above embodiment) is a trained sentence binary classification model, and the output includes a label of "harmful" or "harmless". The semantic review model can be fine-tuned by the bert-base-chinese open source model.
[0078] The sensitive topic module is composed of a sensitive topic library (the second preset knowledge base in the aforementioned embodiment) and a sensitive topic knowledge base (the third preset knowledge base). The sensitive topic knowledge base is divided into different sensitive topic knowledge bases according to its different subject words (phrases).
[0079] The sensitive topics module can achieve the following steps:
[0080] Step 1: Use the keyword matching algorithm to obtain the sensitive subject words (phrases) that are hit by the text to be identified in the sensitive subject library.
[0081] Step 2: Summarize the sensitive subject knowledge base corresponding to the hit sensitive subject words (phrases), use the text feature extraction model to extract all the questions in the summarized sensitive knowledge base as text features, and use it as the retrieval base.
[0082] Step 3: Use the same text feature extraction model to convert the input content into text features as retrieval features.
[0083] Step 4: Find the top k most similar ones in the search base database.
[0084] Step 5. Check whether the maximum similarity score is greater than the threshold value. If it is greater, the sensitive information is hit, otherwise the sensitive information is not hit.
[0085] The harmful word module and semantic review module conduct security reviews on the input / output content from the two aspects of phrases and semantics to ensure the security of the model's generated content.
[0086] The sensitive topic module uses the sensitive topic knowledge base to preset standard answers to sensitive questions, which are sensitive or have complex answers. This ensures the security of the model-generated content while greatly reducing the rejection rate of the model. By adding a sensitive topic library and a topic knowledge base corresponding to each topic, the entire sensitive topic knowledge base is divided into small libraries, which are guided by a highly accurate sensitive topic library (keyword matching algorithm) (only after the sensitive topic library is accurately hit will the corresponding sensitive topic knowledge library be used for matching), thereby greatly reducing the probability of mismatching and improving user experience.
[0087] For content generated by large models, harmful word modules and semantic review modules are also used to improve the security of generated content.
[0088] The harmful word module and the sensitive topic module are easy to update, have a high frequency of update, are low cost, and take effect quickly.
[0089] Through the text recognition method of this application, the security of the output content of the generative large model is fully guaranteed; the rejection rate of the generative large model is guaranteed to be low, creating a good human-computer interaction experience; it can be applied to most generative large models, has good portability, strong emergency handling capabilities and high timeliness.
[0090] It should be pointed out that although the various steps in the above embodiments are described in a specific order, those skilled in the art can understand that in order to achieve the effect of the present application, different steps do not have to be executed in such an order. They can be executed simultaneously (in parallel) or in other orders. These changes are within the scope of protection of the present application.
[0091] Furthermore, the present application also provides a text recognition device.
[0092] See attached Figure 3 , Figure 3 FIG. 1 is a main structural block diagram of a text recognition device according to an embodiment of the present application. Figure 3 As shown, the text recognition device in the embodiment of the present application mainly includes a first acquisition module 11, a determination module 12, a second acquisition module 13 and an input module 14. In some embodiments, one or more of the first acquisition module 11, the determination module 12, the second acquisition module 13 and the input module 14 can be combined into one module.
[0093] In some embodiments, the first acquisition module 11 may be configured to acquire text to be recognized.
[0094] The determination module 12 may be configured to determine whether the text to be recognized contains sensitive information.
[0095] The second acquisition module 13 may be configured to acquire a first text recognition result based on the text to be recognized when the text to be recognized contains sensitive information, wherein the first text recognition result is a preset text recognition result.
[0096] The input module 14 may be configured to input the text to be recognized into a text recognition model to obtain a second text recognition result when the text to be recognized does not contain sensitive information.
[0097] In one implementation, the description of the specific implementation functions can refer to step S101 to step S104.
[0098] The above-mentioned text recognition device is used to perform Figure 1 The text recognition method embodiment shown in the figure has similar technical principles, technical problems solved and technical effects produced. Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process and related instructions of the text recognition device can refer to the contents described in the embodiment of the text recognition method, which will not be repeated here.
[0099] It is understood by those skilled in the art that all or part of the processes in the method for implementing the above-mentioned embodiment of the present application can also be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of each of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include: any entity or device, medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory, random access memory, electric carrier signal, telecommunication signal and software distribution medium that can carry the computer program code. It should be noted that the content contained in the computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable storage media do not include electric carrier signals and telecommunication signals.
[0100] Furthermore, the present application also provides an electronic device. In an electronic device embodiment according to the present application, Figure 4As shown, the electronic device includes at least one processor 41 and at least one memory 42, the memory 42 can be configured to store a program for executing the text recognition method of the above method embodiment, and the processor 41 can be configured to execute the program in the memory, which includes but is not limited to the program for executing the text recognition method of the above method embodiment. For ease of explanation, only the part related to the embodiment of the present application is shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present application.
[0101] In the embodiment of the present application, the electronic device may be a control device device including various devices. In some possible implementations, the electronic device may include multiple memories and multiple processors. The program for executing the text recognition method of the above method embodiment may be divided into multiple subprograms, each of which may be loaded and run by a processor to execute different steps of the text recognition method of the above method embodiment. Specifically, each subprogram may be stored in different memories, respectively, and each processor may be configured to execute programs in one or more memories to jointly implement the text recognition method of the above method embodiment, that is, each processor executes different steps of the text recognition method of the above method embodiment, respectively, to jointly implement the text recognition method of the above method embodiment.
[0102] The above-mentioned multiple processors may be processors deployed on the same device. For example, the above-mentioned electronic device may be a high-performance device composed of multiple processors, and the above-mentioned multiple processors may be processors configured on the high-performance device. In addition, the above-mentioned multiple processors may also be processors deployed on different devices. For example, the above-mentioned electronic device may be a server cluster, and the above-mentioned multiple processors may be processors on different servers in the server cluster.
[0103] Furthermore, the present application also provides a computer-readable storage medium. In a computer-readable storage medium embodiment according to the present application, the computer-readable storage medium can be configured to store a program for executing the text recognition method of the above method embodiment, and the program can be loaded and run by the processor to implement the above text recognition method. For ease of explanation, only the parts related to the embodiment of the present application are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present application. The computer-readable storage medium can be a memory device formed by various electronic devices. Optionally, the computer-readable storage medium in the embodiment of the present application is a non-temporary computer-readable storage medium.
[0104] Further, it should be understood that since the setting of each module is only for illustrating the functional units of the device of the present application, the physical devices corresponding to these modules may be the processor itself, or a part of the software in the processor, a part of the hardware, or a part of the combination of software and hardware. Therefore, the number of each module in the figure is only schematic.
[0105] It is understood by those skilled in the art that each module in the device can be adaptively split or merged. Such splitting or merging of specific modules will not cause the technical solution to deviate from the principle of the present application, and therefore, the technical solutions after splitting or merging will fall within the protection scope of the present application.
[0106] So far, the technical solutions of the present application have been described in conjunction with the specific implementations shown in the accompanying drawings, but it is easy for those skilled in the art to understand that the protection scope of the present application is obviously not limited to these specific implementations. Without departing from the principles of the present application, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present application.
Claims
1. A text recognition method, characterized in that: The method comprises: Get the text to be recognized; Determining whether the text to be identified contains sensitive information; If yes, obtaining a first text recognition result based on the text to be recognized, wherein the first text recognition result is a preset text recognition result; If not, the text to be recognized is input into a text recognition model to obtain a second text recognition result.
2. The text recognition method according to claim 1, characterized in that: The determining whether the text to be identified contains sensitive information includes: Acquire a first preset knowledge base; Performing word segmentation on the text to be recognized to obtain a word segmentation result; Matching the word segmentation result with the first preset knowledge base to obtain a first matching result; Determine whether the text to be identified contains first sensitive information according to the first matching result.
3. The text recognition method according to claim 2, characterized in that: In the case that the text to be recognized does not contain the first sensitive information, determining whether the text to be recognized contains sensitive information further includes: The text to be recognized is input into a semantic analysis model, and a result of whether the text to be recognized contains the second sensitive information is output.
4. The text recognition method according to claim 3, characterized in that: In the case that the text to be recognized does not contain the second sensitive information, determining whether the text to be recognized contains sensitive information further includes: Obtain a second preset knowledge base and a third preset knowledge base, wherein the second preset knowledge base includes multiple sensitive topics, and the third preset knowledge base includes multiple preset sensitive word vector libraries, and one sensitive topic corresponds to one preset sensitive word vector library; Matching the text to be recognized with the second preset knowledge base to obtain a second matching result; Obtain at least one preset sensitive word vector library corresponding to the second matching result; Matching the to-be-recognized text with the at least one preset sensitive word vector library to obtain a third matching result; Based on the third matching result, determine whether the text to be identified contains third sensitive information.
5. The text recognition method according to claim 4, characterized in that: The matching of the to-be-recognized text with the at least one preset sensitive word vector library includes: Obtaining a text feature vector of the text to be recognized; Determining a similarity score between the text feature vector and a word vector in the at least one preset sensitive word vector library; Get the maximum similarity score among all similarity scores; A third matching result is determined based on the maximum similarity score.
6. The text recognition method according to claim 5, characterized in that: The similarity score is the inner product between the text feature vector and the word vector.
7. The text recognition method according to claim 5, characterized in that: The third matching result includes that the text to be recognized hits the preset sensitive word vector library and the text to be recognized does not hit the preset sensitive word vector library; The determining a third matching result based on the maximum similarity score comprises: Determine whether the maximum similarity score is greater than a preset threshold; If yes, it is determined that the text to be identified hits the preset sensitive word vector library; Otherwise, it is determined that the text to be recognized does not hit the preset sensitive word vector library.
8. The text recognition method according to claim 1, characterized in that: The method further includes: performing a post-processing operation on the second text recognition result to determine whether the second text recognition result contains sensitive information.
9. An electronic device comprising at least one processor and at least one memory, wherein the memory is suitable for storing a plurality of program codes, wherein: The program code is suitable for being loaded and run by the processor to execute the text recognition method according to any one of claims 1 to 8.
10. A computer-readable storage medium storing a plurality of program codes, characterized in that: The program code is suitable for being loaded and run by a processor to execute the text recognition method according to any one of claims 1 to 8.
