Text generalization method and device, electronic equipment and storage medium
By identifying target entities in the text to be processed and selecting candidate texts for generalization, the problem of high text collection difficulty in model training is solved, and training efficiency is improved.
Patent Information
- Application Number
- CN202511008448.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-21
- Publication Date
- 2025-11-21
AI Technical Summary
Collecting a large amount of text from real-world scenarios during model training is difficult, resulting in low training efficiency.
By identifying the target entity in the text to be processed, matching candidate texts are selected from a preset knowledge base, and text generalization processing is performed based on the target entity and control information to generate multiple generalized texts.
It reduces the difficulty of text collection, improves model training efficiency, and enables the generation of a large amount of training text based on a small amount of real-world scene text.
Smart Images

Figure CN120996034A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of electronic devices, and more particularly, to a text generalization method and device, an electronic device, and a storage medium. BACKGROUND
[0002] With the rapid development of artificial intelligence technology, large model technology has achieved remarkable results in the fields of speech recognition, natural language processing, etc. However, in the training process of the model, a large amount of text in real scenarios is usually required, and it is difficult to collect a large amount of text in real scenarios, resulting in low model training efficiency. SUMMARY
[0003] The present application provides a text generalization method, device, electronic device, and storage medium to improve the training efficiency of the model.
[0004] In a first aspect, the present application provides a text generalization method, which includes: identifying entities in the text to be processed to obtain at least one target entity included in the text to be processed; selecting a candidate text matching the text to be processed from a plurality of texts included in a preset knowledge base based on the text to be processed and the at least one target entity; performing text generalization processing based on target control information for the at least one target entity, the text to be processed, and the candidate text to obtain a plurality of generalization texts corresponding to the text to be processed.
[0005] In a second aspect, the present application also provides a text generalization device, which includes: an identification module configured to identify entities in the text to be processed to obtain at least one target entity included in the text to be processed; a selection module configured to select a candidate text matching the text to be processed from a plurality of texts included in a preset knowledge base based on the text to be processed and the at least one target entity; a generalization module configured to perform text generalization processing based on target control information for the at least one target entity, the text to be processed, and the candidate text to obtain a plurality of generalization texts corresponding to the text to be processed.
[0006] In a third aspect, the present application also provides an electronic device, which includes one or more processors, a memory, and one or more application programs stored in the memory and configured to be executed by the one or more processors, the one or more programs being configured to execute the method of the first aspect.
[0007] In a fourth aspect, the embodiments of the present application further provide a computer readable storage medium, which stores processor-executable program code, and the program code, when executed by a processor, causes the processor to perform the method described above.
[0008] The present application provides a text generalization method and device, electronic equipment and storage medium. In the present application, at least one target entity included in the to-be-processed text is first identified, then a candidate text is selected based on the to-be-processed text and the at least one target entity, and finally, a large language model performs text generalization processing based on target control information for the at least one target entity, the to-be-processed text and the candidate text to obtain a plurality of generalization texts corresponding to the to-be-processed text. Thus, a large number of generalization text targets are obtained based on a small amount of text in a real scenario, so that in the process of training the model, only a small amount of text in a real scenario needs to be collected, and a large amount of text for training the model can also be obtained by generalization, without the need to collect a large amount of text in a real scenario, thereby reducing the difficulty of collecting text, improving the efficiency of obtaining text required for training the model, and further improving the model training efficiency.
[0009] Other features and advantages of the embodiments of the present application will be described in the following description, and some will become apparent from the description, or will be understood through implementation of the embodiments of the present application. The purposes and other advantages of the embodiments of the present application can be achieved and obtained through the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed in the embodiment description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor on the basis of these drawings.
[0011] Figure 1 A flowchart of a text generalization method according to an embodiment of the present application is shown.
[0012] Figure 2 A flowchart of a text generalization method according to another embodiment of the present application is shown.
[0013] Figure 3 A schematic diagram of a text generalization process in an embodiment of the present application is shown.
[0014] Figure 4 A flowchart of an updating process of a preset knowledge base in an embodiment of the present application is shown.
[0015] Figure 5A schematic diagram of a preset knowledge base updating process in an embodiment of the present application is shown.
[0016] Figure 6 A schematic diagram of a text generalization process in an embodiment of the present application is shown.
[0017] Figure 7 A structural block diagram of a text generalization device according to an embodiment of the present application is shown.
[0018] Figure 8 A structural block diagram of an electronic device according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0019] In order to enable persons skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings of the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application. The components of the embodiments of the present application described and shown in the accompanying drawings can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of the present application.
[0020] It should be noted that: similar reference numerals and letters represent similar items in the following drawings, therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. Meanwhile, in the description of the present application, the terms "first", "second", etc. are only used to distinguish the description, and cannot be understood as indicating or implying relative importance.
[0021] Please refer to Figure 1 , Figure 1 A flowchart of a text generalization method according to an embodiment of the present application is shown, for an electronic device, the method comprises: S110, identifying entities of the to-be-processed text to obtain at least one target entity included in the to-be-processed text.
[0022] The to-be-processed text refers to the text that needs to be generalized, and the to-be-processed text can be a normal text, or a text instruction for controlling a device, a dialogue information for dialogue with artificial intelligence, or a text corresponding to a user's gesture, etc. For example, the to-be-processed text can be a text instruction for controlling a vehicle: help me turn on the air conditioner and adjust the appropriate temperature, and at the same time, according to the current atmosphere, adjust the playing track.
[0023] The text to be processed can be user input text or text obtained by performing text recognition on speech.
[0024] In some embodiments, the speech to be recognized can be obtained; the speech to be recognized is preprocessed to obtain target speech; the preprocessing includes at least one of denoising processing, echo cancellation processing, and speech and environment separation processing; the target speech is subjected to speech-to-text generalization to obtain text to be processed.
[0025] The user input speech can be obtained as the speech to be recognized, and then the speech to be recognized is preprocessed to denoise, cancel echo, and separate environmental sound through preprocessing to obtain preprocessed target speech, the target speech includes less noise, less echo, and less environmental sound, the target speech is relatively pure, and then the target speech can be subjected to speech-to-text generalization through automatic speech recognition (ASR), speech-to-text conversion program, or large language model (LLM) to obtain converted text as text to be processed.
[0026] After obtaining the text to be processed, the text to be processed can be subjected to entity recognition, and the entity recognized from the text to be processed is a target entity. The entity can be a noun, an object name, a function name, etc.
[0027] Optionally, the text to be processed can be subjected to entity recognition through a large language model to recognize at least one target entity. For example, a prompt can be written based on the text to be processed, and the prompt is input into the large language model to enable the large language model to perform entity recognition on the text to be processed based on the prompt to recognize at least one target entity.
[0028] For example, the constructed prompt can be: You are an assistant designed to extract entities from text. Next, I will provide a string of "text to be processed for entity recognition" below. You will extract [air conditioner], [temperature], [music], and [track] from it and return a json object to me. The text to be processed for entity recognition is: ### Help me turn on the air conditioner and adjust the appropriate temperature, and adjust the music playing track according to the current atmosphere ### Json information: { "entities": ["air conditioner", "temperature", "music", "track"] } Of course, in the foregoing example, the constructed prompt information requires the target entity returned by the large language model to be a json object, and the user can set other format requirements based on needs, not limited to json objects and the like.
[0029] S120, selecting a candidate text matching the to-be-processed text from a plurality of texts included in a preset knowledge base based on the to-be-processed text and the at least one target entity.
[0030] The preset knowledge base includes a plurality of texts, each of which is a text with good quality and high accuracy. For example, a text in the preset knowledge base is for the air conditioning and light control scene of a vehicle, and the text includes an air conditioning state that does not exceed all possible states of the air conditioning (for example, the temperature of the air conditioner will not be higher than 35 degrees Celsius or lower than 5 degrees Celsius), and the text includes a light state that does not exceed all possible states of the light (for example, the high beam will not be turned on during the day).
[0031] In this application, the candidate text matching the to-be-processed text is selected in combination with the to-be-processed text and the extracted at least one target entity.
[0032] In some embodiments, the to-be-processed text and the text in the preset knowledge base can be matched respectively to obtain a first text with a matching degree higher than a first threshold, and the at least one target entity and the text in the preset knowledge base can be matched respectively to obtain a second text with a matching degree higher than a second threshold, and then the overlapping text in the first text and the second text is taken as the candidate text. Wherein, the matching can utilize cosine similarity, Euclidean distance and Manhattan distance, and the first threshold and the second threshold are, for example, both 0.5.
[0033] In still some embodiments, the to-be-processed text and the at least one target entity are subjected to embedding processing of features to obtain an embedding feature corresponding to the to-be-processed text and an embedding feature corresponding to the at least one target entity; the embedding feature corresponding to the to-be-processed text and the embedding feature corresponding to the at least one target entity are fused to obtain a fusion feature; and a target number of texts are selected from the preset knowledge base as candidate texts in descending order of similarity between the fusion feature. The similarity can be cosine similarity, Euclidean distance and Manhattan distance, the fusion can include weighted summation, splicing or attention operation, and the target number can be, for example, 3.
[0034] S130, performing generalization processing of the text based on the target control information for the at least one target entity, the to-be-processed text and the candidate text to obtain a plurality of generalization texts corresponding to the to-be-processed text.
[0035] The target control information for the at least one target entity refers to specific control information for the target entity. For example, when the target entity is an air conditioner, the target control information can be an open state and a temperature of 25°C. For another example, when the target entity is music, the target control information can be an open state and playing “Where is Spring”.
[0036] In some embodiments, the target control information for the at least one target entity can be directly used to replace the target entity in the to-be-processed text and the candidate text to realize the generalization processing of the text, to obtain the replaced to-be-processed text and the replaced candidate text, and to obtain the four of the replaced to-be-processed text, the replaced candidate text, the to-be-processed text and the candidate text as the plurality of generalized texts.
[0037] In yet some embodiments, the generalization processing of the text can be performed by the large language model based on the target control information for the at least one target entity, the to-be-processed text and the candidate text to obtain the plurality of generalized texts corresponding to the to-be-processed text.
[0038] For example, a generalization prompt information is constructed according to the target control information for the at least one target entity, the to-be-processed text and the candidate text, and then the generalization prompt information is input into the large language model, the generalization processing of the text is performed by the large language model based on the generalization prompt information, and the plurality of generalized texts are output.
[0039] For example, when the candidate text is three, the obtained generalization prompt information (prompt) can be: I hope you will play an excellent product expert in the field of cockpit scene generalization in the future, use your unique product thinking, and your ability to use all the methods that can make the product better. I will provide a series of “to-be-processed texts that need to be generalized” in the future, and output not less than 5 semantic generalization scenes in combination with the key information I provide: [air conditioner], [temperature], [music] and [song title], and return in json.
[0040] {target control information} {3 candidate texts} To-be-processed text that needs to be generalized: ### Help me turn on the air conditioner and adjust the appropriate temperature, and adjust the music playing according to the current atmosphere ### Json information: { “scene”: [ {"thought": "Turn on the air conditioner and set the temperature to a comfortable level, play 123's 123A", "code": {"condition": {"status": "open", "temp": "auto"}, "music": {"status": "open", "song": "123A"}}, {"thought": "Adjust the air conditioner speed to adapt to the indoor and outdoor temperature difference, play children's song 456B", "code": {"condition": {"status": "open", "temp": "25"}, "music": {"status": "open", "song": "456B"}}, {"thought": "Automatically adjust the air conditioner mode according to the outdoor climate", "code": {"status": "open", "song": "456B"}}, {"thought": "Choose a music style that matches the current atmosphere", "code": {"status": "open", "song": "123A"}}, {"thought": "Recommend different music tracks based on the driver's mood", "code": {"status": "open", "song": "789C"} ] } Among them, the content included in the code in the aforementioned generalized prompt information is the given target control information, and the text behind the thought is the generalized text after generalization. Of course, as mentioned earlier, the constructed generalized prompt information requires the large language model to return a json object, and users can set other format requirements based on their needs, not limited to json objects, etc.
[0041] In this embodiment, first, at least one target entity included in the to-be-processed text is recognized, then a candidate text is selected based on the to-be-processed text and the at least one target entity, and finally, the large language model performs text generalization processing based on the target control information for the at least one target entity, the to-be-processed text and the candidate text, to obtain multiple generalized texts corresponding to the to-be-processed text. In this way, a large number of generalized text targets are obtained based on a small amount of text in a real scenario, so that only a small amount of text in a real scenario needs to be collected during model training, and a large amount of text for training the model can be generalized, without the need to collect a large amount of text in a real scenario, reducing the difficulty of collecting text, improving the efficiency of obtaining text required for training the model, and thereby improving the model training efficiency.
[0042] In some embodiments, as shown in Figure 2 Before S110, the method further includes: S140, performing scene recognition on the to-be-processed text to identify whether the to-be-processed text belongs to a target scene.
[0043] The to-be-processed text can be subjected to scene recognition to identify whether the scene to which the to-be-processed text is directed belongs to a target scene. For the vehicle field, the target scene can include, for example, five scenes: Intelligent interaction experience: multi-modal interaction fusion, gesture control expansion, etc. Cabin environment control: automatic air conditioning adjustment, intelligent seat adjustment, etc. Information exchange and sharing inside and outside the vehicle: business trip scene, family sharing scene, etc. Vehicle safety and health monitoring: fatigue driving, drunk driving scene, etc. Vehicle customization scene: car karaoke, conference scene, etc. Of course, more scenes can be set for the vehicle field, and new scenes can be set for other fields. For example, for the online shopping field, the target scene can include the pre-sale communication scene and the after-sale scene. For example, for the customer service field, the target scene can include the problem consultation scene and the user suggestion scene. The present application is not limited.
[0044] Optionally, the to-be-processed text can be subjected to scene recognition by a neural network model, which can be, for example, a bert model or a scene recognition large model. The scene recognition large model can be a large language model.
[0045] When scene recognition is performed by a scene recognition large model, a scene prompt information can be constructed from the to-be-processed text, and then the scene prompt information is input into the scene recognition large model for scene recognition to identify the scene to which the to-be-processed text belongs, and further determine whether the scene to which the to-be-processed text belongs is included in the target scene, and then determine whether the to-be-processed text belongs to the target scene.
[0046] For example, the constructed scene prompt information (prompt) is: I hope you will play a car scene classifier next, which category does it belong to in [car scene, other category], directly output the category, no need to elaborate the reason, return in json format, for example {“type”: car scene}, the provided to-be-processed text is: ### Help me turn on the air conditioner and adjust the appropriate temperature, and adjust the music playing according to the current atmosphere ### Json information: { "type": "car scene" } Of course, as previously described, the constructed scene prompt information requires the scene recognition large model to return a json object, and the user can set other format requirements based on the needs, not limited to json objects and the like.
[0047] In some embodiments, the training process of the scene recognition large model can be: obtaining a training sample for a target scene; the training sample includes a sample text and a sample label of the sample text, the sample label indicating whether the sample text belongs to the target scene; based on the sample text and the sample label, the reference large language model is fine-tuned to obtain the fine-tuned reference large language model as the scene recognition large model.
[0048] Wherein, the sample text can be a text belonging to the target scene, and the corresponding sample label indicates that the sample text belongs to the target scene, for example, the sample label is 1, the sample text can be a text belonging to the target scene, and the corresponding sample label indicates that the sample text belongs to the target scene, for example, the sample label is 0.
[0049] The sample text can be input into the reference large language model (which can refer to an existing large language model that has not been fine-tuned), and the reference large language model can classify the sample text, identify whether the sample text belongs to the target scene, and obtain a prediction result indicating whether the sample text belongs to the target scene. Then, based on the difference between the prediction result and the sample label, a loss value is determined, and the reference large language model is fine-tuned based on the determined loss value to obtain a fine-tuned reference large language model as a scene recognition large model for scene recognition of the to-be-processed text.
[0050] Correspondingly, S110 includes: S111, if the to-be-processed text belongs to the target scene, performing entity recognition on the to-be-processed text to obtain at least one target entity included in the to-be-processed text.
[0051] In the case where the to-be-processed text belongs to the target scene, it means that the to-be-processed text is for a certain scene included in the target scene, and the to-be-processed text is not a daily conversation, and the to-be-processed text can be used to train the model. At this time, it is determined that the to-be-processed text needs to be generalized, and the to-be-processed text is identified to obtain at least one target entity included in the to-be-processed text, so as to perform text generalization based on the target entity.
[0052] In a case where the to-be-processed text does not belong to the target scenario, that is, the to-be-processed text is not for any one of the scenarios included in the target scenario, the to-be-processed text can be daily conversation language, and the to-be-processed text cannot be used for training the model. At this time, it is determined that the to-be-processed text does not need to be generalized, the to-be-processed text can be ignored, and a new to-be-processed text is reacquired to continue the scenario recognition on the new to-be-processed text.
[0053] For example, the text generalization process is as shown in Figure 3 First, the user voice is acquired, and then the user voice is recognized by speech recognition to obtain the to-be-processed text. Then, the scenario recognition large model is used for scenario recognition. In a case where the to-be-processed text belongs to the target scenario, candidate texts matching the to-be-processed text are selected from the preset knowledge base based on the to-be-processed text and the target entity recognized in the to-be-processed text. Finally, the text generalization is performed by using the candidate texts, the to-be-processed text, and the target control information for the target entity to obtain the generalized text.
[0054] In this embodiment, the effective to-be-processed text is obtained through scenario recognition, so that the multiple generalized texts obtained through generalization are also relatively accurate and effective, the effectiveness and accuracy of the obtained generalized texts are improved, the situation that the effectiveness and accuracy of the generalized texts obtained when the to-be-processed text is invalid are low is avoided, and the text generalization effect is improved.
[0055] In some embodiments, after S130, the method further includes: performing rule verification on the multiple generalized texts by using a preset rule; the preset rule refers to a rule required to be met by the text in the scenario to which the to-be-processed text belongs; and a target generalized text passing the rule verification is acquired.
[0056] The scenario to which the to-be-processed text belongs can be one of the target scenarios. Therefore, the preset rule can also include a rule required to be met by the text in the target scenario, and the preset rule indicates that the text is reasonable, actual, and accurate. For example, for the vehicle field, the preset rule can involve interfaces, instructions, rules, and the like related to the vehicle cabin field. Specifically, for example, the preset rule is that the air conditioner temperature is 5-30°C, and for another example, the preset rule is that the seat angle during driving is not more than 150 degrees.
[0057] The preset rule can be used to filter out unreasonable, actual, and inaccurate generalized texts, and the remaining actual, reasonable, and accurate generalized texts are obtained as the target generalized text. The target generalized text is accurate, effective, actual, and reasonable. Therefore, when the model is trained by using the target generalized text, the training effect is better.
[0058] In some embodiments, as shown in Figure 4 The updating process of the preset knowledge base includes: S210, assemble reference texts in different target scenes to obtain an assembled text.
[0059] In the case of multiple target scenes, a reference text is obtained for each target scene, and then the reference texts in different target scenes are combined to obtain a combined text as the assembled text.
[0060] For example, the target scene is intelligent interaction experience and cockpit environment control, a text control instruction is determined for intelligent interaction experience as a reference text, and a text control instruction is determined for cockpit environment control as a reference text. Then, the two reference texts are combined into a control instruction (which controls intelligent interaction experience and cockpit environment control), and the combined control instruction is used as the assembled text.
[0061] S220, performing text generalization processing on the assembled text based on the large language model to obtain an initial generalization text corresponding to the assembled text.
[0062] The prompt information can be constructed based on the assembled text, and then input into the large language model for text generalization processing to obtain the initial generalization text. There can be multiple initial generalization texts.
[0063] Of course, the prompt information constructed here can be similar to the aforementioned generalization prompt information. The prompt information here can not include the target control information and the selected candidate text.
[0064] S230, adjusting the control information of the entity in the initial generalization text to perform re-generalization processing on the initial generalization text to obtain a candidate generalization assembled text corresponding to the initial generalization text.
[0065] After obtaining the initial generalization text, the control information of at least one entity included in each initial generalization text can be adjusted to generalize the initial generalization text to obtain a candidate generalization assembled text.
[0066] Of course, for any initial generalization text, if the entity included therein is n, the control information of at least one entity is adjusted, and the control information of each entity can be adjusted once, then candidate generalization assembled texts can be obtained. When the control information of each entity can be adjusted m times, m candidate generalization assembled texts can be obtained S240, selecting a target generalization assembled text from the initial generalization text and the candidate generalization assembled text in response to user feedback information on the initial generalization text and the candidate generalization assembled text.
[0067] After obtaining the initial generalized text and the candidate generalized assembled text corresponding to the initial generalized text, the initial generalized text and the candidate generalized assembled text corresponding to the initial generalized text can be displayed to the user, so that the user can make feedback on the initial generalized text and the candidate generalized assembled text corresponding to the initial generalized text, and obtain feedback information. The user can make feedback after using the initial generalized text and the candidate generalized assembled text corresponding to the initial generalized text, or can make feedback directly after seeing the initial generalized text and the candidate generalized assembled text corresponding to the initial generalized text.
[0068] The feedback information is used to indicate that the user selects one or more texts from the initial generalized text and the candidate generalized assembled text corresponding to the initial generalized text, and then directly obtains the selected one or more texts indicated by the feedback information as the target generalized assembled text, or the feedback information is used to indicate that the user is satisfied with one or more texts in the initial generalized text, and then directly obtains the one or more texts with higher satisfaction indicated by the feedback information as the target generalized assembled text.
[0069] S250, adding the target generalized assembled text to the preset knowledge base.
[0070] The target generalized assembled text is added to the preset knowledge base to update the preset knowledge base.
[0071] For example, the updating process of the preset knowledge base is as shown in Figure 5 .
[0072] S501, assembling of the reference text; that is, assembling the reference text under different target scenarios.
[0073] S502, scenario generalization. The generalization processing is performed based on the assembled text obtained after the assembling, and the generalization processing can be realized by using a large language model.
[0074] S503, adjusting the control information; that is, adjusting the control information of the entity in the initial generalized text obtained after the generalization processing, so as to realize the generalization processing.
[0075] S504, outputting the generalized text after the generalization is completed; the outputted text includes the initial generalized text and the candidate generalized assembled text corresponding to the initial generalized text obtained after the first generalization processing; S505, feedback information of the user for the generalized text; obtaining the feedback information of the user for the initial generalized text and the candidate generalized assembled text corresponding to the initial generalized text; S506, selecting the target generalized assembled text based on the feedback information; S507, add a preset knowledge base; that is, add the target generalization assembly text to the preset knowledge base, thereby realizing the update of the preset knowledge base.
[0076] Exemplarily, the text generalization process in the embodiment is shown in Figure 6 Firstly, the user voice is obtained, the user voice is recognized through an ASR (Automatic Speech Recognition) module to obtain a to-be-processed text, and then the to-be-processed text is classified and processed through a scene recognition large model to identify whether the to-be-processed text belongs to a target scene.
[0077] In the case that the to-be-processed text belongs to the target scene, the to-be-processed text is subjected to target entity extraction to obtain at least one extracted target entity, then a candidate text is selected from a preset knowledge base based on the to-be-processed text recognized by the ASR module and the at least one target entity, and text generalization is performed based on the candidate text, the to-be-processed text and target control information for the target entity to obtain a generalized generalization text.
[0078] Finally, the accuracy of the generalization text is verified based on a preset rule to obtain a target generalization text that passes the verification, and the target generalization text is used for model training.
[0079] In the embodiment, the preset knowledge base is also updated, so that the data in the preset knowledge base is rich and accurate, so that the candidate text is more accurate when the candidate text is selected based on the preset knowledge base, and the generalization processing effect is better when the generalization processing is performed based on the candidate text, so that the obtained generalization text is more accurate and effective.
[0080] Referring to the accompanying Figure 7 , Figure 7 A structural block diagram of a text generalization device according to an embodiment of the present application is shown. The device 800 is used for an electronic device, and includes: The recognition module 810 is configured to recognize entities of the to-be-processed text to obtain at least one target entity included in the to-be-processed text. The selection module 820 is configured to select a candidate text matching the to-be-processed text from a plurality of texts included in a preset knowledge base based on the to-be-processed text and the at least one target entity. The generalization module 830 is configured to perform text generalization processing based on target control information for the at least one target entity, the to-be-processed text and the candidate text to obtain a plurality of generalization texts corresponding to the to-be-processed text.
[0081] Optionally, the recognition module 810 is further configured to perform scene recognition on the to-be-processed text to identify whether the to-be-processed text belongs to a target scene; and if the to-be-processed text belongs to the target scene, perform entity recognition on the to-be-processed text to obtain at least one target entity included in the to-be-processed text.
[0082] Optionally, the scene recognition process is implemented by a scene recognition large model; and the apparatus further includes a training module configured to obtain training samples for the target scene; the training samples include sample texts and sample labels of the sample texts, the sample labels indicating whether the sample texts belong to the target scene; and based on the sample texts and the sample labels, perform parameter fine-tuning on a reference large language model to obtain a parameter fine-tuned reference large language model as the scene recognition large model.
[0083] Optionally, the selection module 820 is further configured to perform feature embedding processing on the to-be-processed text and the at least one target entity to obtain embedding features corresponding to the to-be-processed text and embedding features corresponding to the at least one target entity; perform fusion on the embedding features corresponding to the to-be-processed text and the embedding features corresponding to the at least one target entity to obtain a fusion feature; and select a target number of texts from a preset knowledge base in descending order of similarity between the fusion feature and the texts, as candidate texts.
[0084] Optionally, the apparatus further includes a verification module configured to perform rule verification on the plurality of generalized texts by a preset rule; the preset rule is a rule required to be satisfied by texts in a scene to which the to-be-processed text belongs; and the target generalized text that passes the rule verification is obtained.
[0085] Optionally, the apparatus further includes an updating module configured to assemble reference texts under different target scenes to obtain assembled texts; perform text generalization processing on the assembled texts by a large language model to obtain initial generalized texts corresponding to the assembled texts; adjust control information for entities in the initial generalized texts to perform re-generalization processing on the initial generalized texts to obtain candidate generalized assembled texts corresponding to the initial generalized texts; select a target generalized assembled text from the initial generalized texts and the candidate generalized assembled texts in response to feedback information of a user on the initial generalized texts and the candidate generalized assembled texts; and add the target generalized assembled text to the preset knowledge base.
[0086] Optionally, the recognition module 810 is further configured to obtain a to-be-recognized speech; perform preprocessing on the to-be-recognized speech to obtain a target speech; the preprocessing includes at least one of de-noising processing, echo cancellation processing, and speech and environment separation processing; and perform speech-to-text generalization on the target speech to obtain the to-be-processed text.
[0087] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described device and module can refer to the corresponding process in the foregoing method embodiments, which will not be described here.
[0088] In addition, each function in each embodiment of the present application can be integrated into one processing module, or each module can exist physically independently, or two or more modules can be integrated into one module. The integrated module can be realized in the form of hardware or in the form of a software function module.
[0089] Please refer to Figure 8 which shows a structural block diagram of an electronic device provided by an embodiment of the present application. The electronic device 500 can be a smart phone, a tablet computer, an electronic book, a vehicle, or the like, which can run an application program. The electronic device 500 in the present application can include one or more of the following components: a processor 510, a memory 520, and one or more application programs. The one or more application programs can be stored in the memory 520 and configured to be executed by the one or more processors 510, and the one or more programs are configured to perform the method as described in the foregoing method embodiments.
[0090] The processor 510 can include one or more processing cores. The processor 510 connects various parts in the entire electronic device 500 by various interfaces and lines, performs various functions of the electronic device 500 and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 520, and calling data stored in the memory 520. Optionally, the processor 510 can be realized in the form of at least one of digital signal processing (DSP), field programmable gate array (FPGA), programmable logic array (PLA). The processor 510 can integrate a combination of one or several of central processing unit (CPU), graphics processing unit (GPU), and modem, etc. Among them, the CPU mainly processes operating systems, user interfaces, and application programs, etc.; the GPU is responsible for rendering and drawing display content; and the modem is used for processing wireless communication. It can be understood that the above-mentioned modem can also not be integrated into the processor 510, but be realized by a separate communication chip.
[0091] The memory 520 can include a Random Access Memory (RAM) and can also include a Read-Only Memory (ROM). The memory 520 can be used to store instructions, programs, codes, code sets, or instruction sets. The memory 520 can include a program storage area and a data storage area, where the program storage area can store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing each of the methods described below, and the like. The data storage area can also store data created by the electronic device 500 in use (such as a phonebook, audio / video data, chat log data), and the like.
[0092] In another aspect, the present application also provides a computer readable storage medium, which stores program codes, and the program codes can be invoked by a processor to execute the methods described in the above method embodiments.
[0093] The computer readable storage medium can be an electronic storage device such as a flash memory, an EEPROM (Electrically Erasable Programmable Read-Only Memory), an EPROM, a hard disk, or a ROM. Alternatively, the computer readable storage medium includes a non-transitory computer readable storage medium. The computer readable storage medium has a storage space for storing program codes for executing any of the method steps described above. These program codes can be read from or written to one or more computer program products. The program codes can be compressed in an appropriate form, for example.
[0094] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than limit them. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some technical features. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method of text generalization, the method comprising: The method comprises: entity recognition is performed on the to-be-processed text to obtain at least one target entity included in the to-be-processed text; based on the to-be-processed text and the at least one target entity, a candidate text matching the to-be-processed text is selected from a plurality of texts included in a preset knowledge base; based on the target control information for the at least one target entity, the to-be-processed text and the candidate text, text generalization processing is performed to obtain a plurality of generalization texts corresponding to the to-be-processed text.
2. The method of claim 1, wherein, Before the entity recognition of the to-be-processed text to obtain at least one target entity included in the to-be-processed text, the method further comprises: scene recognition is performed on the to-be-processed text to identify whether the to-be-processed text belongs to a target scene; the entity recognition of the to-be-processed text to obtain at least one target entity included in the to-be-processed text comprises: if the to-be-processed text belongs to the target scene, the entity recognition of the to-be-processed text to obtain at least one target entity included in the to-be-processed text.
3. The method of claim 2, wherein, The scene recognition process is realized by a scene recognition large model; before the scene recognition of the to-be-processed text to identify whether the to-be-processed text belongs to a target scene, the method further comprises: obtaining a training sample for the target scene; the training sample comprises a sample text and a sample label of the sample text, and the sample label indicates whether the sample text belongs to a target scene; based on the sample text and the sample label, a reference large language model is parameter fine-tuned to obtain a parameter fine-tuned reference large language model as the scene recognition large model.
4. The method of claim 1, wherein, The method further comprises: feature embedding processing is performed on the to-be-processed text and the at least one target entity to obtain embedding features corresponding to the to-be-processed text and embedding features corresponding to the at least one target entity; the embedding features corresponding to the to-be-processed text and the embedding features corresponding to the at least one target entity are fused to obtain a fusion feature; a target number of texts are selected from the preset knowledge base according to the similarity between the fusion feature from high to low as the candidate text.
5. The method of claim 1, wherein, After the generalization processing of the text based on the target control information for the at least one target entity, the to-be-processed text and the candidate text to obtain a plurality of generalization texts corresponding to the to-be-processed text, the method further comprises: the plurality of generalization texts are verified by a preset rule; the preset rule refers to a rule required to be met by a text in a scene to which the to-be-processed text belongs; obtaining a target generalization text verified by the rule.
6. The method of claim 1, wherein, The method further comprises: the reference texts under different target scenes are assembled to obtain an assembled text; text generalization processing is performed on the assembled text based on the assembled text by a large language model to obtain an initial generalization text corresponding to the assembled text; adjust control information for the entity in the initial generalized text to re-generalize the initial generalized text to obtain a candidate generalized assembled text corresponding to the initial generalized text; select a target generalized assembled text from the initial generalized text and the candidate generalized assembled text in response to feedback information of a user for the initial generalized text and the candidate generalized assembled text; add the target generalized assembled text to the preset knowledge base.
7. The method of claim 1, wherein, Before the entity recognition on the to-be-processed text to obtain at least one target entity included in the to-be-processed text, the method further comprises: acquire a to-be-recognized voice; perform preprocessing on the to-be-recognized voice to obtain a target voice; the preprocessing comprises at least one of denoising processing, echo cancellation processing, and voice and environment separation processing; perform voice-to-text generalization on the target voice to obtain the to-be-processed text.
8. A text generalization apparatus characterized by comprising: The apparatus comprises: an identification module configured to perform entity recognition on a to-be-processed text to obtain at least one target entity included in the to-be-processed text; a selection module configured to select a candidate text matching the to-be-processed text from a plurality of texts included in a preset knowledge base based on the to-be-processed text and the at least one target entity; a generalization module configured to perform text generalization based on target control information for the at least one target entity, the to-be-processed text, and the candidate text to obtain a plurality of generalized texts corresponding to the to-be-processed text.
9. An electronic device, comprising: comprise: one or more processors; a memory; one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, and the one or more application programs are configured to perform the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores processor-executable program code, and the program code is executed by the processor to cause the processor to perform the method according to any one of claims 1-7.