Text processing method, electronic device and related device based on artificial intelligence
Through text processing methods based on artificial intelligence, including data cleaning, error correction and quality prediction, the problem of low original text quality in natural language processing is solved, the smoothness and standardization of the text are improved, and high-quality text output is ensured.
Patent Information
- Application Number
- CN202410833162.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-06-26
AI Technical Summary
In natural language processing, massive unprocessed original text causes the model to be unable to accurately learn key semantic information, reducing the smoothness and standardization of the text.
Text processing methods based on artificial intelligence are adopted, including data cleaning, text error correction and quality prediction processing. By obtaining the original text for data cleaning and error correction processing, the quality information of the error-corrected text is obtained, and the target text is screened out based on the quality information.
It improves the smoothness and standardization of the text, ensures that the quality of the filtered target text is higher, and retains smooth and standard text information.
Smart Images

Figure CN118378618B
Abstract
Description
Technical Field
[0001] The present application relates to artificial intelligence technology, and in particular to an artificial intelligence-based text processing method, electronic device and related devices. Background Art
[0002] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.
[0003] Natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can enable effective communication between people and computers using natural language. Natural language processing involves natural language, which is the language people use in daily life and is closely related to linguistic research; it also involves important technologies for model training in the fields of computer science, mathematics, and artificial intelligence. The pre-trained model is developed from the Large Language Model in the field of NLP. After fine-tuning, the large language model can be widely used in downstream tasks. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graphs and other technologies.
[0004] The natural language processing process requires processing massive amounts of unprocessed raw text. When performing text correction tasks, due to the large amount of noise in the text, the model is unable to accurately learn the key semantic information in the text, reducing the fluency and standardization of the text. Summary of the invention
[0005] The embodiments of the present application provide a text processing method, electronic device and related apparatus based on artificial intelligence, which can improve the fluency and standardization of text.
[0006] The technical solution of the embodiment of the present application is implemented as follows:
[0007] The present application provides an artificial intelligence-based text processing method, the method comprising:
[0008] Acquire the original text, and perform data cleaning on the original text to obtain a cleaned text;
[0009] Performing text error correction processing on the cleaned text to obtain an error-corrected text;
[0010] Performing quality prediction processing on the error correction text to obtain quality information of the error correction text;
[0011] Based on the quality information, a target text is selected from the plurality of error correction texts.
[0012] The embodiment of the present application provides a text processing device based on artificial intelligence, comprising:
[0013] A data cleaning module is used to obtain the original text and perform data cleaning on the original text to obtain a cleaned text;
[0014] An error correction module, used for performing text error correction processing on the cleaned text to obtain an error-corrected text;
[0015] A quality prediction module, used to perform quality prediction processing on the error correction text to obtain quality information of the error correction text;
[0016] A screening module is used to screen out a target text from the plurality of error correction texts based on the quality information.
[0017] An embodiment of the present application provides an electronic device, including:
[0018] A memory for storing computer executable instructions;
[0019] The processor is used to implement the artificial intelligence-based text processing method provided in the embodiment of the present application when executing the computer-executable instructions stored in the memory.
[0020] An embodiment of the present application provides a computer-readable storage medium storing a computer program or computer-executable instructions for implementing an artificial intelligence-based text processing method provided in an embodiment of the present application when executed by a processor.
[0021] An embodiment of the present application provides a computer program product, including a computer program or computer executable instructions. When the computer program or computer executable instructions are executed by a processor, the artificial intelligence-based text processing method provided in the embodiment of the present application is implemented.
[0022] The embodiments of the present application have the following beneficial effects:
[0023] The original text is processed for data cleaning to obtain a cleaned text. Thus, by performing data cleaning on the original text, the text standardization of the cleaned text is improved; the cleaned text is processed for text error correction to obtain a corrected text. Thus, by correcting the cleaned text, the text fluency and text standardization of the cleaned text are improved; the corrected text is processed for quality prediction to obtain quality information of the corrected text. Based on the quality information, a target text is screened out from multiple corrected texts. Thus, a target text with higher quality is further screened out to retain a fluent and standardized target text. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 It is a schematic diagram of the architecture of an artificial intelligence-based text processing system provided in an embodiment of the present application;
[0025] Figure 2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0026] Figure 3A This is a first flow chart of the text processing method based on artificial intelligence provided in an embodiment of the present application;
[0027] Figure 3B 1 is a second flow chart of the text processing method based on artificial intelligence provided in an embodiment of the present application;
[0028] Figure 3C is a third flow chart of the text processing method based on artificial intelligence provided in an embodiment of the present application;
[0029] Figure 3D is a fourth flow chart of the text processing method based on artificial intelligence provided in an embodiment of the present application;
[0030] Figure 3E 5 is a schematic diagram of a fifth flow chart of a text processing method based on artificial intelligence provided in an embodiment of the present application;
[0031] Figure 4 It is a principle diagram of quality inspection and processing for unsupervised text provided in an embodiment of the present application;
[0032] Figure 5 is a schematic diagram of emoticons provided in an embodiment of the present application;
[0033] Figure 6 It is a schematic diagram of error correction provided by an embodiment of the present application;
[0034] Figure 7 is a quality scoring schematic diagram provided in an embodiment of the present application;
[0035] Figure 8 It is a schematic diagram of the question-answering system provided in an embodiment of the present application.
[0036] It should be pointed out that the above-mentioned "first" and "second" are only used to distinguish different solutions, and do not represent the degree of superiority or inferiority of the solutions or the priority in the implementation process. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0038] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0039] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0040] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories), or a combination thereof. Similarly, a 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 part of an overall module or unit that includes the function of the module or unit.
[0041] The relevant data collection and processing in the embodiments of this application should be strictly in accordance with the requirements of relevant national laws and regulations when applied in examples, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of authorization of laws and regulations and the personal information subject.
[0042] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meanings as those commonly understood by those skilled in the art. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0043] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0044] 1) Prompt word construction is to generate effective prompt words based on the input text (such as cleaned text or error correction text) to instruct the language model to generate a specific type of output. The prompt words are used to instruct the language model to perform a specified task based on the input text, and the input text is used to describe the specified task of the language model.
[0045] 2) A prompt word template is used to construct a prompt word based on the input text. The prompt word template includes a replacement text to be replaced by the input text. The replacement text in the prompt word template is replaced with the input text to obtain the prompt word.
[0046] 3) Attention processing is used to instruct the neural network model to focus on important parts when processing information, dynamically determine which parts of the information are more important, identify and focus on the most informative text, so as to facilitate feature comparison based on the features after attention processing.
[0047] 4) Language model, also known as cornerstone model or language big model, refers to a deep neural network (DNN) with large parameters. It is trained on massive unlabeled data. The function approximation ability of large-parameter DNN is used to enable PTM to extract common features from the data. After fine tuning, parameter efficient fine tuning (PEFT), prompt-tuning and other technologies, it is suitable for downstream tasks.
[0048] 5) Machine Learning (ML) is a multi-disciplinary interdisciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning by teaching. The pre-trained model is the latest development of deep learning, which integrates the above technologies.
[0049] The solution provided in the embodiments of the present application involves technologies such as artificial intelligence natural language processing, which is specifically described by the following embodiments:
[0050] In the related art, since a large amount of original text is not processed, the model cannot accurately learn the key semantic information in the text, thereby reducing the fluency and standardization of the text during the text correction process. To address the above problems, the embodiments of the present application provide a text processing method, device, electronic device, computer-readable storage medium and computer program product based on artificial intelligence to improve the fluency and standardization of the text.
[0051] The artificial intelligence-based text processing method recorded in the embodiments of the present application can be applied to various fields, such as automobile promotion, intelligent question and answer and multiple other fields. That is, the artificial intelligence-based text processing method in the embodiments of the present application is not limited to a certain field.
[0052] The following describes an exemplary application of the electronic device provided in the embodiment of the present application. The device provided in the embodiment of the present application can be implemented as a terminal or a server. The following describes an exemplary application when the device is implemented as a server.
[0053] See also Figure 1 , Figure 1 It is a schematic diagram of the architecture of an artificial intelligence-based text processing system 100 provided in an embodiment of the present application. To support an artificial intelligence-based text processing application, a terminal (terminal 400 is shown as an example) is connected to a server 200 via a network 300. The network 300 may be a wide area network or a local area network, or a combination of the two.
[0054] Terminal 400 is used to send the original text to server 200 via network 300. Server 200 is used to perform data cleaning on the original text to obtain a cleaned text, perform text error correction on the cleaned text to obtain a corrected text, perform quality prediction on the corrected text to obtain quality information of the corrected text, and based on the quality information, filter out a target text from multiple corrected texts, and return the target text to terminal 400. Terminal 400 displays the target text through a graphical interface 410.
[0055] An example of terminal 400 performing text processing based on artificial intelligence is described below.
[0056] In some embodiments, terminal 400 can independently complete text processing tasks based on artificial intelligence. For example, terminal 400 is used to obtain original text, and perform data cleaning on the original text to obtain cleaned text, perform text error correction on the cleaned text to obtain corrected text, perform quality prediction on the corrected text to obtain quality information of the corrected text, and based on the quality information, filter out target text from multiple corrected texts, and display the target text through graphical interface 410.
[0057] In one implementation scenario, the server or terminal can perform artificial intelligence-based text processing on the promotion field, first obtain the original promotion text, and perform data cleaning processing on the original promotion text to obtain the cleaned promotion text, perform promotion text error correction processing on the cleaned promotion text to obtain the corrected promotion text, perform quality prediction processing on the corrected promotion text to obtain quality information of the corrected promotion text, and based on the quality information, screen out a target promotion text from multiple corrected promotion texts, and send the target promotion text to the user terminal so that the user can respond based on the target promotion text.
[0058] In one implementation scenario, a server or terminal may perform artificial intelligence-based text processing in the field of intelligent question and answering, and in response to an inquiry request, obtain original reply texts from multiple web pages based on the inquiry question, perform data cleaning processing on the original reply texts to obtain cleaned reply texts, perform reply text error correction processing on the cleaned reply texts to obtain corrected reply texts, perform quality prediction processing on the corrected reply texts to obtain quality information of the corrected reply texts, and based on the quality information, screen out a target reply text from multiple corrected reply texts, and send the target reply text to the user terminal as an answer to the inquiry question.
[0059] In some embodiments, server 200 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0060] The terminal 400 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, an intelligent voice interaction device, a smart home appliance, a vehicle terminal, an aircraft, etc., but is not limited thereto. The terminal and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present application.
[0061] The embodiments of the present application can also be implemented through cloud technology. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model application. It can form a resource pool, which can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The background services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the rapid development and application of the Internet industry, as well as the promotion of search services, social networks, mobile commerce and open collaboration, in the future, each item may have its own hash code identification mark, which needs to be transmitted to the background system for logical processing. Data of different levels will be processed separately, and all kinds of industry data require strong system backing support, which can only be achieved through cloud computing.
[0062] The embodiments of the present application can be implemented through artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that the machines have the functions of perception, reasoning and decision-making.
[0063] See also Figure 2 , Figure 2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, Figure 2 The electronic device 500 shown may be Figure 1 In the terminal 400 or server 200, the electronic device 500 includes: at least one processor 510, a memory 550, and at least one network interface 520. The various components in the server 200 are coupled together through a bus system 540. It can be understood that the bus system 540 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 540 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in Figure 2 Various buses are labeled as bus system 540 .
[0064] The processor 510 may be an integrated circuit chip having signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., wherein the general-purpose processor may be a microprocessor or any conventional processor, etc.
[0065] The user interface 530 includes one or more output devices 531 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 530 also includes one or more input devices 532, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls;
[0066] In some embodiments, when the terminal 400 independently completes the artificial intelligence-based text processing task, the server 200 provided in the embodiment of the present application does not include the user interface 530 .
[0067] The memory 550 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, a hard disk drive, an optical disk drive, etc. The memory 550 may optionally include one or more storage devices that are physically located away from the processor 510.
[0068] The memory 550 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 550 described in the embodiment of the present application is intended to include any suitable type of memory.
[0069] In some embodiments, the memory 550 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.
[0070] Operating system 551, including system programs for processing various basic system services and performing hardware-related tasks, such as framework layer, core library layer, driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0071] A network communication module 552, used to reach other computing devices via one or more (wired or wireless) network interfaces 520, exemplary network interfaces 520 include: Bluetooth, Wireless Compatibility Certification (WiFi), and Universal Serial Bus (USB), etc.;
[0072] a presentation module 553 for enabling presentation of information via one or more output devices 531 (e.g., display screen, speaker, etc.) associated with the user interface 530 (e.g., a user interface for operating peripheral devices and displaying content and information);
[0073] In some embodiments, when the text processing task is performed independently by the terminal 400, the server 200 provided in the embodiment of the present application may not include the presentation module 553.
[0074] The input processing module 554 is used to detect one or more user inputs or interactions from one of the one or more input devices 532 and translate the detected inputs or interactions; in some embodiments, when the embodiment performs text processing tasks independently by the terminal 400, the server 200 provided in the embodiment of the present application may not include the presentation module 553.
[0075] In some embodiments, the device provided in the embodiments of the present application can be implemented in software. Figure 2 The text processing device 555 based on artificial intelligence stored in the memory 550 is shown, which can be software in the form of programs and plug-ins, etc., including the following software modules: data cleaning module 5551, error correction module 5552, quality prediction module 5553 and screening module 5554. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be explained below.
[0076] In other embodiments, the device provided in the embodiments of the present application can be implemented in hardware. As an example, the device provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the artificial intelligence-based text processing method provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application-specific integrated circuits (Application Specific Integrated Circuit, ASIC), digital signal processors (Digital Signal Processor, DSP), programmable logic devices (Programmable Logic Device, PLD), complex programmable logic devices (Complex Programmable Logic Device, CPLD), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other electronic components.
[0077] It should be noted that in the examples of artificial intelligence-based text processing below, those skilled in the art can apply the artificial intelligence-based text processing method provided in the embodiments of the present application to text processing in multiple fields based on their understanding of the following text.
[0078] See also Figure 3A , Figure 3A is a first flow chart of the text processing method based on artificial intelligence provided by the embodiment of the present application, which will be combined with Figure 3A The steps shown are used to illustrate that the artificial intelligence-based text processing method provided in the embodiment of the present application can be implemented by a server or a terminal alone, or by a server and a terminal in collaboration. The collaborative implementation by a server and a terminal will be used as an example for illustration below.
[0079] In step 101, the original text is obtained, and data cleaning processing is performed on the original text to obtain a cleaned text.
[0080] Here, the original text is an unprocessed text. The embodiment of the present application does not limit the source of the original text. The original text can be obtained from a variety of channels such as web pages and documents.
[0081] In some embodiments, see Figure 3B , Figure 3B is a second flow chart of the text processing method based on artificial intelligence provided in the embodiment of the present application, for Figure 3A In step 101, the original text is cleaned to obtain a cleaned text, which can be obtained by Figure 3B Steps 1011 to 1012 are implemented as described in detail below.
[0082] In step 1011, the original text is cleaned according to rules to obtain a regular text.
[0083] It should be noted that the embodiments of the present application do not limit the specific method of rule cleaning, and rule cleaning can be deleting, replacing, etc. characters in the original text.
[0084] In some embodiments, step 1011 can be implemented in the following manner: perform word segmentation processing on the original text to obtain multiple word segments of the original text; determine at least one text to be replaced from the multiple word segments, and determine the replacement text for each text to be replaced; replace the text to be replaced in the original text with the replacement text to obtain a regular text.
[0085] Continuing with the above-mentioned embodiment, determining at least one text to be replaced from a plurality of word segments can be achieved by at least one of the following ways: when the word segment is an emoticon, the word segment is used as the text to be replaced, and the empty character is used as the replacement text of the text to be replaced; when the word segment is a traditional Chinese character, the word segment is used as the text to be replaced, and the simplified Chinese character corresponding to the traditional Chinese character is used as the replacement text of the text to be replaced; when the word segment is a keyword group, the word segment is used as the text to be replaced, and the empty character is used as the replacement text of the text to be replaced; when the word segment is a symbol related to Hypertext Markup Language, the word segment is used as the text to be replaced, and the empty character is used as the replacement text of the text to be replaced.
[0086] In step 1012, cleaned texts are screened out from a plurality of regular texts.
[0087] For example, the cleaned text (such as rule text A) is filtered out from multiple rule texts (such as rule text A "bringing generous discounts to the majority of users" and rule text B "giving back to users").
[0088] In some embodiments, step 1012 can be implemented by performing at least one of the following processes: when the number of characters in the rule text is greater than a quantity threshold, the rule text is determined as a cleansing text; when the ratio of the number of target language characters in the rule text to the number of characters in the rule text is greater than a first ratio threshold, the rule text is determined as a cleansing text; when the first similarity between the characters in the rule text and the sensitive characters is less than a similarity threshold, the rule text is determined as a cleansing text; when the ratio of the number of repeated characters in the rule text to the number of characters in the rule text is less than a second ratio threshold, the rule text is determined as a cleansing text.
[0089] The second ratio threshold value may be the same as or different from the first ratio threshold value.
[0090] Here, the present application does not impose any restrictions on the quantity threshold, which may be an average value of the number of characters in multiple rule text samples or a preset number of characters, wherein the rule text samples are obtained by screening historical rule texts; the present application embodiment does not impose any restrictions on the target language characters, which may be Chinese characters, English characters, etc.; sensitive characters are preset special characters, and the present application embodiment does not impose any restrictions on the selection of sensitive characters, which may be characters that cause security risks in the rule text, ambiguous characters, etc.
[0091] In some embodiments, when the number of characters (such as 39) in a rule text (such as "When the automobile system believes that the vehicle is at risk of being stolen, the steering wheel will be locked") is greater than a quantity threshold (such as 30), the rule text is determined to be a cleansed text; when the ratio (such as 0.98) of the number of target language characters in the rule text (such as 38 Chinese characters) to the number of characters in the rule text (such as 39) is greater than a first ratio threshold (such as 0.6), the rule text is determined to be a cleansed text; when the first similarity (such as 0.3) between the characters in the rule text and the sensitive characters is less than a similarity threshold (such as 0.6), the rule text is determined to be a cleansed text; when the ratio (such as 0) of the number of repeated characters in the rule text (such as 0) to the number of characters in the rule text (such as 39) is less than a second ratio threshold (such as 0.4), the rule text is determined to be a cleansed text.
[0092] Through the embodiments of the present application, data cleaning is performed on the original text, so that the model can learn rich semantic information from the cleaned data, so that the language model can be more effectively applied to downstream tasks.
[0093] Continue to see Figure 3A In step 102, the cleaned text is subjected to text error correction processing to obtain an error-corrected text.
[0094] In some embodiments, see Figure 3C , Figure 3C is a third flow chart of the text processing method based on artificial intelligence provided in the embodiment of the present application, for Figure 3A Step 102 shown can be performed by Figure 3C Steps 1021 to 1022 are implemented as described in detail below.
[0095] In step 1021, a first prompt word template is obtained, and based on the first prompt word template, prompt word construction processing is performed on the cleaned text to obtain error correction prompt words.
[0096] The first prompt word template is a structure used to guide the language model to generate text. The first prompt word template includes keywords (such as subject, purpose) that can be used as prompts so that the language model understands the expected output content and style, thereby instructing the language model to perform text correction tasks based on the cleaned text.
[0097] In some embodiments, the prompt word construction process for the cleaned text may be implemented in the following manner: obtaining a replacement text of the first prompt word template, replacing the replacement text in the first prompt word template with the cleaned text, and obtaining an error correction prompt word.
[0098] For example, the cleaned text is "What should I do if the car steering wheel is locked? The reason why the steering wheel is locked is that we turned the steering pin to change the dial when we pulled out the key, which caused the car's active anti-theft safety system to respond in an emergency", and the first prompt word template is "You are a large language model data expert. Please correct the typos, grammar and other problems in the following text, and be faithful to the original text while ensuring fluency. Text content: text", and replace the replacement text (such as "text") in the first prompt word template with the cleaned text to obtain the error correction prompt word (such as "You are a large language model data expert. Please correct the typos, grammar and other problems in the following text, and be faithful to the original text while ensuring fluency. Text content: What should I do if the car steering wheel is locked? The reason why the steering wheel is locked is that we turned the steering pin to change the dial when we pulled out the key, which caused the car's active anti-theft safety system to respond in an emergency").
[0099] In step 1022, text generation is performed on the error correction prompt word using the first language model to obtain an error correction text.
[0100] Here, the first language model is used to generate text for a given text sequence, thereby obtaining a new text sequence. The embodiment of the present application does not limit the specific selection of the first language model. The first language model can be a deep bidirectional pre-trained language model, a large-scale language model, etc.
[0101] In some embodiments, see Figure 3D , Figure 3D is a fourth flow chart of the text processing method based on artificial intelligence provided by the embodiment of the present application. In step Figure 3C Before the 1022 shown, execute Figure 3D Steps 201 to 203 are described in detail below.
[0102] In step 201, a first language model to be trained and error correction prompt word samples are obtained.
[0103] Here, the first language model to be trained refers to a language model for processing natural language text, which is usually used for tasks such as text generation, text translation, and text error correction. The first language model can receive input including error correction prompt word samples and generate corresponding error correction text samples.
[0104] In step 202, text generation is performed on the error correction prompt word sample using the first language model to be trained to obtain a normalized feature sample.
[0105] In some embodiments, text generation is performed on error correction prompt word samples through the first language model to be trained to obtain normalized feature samples, which can be achieved in the following way: based on the first encoding layer, encoding processing is performed on the error correction prompt word samples to obtain error correction feature samples; based on the first attention layer, attention processing is performed on the error correction feature samples to obtain first attention feature samples; based on the first normalization layer, the first attention feature samples are normalized to obtain normalized feature samples.
[0106] For example, based on the first encoding layer, the error correction prompt word sample (such as "steering wheel") is encoded to obtain an error correction feature sample (such as [0.8, 0.5, 0.9]); based on the first attention layer, the error correction feature sample is attention processed to obtain a first attention feature sample (such as [0.71, 0.54, 0.62]); based on the first normalization layer, the first attention feature sample is normalized to obtain a normalized feature sample (such as [1, 0, 0.67]).
[0107] In step 203, a first loss function is constructed based on the normalized feature samples, and the parameters of the first language model to be trained are updated until the first loss function converges, and the updated parameters of the first language model to be trained when the first loss function converges are used as the parameters of the first language model.
[0108] In some embodiments, back propagation is performed on the first language model to be trained based on the first loss function, wherein the back propagation processing is implemented by a back propagation algorithm, the gradient of the first loss function with respect to the parameters in the first language model to be trained is calculated by the derivative chain rule, the parameters in the first language model to be trained are updated based on the gradient, the parameters of the first language model to be trained are updated until the first loss function gradually converges, and the updated parameters of the first language model to be trained when the first loss function converges are determined as the parameters of the first language model.
[0109] In some embodiments, constructing the first loss function based on the normalized feature sample in step 203 can be achieved in the following way: decoding the normalized feature sample to obtain an error correction prediction sample, and determining the first loss function based on the second similarity between the label text of the error correction prompt word sample and the error correction prediction sample.
[0110] It should be noted that the present application does not limit the method for obtaining the second similarity. The similarity can be obtained by cosine similarity or edit distance, etc., wherein the edit distance is used to characterize the minimum number of editing operations required to convert one string into another, and the editing operations include inserting, deleting, and replacing characters.
[0111] Following the above embodiment, based on the first decoding layer of the first language model to be trained, the normalized features are decoded to obtain error correction prediction samples. Taking the second similarity as the edit distance as an example, the edit distance (such as 5) between the label text of the error correction prompt word sample and the error correction prediction sample is determined, and the inverse of the edit distance is determined as the first loss function.
[0112] For example, given the label text of the error correction prompt word sample (such as "apple is a kind of fruit") and the error correction prediction sample (such as "apple is a kind of fruit"), since converting the error correction prediction sample into a transition text only requires one replacement operation (such as replacing "apple" with "apple"), the edit distance between the label text of the error correction prompt word sample and the error correction prediction sample is obtained (such as 1), and the inverse of the edit distance (such as 1) is determined as the first loss function.
[0113] In some embodiments, constructing the first loss function based on the normalized feature sample in step 203 can be achieved by mapping the label text of the error correction prompt word sample to obtain the label feature, and determining the first loss function based on the third similarity between the label feature and the normalized feature sample.
[0114] It should be noted that the present application does not limit the method for obtaining the third similarity, and the method for obtaining the similarity may be cosine similarity or edit distance, etc.
[0115] Continuing from the above embodiment, mapping the label text of the error correction prompt word sample can be achieved in the following way: using a word embedding model, mapping the label text (such as "error") to a label feature of a fixed length (such as [0.1, 0.2, 0.3, 0.4, 0.5]), wherein the word embedding model is used to map discrete text to a continuous vector space, and taking the third similarity as cosine similarity as an example to illustrate, determining the cosine similarity (such as 0.6) between the label feature and the normalized feature sample, and determining the difference (such as 0.4) between the preset value (such as 1) and the cosine similarity (such as 0.6) as the first loss function.
[0116] It should be noted that the first language model includes a first encoding layer, a first attention layer, a first normalization layer and a first decoding layer.
[0117] In some embodiments, step 1022 can be implemented in the following ways: based on the first encoding layer, encoding the error correction prompt word to obtain the error correction feature; based on the first attention layer, attention processing is performed on the error correction feature to obtain the first attention feature; based on the first normalization layer, the first attention feature is normalized to obtain the first normalized feature; based on the first decoding layer, the first normalized feature is decoded to obtain the error correction text.
[0118] For example, based on the first encoding layer, the error correction prompt word (such as "direction judgment") is encoded to obtain the error correction feature (such as [0.8, 0.5, 0.9]); based on the first attention layer, the error correction feature is attention processed to obtain the first attention feature (such as [0.71, 0.54, 0.62]); based on the first normalization layer, the first attention feature is normalized to obtain the first normalized feature (such as [1, 0, 0.67]); based on the first decoding layer, the first normalized feature is decoded to obtain the error correction text (such as "steering wheel").
[0119] Continuing from the above embodiment, based on the first coding layer, encoding the error correction prompt words to obtain the error correction features can be achieved in the following ways: segmenting the error correction prompt words to obtain multiple first segmentations; encoding the multiple first segmentations to obtain first segmentation coding features; encoding the positions of the multiple first segmentations to obtain first position coding features; fusing the first segmentation coding features and the first position coding features to obtain the error correction features.
[0120] Continuing from the above embodiment, encoding multiple first participles to obtain first participle coding features can be achieved in the following manner: determining the occurrence probability of each first participle, dividing the error correction prompt words into multiple first participles based on the occurrence probability, encoding each first participle to obtain the coding feature of each first participle, and combining the coding features of each first participle to obtain the first participle coding feature.
[0121] For example, the probability of occurrence of the first participle "direction" is 0.2, and the probability of occurrence of the first participle "steering wheel" is 0.1. Based on the occurrence probability, the error correction prompt word (such as "steering wheel") is divided into multiple first participles (such as "direction" and "wheel"), and each first participle is encoded to obtain the encoding feature of each first participle (such as the encoding feature of "direction" is 0.2, and the encoding feature of "wheel" is 0.3). The encoding features of each first participle are combined to obtain the first participle encoding feature (such as [0.2, 0.3]), and the position of each first participle is encoded to obtain a first position encoding feature of length k (such as k=2). For the participle "direction", its position is 1, and the corresponding position encoding feature is [sin (1 / 10000), cos (1 / 10000)]. For the participle "wheel", its position is 2, and the corresponding position encoding feature is [sin (2 / 10000), cos (2 / 10000)].
[0122] Continuing from the above embodiment, taking a multi-head self-attention network as an example, based on the first attention layer, attention processing is performed on the error correction feature, and obtaining the first attention feature can be achieved in the following way: encoding the error correction feature to obtain a first query feature, a first key feature, and a first value feature, determining the similarity matrix of the first attention feature based on the first query feature and the first key feature, and determining the product of the similarity matrix of the first attention feature and the first value feature as the first attention feature.
[0123] For example, the error correction feature is encoded to obtain a first query feature, a first key feature, and a first value feature (such as [0.8, 0.5, 0.9]), and the similarity matrix of the first attention feature is determined based on the first query feature and the first key feature (such as [[0.7 0.3], [0.2 0.8], [0.6 0.4]]), and the product of the similarity matrix of the first attention feature and the first value feature is determined as the first attention feature (such as [0.71, 0.54, 0.62]).
[0124] Continuing from the above embodiment, the first attention feature is normalized based on the first normalization layer, and obtaining the first normalized feature can be achieved in the following way: determining the mean and standard deviation of the first attention feature, and determining the ratio of the difference between the first attention feature and the mean to the standard deviation as the first normalized feature.
[0125] It should be noted that the embodiments of the present application do not limit the normalization method, and the normalization methods include root mean square normalization, batch normalization, layer normalization, etc.
[0126] For example, given a first attention feature (such as [2, 4, 6, 8, 10]), the mean (such as 6) and variance (such as 8) of the first attention feature are determined, and the ratio of the difference between the first attention feature and the mean and the standard deviation is determined as the first normalized feature (such as [-0.89, -0.45, 0, 0.45, 0.89]).
[0127] Continuing with the above embodiment, taking the text correction task as an example, based on the first decoding layer, decoding the first normalized feature to obtain the error correction text can be achieved in the following way: calling the first decoding layer to decode the first normalized feature to obtain the error correction text, wherein the first decoding layer can be an end-to-end neural network structure, and the first decoding layer is used to decode the first normalized feature to obtain the error correction text, thereby converting the imperceptible encoding features into text.
[0128] Through the embodiments of the present application, the cleaned text is corrected, thereby improving the text fluency and text standardization of the cleaned text.
[0129] Continue to see Figure 3AIn step 103, quality prediction processing is performed on the error correction text to obtain quality information of the error correction text.
[0130] In some embodiments, see Figure 3E , Figure 3E is a fifth flow chart of the text processing method based on artificial intelligence provided in the embodiment of the present application, for Figure 3A Step 103 shown can be performed by Figure 3E Steps 1031 to 1032 are implemented as described in detail below.
[0131] In step 1031, a second prompt word template is obtained, and based on the second prompt word template, prompt word construction processing is performed on the error correction text to obtain quality prediction prompt words.
[0132] Here, the second prompt word template is a structure for guiding the language model to generate quality information (such as "high", "medium" or "low"). The second prompt word template includes keywords (such as topic, purpose) that can be used as prompts so that the language model understands the expected output content and style, thereby instructing the second language model to perform a quality prediction task based on the correction text.
[0133] In some embodiments, the prompt word construction process for the error correction text may be implemented in the following manner: obtaining a replacement text of the second prompt word template, replacing the replacement text in the second prompt word template with the error correction text, and obtaining a quality prediction prompt word.
[0134] For example, the error correction text is "What should I do if the car steering wheel is locked? The reason why the steering wheel is locked is that we turned the steering pin to change the dial when we pulled out the key, which caused the car's active anti-theft safety system to respond in an emergency." The second prompt word template is "You are a large language model data expert. You will judge the text quality based on the provided field-related text. The text quality is divided into three categories: low, medium, and high. Please strictly follow the given instructions to classify the quality. The following is the text content that needs to be judged: text". Replace the replacement text (such as "text") in the second prompt word template with the error correction text to obtain the quality prediction prompt word (such as "You are a large language model data expert. You will judge the text quality based on the provided field-related text. The text quality is divided into three categories: low, medium, and high. Please strictly follow the given instructions to classify the quality. The following is the text content that needs to be judged: What should I do if the car steering wheel is locked? The reason why the steering wheel is locked is that we turned the steering pin to change the dial when we pulled out the key, which caused the car's active anti-theft safety system to respond in an emergency").
[0135] In step 1032, quality prediction is performed on the quality prediction prompt words through the second language model to obtain quality information of the error correction text.
[0136] The second language model may be the same as or different from the first language model.
[0137] Here, the second language model is used to predict the quality of a given text sequence, thereby obtaining quality information of the given text sequence. The second language model in the embodiment of the present application is obtained by fine-tuning parameters on the basis of the trained first language model.
[0138] In some embodiments, the second language model is obtained by training the first language model, and the first language model is used to perform text error correction tasks. Before step 1032, the following steps are performed to train the second language model: obtain quality prediction prompt word samples, and perform quality prediction on the quality prediction prompt word samples through the first language model to obtain quality prediction information; construct a second loss function based on the quality prediction information and the label information of the quality prediction prompt word samples; update the parameters of the first language model until the second loss function converges, and use the parameters updated by the first language model when the second loss function converges as the parameters of the second language model.
[0139] Continuing from the above embodiment, quality prediction of quality prediction prompt word samples is performed through the first language model to obtain quality prediction information in the following manner: based on the second encoding layer, the quality prediction prompt word samples are encoded to obtain quality prediction feature samples; based on the second attention layer, the quality prediction feature samples are attention processed to obtain second attention feature samples; based on the second normalization layer, the second attention feature samples are normalized to obtain quality prediction normalized feature samples; based on the first decoding layer, the quality prediction normalized feature samples are decoded to obtain quality prediction information.
[0140] For example, based on the second encoding layer, the quality prediction prompt word sample (such as "steering wheel") is encoded to obtain a quality prediction feature sample (such as [0.8, 0.5, 0.9]); based on the second attention layer, the quality prediction feature sample is attention processed to obtain a second attention feature sample (such as [0.71, 0.54, 0.62]); based on the second normalization layer, the second attention feature sample is normalized to obtain a quality prediction normalized feature sample (such as [1, 0, 0.67]); based on the first decoding layer, the quality prediction normalized feature sample is decoded to obtain quality prediction information (such as "high").
[0141] Following the above embodiment, back propagation is performed on the trained first language model based on the second loss function, wherein the back propagation processing is implemented by a back propagation algorithm, the gradient of the second loss function with respect to the parameters in the first language model is calculated by the derivative chain rule, the parameters in the first language model are updated based on the gradient, the parameters of the first language model are updated until the second loss function gradually converges, and the parameters updated by the first language model when the second loss function converges are determined as the parameters of the second language model.
[0142] In some embodiments, step 1032 can be implemented in the following manner: based on the second encoding layer, encoding the quality prediction prompt word to obtain a quality prediction feature; based on the second attention layer, attention processing is performed on the quality prediction feature to obtain a second attention feature; based on the second normalization layer, the second attention feature is normalized to obtain a second normalized feature; based on the second decoding layer, the second normalized feature is decoded to obtain quality information of the error correction text, wherein the second language model includes a second encoding layer, a second attention layer, a second normalization layer and a second decoding layer.
[0143] For example, based on the second encoding layer, the quality prediction prompt word (such as "steering wheel") is encoded to obtain quality prediction features (such as [0.8, 0.5, 0.9]); based on the second attention layer, the quality prediction features are attention processed to obtain second attention features (such as [0.71, 0.54, 0.62]); based on the second normalization layer, the second attention features are normalized to obtain quality prediction normalized features (such as [1, 0, 0.67]); based on the second decoding layer, the quality prediction normalized features are decoded to obtain quality information of the error correction text (such as "high").
[0144] Continuing from the above embodiment, the step of encoding the error correction prompt word based on the second coding layer to obtain the error correction feature is similar to the step of encoding the error correction prompt word based on the first coding layer to obtain the error correction feature, and will not be repeated here.
[0145] Continuing from the above embodiment, taking the multi-head self-attention network as an example, based on the second attention layer, the quality prediction feature is subjected to attention processing, and obtaining the second attention feature can be achieved in the following way: the quality prediction feature is encoded to obtain a second query feature, a second key feature, and a second value feature, and the similarity matrix of the second attention feature is determined based on the second query feature and the second key feature, and the product of the similarity matrix of the second attention feature and the second value feature is determined as the second attention feature.
[0146] Continuing from the above embodiment, based on the second normalization layer, the second attention feature is normalized to obtain the second normalized feature, which can be achieved in the following way: determine the mean and standard deviation of the second attention feature, and determine the ratio of the difference between the second attention feature and the mean to the standard deviation as the second normalized feature.
[0147] For example, given a second attention feature (such as [2, 4, 6, 8, 10]), determine the mean (such as 6) and variance (such as 8) of the second attention feature, and determine the ratio of the difference between the second attention feature and the mean to the standard deviation as the second normalized feature (such as [-0.89, -0.45, 0, 0.45, 0.89]).
[0148] Continuing with the above embodiment, taking the quality prediction task as an example, the second decoding layer is called to decode the second normalized feature to obtain the quality information of the error-corrected text, wherein the second decoding layer can be an end-to-end neural network structure, and the second decoding layer is used to decode the second normalized feature to obtain the category corresponding to the quality of the error-corrected text (for example, high, medium or low), and convert the imperceptible coding features into the probability distribution of the quality of the error-corrected text belonging to different categories.
[0149] In some embodiments, the step of performing quality prediction on the quality prediction prompt words through the third language model to obtain quality information of the correction text is similar to the step of performing quality prediction on the quality prediction prompt words through the second language model to obtain quality information of the correction text, and will not be repeated here.
[0150] The third language model may be the same as or different from the second language model.
[0151] It should be noted that the third language model can be used for both quality prediction of quality prediction prompt words and text generation of error correction prompt words.
[0152] Following the above embodiment, the following steps are performed to train a third language model: obtaining a third language model to be trained and a prompt word sample; performing text generation on the prompt word sample by using the third language model to be trained to obtain a generated sample; constructing a third loss function based on the similarity between the generated sample and the label text; updating the parameters of the third language model to be trained until the third loss function converges, and using the updated parameters of the third language model to be trained when the third loss function converges as the parameters of the third language model.
[0153] Here, the third language model to be trained refers to a language model used to process natural language text, which is usually used for tasks such as text generation, text translation, text error correction, and quality prediction.
[0154] It should be noted that the prompt word samples include error correction prompt word samples or quality prediction prompt word samples. When the prompt word sample is an error correction prompt word sample (such as "direction judgment"), the sample label corresponding to the prompt word sample is the error correction label text corresponding to the error correction prompt word sample (such as "steering wheel"); when the prompt word sample is a quality prediction prompt word sample (such as "steering wheel"), the sample label corresponding to the prompt word sample is the quality prediction label text corresponding to the quality prediction prompt word sample (such as "high").
[0155] Following the above embodiment, obtaining prompt word samples can be achieved by the following method: constructing a sample data set based on error correction prompt word samples and quality prediction prompt word samples, and selecting some samples from the sample data set as prompt word samples.
[0156] For example, some samples (such as error correction prompt word sample C and quality prediction prompt word sample B) are randomly selected from a sample data set (such as a sample data set containing error correction prompt word sample A "You are a large language model data expert. Please correct the typos, grammar and other problems in the following text. Text content: What should I do if the car steering wheel is locked", quality prediction prompt word sample B "You are a large language model data expert. You will judge the text quality based on the provided field-related text. The following is the text content that needs to be judged: Complete the registration to receive gift certificate benefits", and error correction prompt word sample C "You are a large language model data expert. Please correct the typos, grammar and other problems in the following text. Text content: What should I do if the car doors and windows are locked") as prompt word samples.
[0157] Continuing from the above embodiment, the third language model includes a third encoding layer, a third attention layer, a third normalization layer and a third decoding layer; text generation is performed on the prompt word sample through the third language model to be trained, and the generated sample can be achieved in the following manner: based on the third encoding layer, the prompt word sample is encoded to obtain a feature sample; based on the third attention layer, the feature sample is attention processed to obtain a third attention feature sample; based on the third normalization layer, the third attention feature sample is normalized to obtain a normalized feature sample; based on the third decoding layer, the normalized feature sample is decoded to obtain the generated text.
[0158] For example, based on the third encoding layer, the prompt word sample (such as "steering wheel") is encoded to obtain a feature sample (such as [0.8, 0.5, 0.9]); based on the third attention layer, the feature sample is attention processed to obtain a third attention feature sample (such as [0.71, 0.54, 0.62]); based on the third normalization layer, the third attention feature sample is normalized to obtain a normalized feature sample (such as [1, 0, 0.67]); based on the third decoding layer, the normalized feature sample is decoded to obtain the generated text (such as "high").
[0159] Continuing from the above embodiment, based on the third encoding layer, the step of encoding the prompt word sample to obtain the feature sample is similar to the step of encoding the error correction prompt word based on the first encoding layer to obtain the error correction feature, which will not be repeated here; based on the third attention layer, the step of performing attention processing on the feature sample to obtain the third attention feature sample is similar to the step of performing attention processing on the error correction feature based on the first attention layer to obtain the first attention feature, which will not be repeated here; the step of normalizing the third attention feature sample to obtain the normalized feature sample is similar to the step of normalizing the first attention feature based on the first normalization layer to obtain the first normalized feature, which will not be repeated here; based on the third decoding layer, the step of decoding the normalized feature sample to obtain the generated text is similar to the step of decoding the first normalized feature based on the first decoding layer to obtain the error correction text, which will not be repeated here.
[0160] Continuing from the above embodiments, the embodiments of the present application do not limit the method of constructing the third loss function based on the similarity between the generated sample and the label text. The method of constructing the third loss function can be the difference (such as 0.8) between a preset value (such as 1) and the cosine similarity (such as 0.2) between the generated sample and the label text, the Jaccard similarity between the generated sample and the label text, etc.
[0161] Following the above embodiment, back propagation is performed on the third language model to be trained based on the third loss function, wherein the back propagation processing is implemented by a back propagation algorithm, and the gradient of the third loss function with respect to the parameters in the third language model to be trained is calculated by the derivative chain rule, and the parameters in the third language model to be trained are updated based on the gradient, and the parameters of the third language model to be trained are updated until the third loss function gradually converges, and the parameters updated by the third language model to be trained when the third loss function converges are determined as the parameters of the third language model.
[0162] Through the embodiments of the present application, target texts with higher quality are further screened out, and fluent and standardized target texts are retained.
[0163] Continue to see Figure 3A , in step 104, based on the quality information, the target text is screened out from the multiple error correction texts.
[0164] In some embodiments, step 104 can be implemented in the following manner: sorting multiple error correction texts based on quality information to obtain a sorting result, and determining part of the error correction texts in the sorting result as target texts, or, when the quality information is greater than a quality threshold, determining the error correction text corresponding to the quality information as the target text.
[0165] For example, when the quality information (such as 0.85) is greater than the quality threshold (such as 0.8), the correction text corresponding to the quality information (such as 0.85) is determined as the target text, or the correction text A corresponds to the quality information (such as 0.85), and the correction text B corresponds to the quality information (such as 0.8), and the correction texts are sorted in ascending order based on the quality information (such as 0.85 and 0.8) to obtain an ascending sorting result (such as [B, A]), and the latter part of the ascending sorting result (such as A) is determined as the target text, and the correction texts are sorted in descending order based on the quality information (such as 0.85 and 0.8) to obtain a descending sorting result (such as [A, B]), and the former part of the correction text (such as A) in the descending sorting result is determined as the target text.
[0166] Through the embodiments of the present application, target texts with higher quality are further screened out, and fluent and standardized target texts are retained.
[0167] Below, an exemplary application of the text processing method for unsupervised text provided in an embodiment of the present application (implemented by an artificial intelligence-based text processing method) in an actual application scenario will be described.
[0168] In related technologies, due to the massive amount of unprocessed original text, the model is unable to accurately learn the key semantic information in the text, thereby reducing the fluency and standardization of the text during the text correction process.
[0169] In order to solve the above problems, the embodiments of the present application propose a text processing method and system for unsupervised text. The solution serves the unsupervised text data processing and quality detection, and aims to produce high-quality text data. By providing high-quality text data, the training quality of the large language model in the pre-training stage is further improved.
[0170] Take the quality inspection of unsupervised text as an example, see Figure 4 , Figure 4 is a schematic diagram of quality inspection processing for unsupervised text provided in the embodiment of the present application. Figure 4 middle, Figure 4 It includes multiple modules for quality inspection and processing of unsupervised text in the embodiment of the present application, such as a normalization module 301, a screening module 302, an error correction module 303, and a scoring module 304. The multiple modules for quality inspection and processing of unsupervised text provided in the embodiment of the present application are explained below.
[0171] The normalization module 301 is used for rule cleaning of the original text. Abnormal characters, URL links, etc. in the original text are deleted through rules to obtain the text after rule cleaning (i.e., rule text), wherein the rules are selectively processed according to the actual data situation, and the implementation of each function can be quickly achieved by referring to different toolkits. The process in the normalization module 301 provided in the embodiment of the present application is explained below.
[0172] Regarding removing emojis, you can remove emojis according to the character encoding standard (unicode) range, see Figure 5 , Figure 5 is a schematic diagram of emoticons provided in the embodiment of the present application, such as Figure 5 As shown, Figure 5 The categories of emoticons in the text include expression and emotion category 401, person and body category 402, and animal and nature category 403. Figure 5 Remove emojis when you type emojis or other emojis in the text box.
[0173] Continue to see Figure 4 , remove HyperText Markup Language (HTML) related symbols, use the algorithm library (BeautifulSoup) for parsing HTML to process, use specific codes (such as "from bs4import BeautifulSoup; soup = BeautifulSoup(html, "html.parser")") to call the algorithm library for parsing HTML to remove Hypertext Markup Language related symbols.
[0174] Regarding the conversion from Traditional to Simplified, use the command line tool (zhconv) to convert from Traditional to Simplified, and use specific codes (such as "import zhconv; new-str=zhconv.convert(string, "zh-hans")") to call the algorithm library for converting between Traditional and Simplified to convert from Traditional to Simplified.
[0175] Regarding regular deletion of related keyword groups, regular expressions (RE) use specific rules or pattern syntax to perform various text processing operations such as matching, searching, and replacing. By calling code (such as "import re; matches = re.findall (match-rule, text); for match in matches: text = text.replace (str (match), replace-text)"), a specific keyword group (such as "match") in the text is replaced with a specific character (such as "replace-text", that is, replace text). Among them, regular expressions are a powerful syntax tool for matching and operating texts. It is a pattern composed of a series of characters and special characters, which is used to describe the text pattern to be matched.
[0176] The screening module 302 is used for rule filtering of texts. Invalid data is deleted by length, Chinese percentage, sensitive word filtering, repetitive filtering and other methods. The screening module 302 is used to filter texts that do not meet the quality requirements of the rules. The quality of the text can be judged by the rules, thereby retaining texts greater than the quality threshold (i.e., cleaned texts). The following is an explanation of the process in the normalization module 301 provided in the embodiment of the present application.
[0177] Regarding length screening, documents are filtered by their average line length and total text length. When the average length of a document is too low (i.e., the average length is less than the average number of characters of multiple regular text samples) or the total length is insufficient (i.e., the total length is less than the preset number of characters), the document is deleted. Among them, texts with an average length that is too low (the modifiable parameter is set to be less than 10) have an obvious characteristic of poor text coherence, while texts with insufficient total length (the modifiable parameter is set to be less than 200, i.e., the quantity threshold) have the disadvantage of insufficient text information.
[0178] Regarding the filtering of Chinese characters, if the proportion of Chinese characters (i.e., the target language characters in the rule text) is too small (the Chinese proportion can be modified to be less than 0.3, i.e., the first ratio threshold), it is not conducive to the model's Chinese knowledge learning.
[0179] Regarding sensitive word filtering, we use a sensitive word dictionary (i.e. sensitive characters) to perform discrimination and filtering, and delete sensitive knowledge.
[0180] Regarding the filtering of internal repetition in articles, since knowledge obtained through online channels often has internal repetition, the repetition here is meaningless. N-grams (i.e., consecutive N characters) are used to detect whether there are repeated N-grams (i.e., repeated characters in regular text) in a given text. Counters are used to count the number of times each N-gram appears, and the ratio of repeated N-grams to total N-grams (i.e., the number of characters in regular text) is calculated. When the ratio is greater than the threshold (i.e., the second ratio threshold), it is selected for deletion.
[0181] The error correction module 303 is used to correct spelling, grammar, punctuation and other errors to improve the fluency and standardization of the text.
[0182] Here, see Figure 6 , Figure 6 is a schematic diagram of error correction provided by an embodiment of the present application, such as Figure 6 As shown, the large model (i.e., the first language model) is used to input error correction prompts 501 (such as "You are a large language model data expert. Please correct the typos, grammar, and other issues in the following text, and be faithful to the original text while ensuring fluency. Text content: What should I do if the car steering wheel is locked? \nThe reason why the steering wheel is locked is that we turned the steering wheel when we pulled out the key, which caused the car's active anti-theft safety system to respond in an emergency"), and text correction is performed to obtain the final text output 502 (such as "What should I do if the car steering wheel is locked? The reason why the steering wheel is locked is that we turned the steering wheel when we pulled out the key, which caused the car's active anti-theft safety system to respond in an emergency", i.e., the error correction text).
[0183] The scoring module 304 scores the quality of the text (i.e., quality prediction), and retains the high-scoring text (i.e., target text) for secondary training to improve the model capability.
[0184] Here, see Figure 7 , Figure 7 is a quality scoring schematic diagram provided in the embodiment of the present application, such as Figure 7 As shown, given scoring prompt words 601 (i.e., quality prediction prompt words, such as "You are a large language model data expert, you will judge the text quality based on the provided domain-related text. The text quality is divided into three categories: low, medium, and high. Please strictly follow the given instructions to classify the quality.
[0185] 1. Knowledge-based texts in the field of automobile travel.
[0186] 2. The text is fluent and has no typos, grammatical errors or other problems.
[0187] 3. The text is authentic, safe, and unambiguous.
[0188] 4. It is beneficial to train and understand large language models.
[0189] If all the above conditions are met, the quality is high. If there are a few problems such as incoherence and typos, the quality is medium. If it does not belong to the knowledge related to the field, or the text is harmful, biased, or the text content is affected by timeliness, specific scenarios (such as: only notification without content, attachment list, etc.), etc., the quality is low. The following is the text content that needs to be judged: Activity time: XX-XX\nActivity 1: Registration gift\nActivity target: All users\nActivity content: Complete registration and you can receive gift certificate benefits\Please output in the format of "Text quality is: low / medium / high. Reason: xxxx"), use the big model to input the scoring prompt words, perform text scoring, and obtain the scoring result 602 (that is, the quality information of the error correction text, such as "Text quality is: low. Reason: Although this text belongs to the field of automobile travel and has no grammar and typos, its content is limited by specific time and activities and has expired, which is not very helpful for the training and understanding of the big language model").
[0190] The text processing method for unsupervised text provided in the embodiment of the present application can be applied to the construction of pre-training data of the Large Language Model (LLM) in the intelligent customer service scenario, wherein the Large Language Model is a natural language processing model based on deep learning, an artificial intelligence model used to process language and text (or symbol system), which can learn the grammar and semantics of natural language, so as to generate human-readable text, discover the rules therein, and automatically generate content that conforms to the rules according to prompts. Good pre-training data can help LLM to be more effective in downstream tasks. The system provided in the embodiment of the present application processes and performs quality inspection on unsupervised text data, so that the high-quality text data produced can be used for pre-training of large language models. It can also handle the import quality inspection and verification of various types of information and directly act on customer service products, process customer documents, and convert various types of text data into knowledge bases. See. Figure 8 , Figure 8 is a schematic diagram of a question-answering system provided in an embodiment of the present application, such as Figure 8 As shown, Figure 8The knowledge document / web page / information import 701 includes a source file import method 7011 for importing high-quality knowledge from knowledge documents and an import method 7012 for importing high-quality consultation from information guides. The content obtained from the web page includes web page content (such as "How to promote? Promotion is mainly to leave a deep impression on users"), web page address, title (such as "How to promote?"), prediction label (such as "culture and tourism"), prediction possibility (such as 0.8), keywords (such as "promotion, user") and key times (such as 2) and other network information. After the high-quality knowledge is imported into the knowledge base, the knowledge is verified 702 by the text processing method for unsupervised text provided in the embodiment of the present application. In the question and answer verification interface, by entering the corresponding question "What is the function of the control button" in question 7021, in response to question 7021, the answer obtained based on the text processing method for unsupervised text provided in the embodiment of the present application is displayed in the answer 7022. The answer (such as "click the button to run automatically") is generated in response to the trigger operation of the acceptance button 7023, and the clipboard is called to copy the answer 7022 to facilitate the user to paste the text. In response to the trigger operation of the rejection button 7024, the answer 7022 is regenerated based on the question 7021 and the text processing method for unsupervised text provided in the embodiment of the application. In addition, the text processing method for unsupervised text provided in the embodiment of the present application can also be used to help the question and answer system improve the answer rate. In the dialogue experience 703 of the question and answer system, the dialogue is accurately conducted based on the verified knowledge. In response to the sending operation of the user dialogue input in the text box 7033, the user dialogue 7031 is displayed in the dialogue interface, and the system dialogue 7032 is generated in the question and answer system based on the user dialogue 7031 and the text processing method for unsupervised text provided in the embodiment of the present application, so as to avoid the failure of the answer caused by the unverified knowledge, thereby improving the answer rate of the question and answer system.
[0191] The following is an explanation of the process of the text processing method for unsupervised text provided in the embodiment of the present application in combination with the above modules.
[0192] The input and output of the error correction module 303 and the scoring module 304 can be organized as data for fine-tuning training, so that the output results of the large model for these two tasks in the fine-tuning stage tend to be better. After multiple iterations, the performance of the error correction module 303 and the scoring module 304 tend to be stable, and unsupervised data can be better produced. In the training stage, the embodiment of the present application can train the error correction module 303 and the scoring module 304 respectively through LLM. In addition, the embodiment of the present application can also perform full training on the data in the error correction module 303 and the scoring module 304 through LLM, build a mixed data set based on the data in the error correction module 303 and the scoring module 304, obtain samples of the mixed data set and the corresponding labels of the samples, so that the LLM can be trained with samples of the mixed data set. In the reasoning stage, LLM is called twice in sequence to perform different tasks to obtain the quality of the error correction text.
[0193] In summary, the embodiment of the present application proposes a text processing method and system for unsupervised text, which can produce high-quality text data, improve the training quality of the large language model in the pre-training stage by providing high-quality text data, and the system can also be applied to the knowledge processing of customer service products. The processed high-quality knowledge can be stored in the knowledge base for question-answering services. The normalization module 301 and the screening module 302 provided in the embodiment of the present application select rules and adjust parameters by combining actual scene data, and denoise the text to avoid irrelevant text from affecting model reasoning, thereby improving the accuracy of text error correction. In addition, the error correction module 303 and the scoring module 304 provided in the embodiment of the present application are iterated through the ability of LLM itself. When the performance of the error correction module 303 and the scoring module 304 tends to be stable, the system can stably produce high-quality unsupervised text.
[0194] The following is a description of an exemplary structure of the text processing device 555 based on artificial intelligence provided in the present application as a software module. In some embodiments, Figure 2 As shown, the software modules stored in the artificial intelligence-based text processing device 555 of the memory 550 may include:
[0195] The data cleaning module 5551 is used to obtain the original text and perform data cleaning on the original text to obtain a cleaned text.
[0196] The error correction module 5552 is used to perform text error correction processing on the cleaned text to obtain an error-corrected text.
[0197] The quality prediction module 5553 is used to perform quality prediction processing on the error correction text to obtain quality information of the error correction text.
[0198] The screening module 5554 is used to screen out the target text from multiple error correction texts based on the quality information.
[0199] In some embodiments, the data cleaning module 5551 is also used to perform rule cleaning on the original text to obtain a rule text; and filter out the cleaned text from multiple rule texts.
[0200] In some embodiments, the data cleaning module 5551 is also used to perform word segmentation processing on the original text to obtain multiple word segments of the original text; determine at least one text to be replaced from the multiple word segments, and determine the replacement text for each text to be replaced; replace the text to be replaced in the original text with the replacement text to obtain a regular text.
[0201] In some embodiments, the data cleaning module 5551 is also used to perform at least one of the following processing: when the number of characters in the rule text is greater than a quantity threshold, the rule text is determined as a cleaned text; when the ratio of the number of target language characters in the rule text to the number of characters in the rule text is greater than a first ratio threshold, the rule text is determined as a cleaned text; when the first similarity between the characters in the rule text and the sensitive characters is less than a similarity threshold, the rule text is determined as a cleaned text; when the ratio of the number of repeated characters in the rule text to the number of characters in the rule text is less than a second ratio threshold, the rule text is determined as a cleaned text.
[0202] In some embodiments, the error correction module 5552 is further used to obtain a first prompt word template, and based on the first prompt word template, perform prompt word construction processing on the cleaned text to obtain error correction prompt words; and generate text for the error correction prompt words through the first language model to obtain error correction text.
[0203] In some embodiments, the error correction module 5552 is also used to encode the error correction prompt words based on the first encoding layer to obtain error correction features; based on the first attention layer, perform attention processing on the error correction features to obtain first attention features; based on the first normalization layer, normalize the first attention features to obtain first normalized features; based on the first decoding layer, decode the first normalized features to obtain error correction text, wherein the first language model includes a first encoding layer, a first attention layer, a first normalization layer and a first decoding layer.
[0204] In some embodiments, the error correction module 5552 is further used to obtain a first language model to be trained and error correction prompt word samples; perform text generation on the error correction prompt word samples through the first language model to be trained to obtain normalized feature samples; construct a first loss function based on the normalized feature samples, and update the parameters of the first language model to be trained until the first loss function converges, and use the updated parameters of the first language model to be trained when the first loss function converges as the parameters of the first language model.
[0205] In some embodiments, the error correction module 5552 is also used to decode the normalized feature sample to obtain the error correction prediction sample, and determine the first loss function based on the second similarity between the label text of the error correction prompt word sample and the error correction prediction sample, or to map the label text of the error correction prompt word sample to obtain the label feature, and determine the first loss function based on the third similarity between the label feature and the normalized feature sample.
[0206] In some embodiments, the quality prediction module 5553 is further used to obtain a second prompt word template, and based on the second prompt word template, perform prompt word construction processing on the correction text to obtain quality prediction prompt words; perform quality prediction on the quality prediction prompt words through the second language model to obtain quality information of the correction text.
[0207] In some embodiments, the quality prediction module 5553 is further used to encode the quality prediction prompt words based on the second encoding layer to obtain quality prediction features; based on the second attention layer, perform attention processing on the quality prediction features to obtain second attention features; based on the second normalization layer, normalize the second attention features to obtain second normalized features; based on the second decoding layer, decode the second normalized features to obtain quality information of the error-corrected text, wherein the second language model includes a second encoding layer, a second attention layer, a second normalization layer and a second decoding layer.
[0208] In some embodiments, the quality prediction module 5553 is also used to obtain quality prediction prompt word samples, and perform quality prediction on the quality prediction prompt word samples through the first language model to obtain quality prediction information; construct a second loss function based on the quality prediction information and the label information of the quality prediction prompt word samples; update the parameters of the first language model until the second loss function converges, and use the parameters updated by the first language model when the second loss function converges as the parameters of the second language model, wherein the second language model is obtained by training the first language model, and the first language model is used to perform text error correction tasks.
[0209] An embodiment of the present application provides a computer program product, which includes computer executable instructions. The computer executable instructions are stored in a computer-readable storage medium. A processor of an electronic device reads the computer executable instructions from the computer-readable storage medium, and the processor executes the computer executable instructions, so that the electronic device executes the artificial intelligence-based text processing method described above in the embodiment of the present application.
[0210] The embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions or computer programs are stored. When the computer-executable instructions or computer programs are executed by a processor, the processor will be caused to execute the artificial intelligence-based text processing method provided by the embodiment of the present application, for example, FIG. 3A to FIG. 3E The text processing method based on artificial intelligence is shown.
[0211] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or may be various devices including one or any combination of the above memories.
[0212] In some embodiments, computer executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0213] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file storing other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0214] As an example, computer executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed at multiple sites and interconnected by a communication network.
[0215] To summarize, the original text is obtained, and data cleaning processing is performed on the original text to obtain the cleaned text. In this way, the text standardization of the cleaned text is improved by performing data cleaning processing on the original text. The cleaned text is subjected to text correction processing to obtain the corrected text. In this way, the text fluency and text standardization of the cleaned text are improved by correcting the cleaned text. The corrected text is subjected to quality prediction processing to obtain quality information of the corrected text. Based on the quality information, the target text is screened out from multiple corrected texts. In this way, the target text with higher quality is further screened out, and the fluent and standardized target text is retained.
[0216] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.
Claims
1. A text processing method based on artificial intelligence, characterized in that: The method comprises: Acquire the original text, and perform data cleaning on the original text to obtain a cleaned text; Acquire a first prompt word template, and perform prompt word construction processing on the cleaned text based on the first prompt word template to obtain error correction prompt words; The following processing is performed by a first language model, wherein the first language model includes a first encoding layer, a first attention layer, a first normalization layer, and a first decoding layer: based on the first encoding layer, the error correction prompt word is encoded to obtain an error correction feature; based on the first attention layer, the error correction feature is subjected to attention processing to obtain a first attention feature; based on the first normalization layer, the first attention feature is normalized to obtain a first normalized feature; based on the first decoding layer, the first normalized feature is decoded to obtain an error correction text; Acquire a second prompt word template, and perform prompt word construction processing on the error correction text based on the second prompt word template to obtain a quality prediction prompt word; The following processing is performed by the second language model, wherein the second language model includes a second encoding layer, a second attention layer, a second normalization layer, and a second decoding layer: based on the second encoding layer, the quality prediction prompt word is encoded to obtain a quality prediction feature; based on the second attention layer, the quality prediction feature is attention processed to obtain a second attention feature; based on the second normalization layer, the second attention feature is normalized to obtain a second normalized feature; based on the second decoding layer, the second normalized feature is decoded to obtain the quality information of the error correction text; Based on the quality information, a target text is selected from the plurality of error correction texts.
2. The method according to claim 1, characterized in that: The step of performing data cleaning on the original text to obtain a cleaned text includes: Performing rule cleaning on the original text to obtain a rule text; The cleaning text is screened out from the plurality of rule texts.
3. The method according to claim 2, characterized in that The step of performing rule cleaning on the original text to obtain a rule text includes: Performing word segmentation processing on the original text to obtain multiple word segments of the original text; Determine at least one to-be-replaced text from the multiple segmented words, and determine a replacement text for each of the to-be-replaced texts; The text to be replaced in the original text is replaced with the replacement text to obtain the regular text.
4. The method according to claim 2, characterized in that: The step of screening out the cleaned text from the plurality of rule texts comprises: Perform at least one of the following: When the number of characters in the regular text is greater than a number threshold, determining the regular text as the cleaned text; When the ratio of the number of target language characters in the regular text to the number of characters in the regular text is greater than a first ratio threshold, determining the regular text as the cleaned text; When the first similarity between the characters in the regular text and the sensitive characters is less than a similarity threshold, determining the regular text as the cleaned text; When the ratio of the number of repeated characters in the regular text to the number of characters in the regular text is less than a second ratio threshold, the regular text is determined to be the cleaned text.
5. The method according to claim 1, characterized in that Before obtaining the error correction text, the method further includes: Obtaining a first language model to be trained and error correction prompt word samples; Generating text for the error correction prompt word sample by using the first language model to be trained to obtain a normalized feature sample; A first loss function is constructed based on the normalized feature sample, and parameters of the first language model to be trained are updated until the first loss function converges, and the parameters updated by the first language model to be trained when the first loss function converges are used as parameters of the first language model.
6. The method according to claim 5, characterized in that The constructing a first loss function based on the normalized feature sample includes: Decoding the normalized feature sample to obtain an error correction prediction sample, and determining the first loss function based on a second similarity between the label text of the error correction prompt word sample and the error correction prediction sample; or, The label text of the error correction prompt word sample is mapped to obtain a label feature, and the first loss function is determined based on the third similarity between the label feature and the normalized feature sample.
7. The method according to claim 1, characterized in that The second language model is obtained by training the first language model, and the first language model is used to perform a text error correction task; Before obtaining the quality information of the error-correcting text, the method further includes: Acquire a quality prediction prompt word sample, and perform quality prediction on the quality prediction prompt word sample by using the first language model to obtain quality prediction information; Constructing a second loss function based on the quality prediction information and the label information of the quality prediction prompt word sample; The parameters of the first language model are updated until the second loss function converges, and the parameters updated by the first language model when the second loss function converges are used as the parameters of the second language model.
8. A text processing device based on artificial intelligence, characterized in that: The device comprises: A data cleaning module is used to obtain the original text and perform data cleaning on the original text to obtain a cleaned text; The error correction module is used to obtain a first prompt word template, and based on the first prompt word template, perform prompt word construction processing on the cleaned text to obtain an error correction prompt word; perform the following processing through a first language model, the first language model includes a first encoding layer, a first attention layer, a first normalization layer and a first decoding layer: based on the first encoding layer, encode the error correction prompt word to obtain an error correction feature; based on the first attention layer, perform attention processing on the error correction feature to obtain a first attention feature; based on the first normalization layer, normalize the first attention feature to obtain a first normalized feature; based on the first decoding layer, decode the first normalized feature to obtain an error correction text; The quality prediction module is used to obtain a second prompt word template, and based on the second prompt word template, perform prompt word construction processing on the error correction text to obtain a quality prediction prompt word; perform the following processing through a second language model, wherein the second language model includes a second encoding layer, a second attention layer, a second normalization layer, and a second decoding layer: based on the second encoding layer, encode the quality prediction prompt word to obtain a quality prediction feature; based on the second attention layer, perform attention processing on the quality prediction feature to obtain a second attention feature; based on the second normalization layer, normalize the second attention feature to obtain a second normalized feature; based on the second decoding layer, decode the second normalized feature to obtain quality information of the error correction text; A screening module is used to screen out a target text from the plurality of error correction texts based on the quality information.
9. An electronic device, characterized in that: The electronic device comprises: A memory for storing computer executable instructions; A processor, for implementing the artificial intelligence-based text processing method according to any one of claims 1 to 7 when executing the computer executable instructions or computer programs stored in the memory.
10. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that: When the computer executable instructions or computer program are executed by a processor, the artificial intelligence-based text processing method according to any one of claims 1 to 7 is implemented.
11. A computer program product comprising computer executable instructions or a computer program, characterized in that: When the computer executable instructions or computer program are executed by a processor, the artificial intelligence-based text processing method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Chinese grammar error correction corpus construction method based on ChatGPT-like open source large model
CN117272984A
Key character name error correction method and system, electronic equipment and storage medium
CN118193677A
