Text processing method and device, electronic equipment and storage medium
Optimizing the process of LLM generating reply text through emotion classification model and emotion matching strategy solves the problem of emotional singleness of reply text in the prior art, and improves the naturalness and expressiveness of dialogue.
Patent Information
- Application Number
- CN202311493415.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-09
- Publication Date
- 2025-05-13
AI Technical Summary
In the prior art, the reply text generated by the LLM is usually single in emotion and weak in expression, resulting in unnatural dialogue.
By obtaining the user input text, using the emotion classification model to determine the user's emotional category, determining the emotion matching strategy based on the user input text and emotion category, and generating reply text using the target large language model.
Improves the emotional expression accuracy of the generated reply text, making the conversation more natural and expressive.
Smart Images

Figure CN119990147A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of text processing, and in particular to a method, device, electronic device and storage medium for text processing. Background Art
[0002] In some conversation scenarios, it is usually necessary to automatically reply to the text entered by the user. For example, when a user talks to a robot customer service, the robot customer service usually generates a reply text based on the user's question and returns the reply text to the user.
[0003] In the prior art, the user input text is usually input into a large language model (LLM) to obtain a reply text.
[0004] However, since the text generated by LLM usually does not have obvious emotional expression, the generated reply text is usually emotionally simple and weak in expression, resulting in unnatural conversation. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a text processing method, device, electronic device and storage medium, so as to improve the accuracy of emotional expression of the generated reply text during text processing.
[0006] On the one hand, an embodiment of the present application provides a method for text processing, the method comprising:
[0007] Get the user input text to be processed;
[0008] Adopting sentiment classification model to determine the user sentiment category of the user input text;
[0009] Based on the user input text and the user emotion category, determine the emotion matching strategy corresponding to the user input text;
[0010] The target large language model is adopted to determine the target reply text corresponding to the user input text based on the sentiment matching strategy of the user input text.
[0011] In one implementation, a sentiment classification model is used to determine the user sentiment category of the user input text, including:
[0012] Segment the user input text to obtain multiple segmentation encoding vectors;
[0013] Transform each word segmentation encoding vector to obtain the semantic vector of the user input text;
[0014] Based on the semantic vector, sentiment classification is performed to obtain the user sentiment category.
[0015] In one implementation, based on the user input text and the user emotion category, determining the emotion matching strategy corresponding to the user input text includes:
[0016] Filter out historical texts matching the user input text and historical sentiment categories corresponding to the historical texts from the historical text collection; the historical text collection contains at least one historical text and its corresponding historical sentiment category, and the historical text is the user input text within a historical time period;
[0017] Perform weighted summation of user sentiment categories and historical sentiment categories to obtain comprehensive sentiment categories;
[0018] Get the sentiment matching strategy corresponding to the comprehensive sentiment category.
[0019] In one embodiment, the method further comprises:
[0020] Add the user input text and user sentiment category to the historical text collection.
[0021] In one implementation, a target large language model is used to determine a target reply text corresponding to the user input text based on a user input text sentiment matching strategy, including:
[0022] Selecting a target large language model from a large language model set; the large language model includes at least one large language model;
[0023] The user input text and sentiment matching strategy are input into the target large language model to obtain the target reply text.
[0024] On the one hand, an embodiment of the present application provides a text processing device, including:
[0025] An acquisition unit, used for acquiring user input text to be processed;
[0026] A first determining unit, configured to determine a user emotion category of a user input text by using an emotion classification model;
[0027] A second determining unit, configured to determine an emotion matching strategy corresponding to the user input text based on the user input text and the user emotion category;
[0028] The third determination unit is used to adopt a target large language model and determine a target reply text corresponding to the user input text based on a user input text sentiment matching strategy.
[0029] In one implementation, the first determining unit is used to:
[0030] Segment the user input text to obtain multiple segmentation encoding vectors;
[0031] Using the transformation module, each word segmentation encoding vector is transformed to obtain the semantic vector of the user input text;
[0032] The self-attention mechanism module is used to perform sentiment classification based on semantic vectors to obtain user sentiment categories.
[0033] In one implementation, the second determining unit is used to:
[0034] Filter out historical texts matching the user input text and historical sentiment categories corresponding to the historical texts from the historical text collection; the historical text collection contains at least one historical text and its corresponding historical sentiment category, and the historical text is the user input text within a historical time period;
[0035] Perform weighted summation of user sentiment categories and historical sentiment categories to obtain comprehensive sentiment categories;
[0036] Get the sentiment matching strategy corresponding to the comprehensive sentiment category.
[0037] In one implementation, the second determining unit is further configured to:
[0038] Add the user input text and user sentiment category to the historical text collection.
[0039] In one implementation, the third determining unit is used to:
[0040] Selecting a target large language model from a large language model set; the large language model includes at least one large language model;
[0041] The user input text and sentiment matching strategy are input into the target large language model to obtain the target reply text.
[0042] On the one hand, an embodiment of the present application provides an electronic device, including:
[0043] Processor; and
[0044] A memory stores computer instructions, wherein the computer instructions are used to cause a processor to execute the steps of the method provided in any of the various optional implementations of any of the above-mentioned text processing.
[0045] On the one hand, an embodiment of the present application provides a storage medium storing computer instructions, which are used to enable a computer to execute the steps of the method provided in any of the various optional implementations of any of the above-mentioned text processing.
[0046] The text processing method in the embodiment of the present application includes obtaining a user input text to be processed; using a sentiment classification model to determine the user sentiment category of the user input text; determining a sentiment matching strategy corresponding to the user input text based on the user input text and the user sentiment category; using a target large language model, based on the user input text sentiment matching strategy, determining a target reply text corresponding to the user input text. In this way, the accuracy of the sentiment expression of the generated reply text is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0048] Figure 1 It is a flowchart of a text processing method in an embodiment of the present application.
[0049] Figure 2 This is a structural example diagram of a sentiment classification model in an embodiment of the present application.
[0050] Figure 3 It is a schematic diagram of determining an emotion matching strategy in an embodiment of the present application.
[0051] Figure 4 This is an example diagram of a user session in an embodiment of the present application.
[0052] Figure 5 It is a flowchart of a text conversation method in an embodiment of the present application.
[0053] Figure 6 It is a structural block diagram of a text processing device in an embodiment of the present application.
[0054] Figure 7 It is a structural schematic diagram of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0055] The technical solution of the present application will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described implementation methods are part of the implementation methods of the present application, rather than all of the implementation methods. Based on the implementation methods in the present application, all other implementation methods obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In addition, the technical features involved in the different implementation methods of the present application described below can be combined with each other as long as they do not conflict with each other.
[0056] First, some terms involved in the embodiments of the present application are explained to facilitate understanding by those skilled in the art.
[0057] Terminal device: can be a mobile terminal, a fixed terminal or a portable terminal, such as a mobile phone, a station, a unit, a device, a multimedia computer, a multimedia tablet, an Internet node, a communicator, a desktop computer, a laptop computer, a notebook computer, a netbook computer, a tablet computer, a personal communication system device, a personal navigation device, a personal digital assistant, an audio / video player, a digital camera / camcorder, a positioning device, a television receiver, a radio broadcast receiver, an electronic book device, a gaming device or any combination thereof, including accessories and peripherals of these devices or any combination thereof. It is also foreseeable that the terminal device can support any type of interface for the user (such as a wearable device), etc.
[0058] Server: It can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or 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, and big data and artificial intelligence platforms.
[0059] Based on the defects of the above-mentioned related technologies, a method, device, electronic device and storage medium for text processing are provided in the embodiments of the present application, aiming to improve the accuracy of emotional expression of the generated reply text during text processing.
[0060] A text processing method is provided in an embodiment of the present application. The method can be applied to electronic devices. The present application does not limit the type of electronic device. It can be any type of device suitable for implementation, such as a terminal device and a server, etc. The present application will not go into details about this.
[0061] See also Figure 1 As shown, it is a flowchart of a text processing method in an embodiment of the present application. Figure 1 The method is described below. The specific implementation process of the method is as follows:
[0062] Step 100: Obtain user input text to be processed.
[0063] Step 101: Using a sentiment classification model, determine the user sentiment category of the user input text.
[0064] In one implementation, the sentiment classification model is built based on a language representation model (Bidirectional Encoder Representation from Transformers, BERT). Bert is a powerful neural network model based on Transformer. By stacking multiple Transformer encoders as its basic structure, it can learn richer semantic information of the text. The input of the sentiment classification model is the user input text (Input Text).
[0065] See also Figure 2 The figure shows an example structure of a sentiment classification model. Figure 2 It includes a vector module, a transformation module and a self-attention module. The transformation module includes multiple transformer encoders.
[0066] Combine the following Figure 2 To illustrate determining the user emotion category, when executing step 101, the following steps may be used:
[0067] S1011: Segment the user input text to obtain multiple segmentation encoding vectors.
[0068] In one implementation, a word segmentation module is used to segment user input text (ie, input text) to obtain a plurality of word segmentation encoding vectors.
[0069] As an example, the questions that the user sends to the intelligent customer service through text are taken as the user input text.
[0070] As another example, converting the user's speech to the smart speaker into text as user input text
[0071] S1012: Transform each word segmentation encoding vector to obtain a semantic vector of the user input text.
[0072] In one implementation, each word segmentation encoding vector is input into a transformation module, and each Transformer Encoder in the transformation module transforms each word segmentation encoding vector to obtain a semantic vector.
[0073] Among them, the semantic vector can represent the semantic information of the user input text.
[0074] S1013: Perform sentiment classification based on the semantic vector to obtain the user sentiment category.
[0075] In one implementation, the semantic vector is input into an attention mechanism module (Self-Attention) to obtain the user emotion category.
[0076] As an example, the emotion classification may include at least one of: extremely happy, generally happy, neutral, depressed, extremely sad, and angry.
[0077] In practical applications, sentiment classification and sentiment classification models can be set according to actual application scenarios and are not restricted here.
[0078] In this way, the user's emotion can be judged through the text input by the user, and then in the subsequent steps, a response can be given to the user based on the user's emotion.
[0079] Step 102: Based on the user input text and the user emotion category, determine the emotion matching strategy corresponding to the user input text.
[0080] See also Figure 3 The figure shows a schematic diagram of determining an emotion matching strategy. Figure 3 It includes sentiment classification model, historical text collection, sentiment matching module and LLM.
[0081] The historical text set includes at least one historical text and its corresponding historical sentiment category. The historical text is the user input text within a certain historical time period. The sentiment matching module is constructed based on a fully connected network, including six sentiment categories and their corresponding sentiment matching strategies.
[0082] In one embodiment, when executing step 102, Figure 3 Use the following steps:
[0083] S1021: Filter out historical texts that match the user input text and historical sentiment categories corresponding to the historical texts from the historical text collection.
[0084] In one implementation, the matching degree between the user input text and each historical text in the historical text set is determined, and the historical texts are filtered according to the matching degrees and the set quantity, and the historical sentiment categories corresponding to the filtered historical texts are obtained.
[0085] In actual applications, the set number can be set according to the actual application scenario, for example, the set number can be one or five.
[0086] As an example, a historical text with the highest matching degree is selected.
[0087] As another example, historical texts with a matching degree higher than a set matching degree are screened out. If the number of the screened out historical texts is higher than the set number, the set number of historical texts are screened out, and their corresponding historical sentiment categories are obtained.
[0088] S1022: Perform weighted summation on the user emotion category and the historical emotion category to obtain a comprehensive emotion category.
[0089] In one implementation, a user emotion category based on an output of an emotion classification model is obtained, and a weighted sum is performed on the user emotion category and at least one historical emotion category to obtain a comprehensive emotion category.
[0090] S1023: Obtain the emotion matching strategy corresponding to the comprehensive emotion category.
[0091] In one implementation, the comprehensive emotion category is input into an emotion matching module, and the emotion matching strategy corresponding to the comprehensive emotion category is determined by the emotion matching module.
[0092] Optionally, the emotion matching strategy may be identification information for indicating an emotion category, such as a prompt word or a digital mark indicating an emotion category.
[0093] In practical applications, the emotion matching strategy can be set according to the actual application scenario and is not limited here.
[0094] Furthermore, the user input text and the user emotion category may be added to the historical text collection.
[0095] Optionally, the historical text set may be a set of user input texts and their corresponding user emotion categories of the user corresponding to the user input text within a historical time period, or may be a set of user input texts and their corresponding user emotion categories of multiple users within a historical time period.
[0096] Furthermore, the comprehensive emotion category can also be used as the historical emotion category.
[0097] Step 103: Using the target large language model, based on the user input text sentiment matching strategy, determine the target reply text corresponding to the user input text.
[0098] In one implementation, a user inputs a text sentiment matching strategy, inputs a target LLM, and obtains a target reply text.
[0099] Furthermore, the target large language model may be switched among different large language models.
[0100] In one implementation, when executing step 103, the following steps may be used:
[0101] S1031: Select a target large language model from a large language model set; the large language model includes at least one large language model.
[0102] In one implementation, a conversation scenario is determined based on user input text and environmental information, and a target large language model corresponding to the conversation scenario is obtained from a large language model set.
[0103] In practical applications, the target large language model can be set according to the actual application scenario and is not restricted here.
[0104] S1032: Input the user input text and sentiment matching strategy into the target large language model to obtain the target reply text.
[0105] In one implementation, a user sends user input text to a customer service server of a customer service device through a conversation client in a user device. The customer service server generates a target reply text corresponding to the user input text and sends the target reply text to the user.
[0106] Furthermore, it can also be applied to voice interaction scenarios. In one embodiment, a user issues a voice command to a user device (such as a smart speaker). The user device converts the collected voice command into user input text and sends the user input text to the customer service server of the customer service device. The customer service server generates a target reply text corresponding to the user input text and sends the target reply text to the user device. The user device converts the target reply text into voice and plays it to play the target reply text to the user by voice.
[0107] The user device and the customer service device form a dialogue system, so that the user can interact with the dialogue system.
[0108] See also Figure 4 The figure shows an example diagram of a user session. Figure 4 In the text processing method of the present application, after performing sentiment and semantic analysis on the user's input text, a corresponding target reply text is generated, and the target reply text is returned to the user.
[0109] In an embodiment of the present application, the user's user input text is input into a sentiment classification model, and the user's current emotional state is dynamically captured through the sentiment classification model to determine the user's user emotion category, and based on the user's user emotion category and historical emotion category, the user's emotion matching strategy is determined. In addition, an LLM model is used to determine the user's target reply text based on the user's user input text and the emotion matching strategy. This can more accurately determine the user's emotional needs, and then generate a target reply text that is expressive, emotionally matches the user, and communicates naturally, thereby improving the user's interactive experience. Furthermore, different LLMs can be switched freely, and it also has the characteristics of strong flexibility.
[0110] The text processing method provided in the embodiments of the present application can be applied to text generation scenarios that require strong emotional expression. For example, it can be applied to the scenario of artificial intelligence virtual anchors. Users can communicate with artificial intelligence virtual anchors through barrages. Artificial intelligence virtual anchors can use the method provided in the embodiments of the present application to generate corresponding target reply texts according to the user's barrages as an answer to the user's barrages. It can also be applied to systems that need to generate richer emotional expressions (such as smart speakers), and can also be applied to industries that provide mental health services to help people solve psychological problems, thereby providing emotional support at a low cost.
[0111] See also Figure 5 The figure is a flowchart of a text conversation method. Figure 5 , the above embodiments are illustrated.
[0112] Step 500: When it is determined that user input text input by the user is received, the user input text is obtained.
[0113] Furthermore, the user input text may be added to the historical text collection.
[0114] Step 501: Determine the user emotion category based on the user input text through the emotion classification model.
[0115] Furthermore, the user emotion category corresponding to the historical text may be added to the historical text collection.
[0116] Step 502: Obtain the historical text corresponding to the user input text and its corresponding historical sentiment category from the historical text set.
[0117] In this way, the user input text and its corresponding user emotion category can be used as a new historical record, and the historical records within the historical time period can be used as auxiliary judgment tools for emotion determination. In the iterative process, the user's next round of emotion category is corrected by comparing the consistency of the emotion classification of the context, so as to generate targeted target reply text for the user's user input text, thereby realizing continuous iterative communication and interaction with the user.
[0118] Step 503: Determine an emotion matching strategy based on the user emotion category and the historical emotion category.
[0119] Step 504: Input the user input text and the sentiment matching strategy into the LLM to obtain the target reply text.
[0120] Step 505: Send the target reply text to the user device and execute step 500.
[0121] Furthermore, the target reply text may be added to the historical text collection.
[0122] Specifically, when executing step 500 to step 505, the specific steps refer to the above-mentioned step 101 to step 103, which will not be repeated here.
[0123] Based on the same inventive concept, a text processing device is also provided in the embodiment of the present application. Since the principle of solving the problem by the above device and equipment is similar to that of a text processing method, the implementation of the above device can refer to the implementation of the method, and the repeated parts will not be repeated. The device can be applied to electronic devices. The present application does not limit the type of electronic devices. It can be any type of device suitable for implementation, such as terminal devices and servers, etc., and the present application will not repeat them.
[0124] See also Figure 6 , which is a structural block diagram of a text processing device in an embodiment of the present application. In some embodiments, the text processing device in the example of the present application includes:
[0125] An acquisition unit 601 is used to acquire a user input text to be processed;
[0126] A first determining unit 602 is used to determine a user emotion category of a user input text by using an emotion classification model;
[0127] A second determining unit 603 is used to determine a sentiment matching strategy corresponding to the user input text based on the user input text and the user sentiment category;
[0128] The third determination unit 604 is used to determine a target reply text corresponding to the user input text by using a target large language model and based on a user input text sentiment matching strategy.
[0129] In one implementation, the first determining unit 602 is configured to:
[0130] Segment the user input text to obtain multiple segmentation encoding vectors;
[0131] Using the transformation module, each word segmentation encoding vector is transformed to obtain the semantic vector of the user input text;
[0132] The self-attention mechanism module is used to perform sentiment classification based on semantic vectors to obtain user sentiment categories.
[0133] In one implementation, the second determining unit 603 is configured to:
[0134] Filter out historical texts matching the user input text and historical sentiment categories corresponding to the historical texts from the historical text collection; the historical text collection contains at least one historical text and its corresponding historical sentiment category, and the historical text is the user input text within a historical time period;
[0135] Perform weighted summation of user sentiment categories and historical sentiment categories to obtain comprehensive sentiment categories;
[0136] Get the sentiment matching strategy corresponding to the comprehensive sentiment category.
[0137] In one implementation manner, the second determining unit 603 is further configured to:
[0138] Add the user input text and user sentiment category to the historical text collection.
[0139] In one implementation, the third determining unit 604 is configured to:
[0140] Selecting a target large language model from a large language model set; the large language model includes at least one large language model;
[0141] The user input text and sentiment matching strategy are input into the target large language model to obtain the target reply text.
[0142] The text processing method in the embodiment of the present application includes obtaining a user input text to be processed; using a sentiment classification model to determine the user sentiment category of the user input text; determining a sentiment matching strategy corresponding to the user input text based on the user input text and the user sentiment category; using a target large language model, based on the user input text sentiment matching strategy, determining a target reply text corresponding to the user input text. In this way, the accuracy of the sentiment expression of the generated reply text is improved.
[0143] In an embodiment of the present application, an electronic device is provided, including:
[0144] Processor; and
[0145] The memory stores computer instructions, where the computer instructions are used to enable the processor to execute the method of any of the above embodiments.
[0146] In an embodiment of the present application, a storage medium is provided, which stores computer instructions, and the computer instructions are used to enable a computer to execute a method in any of the above-mentioned embodiments. Figure 7 FIG. 7 is a schematic diagram showing the structure of an electronic device 7000. Figure 7 As shown, the electronic device 7000 includes: a processor 7010 and a memory 7020 , and optionally, may also include a power supply 7030 , a display unit 7040 , and an input unit 7050 .
[0147] The processor 7010 is the control center of the electronic device 7000. It connects various components using various interfaces and lines, and performs various functions of the electronic device 7000 by running or executing software programs and / or data stored in the memory 7020, thereby monitoring the electronic device 7000 as a whole.
[0148] In the embodiment of the present application, the processor 7010 executes the various steps in the above embodiment when calling the computer program stored in the memory 7020.
[0149] Optionally, the processor 7010 may include one or more processing units; preferably, the processor 7010 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and applications, and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor 7010. In some embodiments, the processor and the memory may be implemented on a single chip, and in some embodiments, they may also be implemented separately on separate chips.
[0150] The memory 7020 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, various applications, etc.; the data storage area may store data created according to the use of the electronic device 7000, etc. In addition, the memory 7020 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices, etc.
[0151] The electronic device 7000 also includes a power source 7030 (such as a battery) for supplying power to various components. The power source can be logically connected to the processor 7010 through a power management system, thereby managing functions such as charging, discharging, and power consumption through the power management system.
[0152] The display unit 7040 may be used to display information input by a user or information provided to a user, various menus of the electronic device 7000, and in the embodiment of the present application, is mainly used to display the display interface of each application in the electronic device 7000 and objects such as text and pictures displayed in the display interface. The display unit 7040 may include a display panel 7041. The display panel 7041 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), and the like.
[0153] The input unit 7050 may be used to receive information such as numbers or characters input by the user. The input unit 7050 may include a touch panel 7051 and other input devices 7052. The touch panel 7051, also known as a touch screen, may collect touch operations of the user on or near it (such as operations of the user using a finger, a stylus, or any other suitable object or accessory on or near the touch panel 7051).
[0154] Specifically, the touch panel 7051 can detect the user's touch operation, detect the signal brought by the touch operation, convert these signals into touch point coordinates, send them to the processor 7010, and receive and execute the command sent by the processor 7010. In addition, the touch panel 7051 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic wave. Other input devices 7052 can include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, power on / off keys, etc.), a trackball, a mouse, a joystick, etc.
[0155] Of course, the touch panel 7051 can cover the display panel 7041. When the touch panel 7051 detects a touch operation on or near it, it is transmitted to the processor 7010 to determine the type of touch event. Then the processor 7010 provides corresponding visual output on the display panel 7041 according to the type of touch event. Figure 7 In the embodiment, the touch panel 7051 and the display panel 7041 are used as two independent components to realize the input and output functions of the electronic device 7000, but in some embodiments, the touch panel 7051 and the display panel 7041 can be integrated to realize the input and output functions of the electronic device 7000.
[0156] The electronic device 7000 may also include one or more sensors, such as a pressure sensor, a gravity acceleration sensor, a proximity light sensor, etc. Of course, according to the needs of specific applications, the electronic device 7000 may also include other components such as a camera. Since these components are not the key components used in the embodiments of the present application, Figure 7It is not shown and will not be described in detail.
[0157] Those skilled in the art will understand that Figure 7 The electronic device is merely an example and does not limit the electronic device, and may include more or less components than those shown in the figure, or may combine certain components, or may include different components.
[0158] For the convenience of description, the above parts are divided into modules (or units) according to their functions and described separately. Of course, when implementing this application, the functions of each module (or unit) can be implemented in the same or multiple software or hardware.
[0159] Obviously, the above embodiments are merely examples for the purpose of clear explanation, and are not intended to limit the embodiments. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. The obvious changes or modifications derived therefrom are still within the scope of protection created by this application.
Claims
1. A method for text processing, characterized in that: The method comprises: Get the user input text to be processed; Adopting sentiment classification model to determine the user sentiment category of the user input text; Based on the user input text and the user emotion category, determining an emotion matching strategy corresponding to the user input text; A target large language model is adopted to determine a target reply text corresponding to the user input text based on the sentiment matching strategy of the user input text.
2. The method according to claim 1, characterized in that The emotion classification model is used to determine the emotion category of the user input text, including: Segmenting the user input text to obtain multiple segmentation encoding vectors; Transforming each word segmentation encoding vector to obtain a semantic vector of the user input text; Based on the semantic vector, sentiment classification is performed to obtain the user sentiment category.
3. The method according to claim 1 or 2, characterized in that: The step of determining the emotion matching strategy corresponding to the user input text based on the user input text and the user emotion category includes: Filter out historical texts matching the user input text and historical emotion categories corresponding to the historical texts from the historical text collection; the historical text collection contains at least one historical text and its corresponding historical emotion category, and the historical text is the user input text within a historical time period; Performing a weighted summation of the user emotion category and the historical emotion category to obtain a comprehensive emotion category; The emotion matching strategy corresponding to the comprehensive emotion category is obtained.
4. The method according to claim 3, characterized in that The method further comprises: The user input text and the user emotion category are added to the historical text collection.
5. The method according to claim 1 or 2, characterized in that: The adopting of the target large language model and determining the target reply text corresponding to the user input text based on the sentiment matching strategy of the user input text includes: Selecting a target large language model from a large language model set; the large language model includes at least one large language model; The user input text and the sentiment matching strategy are input into the target large language model to obtain the target reply text.
6. A text processing device, characterized in that: The device comprises: An acquisition unit, used for acquiring user input text to be processed; A first determining unit, configured to determine a user emotion category of a user input text by using an emotion classification model; A second determining unit, configured to determine a sentiment matching strategy corresponding to the user input text based on the user input text and the user sentiment category; The third determination unit is used to adopt a target large language model and determine a target reply text corresponding to the user input text based on the sentiment matching strategy of the user input text.
7. The device according to claim 6, characterized in that The first determining unit is used for: Segmenting the user input text to obtain multiple segmentation encoding vectors; Using a transformation module to transform each word segmentation encoding vector to obtain a semantic vector of the user input text; A self-attention mechanism module is used to perform sentiment classification based on the semantic vector to obtain the user sentiment category.
8. The device according to claim 6 or 7, characterized in that The second determining unit is used for: Filter out historical texts matching the user input text and historical emotion categories corresponding to the historical texts from the historical text collection; the historical text collection contains at least one historical text and its corresponding historical emotion category, and the historical text is the user input text within a historical time period; Performing a weighted summation of the user emotion category and the historical emotion category to obtain a comprehensive emotion category; The emotion matching strategy corresponding to the comprehensive emotion category is obtained.
9. The device according to claim 8, characterized in that The second determining unit is further configured to: The user input text and the user emotion category are added to the historical text collection.
10. The device according to claim 6 or 7, characterized in that The third determining unit is used for: Selecting a target large language model from a large language model set; the large language model includes at least one large language model; The user input text and the sentiment matching strategy are input into the target large language model to obtain the target reply text.
11. An electronic device, characterized in that: include: processor; as well as A memory storing computer instructions, wherein the computer instructions are used to enable the processor to execute the method according to any one of claims 1 to 5.
12. A storage medium, characterized in that: Computer instructions are stored, and the computer instructions are used to make a computer execute the method according to any one of claims 1 to 5.