Text detection model training method and apparatus, text detection method and apparatus, and computer device, medium, and program product

By adjusting the parameters of the text detection model to ensure consistent mapping between characters, the problems of error correction and overcorrection in spell checking tasks of large language models are solved, thus improving the accuracy of text detection.

WO2026051603A1PCT designated stage Publication Date: 2026-03-12TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2025-07-17
Publication Date
2026-03-12

AI Technical Summary

Technical Problem

In existing technologies, large language models are prone to miscorrection and overcorrection in spell checking tasks, resulting in low text detection accuracy. This is because they cannot correctly establish the mapping relationship between characters and cannot learn the concept of character length.

Method used

By acquiring training text samples with text labels, the model parameters of the initial text detection model are adjusted so that the length of the first predicted text character is consistent with the length of the text label character, and a mapping relationship between characters is established to meet the length and pronunciation constraints of the spell check task.

Benefits of technology

This improved the accuracy of the text detection model's output of correct statements, enhanced its error correction capabilities, and ultimately improved the accuracy of text detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025109055_12032026_PF_FP_ABST
    Figure CN2025109055_12032026_PF_FP_ABST
Patent Text Reader

Abstract

Disclosed in the embodiments of the present application are a text detection model training method and apparatus, a text detection method and apparatus, and a computer device, a medium, and a program product. The text detection model training method comprises: acquiring a training text sample having a text label; and on the basis of the training text sample, performing prediction by means of an initial text detection model, so as to obtain a first predicted text. First predicted text characters and text label characters having a correspondence have the same lengths and the same word segmentation positions, such that the encoding granularities of the first predicted text characters and text label characters having a correspondence are consistent. Thus, model parameters of the initial text detection model can be adjusted on the basis of the differences between the first predicted text characters and text label characters having a correspondence, so as to obtain a text detection model. Therefore, the error correction capability of the text detection model is improved, thereby improving the accuracy of text detection.
Need to check novelty before this filing date? Find Prior Art

Description

A text detection model training method, a text detection method, a device, a computer device, a medium and a program product

[0001] The present application claims priority to the Chinese patent application No. 2024112430150, filed on September 4, 2024, and entitled "A text detection model training method, a text detection method, a device, a computer device, a medium and a program product", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD

[0002] The present application relates to the technical field of artificial intelligence, and in particular to a text detection model training method, a text detection method, a device, a computer device, a medium and a program product. BACKGROUND

[0003] The spelling correction task is to find the wrong spelling in the text (not related to grammatical errors). Taking the Chinese spelling correction task as an example, it mainly focuses on correcting the errors at the word or character level. The preliminary goal of the task is to find the position of the wrong character, and then to correct the wrong character.

[0004] In related technologies, a prompt is generally used to let a large language model (LLM) perform a spelling correction task. Specifically, the prompt includes a task description, an example, and a text to be detected. The large language model directly outputs a corrected text for the text to be detected according to the input prompt.

[0005] However, this method often results in incorrect correction and over-correction, and the accuracy of text detection is low. SUMMARY

[0006] To solve the above technical problems, the present application provides a text detection model training method, a text detection method, a device, a computer device, a medium and a program product, which are used to reduce the probability of incorrect correction and over-correction in the spelling correction task, and improve the accuracy of text detection.

[0007] The embodiments of the present application disclose the following technical solutions:

[0008] In one aspect, the present application provides a text detection model training method, which is executed by a computer device, and the method comprises:

[0009] Obtaining a training text sample with a text label, the text label being a correct expression text corresponding to the training text sample, and the text label including a plurality of text label characters with a preset length and a semantic order;

[0010] According to the training text sample, a first predicted text is obtained by prediction through an initial text detection model, the first predicted text including a plurality of first predicted text characters with a preset length and a semantic order;

[0011] According to differences between the first predicted text characters and the text label characters with a corresponding relationship, model parameters of the initial text detection model are adjusted to obtain a text detection model, the text detection model being used for correcting input text to output a correct expression text corresponding to the input text, the first predicted text characters and the text label characters with the corresponding relationship being consistent in ordering positions in respective semantic orders.

[0012] In another aspect, an embodiment of the present application provides a training device of a text detection model, the device including an acquisition unit, a prediction unit and an adjustment unit.

[0013] The acquisition unit is configured to acquire a training text sample with a text label, the text label being a correct expression text corresponding to the training text sample, the text label including a plurality of text label characters with a preset length and a semantic order.

[0014] The prediction unit is configured to obtain a first predicted text by prediction through an initial text detection model according to the training text sample, the first predicted text including a plurality of first predicted text characters with the preset length and the semantic order.

[0015] The adjustment unit is configured to adjust model parameters of the initial text detection model according to differences between the first predicted text characters and the text label characters with a corresponding relationship to obtain a text detection model, the text detection model being used for correcting input text to output a correct expression text corresponding to the input text, the first predicted text characters and the text label characters with the corresponding relationship being consistent in ordering positions in respective semantic orders.

[0016] In another aspect, an embodiment of the present application provides a text detection method, the method including:

[0017] In response to a text input operation, a to-be-detected text corresponding to the text input operation is displayed.

[0018] If it is detected that the to-be-detected text has an error expression, the error expression and a correct expression corresponding to the error expression are displayed.

[0019] In response to a trigger operation for the correct expression, the error expression is replaced by the correct expression to obtain an updated text.

[0020] display the updated text.

[0021] In another aspect, an embodiment of the present application provides a text detection apparatus, the apparatus comprising: a display unit and a replacement unit;

[0022] The display unit is configured to display, in response to a text input operation, to-be-detected text corresponding to the text input operation.

[0023] The display unit is further configured to display, if it is detected that the to-be-detected text has an incorrect expression, the incorrect expression and a correct expression corresponding to the incorrect expression.

[0024] The replacement unit is configured to replace, in response to a trigger operation for the correct expression, the incorrect expression with the correct expression to obtain updated text.

[0025] The display unit is further configured to display the updated text.

[0026] In another aspect, an embodiment of the present application provides a computer device, the computer device comprising a processor and a memory:

[0027] The memory is configured to store a computer program and transmit the computer program to the processor.

[0028] The processor is configured to execute the method according to the instructions in the computer program.

[0029] In another aspect, an embodiment of the present application provides a computer readable storage medium, the computer readable storage medium being configured to store a computer program, the computer program being configured to execute the method according to the above aspect.

[0030] In another aspect, an embodiment of the present application provides a computer program product or a computer program, the computer program product or the computer program comprising computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method according to the above aspect.

[0031] It can be seen from the technical solution that the training text sample with the text label is obtained, the text label is a correct expression text corresponding to the training text sample, and the text label includes a plurality of text label characters of a preset length and has a semantic order between the plurality of text label characters. In this application, the text detection model is equivalent to regarding the spelling checking task as a text generation task of predicting a text with basically no misspelling based on a text that may have misspelling. Therefore, according to the training text sample, a first prediction text is obtained by prediction of the initial text detection model. The first prediction text includes a plurality of first prediction text characters of a preset length, and the plurality of first prediction text characters have a semantic order. Thus, the lengths of the first prediction text and the text label are consistent with the length of the training text sample, the length of the first prediction text character is consistent with the length of the text label character, the segmentation positions and the number of segments of the first prediction text character and the text label character are consistent, the coding granularity of the first prediction text character and the text label character is consistent, and a one-to-one mapping relationship can be established between the first prediction text character and the text label character based on the semantic order. The first prediction text is the corrected text obtained by the initial text detection model for the training text sample, and the text label is the correct expression text corresponding to the training text sample. Therefore, the model parameters of the initial text detection model can be adjusted according to the difference between the first prediction text character and the text label character having the corresponding relationship, and the text detection model is obtained.

[0032] Thus, in the process of training the text detection model, the length of the first prediction text character is consistent with the length of the text label character, the model can directly establish a mapping relationship between characters and characters, the model can understand the length concept of the characters, and the mapping relationship includes the mapping relationship between the misspelled words and the corrected words, thereby meeting the length constraint and the pinyin constraint of the spelling checking task. The accuracy of the text with correct expression output by the text detection model is improved, that is, the correction ability of the text detection model is improved, and thus the accuracy of the text detection is improved. BRIEF DESCRIPTION OF DRAWINGS

[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0034] FIG. 1 is a schematic diagram of an application scenario of a training method of a text detection model according to an embodiment of the present application;

[0035] FIG. 2 is a schematic diagram of a typing software applying the text detection model according to an embodiment of the present application;

[0036] FIG. 3 is a schematic diagram of an online education scenario applying a text detection model according to an embodiment of the present application;

[0037] FIG. 4 is a schematic diagram of a training method of a text detection model according to an embodiment of the present application;

[0038] FIG. 5 is a schematic diagram of an application of a text detection model according to an embodiment of the present application;

[0039] FIG. 6 is a schematic diagram of a training of a text detection model according to an embodiment of the present application;

[0040] FIG. 7 is a schematic diagram of a mapping relationship according to an embodiment of the present application;

[0041] FIG. 8 is a schematic diagram of a structure of a training device of a text detection model according to an embodiment of the present application;

[0042] FIG. 9 is a schematic diagram of a structure of a server according to an embodiment of the present application;

[0043] FIG. 10 is a schematic diagram of a structure of a terminal device according to an embodiment of the present application;

[0044] FIG. 11 is a schematic diagram of a text detection method according to an embodiment of the present application;

[0045] FIG. 12 is a schematic diagram of a text detection method according to an embodiment of the present application;

[0046] FIG. 13 is a schematic diagram of a structure of a text detection device according to an embodiment of the present application. DETAILED DESCRIPTION

[0047] Embodiments of the present application will be described below with reference to the accompanying drawings.

[0048] In the related art, a large language model is prompted to perform a spelling check task by using a prompt word, the prompt word including a task description, a sample, and a text to be detected, which can be shown in Table 1.

[0049] Table 1

[0050] In Table 1, the task description is to correct spelling errors in a sentence, the sample includes three groups, and each group of samples includes an input sentence and a corrected text. The text to be detected is that this kind of special weather also appears in the M country. However, this kind of method often has wrong correction and over-correction, and the text detection effect is poor.

[0051] Based on this, it is found through analysis that the reason for poor text detection effect is that the large language model cannot learn the length concept of characters, so it cannot correctly establish the mapping relationship between characters and characters, and thus error correction and over-correction occur, leading to poor text detection effect. The analysis process is described below.

[0052] First, the spelling checking task is described.

[0053] The spelling checking task mainly focuses on the correction of character or word level errors, rather than grammatical errors. Since everyone has their own speaking habits (or typing habits, etc.), in order to ensure that the user's common habits are not affected while performing the spelling checking task, there are two strong constraint conditions, which are (1) length constraint: the length of the corrected text needs to be equal to the length of the text to be detected, (2) pronunciation constraint: the pinyin of the corrected word in the corrected text needs to be the same or similar to the pinyin of the wrong word in the text to be detected.

[0054] In related technologies, the corrected text obtained by the large language model through the prompt word often cannot meet the above two constraints, resulting in many non-equal-length and non-phonetically similar characters, causing the generated corrected text to not meet the task requirements, and producing a large number of over-correction and error correction.

[0055] Then, the concepts of error correction and over-correction are described.

[0056] (1) Over-correction: A word in the text is correct, but it has been modified unnecessarily. An example is used to help understand.

[0057] Text to be detected: New scheme is still in multi-party game.

[0058] Corrected text: New scheme is still in multi-party game.

[0059] Over-correction example of large language model: New scheme is still in multi-party game.

[0060] In this example, the large language model does not need to correct the error, but the correction it makes is: place = > in, which means an extra word is added, not meeting the length constraint, resulting in over-correction.

[0061] (2) Error correction: A word in the text is wrong, and the model also makes a correction, but makes an error correction.

[0062] Text to be detected: Breaking the deadlock is still very difficult.

[0063] Corrected text: Breaking the deadlock is still very difficult.

[0064] Error correction example of large language model: Breaking the deadlock is still very difficult.

[0065] In this example, the correction that the large language model should have made is: jiu still (jiu) = > still (jiu), but the correction it made is: jiu still (jiu) = > still (ran), which does not meet the pitch constraint, resulting in a wrong correction.

[0066] Finally, the reasons why the large language model in the related art does not meet the length constraint and the pitch constraint are analyzed.

[0067] Through analysis, it is found that the root cause lies in the coding granularity of the model, that is, the coding granularity of the large language model in the related art is not uniform. Specifically, the model parameters of the large language model are adjusted according to the difference between the text label of the training text sample and the first predicted text of the training text sample, but due to the non-uniform coding granularity, the large language model cannot correctly compare the difference between the text label and the first predicted text, such as the number of word segmentation and the position of word segmentation in the coding process, so that the large language model cannot learn the length concept of characters, it cannot correctly establish the mapping relationship between characters and characters, and further, wrong correction and over-correction occur, resulting in low accuracy of text detection. The following examples are used for illustration.

[0068] Example 1.

[0069] Training text sample: He has the experience of going to the countryside.

[0070] First predicted text (error segmentation mode): he / has / knows / goes to the countryside / experience.

[0071] Text label (correct segmentation mode): he / has / knows / goes to the countryside / experience.

[0072] In this example, " / " represents the word segmentation position of the model. Since there is a wrong character in the training text sample, but the wrong character cannot be clearly identified in the word segmentation process, resulting in errors in word segmentation, the number of word segmentation of the text label and the number of word segmentation of the first predicted text are inconsistent, and further in the process of training the large language model, the large language model cannot learn the mapping relationship between the wrong character and the correct character, that is, the large language model cannot directly establish the mapping relationship between characters and characters, so it cannot learn the length constraint and the pitch constraint of the spelling checking task.

[0073] Example 2:

[0074] Training text sample: Colleagues work very hard and very hard.

[0075] First predicted text (error segmentation mode): colleagues / work / very / tired / very / hard.

[0076] Text label (correct segmentation mode): colleagues / work / very / tired / very / hard.

[0077] In the example, " / " represents the word segmentation position of the model for the sentence. Since there is a misspelling in the training text sample, but the misspelling cannot be determined in the word segmentation process, resulting in an error in word segmentation, although the number of segmented words of the first predicted text and the number of segmented words of the text label are consistent, the segmented positions are inconsistent, such as the misspelling "de" and the corrected word "de" being segmented into two non-corresponding segmented words (or semantic units). This also makes it impossible for the large language model to directly establish a correct mapping relationship between characters and characters, so that the length constraint and the pitch constraint of the spelling check task cannot be learned.

[0078] That is, due to the presence of misspellings in the training text sample, the positions of the segmented words in the first predicted text and the positions of the segmented words in the text label cannot be accurately corresponded when the training text sample is segmented according to semantics, that is, the coding granularity of the segmented words in the first predicted text and the text label is different, so that the large language model cannot directly establish a correct mapping relationship between characters and characters between the first predicted text and the text label, so that the length constraint and the pitch constraint of the spelling check task cannot be learned.

[0079] Based on this, the embodiment of the present application provides a text detection model training method, which makes the length of the first predicted text character and the length of the text label character consistent during the training of the text detection model, so that the model can directly establish a mapping relationship between characters, so that the model can understand the length concept of characters, and the mapping relationship includes the mapping relationship between misspellings and corrected words, thereby satisfying the length constraint and the pitch constraint of the spelling check task. The accuracy of the text detection model output with correct expression is improved, that is, the correction ability of the text detection model is improved, thereby improving the accuracy of text detection.

[0080] The text detection model training method provided by the present application can be applied to a computer device with a training capability of a text detection model, such as a terminal device, a server.

[0081] The terminal device can be a desktop computer, a notebook computer, a smart phone, a tablet computer, an Internet of Things device, and a portable wearable device. The Internet of Things device can be a smart speaker, a smart television, a smart air conditioner, a smart vehicle-mounted device, etc. The smart vehicle-mounted device can be a vehicle-mounted navigation terminal and a vehicle-mounted computer, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc., but is not limited thereto.

[0082] The server can be a standalone physical server, a server cluster or a distributed system composed of multiple physical servers, a cloud server or a server cluster providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal device and the server can be connected directly or indirectly through wired or wireless communication, which is not limited in the present application.

[0083] In order to facilitate the understanding of the training method of the text detection model provided by the embodiments of the present application, the application scenario of the training method of the text detection model is exemplarily introduced below taking the execution subject of the training method of the text detection model as a server.

[0084] Referring to FIG. 1, it is an application scenario diagram of a training method of a text detection model provided by an embodiment of the present application. As shown in FIG. 1, the application scenario includes a server 100. The server 100 can be a standalone server for training a text detection model. After the training of the text detection model is completed, the trained text detection model can be deployed on a server or a terminal device corresponding to a product to provide a text detection service. The server 100 can also be a server for providing a text detection service for various products, that is, the server 100 directly provides a text detection service based on the trained text detection model after training the text detection model, such as whether there is a wrong word in the text. The training of the text detection model by the server 100 is taken as an example for description.

[0085] The server 100 obtains a training text sample. The training text sample has a text label, and the text label is used to represent the correct expression corresponding to the training text sample. For example, the training text sample is he has the experience of going to the countryside as a youth, and the corresponding text label is he has the experience of going to the countryside as a youth. Moreover, the text label includes a plurality of text label characters, the length of the plurality of text label characters is a preset length, and there is a semantic order between the plurality of text label characters. For example, one of the semantic orders of the plurality of text label characters can be represented as he, has, youth, countryside, of, experience, and the preset length is 1 character.

[0086] In this application, the text detection model is equivalent to regarding the spelling checking task as a text generation task based on the text with possible misspelled words to predict the text with basically no misspelled words. Therefore, the server 100 predicts the first predicted text by the initial text detection model according to the training text sample. The first predicted text includes a plurality of first predicted text characters with a preset length, and the plurality of first predicted text characters have a semantic order. Taking the preset length as 1 character as an example, one of the semantic orders of the plurality of first predicted text characters included in the first predicted text "he has the experience of going to the countryside with knowledge" can be he, has, knows, emotion, down, countryside, of, and history.

[0087] Therefore, the length of the first predicted text character is consistent with the length of the text label character, and the length of the first predicted text and the text label is equal to the length of the training text sample, so the segmentation position and the number of segmented words of the first predicted text and the text label are consistent, so that the coding granularity of the first predicted text character and the text label character is consistent, thereby the one-to-one mapping relationship between the first predicted text character and the text label character can be established based on the semantic order, such as the mapping relationship between "emotion" and "green". The server 100 can adjust the model parameters of the initial text detection model according to the difference between the first predicted text character and the corresponding text label character, that is, comparing the characters with the mapping relationship, to obtain a text detection model, which can be used to output text with correct expression.

[0088] Therefore, in the process of training the text detection model, the length of the first predicted text character is consistent with the length of the text label character, and the model can directly establish the mapping relationship between the characters, so that the model can understand the length concept of the characters, and the mapping relationship includes the mapping relationship between the misspelled words and the corrected words, thereby satisfying the length constraint and the pinyin constraint of the spelling checking task. The accuracy of the text detection model outputting the text with correct expression is improved, that is, the correction ability of the text detection model is improved, thereby improving the accuracy of the text detection.

[0089] The training method of the text detection model provided in the embodiments of the present application can be executed by the server. However, in other embodiments of the present application, the terminal device can also have similar functions as the server, so as to execute the training method of the text detection model provided in the embodiments of the present application, or the training method of the text detection model provided in the embodiments of the present application is executed by the terminal device and the server together, which is not limited in the present embodiment.

[0090] The text detection model obtained by the training method of the text detection model provided in the present application can be applied to various scenes, including but not limited to social media, online education, machine translation, content review, typing software, etc. The following takes three scenes as examples.

[0091] Scenario 1: Typing software scenario.

[0092] When a user inputs text using typing software, if the user pauses for more than a preset time or inputs punctuation marks, the typing software uses the text detection model provided in this application to detect the currently input text and determine whether there are any errors, thereby improving the accuracy of the user's input text and enhancing the user experience.

[0093] Referring to Figure 2, which is a schematic diagram of a typing software using a text detection model provided in an embodiment of this application, the user inputs the text "The future of the nation lies in the youth". This text is used as the text to be detected. The text detection model trained in this embodiment of the application makes a prediction and obtains a third predicted text for the text to be detected, which is "The future of the nation lies in the youth". That is, the incorrect expression "NIO" is detected in the text to be detected, and then it is displayed to the user so that the user can decide whether to perform a replacement operation.

[0094] Scenario 2: Online Education Scenario.

[0095] This application scenario includes terminal devices and servers, which can communicate with each other via a communication network. The communication network uses standard communication technologies and / or protocols, typically the Internet, but can also be any network, including but not limited to Bluetooth, local area networks (LANs), metropolitan area networks (MANs), wide area networks (WANs), mobile networks, private networks, or any combination of virtual private networks. In some embodiments, customized or dedicated data communication technologies may be used to replace or supplement the aforementioned data communication technologies.

[0096] The terminal device has an online education client installed, which provides online education services. The server provides these services to the online education client. The online education platform can frequently grade student assignments such as essays. As shown in Figure 3, after a student submits an assignment through the online education client, the client sends the assignment to the server. The server uses a text detection model deployed on it to check the received assignment for spelling errors, even helping students correct them, thus improving teachers' efficiency and helping students correct mistakes promptly, improving learning outcomes.

[0097] Scenario 3: Content review scenario.

[0098] In daily writing and editing process, whether it is to write articles, reports or emails, Chinese spelling check technology can help authors find and correct spelling errors in time, improve the quality and readability of the text.

[0099] In content review platforms such as news publishing platforms, blog platforms, novel platforms, and email platforms, it is necessary to quickly review the content generated by users to ensure the accuracy and compliance of the content. Through the text detection model provided by the embodiments of the present application, it can automatically detect whether there are spelling errors in the content generated by the user, and help the user correct the spelling errors, not only improving the quality and readability of the text, but also improving the efficiency and quality of the content review platform.

[0100] It should be noted that the above application scenarios are only examples, and the training method of the text detection model provided by the embodiments can also be applied to other scenarios, which are not limited here.

[0101] The training method of the text detection model provided by the present application will be described in detail below.

[0102] Referring to FIG. 4, which is a flowchart of the training method of the text detection model provided by the embodiments of the present application. In order to facilitate description, the following embodiments will still be described by taking the server as an example of the execution subject of the training method of the text detection model. As shown in FIG. 4, the training method of the text detection model includes S401-S403.

[0103] S401: Obtain a training text sample with a text label.

[0104] The training text sample is a text used to train the text detection model, which has a corresponding text label, which is used to represent the correct expression corresponding to the training text sample. For example, the training text sample is still difficult to break the deadlock, and the corresponding text label is still difficult to break the deadlock.

[0105] The text label includes a plurality of text label characters, each text label character has a preset length, and the plurality of text label characters have a semantic order.

[0106] The present application does not limit the preset length, and those skilled in the art can set it according to actual needs. It should be noted that for the Chinese spelling check task, since each character has a corresponding semantic, the combination of characters also has a new semantic, so the preset length can be set to 1 character length, i.e. 1 character. Compared with setting the preset length to more than 1 character length such as 2 character length, it can reduce the learning difficulty of the initial text detection model, avoid the sparsity of the initial file detection model, and improve the accuracy of the subsequent text detection model.

[0107] As a possible implementation manner, the preset length can also be set based on the language. For example, if the training text sample is Chinese, the text detection model is used to detect whether the Chinese has an error expression, and at this time, the preset length can be less than the first length threshold, and the first length threshold can be 2 characters. For another example, if the training text is English, the text detection model is used to detect whether the English has an error expression, and at this time, the preset length can be less than the second length threshold, and the second length threshold can be 4 characters.

[0108] In the formula, since one character of Chinese can express one semantic, for example, one word represents one semantic, and multiple words can also introduce other semantics or even error semantics, and English generally needs multiple characters to express one semantic, for example, different roots correspond to different meanings, and the first length threshold is less than the second length threshold. Therefore, the preset length is set based on the characteristics of the language, so that the text detection model obtained by training is more suitable for the corresponding language, thereby expanding the application scenarios and improving the accuracy of the text detection model in different application scenarios.

[0109] The embodiments of the present application are not limited to the manner of obtaining the multiple text label characters. For example, after obtaining the training text sample each time, the text label is divided according to the preset length to obtain the multiple text label characters. For another example, the text label of all training text samples is divided in advance to obtain the multiple text label characters, and in the process of training the initial text detection model, the training text sample and the text label including the multiple text label characters are directly obtained.

[0110] In the formula, the semantic order refers to the order of understanding the text. Taking Chinese as an example, the order is generally from left to right. The multiple text label characters have the semantic order to identify the arrangement order between the multiple text label characters included in the text label. Taking the text label as an example, the arrangement order corresponding to the semantic order of the multiple text label characters can be fight, break, deadlock, still, old, difficult, heavy, and so on, or the arrangement order corresponding to the semantic order of the multiple text label characters can be heavy, heavy, difficult, heavy, old, still, deadlock, break, fight, and so on, and the present application does not make a specific limitation.

[0111] In addition, it should be noted that if the preset length is 1 character, no matter how the splitting is, it will be an integer, so the length of each text label character is 1 character. If the preset length is more than 1 character, if the length of the text label is not an integer multiple of the preset length, the splitting may not be an integer, such as the length of the last text label character included in the text label may not be the preset length. Based on this, the length of the last text label character can be ignored, or the last text label character can be supplemented with meaningless characters to make its length the preset length. It can be understood that no matter which way it is, the length of the text label character and the first predicted text character will be consistent, so as not to affect the establishment of the mapping relationship between the characters.

[0112] Taking the preset length as 2 characters and the text label as an example, the text label characters are still difficult to break the deadlock, and the text label characters are broken, deadlock, still, difficult, heavy, and oh, it can be seen that the last text label character is 1 word, and by analogy, the first predicted text character is broken, deadlock, still, difficult, heavy, and oh, the last first predicted text character is 1 word. Alternatively, the length can be supplemented to 2 or the like based on meaningless characters, which is not limited in the present application.

[0113] It can be understood that in the specific embodiments of the present application, if the data such as training text samples involve data related to the user, when the above embodiments of the present application are applied to specific products or technologies, the user's permission or consent needs to be obtained, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of the country and region.

[0114] S402: According to the training text sample, the initial text detection model is used for prediction to obtain the first predicted text.

[0115] The initial text detection model is a text detection model that has not been trained. The initial text detection model is not limited in the present application, and a model obtained by fine-tuning (Low-Rank Adaptation of Large Language Models, LoRA) based on a large language model can be used as the initial text detection model.

[0116] In the embodiments of the present application, the text detection model is equivalent to regarding the spelling checking task as a text generation task of predicting a text with basically no misspelling based on a text that may have misspelling, that is, the initial text detection model can also regard the spelling checking task as a text generation task of predicting a text with basically no misspelling based on a text that may have misspelling. Therefore, according to the training text sample, the initial text detection model can be used for prediction to obtain the first predicted text.

[0117] For example, the training text sample is input into the initial text detection model, prediction is performed by the initial text detection model, and the first predicted text is output. For another example, the training text sample is encoded to obtain an embedding vector for the training text sample, the embedding vector is input into the initial text detection model, prediction is performed by the initial text detection model, and the first predicted text is output.

[0118] The first predicted text is the corrected text for the training text sample, or the training text sample can obtain the first predicted text after error correction by the initial text detection model. The first predicted text includes a plurality of first predicted text characters with a preset length and a semantic order, that is, the first predicted text can be divided into a plurality of first predicted text characters.

[0119] The length of each first predicted text character is the preset length, and the length of each text label character is the preset length, so the length of the first predicted text character is consistent with the length of the text label character. Alternatively, the preset length is used as a division rule, and the first predicted text and the text label are divided by the same division rule, so that the number of first predicted text characters is consistent with the number of text label characters, and the division position of the first predicted text character is consistent with the division position of the text label character, so that the coding granularity of the two is consistent, and a one-to-one mapping relationship between the first predicted text character and the text label character can be established based on the semantic order.

[0120] In addition, it should be noted that if the preset length is 1 character, no matter how it is divided, it will be an integer, so the length of each first predicted text character is 1 character. If the preset length is greater than 1 character, if the length of the first predicted text is not an integer multiple of the preset length, the division may not be an integer, and the length of the last first predicted text character included in the first predicted text may not be the preset length. Based on this, the length of the last first predicted text character can be ignored, or the last first predicted text character can be supplemented with meaningless characters to make its length the preset length. It can be understood that no matter which way is used, the length of the text label character and the first predicted text character will be consistent, so as not to affect the mapping relationship between the characters.

[0121] The semantic order between the plurality of first predicted text characters is used to identify an arrangement order between the plurality of first predicted text characters included in the first predicted text. For example, the first predicted text can be still difficult to break the deadlock, and the arrangement order corresponding to the semantic order of the plurality of first predicted text characters can be: break, deadlock, still, difficult, and so on. The application does not make specific limitations.

[0122] The application does not specifically limit the way to obtain the plurality of first predicted text characters, which is illustrated below by taking two ways as examples.

[0123] In the first way, the plurality of first predicted text characters included in the first predicted text can be directly obtained by the initial text prediction model. For example, if the initial text prediction model can continuously predict the next first predicted text character, the plurality of first predicted text characters can be directly obtained.

[0124] In the second way, in the related art, the first predicted text is generally segmented based on a dictionary to obtain a plurality of segmented units. The dictionary includes a word or a word group, so that the segmented units can be a word or a word group. Therefore, the segmentation of the first predicted text based on the dictionary can cause the lengths of the first predicted text characters to be different, so that the initial text detection model cannot understand the length concept of the word, resulting in the problems of incorrect correction or incorrect correction, and reducing the accuracy of text detection.

[0125] Therefore, the initial text prediction model can directly output the complete first predicted text, and then the first predicted text can be segmented based on a preset length to obtain a plurality of first predicted text characters, so that the length of each first predicted text character is equal to the preset length, so that the initial text detection model can understand the length concept of the word, and improve the accuracy of the subsequent text detection model.

[0126] S403: Adjusting the model parameters of the initial text detection model according to the difference between the first predicted text characters and the text label characters having the corresponding relationship, to obtain a text detection model.

[0127] Since the length of the first predicted text character is consistent with the length of the text label character, the length of the first predicted text and the length of the text label are consistent with the length of the training text sample, and the plurality of first predicted text characters are arranged in the semantic order, and the plurality of text label characters are arranged in the semantic order, a one-to-one correspondence can be established between the first predicted text character and the text label character. The first predicted text is the corrected text obtained by the initial text detection model for the training text sample, and the text label is the correct expression text for the training text sample. The first predicted text character and the text label character having the correspondence relationship have consistent sorting positions in the semantic order to which they respectively belong, that is, a mapping relationship can be established between them, forming a pair of characters. Based on the difference between the pair of characters having the mapping relationship, the parameters of the initial text detection model are adjusted, so that the prediction ability of the initial text detection model becomes stronger and stronger, so that the difference between the pair of characters having the mapping relationship becomes smaller and smaller, and a trained text detection model is obtained.

[0128] Moreover, the first predicted text character and the text label character have a correspondence relationship, and the sorting positions of the two in the semantic order to which they respectively belong are consistent, the positions of the segmented words are consistent, and the lengths are consistent, so that the coding granularity of the two is the same, and the coding granularity of each text character is also the same. Furthermore, in the training process of the initial text detection model, the correspondence relationship between characters, such as the correspondence relationship between the wrong word and the corrected word, can be better established, so that the length concept of the character is learned, and the length constraint and the pitch constraint of the spelling checking task are learned.

[0129] The text detection model is a trained model, which is used to correct the input text to output the correct expression text corresponding to the input text, thereby realizing the ability of text detection.

[0130] It can be seen from the above technical solution that a training text sample with a text label is obtained, the text label is a correct expression text corresponding to the training text sample, and the text label includes a plurality of text label characters of a preset length and has a semantic order between the plurality of text label characters. In this application, the text detection model is equivalent to regarding the spelling check task as a text generation task based on a text that may have a misspelling to predict a text that basically has no misspelling. Therefore, according to the training text sample, a first prediction text is obtained by predicting through the initial text detection model. The first prediction text includes a plurality of first prediction text characters each having a preset length, and the plurality of first prediction text characters have a semantic order. Thus, the lengths of the first prediction text and the text label are consistent with the length of the training text sample, the length of the first prediction text character is consistent with the length of the text label character, the segmentation positions and the number of segments of the first prediction text character and the text label character are consistent, the coding granularity of the first prediction text character and the text label character is consistent, and a one-to-one mapping relationship can be established between the first prediction text character and the text label character based on the semantic order. The first prediction text is a corrected text obtained by the initial text detection model for the training text sample, and the text label is a correct expression text corresponding to the training text sample. Thus, the model parameters of the initial text detection model can be adjusted according to the difference between the first prediction text character and the text label character having a corresponding relationship, and the text detection model is obtained.

[0131] Thus, in the process of training the text detection model, the length of the first prediction text character is consistent with the length of the text label character, the model can directly establish a mapping relationship between characters, the model can understand the length concept of the character, and the mapping relationship includes a mapping relationship between a misspelling and a corrected word, thereby meeting the length constraint and the pinyin constraint of the spelling check task. The accuracy of the text detection model outputting a text with a correct expression is improved, that is, the correction ability of the text detection model is improved, and thus the accuracy of text detection is improved.

[0132] In related technologies, a vocabulary (hereinafter referred to as a historical vocabulary for distinction) can be used to assist a large language model in prediction. The historical vocabulary assigns a unique vocabulary index to each character. After obtaining the input text, the input text is segmented to obtain a plurality of segments, and a vocabulary index corresponding to each segment is determined based on the historical vocabulary. Based on the vocabulary index corresponding to each segment, the large language model is used to predict an output text corresponding to the input text, and the output text includes fewer misspellings than the input text. Thus, the large language model can indirectly process the input text by processing these vocabulary indexes instead of directly processing the input text itself. This greatly simplifies the calculation process of the large language model and improves the efficiency.

[0133] However, the historical vocabulary in the related art generally includes words and characters of inconsistent lengths, so in the process of establishing the historical vocabulary, vocabulary indexes are established based on the words and characters of inconsistent lengths, and in the process of performing word segmentation on the input text, the lengths of the words and characters are also inconsistent, thereby leading to different coding granularities of the words and characters, so that the large language model cannot directly establish the mapping relationship between characters, thereby failing to learn the length constraint and the accuracy constraint of the spelling checking task.

[0134] Based on this, the embodiment of the present application no longer processes based on the existing historical vocabulary assisted text detection model, but newly establishes a new vocabulary (hereinafter referred to as vocabulary for the sake of distinction). The vocabulary includes a plurality of basic characters and a vocabulary index corresponding to each basic character. Each vocabulary index is used to uniquely identify a basic character, and the length of each basic character is a preset length. Taking a preset length of 1 character as an example, the vocabulary only includes a plurality of characters, and does not include words composed of characters.

[0135] The embodiment of the present application does not specifically limit the creation method of the vocabulary. For example, a plurality of characters are obtained based on Chinese books, Chinese Internet, Chinese encyclopedias and other corpus, and each character is taken as a basic character, thereby obtaining a vocabulary including a plurality of basic characters.

[0136] Alternatively, when the vocabulary is a Chinese corresponding vocabulary, or in other words, the training text sample is Chinese, the required vocabulary is a Chinese corresponding vocabulary, and the preset length can be 1 character, that is, the vocabulary only includes characters and does not include words composed of characters. Based on this, an existing historical vocabulary can be obtained, for example, a historical vocabulary is established based on the BPE (Byte Pair Encoding) method. The historical vocabulary includes a plurality of words, and the plurality of words include words of different lengths, such as words of 1 character and words of 2 characters. Then, the historical vocabulary is modified, that is, words longer than 1 are filtered out from the historical vocabulary, thereby obtaining an updated historical vocabulary, that is, a vocabulary.

[0137] It should be noted that for Chinese, the basic character is 1 character, that is, the effect of the preset length being 1 character is the best. If the preset length is 2 characters, the basic characters included in the vocabulary are all 2 characters, which may generate a plurality of non-semantic words such as “kaoxian”, not only the data amount of the basic characters included in the vocabulary is doubled, but also the subsequent text detection model based on the vocabulary has sparsity, which has low accuracy.

[0138] Therefore, not only the speed of establishing the glossary can be accelerated, but also the initial text detection model cannot directly identify the words composed of characters and cannot obtain characters of different lengths when performing word segmentation, but can only split the training text samples into multiple characters for understanding respectively, so as to avoid the ambiguous corresponding relationship between characters caused by the word segmentation of multiple characters, thereby making the initial text detection model more easily meet the length constraint and the pitch constraint, and improving the accuracy of the text detection model.

[0139] After obtaining the newly established glossary, the following describes how to make a prediction based on the newly established glossary, and details are described with reference to S4021-S4023 (not shown in the figure).

[0140] S4021: Splitting the training text sample based on a preset length to obtain multiple training text characters.

[0141] The training text sample is split based on the preset length, and the length of each training text character obtained by the splitting is the preset length, and the multiple training text characters have a semantic order.

[0142] For example, the training text sample is colleagues work very tired and very hard. The preset length is 1 character, and the training text sample is split based on the preset length to obtain 11 training text characters, and one of the semantic order arrangements is same, people, work, work, very, tired, very, hard.

[0143] S4022: Finding the word index corresponding to each training text character according to the glossary.

[0144] Since the glossary includes the basic characters and the word index corresponding to each basic character, the basic character corresponding to the training text character can be found from the multiple basic characters in the glossary, so that the word index corresponding to the basic character is determined as the word index corresponding to the training text character, thereby realizing the encoding of the training text character.

[0145] S4023: Making a prediction through the initial text detection model according to the word index corresponding to each training text character to obtain a first predicted text.

[0146] For example, the word index corresponding to each training text character is input into the initial text detection model, and a prediction is made through the initial text detection model, so that the word index of each first predicted text character included in the first predicted text is output, and the corresponding basic character is found based on the word index, thereby obtaining the first predicted text.

[0147] It should be noted that the initial text detection model can continuously predict the next character, i.e., the first predicted text character, based on the context understanding of the training text sample, so as to obtain the first predicted text including a plurality of first predicted text characters.

[0148] Therefore, instead of using the historical vocabulary, a new vocabulary is created, in which the length of each base character is a preset length, i.e., consistent with the length of the training text character, the first predicted text character, the text label character, etc. The initial text detection model is incrementally trained by the vocabulary, so that the initial text detection model can adapt to the new vocabulary, so that the initial text detection model can implicitly learn the concept of the word, i.e., how long the preset length is, so as to better understand the length concept of the word, establish the mapping relationship between characters and characters, and thus make the initial text detection model more easily meet the length constraint and the pitch constraint, and improve the accuracy of the text detection model. It is found through experiments that after the text detection model understands the length concept of the word, its accuracy can be improved from 70%-80% to 99%.

[0149] Regardless of Chinese or English, etc. The combination of characters and characters may generate new semantics. In order to make the text detection model better understand the text, the text detection model is obtained by two-stage training in the embodiments of the present application. The first stage training is referred to as A1-A3 (not shown in the figure).

[0150] A1: Obtain general text samples.

[0151] Taking Chinese as an example, the general text sample can be obtained based on Chinese books, Chinese Internet, and Chinese encyclopedias. The general text sample includes a plurality of general text characters with a preset length and a semantic order. It should be noted that in order to train the ability of the base text detection model to predict the next character later, no wrong text can be used here, i.e., there is no wrong word in the general text sample, so that the initial text detection model trained based on the base text detection model can correctly predict the next character later.

[0152] As a possible implementation, the general text sample can be split based on the preset length, so as to obtain a plurality of general text characters, each of which has a preset length, and the plurality of general text characters have a semantic order.

[0153] A2: According to the general text sample, the second predicted text is obtained by predicting through the base text detection model.

[0154] The basic text detection model is used to learn the composition of the input text. The second predicted text can be obtained by predicting the basic text detection model according to the general text sample. The basic text detection model in the embodiments of the present application can be LoRA model, etc.

[0155] The second predicted text is a paraphrase text for the general text sample. The more similar the second predicted text is to the general text sample, the stronger the prediction ability of the basic text detection model, that is, the basic text detection model can predict the next character. The second predicted text includes a plurality of second predicted text characters with a preset length and a semantic order. The manner of obtaining the plurality of second predicted text characters is not limited in the embodiments of the present application, which will be described below by way of example.

[0156] In the first manner, the plurality of second predicted text characters included in the second predicted text can be directly obtained by the basic text detection model. For example, if the basic text detection model can continuously predict the next second predicted text character, the plurality of second predicted text characters can be directly obtained.

[0157] In the second manner, the basic text detection model can directly output a complete second predicted text, and then the second predicted text can be divided into a plurality of second predicted text characters based on the preset length, so that the length of each second predicted text character is equal to the preset length, thereby enabling the basic text detection model to understand the length concept of the word and improving the accuracy of the subsequent initial detection model.

[0158] As a possible implementation manner, the vocabulary index corresponding to each general text character can also be found based on the aforementioned vocabulary, and the second predicted text can be obtained by predicting the basic text detection model according to the vocabulary index corresponding to each general text character. For details, please refer to the foregoing S4021-S4023. Thus, the initial file detection model can be adapted to a new vocabulary based on the general training text, the understanding of the length concept of the word can be improved, and the ability of the initial file detection model for text detection can be improved.

[0159] A3: Adjusting the model parameters of the basic text detection model according to the difference between the second predicted text characters and the general text characters having the corresponding relationship, to obtain an initial text detection model.

[0160] Since the length of the second predicted text is equal to the length of the general text sample, the length of the second predicted text character is consistent with the length of the general text character, and the plurality of second predicted text characters are arranged in a semantic order, and the plurality of general text characters are arranged in a semantic order, a one-to-one correspondence can be established between the second predicted text characters and the general text characters.

[0161] The second predicted text character and the general text character having the corresponding relationship are consistent in the sorting position in the respective semantic order, that is, a mapping relationship can be established between the second predicted text character and the general text character arranged at the same position in the two semantic orders, and a pair of characters is formed. Based on the difference between the pair of characters having the mapping relationship, the parameters of the basic text detection model are adjusted, so that the prediction ability of the basic text detection model becomes stronger and stronger, so that the difference between the pair of characters having the mapping relationship becomes smaller and smaller, and an initial text detection model obtained by first-stage training is obtained.

[0162] Moreover, the second predicted text character and the general text character having the corresponding relationship are consistent in the sorting position in the respective semantic order, consistent in the position of word segmentation, and consistent in length, so that the coding granularity of the two is the same, and the coding granularity of each text character is also the same. Furthermore, in the training process of the basic text detection model, the corresponding relationship between characters, such as the corresponding relationship between a wrong word and a corrected word, and the semantics of the combination of characters, such as the new semantics obtained by combining un and happy, can be better established.

[0163] Then, the initial text detection model obtained by first-stage training is trained based on the manner of S401-S403, and a text detection model obtained by second-stage training is obtained.

[0164] Therefore, the text detection model is obtained by two-stage training. In the first stage, the basic text detection model is trained by using the general text sample, and the mapping relationship between characters and the semantics of the combination of characters can be learned, so that the initial text detection model obtained based on the basic text detection model can predict the next character. In the second stage, the initial text detection model is fine-tuned by using the training text sample, so that the initial text detection model can correctly predict the next character while having the ability to predict the next character, that is, the correction function is realized, so that the text detection model obtained based on the initial text detection model is more suitable for the spelling checking task. Therefore, by combining the general training and the domain training through two-stage training, the detection ability of the text detection model is improved while the training difficulty of the text detection model is reduced.

[0165] As a possible implementation manner, if the text detection model is used for text detection of Chinese, the training text sample and other data also need to be Chinese. Generally, in the scenario of detecting Chinese, the preset length is set to be relatively small, that is, the preset length is less than a first length threshold, such as 1 character, so as to avoid the sparsity of the text detection model and reduce the training difficulty of the text detection model.

[0166] Moreover, since Chinese is generally spelled based on pinyin, and the number of pinyins of a character is small, in order to meet the phonetic accuracy constraint, the pinyins of the characters should differ by a small amount, and in the case of small character length, the pinyins of the characters should also differ by a small amount. Taking a preset length of 1 character as an example, the pinyin of a character is generally about 3, and the possibility of a 1-pinyin difference between two characters is high, and the possibility of a 2-pinyin difference between two characters is low, because a 2-pinyin difference may not be able to express a meaning.

[0167] Based on this, in order to meet the phonetic accuracy constraint, when the training text sample is Chinese and the preset length is small, the pinyins of the training text characters included in the training text sample and the corresponding text label characters should differ by a small amount, such as less than a pinyin threshold. Those skilled in the art can set the pinyin threshold according to actual needs, such as 1 pinyin, etc., which is not limited in the present application.

[0168] Taking one of the training text characters included in the training text sample, i.e., a target training text character, as an example, since the length of the text label is consistent with the length of the training text sample, the length of the text label character is consistent with the length of the training text character, i.e., the splitting rule of the text label character is consistent with that of the training text character, so that the text label characters and the training text characters that have the same sorting position in the semantic order have a mapping relationship, and the text label character that has a mapping relationship with the target training text character is a target text label character. The difference between the pinyin of the target training text character and the pinyin of the target text label character is less than the pinyin threshold, such as more than one pinyin, less than one pinyin, or one wrong pinyin, etc., so that the text detection model trained based on the training text sample can meet the phonetic accuracy constraint.

[0169] Therefore, in the case of detecting Chinese and small character length, by limiting the training text sample of the training text detection model, the pinyin difference between the training text sample and the corresponding text label is small, i.e., the pinyin difference between the training text characters included in the training text sample and the corresponding text label characters is less than the pinyin threshold, so that the text detection model can recognize the wrong characters with small pinyin difference, meet the phonetic accuracy constraint of the spelling checking task, thereby reducing the probability of wrong correction and over-correction, and improving the accuracy of the text detection model.

[0170] As a possible implementation manner, although the length of the character is smaller when detecting Chinese, the corresponding pinyin threshold is smaller, but due to the difference of the keyboard for inputting Chinese, the error generated thereby is also different. For example, compared with the virtual keyboard of the mobile phone, the physical keyboard of the computer is larger, and the range of the key is larger, so that the possibility of pinyin error is higher in the process of inputting pinyin based on the physical keyboard, and thus the pinyin threshold of the pinyin input based on the physical keyboard can be set to be larger on the premise of meeting the user input intention.

[0171] Based on this, the keyboard type of the input training text sample can be obtained, and the pinyin threshold is determined according to the keyboard type. Thus, different text detection models are set for different keyboard types, so that the text detection model is more suitable for the actual scene. Thus, the accuracy of the text detection model is further improved on the premise of meeting the user input intention, and the application scene is refined.

[0172] The application process of the text detection model is described below, and S501-S503 are referred to.

[0173] Referring to FIG. 5, it is an application schematic diagram of a text detection model provided by an embodiment of the present application.

[0174] S501: Obtain the text to be detected.

[0175] The text to be detected is the text waiting to be corrected by the text detection model, which includes a plurality of text characters to be detected with a predetermined length and a semantic order.

[0176] As a possible implementation manner, the text to be detected can be divided based on the predetermined length to obtain a plurality of text characters to be detected, and the length of each text character to be detected is the predetermined length, and the plurality of text characters to be detected have a semantic order.

[0177] The present application embodiment does not specifically limit the acquisition method of the text to be detected, and a person skilled in the art can set it according to actual needs. For example, in the character input process, if it is detected that the i-th character meets the preset condition, the character obtained after the (i-1)-th character meets the preset condition, i.e. the character input between the last time when the preset condition is met and the current time when the preset condition is met, is determined as the text to be detected. i is a positive integer.

[0178] The present application embodiment does not specifically limit the preset condition, for example, the preset condition can be set as a special character (such as a comma, a period, etc.).

[0179] Thus, without detecting each character by the text detection model, the character is identified by the preset condition, and after the preset condition is met, one detection is performed by the text detection model, so that the length of the to-be-detected text can be reduced while meeting certain related semantics, that is, the detection times are reduced, the text with related semantics can be detected, and the detection accuracy is improved.

[0180] S502: According to the to-be-detected text, a third prediction text is obtained by predicting through the text detection model.

[0181] The third prediction text is an error correction text for the to-be-detected text, and the third prediction text includes a plurality of third prediction text characters with a preset length and a semantic order.

[0182] The embodiments of the present application do not specifically limit the manner of obtaining the plurality of third prediction text characters, which will be described below as an example in two ways.

[0183] In the first way, the plurality of third prediction text characters included in the third prediction text can be directly obtained by the text detection model, for example, the text detection model can continuously predict the next third prediction text character, so that the plurality of third prediction text characters can be directly obtained, and the output order is the semantic order of the plurality of third prediction text characters.

[0184] In the second way, the text detection model can directly output a complete third prediction text, and then the third prediction text can be divided based on the preset length to obtain a plurality of third prediction text characters, so that the length of each third prediction text character is equal to the preset length, and the plurality of third text characters have a semantic order.

[0185] As a possible implementation manner, the word table can be used to find the word index corresponding to each to-be-detected text character, and the third prediction text can be obtained by predicting through the text detection model according to the word index corresponding to each to-be-detected text character. For details, please refer to S4021-S4023.

[0186] S503: If the third prediction text character and the to-be-detected text character with the corresponding relationship are different, a prompt that the to-be-detected text has an error expression is sent.

[0187] Since the third predicted text is consistent with the length of the to-be-detected text, the length of the third predicted text character is consistent with the length of the to-be-detected text character, and the plurality of third predicted text characters are arranged in a semantic order and the plurality of to-be-detected text characters are arranged in a semantic order, a one-to-one correspondence can be established between the third predicted text character and the to-be-detected text character. Moreover, the third predicted text character and the to-be-detected text character having the correspondence are consistent in position and length of segmentation, so that the coding granularity of the two is the same, and if the two are not the same and the accuracy of the third predicted text character is higher, the to-be-detected text character corresponding to the third predicted text character is a wrong character, at this time, a prompt can be sent to prompt that the to-be-detected text has an error expression.

[0188] The embodiment of the present application does not specifically limit the way of sending the prompt, and a person skilled in the art can set it according to actual needs, which is described below as an example.

[0189] If the third predicted text character and the to-be-detected text character having the correspondence are different, it indicates that there is an error expression in the to-be-detected text, and the to-be-detected text character different from the third predicted text character is an error expression. In order to facilitate expression, the to-be-detected text character of the error expression is referred to as a target to-be-detected text character, and the third predicted text character corresponding to the correct expression of the target to-be-detected text character is referred to as a target third predicted text character, that is, the target third predicted text character and the target to-be-detected text are consistent in the sorting position in the respective semantic order, and the target third predicted text character and the target to-be-detected text character are different.

[0190] That is, if the target third predicted text character and the target to-be-detected text character are different, the segmentation including the target third predicted text character is determined from the third predicted text, and the segmentation including the target to-be-detected text character is determined from the to-be-detected text. Therefore, the segmentation including the target third predicted text character and the segmentation including the target to-be-detected text character are displayed, that is, the prompt composed of the segmentation including the target third predicted text character and the segmentation including the target to-be-detected text character, that is, directly based on the error expression and the correct expression as a prompt to display to the user.

[0191] Therefore, compared with only displaying a character having an error expression, displaying the segmentation having an error expression and the segmentation of the correct expression corresponding thereto, the segmentation includes the character, the user can determine the character having an error expression from the level of the segmentation, and it is easier to understand and correct errors, thereby improving the user experience.

[0192] The embodiment of the present application does not specifically limit the way of determining the segmentation including the target to-be-detected text character and the segmentation including the target third predicted text character, which is described below as an example.

[0193] In a first mode, the text to be detected is segmented to obtain a plurality of segmented words, the target character of the text to be detected is compared with the plurality of segmented words, and a segmented word including the target character of the text to be detected is obtained. Similarly, the third predicted text character is segmented to obtain a plurality of segmented words, the target third predicted text character is compared with the plurality of segmented words, and a segmented word including the target third predicted text character is obtained. This mode is convenient and fast.

[0194] In a second mode, the text to be detected is segmented to obtain a plurality of segmented words, the target character of the text to be detected is compared with the plurality of segmented words, and a segmented word including the target character of the text to be detected is obtained. Then, based on the position of the segmented word including the target character of the text to be detected in the text to be detected, a segmented word is obtained from the third predicted text character, and a segmented word including the target third predicted text character is obtained. This mode has high accuracy.

[0195] In addition, after displaying the prompt based on the segmented word including the target third predicted text character and the segmented word including the target character of the text to be detected, the prompt composed of the two segmented words is displayed based on one control, as shown in FIG. 2. In response to a triggering operation on the prompt, the target character of the text to be detected is replaced based on the target third predicted text character, thereby updating the text to be detected to obtain an updated text.

[0196] Therefore, compared with directly replacing the detected incorrect expression, replacing the incorrect expression according to the user's intention can detect the text and replace the incorrect expression without affecting the user's input habit, thereby improving the user experience.

[0197] As a possible implementation, the embodiment of the present application also provides a text detection method for detecting and replacing the text corresponding to a text input operation. The following will be described in detail.

[0198] The user can perform a text input operation through an application, and the text input operation is used to input text, for example, the user inputs text through a typing software. In response to the text input operation, the application obtains the text corresponding to the text input operation, detects the text as text to be detected, and displays the text to be detected to the user. As shown in FIG. 2, the user inputs the text to be detected "the country's wey in young people" through a text input operation.

[0199] If an incorrect expression is detected in the text to be detected, such as a typo in the text to be detected, the incorrect expression and the correct expression can be displayed. Here, the incorrect expression includes characters that are not correctly used in the text to be detected, such as a typo, or a word segment including a typo. Similarly, the correct expression is the correct expression corresponding to the incorrect expression. Continuing to refer to Figure 2, when an incorrect expression "NIO" is detected in the text to be detected, the incorrect expression "NIO" and its corresponding correct expression "future" can be displayed. It can be understood that displaying the incorrect expression and the correct expression is a feasible way of sending a prompt that there is an incorrect expression in the text to be detected in the aforementioned S503.

[0200] If the user wants to replace the incorrect expression with the correct expression, a trigger operation can be performed on the correct expression. In response to the trigger operation on the correct expression, the incorrect expression in the text to be detected can be replaced with the correct expression, that is, the text to be detected is updated to obtain the updated text, and the updated text is displayed. Refer to Figure 11, which is a schematic diagram of a text detection method provided by an embodiment of this application. In Figure 11, the incorrect expression and the correct expression are displayed in the form of a control, such as control 1101. After the user performs a trigger operation on this control 1101, the incorrect expression in the text to be detected is replaced with the correct expression, and the updated text "The future of the country lies in the youth" is displayed. In addition, after receiving the trigger operation of the user on control 1101, control 1101 can cancel the display to avoid confusion.

[0201] Similarly, if the user does not want to replace the incorrect expression with the correct expression, a cancellation operation can be performed on the correct expression, or if there is no trigger operation for a long time, no replacement operation is performed on the text to be detected. Refer to Figure 12, which is a schematic diagram of a text detection method provided by an embodiment of this application. In Figure 12, there is a cancellation control 1102 on control 1101. When the user performs a cancellation operation (such as a click operation, etc.) through cancellation control 1102, no replacement operation is performed on the text to be detected, and the text to be detected "The NIO of the country lies in the youth" continues to be displayed.

[0202] It should be noted that the application can call the aforementioned text detection model to perform text detection on the to-be-detected text. Specifically, according to the to-be-detected text, a third prediction text is obtained by prediction through the text detection model, the third prediction text includes a plurality of third prediction text characters with a preset length and a semantic order, and the to-be-detected text also includes a plurality of to-be-detected text characters with a preset length and a semantic order. If the target third prediction text character and the target to-be-detected text character with the corresponding relationship are different, it indicates that the to-be-detected text has an incorrect expression, that is, it is detected that the to-be-detected text has an incorrect expression, wherein the incorrect expression is a word segmentation including the target to-be-detected text character, and the correct expression is a word segmentation including the target third prediction text character. For details, please refer to the foregoing S401-S403 and S501-S503, which will not be repeated here.

[0203] Therefore, in the process of using the application with the text detection function, the application can perform text detection on the to-be-detected text input by the user. If it is detected that the to-be-detected text has an incorrect expression, a replacement operation can be performed based on the user's demand, thereby helping the user to improve the correctness of the input text and improving the user experience.

[0204] In order to further understand the technical solutions provided by the embodiments of the present application, the training method of the text detection model provided by the embodiments of the present application will be exemplarily introduced as a whole taking the server as the execution subject of the training method of the text detection model and the text detection model being used to detect whether Chinese has an incorrect expression (the preset length is 1 character) as an example.

[0205] Referring to FIG. 6, which is a training diagram of a text detection model provided by an embodiment of the present application. In FIG. 6, three stages are required to train the text detection model, which are (1) constructing a word table, (2) training an initial text detection model, (3) training a text detection model, and (4) application of the text detection model. The following will be described respectively.

[0206] (1) Construct a word table.

[0207] A word table including only one character is constructed, that is, each basic character in the word table is a character, so that subsequent models such as the text detection model cannot directly identify Chinese words when performing prediction based on the word table, and cannot directly divide the words into word groups including multiple characters, but can only split the input text into multiple characters for understanding respectively. Thus, the ambiguous correspondence between characters caused by the original mixed character-word segmentation is avoided, so that the large model is more likely to meet the character-level length and pinyin constraints.

[0208] The historical vocabulary can be obtained by deleting all the words in the historical vocabulary that are not a single Chinese character. Taking the establishment of the historical vocabulary in the BPE-based manner as an example, for the vocabulary V included in the historical vocabulary and the merging rule M, if the length of the vocabulary V is greater than 1 or it is a non-Chinese character, the vocabulary V is deleted from the historical vocabulary, a Chinese character V' with a length of 1 is obtained, and a new merging rule M' is obtained for the Chinese character V', thereby obtaining a new vocabulary.

[0209] Thus, the first predicted text is segmented based on the vocabulary, and the obtained multiple first predicted text characters are: same / colleagues / working / very / tired / very / hard. The text label is segmented based on the vocabulary, and the multiple text label characters are: same / colleagues / working / very / tired / very / hard. Thus, the mapping relationship between the characters can be directly established, such as the mapping relationship between the wrong character "de" and the corrected character "de".

[0210] (2) Training to obtain an initial text detection model.

[0211] After the historical vocabulary is trimmed into a vocabulary, the semantic understanding ability of the model can be affected, and therefore, the model can be incrementally trained based on the vocabulary to adapt to the new vocabulary.

[0212] The general text sample can be obtained based on Chinese books, Chinese Internet, and Chinese encyclopedias. The general text sample is segmented based on a preset length to obtain multiple general text characters. Each general text character corresponds to a vocabulary index based on the aforementioned vocabulary. The initial text detection model is obtained by predicting the second predicted text based on the vocabulary index corresponding to each general text character through the basic text detection model, adjusting the model parameters of the basic text detection model based on the difference between the second predicted text characters and the general text characters having a corresponding relationship, and predicting the next second predicted text character. For related information, please refer to A1-A3.

[0213] (3) Training to obtain a text detection model.

[0214] The initial text detection model is further trained based on the data set of the spelling checking task, so that the text detection model obtained by training is more suitable for the spelling checking task. For example, a prompt word can be constructed, as shown in Table 2, and the prompt word is input into the initial text detection model to train the text detection model.

[0215] Table 2

[0216] Obtain training text samples with text labels. These training text samples can be obtained based on the dataset of the spelling detection task. According to the training text samples, make predictions through the initial text detection model to obtain the first predicted text. Based on a preset length, segment the first predicted text to obtain multiple first predicted text characters. Based on the preset length, segment the text labels to obtain multiple text label characters. Adjust the model parameters of the initial text detection model according to the differences between the first predicted text characters and the text label characters with corresponding relationships to obtain the text detection model. For the relevant parts, refer to S401 - S403.

[0217] Thus, through the above three stages, a text detection model can be trained. This text detection model can establish a clear mapping relationship between characters, correct errors by character, avoid the length of the third predicted text being inconsistent with the text to be detected, and thus reduce the probability that the content of the third predicted text is not similar to the pinyin of the text to be detected.

[0218] Refer to FIG. 7, which is a schematic diagram of a mapping relationship provided by an embodiment of the present application. Take the first predicted text "exposure of a picture with courage" as an example. In the related art, based on a traditional large model (such as Original LLM) as the text detection model, it segments the first predicted text into "have", "courage", "of", "picture", "exposure", that is, in a way of mixing words and characters. Its corresponding text label is segmented into "have", "a large amount of", "picture", "exposure". During training, the model needs to learn that "courage" and "of" correspond to "a large amount of", that is, a mapping from character to word. This kind of character - to - word mapping relationship, in the view of the model, the number of word segments in the two sentences is inconsistent, which is not conducive to the model understanding the concept of character length, and thus cannot meet the length constraint. Moreover, the character - to - word mapping also requires the model to infer that "courage" corresponds to "big" in "a large amount of", which is not conducive to the model establishing a clear character error - correction relationship and phonetic proximity relationship, and thus is not conducive to its understanding of the pinyin constraint.

[0219] However, using the training method of the embodiment of the present application, it segments the first predicted text into "have", "courage", "quantity", "of", "picture", "piece", "exposure", "light", and its corresponding text label is segmented into "have", "big", "quantity", "of", "picture", "piece", "exposure", "light". Thus, a character - to - character mapping can be established, and the number of word segments in the two sentences is the same. The model can understand the concept of character length, and thus meet the length constraint. Moreover, a clear character error - correction relationship is established, such as the mapping relationship between "courage" and "big". During training, the number of word segments seen by the model is the same, and it is easier to learn the phonetic proximity relationship between characters, and thus it is easier to meet the length constraint and the phonetic accuracy constraint.

[0220] (4) Application of the text detection model

[0221] Obtain the text to be detected, split the text to be detected based on a preset length to obtain a plurality of text characters to be detected. According to the text to be detected, a third prediction text is obtained by predicting through a text detection model, the third prediction text is split based on a preset length to obtain a plurality of third prediction text characters, if the third prediction text characters and the text characters to be detected have a corresponding relationship, and are different, a prompt that the text to be detected has an incorrect expression is sent, such as displaying the incorrect expression and the correct expression, etc., so as to realize the correction at the character level. For details, see S501-S503.

[0222] If a trigger operation for the prompt is obtained, the incorrect expression in the text to be detected is replaced by the correct expression to obtain an updated text, so as to realize the detection and correction of the text.

[0223] Therefore, the text detection model can greatly improve the error correction ability, reduce the phenomenon of over-correction and wrong correction, and has good error correction effect.

[0224] For the training method of the text detection model described above, the application also provides a corresponding training device of the text detection model, so that the training method of the text detection model can be applied and implemented in practice.

[0225] Referring to FIG. 8, which is a structural schematic diagram of a training device of a text detection model provided by an embodiment of the application. As shown in FIG. 8, the training device 800 of the text detection model comprises an acquisition unit 801, a prediction unit 802 and an adjustment unit 803.

[0226] The acquisition unit 801 is configured to acquire a training text sample with a text label, the text label being a correct expression text corresponding to the training text sample, and the text label comprising a plurality of text label characters with a preset length and a semantic order.

[0227] The prediction unit 802 is configured to predict through an initial text detection model according to the training text sample to obtain a first prediction text, the first prediction text comprising a plurality of first prediction text characters with the preset length and the semantic order.

[0228] The adjustment unit 803 is configured to adjust model parameters of the initial text detection model according to differences between the first prediction text characters and the text label characters having a corresponding relationship, to obtain a text detection model, the text detection model being used for correcting an input text to output a correct expression text corresponding to the input text, and the first prediction text characters and the text label characters having the corresponding relationship being consistent in the sorting position in the respective semantic order.

[0229] As a possible implementation manner, the acquisition unit 801 is further configured to acquire a vocabulary, the vocabulary comprising a plurality of base characters and a vocabulary index corresponding to each base character, and each base character having the preset length;

[0230] The prediction unit 802 is specifically configured to:

[0231] divide the training text sample based on the preset length to obtain a plurality of training text characters, each training text character having the preset length, and the plurality of training text characters having the semantic order;

[0232] find a vocabulary index corresponding to each training text character according to the vocabulary;

[0233] predict by the initial text detection model according to the vocabulary index corresponding to each training text character to obtain the first predicted text.

[0234] As a possible implementation manner, if the training text sample is Chinese and the preset length is 1 character, the text detection model training device 800 further comprises a vocabulary establishing unit configured to:

[0235] acquire a historical vocabulary comprising a plurality of segmented words, the plurality of segmented words comprising segmented words of different lengths;

[0236] if the length of the segmented word is greater than the preset length, delete the segmented word with the length greater than the preset length from the historical vocabulary to obtain the vocabulary.

[0237] As a possible implementation manner, the text detection model training device 800 further comprises an initial text detection model training unit configured to:

[0238] acquire a general text sample, the general text sample comprising a plurality of general text characters having the preset length and the semantic order;

[0239] predict by a base text detection model according to the general text sample to obtain a second predicted text, the second predicted text comprising a plurality of second predicted text characters having the preset length and the semantic order;

[0240] adjust model parameters of the base text detection model according to differences between the second predicted text characters and the general text characters having a corresponding relationship, so as to obtain the initial text detection model, the second predicted text characters and the general text characters having the corresponding relationship having consistent ordering positions in the semantic order to which each belongs.

[0241] As a possible implementation manner, if the training text sample is Chinese and the preset length is less than a first length threshold, a difference between a pinyin of a target training text character included in the training text sample and a pinyin of a target text label character is less than a pinyin threshold, the target text label character is one of a plurality of text label characters included in the text label, and the target training text character corresponds to the target text label character.

[0242] As a possible implementation manner, the training apparatus 800 of the text detection model further includes a pinyin threshold determination unit, configured to:

[0243] obtain a keyboard type of inputting the training text sample;

[0244] determine the pinyin threshold according to the keyboard type.

[0245] As a possible implementation manner, the training apparatus 800 of the text detection model further includes an application unit, configured to:

[0246] obtain a to-be-detected text, the to-be-detected text including a plurality of to-be-detected text characters with the preset length and the semantic order;

[0247] perform prediction on the to-be-detected text by using the text detection model to obtain a third predicted text, the third predicted text including a plurality of third predicted text characters with the preset length and the semantic order;

[0248] if the third predicted text character and the to-be-detected text character with the corresponding relationship are different, send a prompt that the to-be-detected text has an error expression, the third predicted text character and the to-be-detected text character with the corresponding relationship have the same order in the semantic order to which each of them belongs.

[0249] As a possible implementation manner, the application unit is further configured to:

[0250] in a character input process, if it is detected that the i-th character meets a preset condition, the character obtained after the (i-1)-th character meets the preset condition is determined as the to-be-detected text, i is a positive integer.

[0251] As a possible implementation manner, the application unit is specifically configured to:

[0252] if the third predicted text character corresponding to the relationship is different from the to-be-detected text character, determining a word including a target third predicted text character from the third predicted text, determining a word including a target to-be-detected text character from the to-be-detected text, the target third predicted text character and the target to-be-detected text character being consistent in the order in the respective semantic sequence, and the target third predicted text character being different from the target to-be-detected text character;

[0253] displaying a prompt, the prompt being the word including the target third predicted text character and the word including the target to-be-detected text character.

[0254] As a possible implementation manner, the training apparatus 800 of the text detection model further includes an updating unit, configured to:

[0255] in response to a trigger operation on the prompt, replacing the target to-be-detected text character with the target third predicted text character in the to-be-detected text to obtain an updated text.

[0256] As a possible implementation manner, if the training text sample is Chinese, the preset length is less than a first length threshold, if the training text sample is English, the preset length is less than a second length threshold, and the first length threshold is less than the second length threshold.

[0257] As a possible implementation manner, the present application further provides a text detection apparatus. Referring to FIG. 13, which is a structural schematic diagram of a text detection apparatus provided by an embodiment of the present application. As shown in FIG. 13, the text detection apparatus 1300 includes a display unit 1301 and a replacement unit 1302;

[0258] The display unit 1301 is configured to display a to-be-detected text corresponding to a text input operation in response to the text input operation.

[0259] The display unit 1301 is further configured to display an error expression and a correct expression corresponding to the error expression if it is detected that the to-be-detected text has the error expression.

[0260] The replacement unit 1302 is configured to replace the error expression with the correct expression to obtain an updated text in response to a trigger operation on the correct expression.

[0261] The display unit 1301 is further configured to display the updated text.

[0262] As a possible implementation manner, the to-be-detected text includes a plurality of to-be-detected text characters with a preset length and a semantic sequence, and the text detection apparatus 1300 further includes a detection unit, configured to:

[0263] According to the to-be-detected text, a third predicted text is obtained by prediction through a text detection model, the third predicted text including a plurality of third predicted text characters with the preset length and the semantic order, the text detection model being obtained by training in the manners of S401-S403;

[0264] If the target third predicted text character and the target to-be-detected text character with the corresponding relationship are different, it is detected that the to-be-detected text has an erroneous expression, wherein the erroneous expression is a word segmentation including the target to-be-detected text character, the correct expression is a word segmentation including the target third predicted text character, the target third predicted text character is one of the third predicted text characters included in the third predicted text, and the target to-be-detected text character is one of the to-be-detected text characters included in the to-be-detected text.

[0265] Embodiments of the present application also provide a computer device, which can be a server or a terminal device. In the following, the computer device provided by the embodiments of the present application will be introduced from the perspective of hardware embodiment. FIG. 10 shows a structural schematic diagram of a server, and FIG. 11 shows a structural schematic diagram of a terminal device.

[0266] Referring to FIG. 10, which is a structural schematic diagram of a server provided by an embodiment of the present application, the server 1400 can have great differences due to different configurations or performances, and can include one or more processors 1422, such as a central processing unit (CPU), a memory 1432, one or more storage media 1430 (for example, one or more mass storage devices) for storing one or more application programs 1442 or data 1444. The memory 1432 and the storage media 1430 can be temporary storage or persistent storage. The programs stored in the storage media 1430 can include one or more modules (not shown in the figure), each of which can include a series of instruction operations in the server. Further, the processor 1422 can be configured to communicate with the storage media 1430 and execute a series of instruction operations in the storage media 1430 on the server 1400.

[0267] The server 1400 can also include one or more power supplies 1426, one or more wired or wireless network interfaces 1450, one or more input and output interfaces 1458, and / or one or more operating systems 1441, such as Windows Server TM , Mac OS X TM , Unix TM , Linux TMFreeBSD TM and so on.

[0268] The steps performed by the server in the above embodiments can be based on the server structure shown in FIG. 10.

[0269] The processor 1422 is configured to perform the method steps of any of the specific implementation manners of the text detection model training method or the method steps of any of the specific implementation manners of the text detection method.

[0270] Referring to FIG. 11, which is a structural schematic diagram of a terminal device provided in an embodiment of the present application. Taking the terminal device as a smart phone as an example, FIG. 11 shows a block diagram of part of the structure of the smart phone, which includes a radio frequency (RF) circuit 1510, a memory 1520, an input unit 1530, a display unit 1540, a sensor 1550, an audio circuit 1560, a wireless fidelity (WiFi) module 1570, a processor 1580, and a power supply 1590, and the like. Those skilled in the art can understand that the structure of the smart phone shown in FIG. 11 does not constitute a limitation on the smart phone, and can include more or fewer components than shown, or combine certain components, or different component arrangements.

[0271] The various constituent components of the smart phone will be specifically introduced below in combination with FIG. 11:

[0272] The RF circuit 1510 can be used for receiving and sending signals in the process of information or call, in particular, receiving the downlink information of the base station and processing by the processor 1580; in addition, sending the uplink data to the base station.

[0273] The memory 1520 can be used to store software programs and modules, and the processor 1580 realizes various functional applications and data processing of the smart phone by running the software programs and modules stored in the memory 1520.

[0274] The input unit 1530 can be used to receive input digital or character information, and generate key signal input related to user settings and function control of the smart phone. Specifically, the input unit 1530 can include a touch panel 1531 and other input devices 1532. The touch panel 1531, also known as a touch screen, can collect touch operations of a user on or near it, and drive the corresponding connection device according to the pre-set program. In addition to the touch panel 1531, the input unit 1530 can also include other input devices 1532. Specifically, the other input devices 1532 can include one or more of, but are not limited to, a physical keyboard, function keys (such as volume control keys, on-off keys, etc.), a trackball, a mouse, a joystick, and the like.

[0275] The display unit 1540 can be used to display information input by a user or information provided to the user as well as various menus of the smart phone. The display unit 1540 can include a display panel 1541, which can be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like.

[0276] The smart phone can further include at least one sensor 1550, such as a light sensor, a motion sensor, and other sensors. Gyroscopes, barometers, hygrometers, thermometers, infrared sensors, and other sensors that can be configured in the smart phone are not described herein.

[0277] The audio circuit 1560, the speaker 1561, and the microphone 1562 can provide an audio interface between a user and the smart phone. The audio circuit 1560 can convert received audio data into an electrical signal and transmit the electrical signal to the speaker 1561, which converts the electrical signal into a sound signal and outputs the sound signal. On the other hand, the microphone 1562 converts a sound signal collected into an electrical signal, which is received by the audio circuit 1560 and converted into audio data. The audio data is output to the processor 1580 for processing, and then transmitted to another smart phone via the RF circuit 1510, or output to the memory 1520 for further processing.

[0278] The processor 1580 is a control center of the smart phone, which connects various parts of the smart phone through various interfaces and lines, and performs various functions of the smart phone and processes data by running or executing software programs and / or modules stored in the memory 1520 and calling data stored in the memory 1520. Optionally, the processor 1580 can include one or more processing units.

[0279] The smart phone further includes a power supply 1590 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 1580 through a power management system, so that the power management system can realize functions such as management of charging, discharging, and power consumption management.

[0280] Although not shown, the smart phone can further include a camera, a Bluetooth module, and the like, which are not described herein.

[0281] In the embodiments of the present application, the memory 1520 included in the smart phone can store a computer program and transmit the computer program to the processor.

[0282] The processor 1580 included in the smart phone can execute the training method of the text detection model or the text detection method provided in the above embodiments according to instructions in the computer program.

[0283] The embodiment of the present application further provides a computer readable storage medium for storing a computer program, the computer program being used for executing the training method of the text detection model or the text detection method provided in the above embodiments.

[0284] The embodiment of the present application further provides a computer program product or a computer program, the computer program product or the computer program including computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the training method of the text detection model or the text detection method provided in various optional implementation manners of the above aspect.

[0285] Those skilled in the art can understand that all or part of the steps of the above method embodiments can be completed by program instruction related hardware, and the foregoing program can be stored in a computer readable storage medium. When the program is executed, the steps of the above method embodiments are executed. The storage medium can be at least one of the following media: read-only memory (English: Read-Only Memory, abbreviation: ROM), RAM, magnetic disc or optical disc, and various media that can store computer programs.

[0286] The terms "first", "second", "third", "fourth" and the like (if any) in the specification and claims of the present application and the above drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "correspond to" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not necessarily have to include those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0287] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined target, and can be implemented entirely or partially by using software, hardware (such as a processing circuit or a memory) or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of an integral module or unit that contains the functions of the module or unit.

[0288] It should be noted that each of the embodiments in the present specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment mainly describes the difference from other embodiments. Especially, the device and system embodiments are described more simply because they are basically similar to the method embodiments, and the relevant parts can be referred to the part of the description of the method embodiments. The above-described device and system embodiments are merely illustrative, and the units described as separate components can be or can not be physically separated, and the components shown as units can be or can not be physical units, that is, they can be located in one place, or can be distributed on multiple network units. Part or all of the modules can be selected to achieve the purpose of the embodiments according to the actual needs. Those skilled in the art can understand and implement it without creative labor.

[0289] The above is only one specific embodiment of the present application, but the protection scope of the present application is not limited to this. Any skilled person in the art can easily think of changes or replacements within the technical range disclosed in the present application, which should be covered within the protection scope of the present application. On the basis of the implementation manners provided by the above aspects of the present application, further combinations can be made to provide more implementation manners. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method for training a text detection model, executed by a computer device, the method comprising: obtaining a training text sample with a text label, the text label being a correct expression text corresponding to the training text sample, the text label comprising a plurality of text label characters each having a preset length and a semantic order; predicting, according to the training text sample, by an initial text detection model to obtain a first predicted text, the first predicted text comprising a plurality of first predicted text characters each having the preset length and the semantic order; adjusting model parameters of the initial text detection model according to a difference between the first predicted text characters and the text label characters having a corresponding relationship, to obtain a text detection model, the text detection model being configured to correct an input text to output a correct expression text corresponding to the input text, the first predicted text characters and the text label characters having the corresponding relationship having a same order position in a respective semantic order.

2. The method of claim 1, wherein, The method further comprises: obtaining a vocabulary table, the vocabulary table comprising a plurality of base characters and a vocabulary index corresponding to each base character, each base character having the preset length; The predicting, according to the training text sample, by an initial text detection model to obtain a first predicted text comprises: segmenting the training text sample based on the preset length to obtain a plurality of training text characters, each training text character having the preset length, and the plurality of training text characters having the semantic order; looking up, according to the vocabulary table, a vocabulary index corresponding to each training text character; predicting, according to the vocabulary index corresponding to each training text character, by the initial text detection model to obtain the first predicted text.

3. The method of claim 2, wherein, If the training text sample is Chinese and the preset length is 1 character, the method further comprises: obtaining a historical vocabulary table comprising a plurality of segmented words, the plurality of segmented words comprising segmented words having different lengths; if the length of the segmented word is greater than the preset length, deleting the segmented word having a length greater than the preset length from the historical vocabulary table to obtain the vocabulary table.

4. The method according to any one of claims 1 to 3, wherein, The method further comprises: obtaining a general text sample, the general text sample comprising a plurality of general text characters each having the preset length and the semantic order; predicting, according to the general text sample, by a base text detection model to obtain a second predicted text, the second predicted text comprising a plurality of second predicted text characters each having the preset length and the semantic order; adjusting model parameters of the base text detection model according to a difference between the second predicted text characters and the general text characters having a corresponding relationship, to obtain the initial text detection model, the second predicted text characters and the general text characters having the corresponding relationship having a same order position in a respective semantic order.

5. The method according to any one of claims 1 to 4, wherein, If the training text sample is Chinese and the preset length is less than a first length threshold, a difference between a pinyin of a target training text character included in the training text sample and a pinyin of a target text label character included in the text label is less than a pinyin threshold, the target text label character is one of a plurality of text label characters included in the text label, and the target training text character corresponds to the target text label character.

6. The method of claim 5, wherein, The method further includes: obtaining a keyboard type used to input the training text sample; determining the pinyin threshold according to the keyboard type.

7. The method according to any one of claims 1 to 6, wherein, The method further includes: obtaining a to-be-detected text, the to-be-detected text including a plurality of to-be-detected text characters each having the preset length and having the semantic order; performing prediction on the to-be-detected text by using the text detection model to obtain a third predicted text, the third predicted text including a plurality of third predicted text characters each having the preset length and having the semantic order; if the third predicted text character having the corresponding relationship and the to-be-detected text character are different, sending a prompt that the to-be-detected text has an incorrect expression, the third predicted text character having the corresponding relationship and the to-be-detected text character having the same order in the semantic order to which they respectively belong.

8. The method of claim 7, wherein, The method further includes: in a character input process, if it is detected that the i-th character meets a preset condition, determining a character obtained after the (i-1)-th character meets the preset condition as the to-be-detected text, i being a positive integer.

9. The method of claim 7 or 8, wherein, The if the third predicted text character having the corresponding relationship and the to-be-detected text character are different, sending a prompt that the to-be-detected text has an incorrect expression includes: if the third predicted text character having the corresponding relationship and the to-be-detected text character are different, determining a word including a target third predicted text character from the third predicted text and a word including a target to-be-detected text character from the to-be-detected text, the target third predicted text character and the target to-be-detected text character having the same order in the semantic order to which they respectively belong, and the target third predicted text character being different from the target to-be-detected text character; displaying the prompt, the prompt being the word including the target third predicted text character and the word including the target to-be-detected text character.

10. The method of claim 9, wherein, The method further includes: in response to a trigger operation on the prompt, replacing the target to-be-detected text character with the target third predicted text character in the to-be-detected text to obtain an updated text.

11. The method according to any one of claims 1 to 10, wherein, If the training text sample is Chinese, the preset length is less than a first length threshold, and if the training text sample is English, the preset length is less than a second length threshold, the first length threshold being less than the second length threshold.

12. A text detection method performed by a computer device, the method comprising: in response to a text input operation, displaying a to-be-detected text corresponding to the text input operation; if it is detected that the to-be-detected text has an incorrect expression, displaying the incorrect expression and a correct expression corresponding to the incorrect expression; In response to a trigger operation for the correct expression, the error expression is replaced by the correct expression to obtain updated text; The updated text is displayed.

13. The method of claim 12, wherein, If the target third predicted text character and the target to-be-detected text character have a corresponding relationship, it is detected that the to-be-detected text has an error expression, wherein the error expression is a word segmentation including the target to-be-detected text character, and the correct expression is a word segmentation including the target third predicted text character, the target third predicted text character is one of the third predicted text characters included in the third predicted text, and the target to-be-detected text character is one of the to-be-detected text characters included in the to-be-detected text. The device comprises an acquisition unit, a prediction unit, and an adjustment unit; The acquisition unit is configured to acquire a training text sample with a text label, the text label being a correct expression text corresponding to the training text sample, and the text label comprising a plurality of text label characters having a preset length and a semantic order; 14. An apparatus for training a text detection model, wherein, The prediction unit is configured to predict a first predicted text by using an initial text detection model according to the training text sample, the first predicted text comprising a plurality of first predicted text characters having the preset length and the semantic order; The adjustment unit is configured to adjust model parameters of the initial text detection model according to differences between the first predicted text characters and the text label characters having a corresponding relationship, to obtain a text detection model, the text detection model being used for correcting input text to output a correct expression text corresponding to the input text, and the first predicted text characters and the text label characters having the corresponding relationship having consistent ordering positions in the respective semantic orders. The device comprises a display unit and a replacement unit; The display unit is configured to display a to-be-detected text corresponding to a text input operation in response to the text input operation; 15. A text detection apparatus, wherein, The display unit is further configured to display an error expression and a correct expression corresponding to the error expression if it is detected that the to-be-detected text has the error expression; The replacement unit is configured to replace the error expression by the correct expression to obtain updated text in response to a trigger operation for the correct expression; The display unit is further configured to display the updated text. The computer device comprises a processor and a memory: The memory is configured to store a computer program and transmit the computer program to the processor; 16. A computer device, wherein, ​ ​ The processor is configured to execute the method of any one of claims 1-11 or the method of claim 12 or 13.

17. A computer readable storage medium, wherein, The computer readable storage medium is configured to store a computer program configured to execute the method of any one of claims 1-11 or the method of claim 12 or 13.

18. A computer program product comprising a computer program, wherein, When it is run on a computer device, it causes the computer device to execute the method of any one of claims 1-11 or the method of claim 12 or 13.

Citation Information

Patent Citations

  • Chinese spelling error correction method, system and equipment and storage medium

    CN114386371A

  • End-to-end Chinese speech text error correction method and device and storage medium

    CN114444479A

  • Text error correction method and device, electronic equipment and storage medium

    CN115270769A

  • Chinese spelling error correction method and device based on comparative learning and medium

    CN116127953A

  • Phonetic-meaning fused Chinese grammar sequence editing error correction method, system, medium and equipment

    CN116611427A