Text processing method, electronic device, and program product

CN122946483APending Publication Date: 2026-10-20MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510466534.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-14
Publication Date
2026-10-20

AI Technical Summary

Technical Problem

[0003]本申请提供一种文本处理方法、电子设备及程序产品,以解决数据标注的准确度低下的技术问题

Benefits of technology

[0009]在本实施例的文本处理方法中,通过第一文本对答复文本进行逻辑性评估,通过第二文本中与答复文本匹配的第三文本确定答复文本的第二评分,通过第二文本中与第一文本匹配的第四文本确定答复文本的第三评分,能够从多个不同角度对答复文本进行评分,提高了答复文本的评分准确性,进而提高了文本标注的准确性及客观性,从而提高了数据集的构建准确性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure FT_1
    Figure FT_1
  • Figure FT_2
    Figure FT_2
  • Figure FT_3
    Figure FT_3
Patent Text Reader

Abstract

This application relates to artificial intelligence, providing a text processing method, electronic device, and program product. The text processing method includes: generating a response text based on a first text and a second text matching the first text; performing a logical evaluation of the response text using a preset logical template based on the first text to obtain a first score for the response text; determining a third text matching the response text from the second text, and determining a second score for the response text based on the third text; determining a fourth text matching the first text from the second text, and determining a third score for the response text based on the fourth text; determining a label for the first text based on the second text, the response text, the first score, the second score, and the third score, and constructing a dataset based on the first text and its label. The above method can improve the accuracy of dataset construction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, specifically to a text processing method, electronic device, and program product. Background Technology

[0002] In the field of natural language processing, high-quality text is crucial for model training and optimization. Currently, text annotation is mainly done manually. However, with the continuous growth of data demand, the manpower required for this manual annotation method is increasing, and the accuracy of manual annotation is difficult to guarantee when dealing with large amounts of data. Summary of the Invention

[0003] This application provides a text processing method, electronic device, and program product to solve the technical problem of low accuracy in data annotation.

[0004] A first aspect of this application provides a text processing method, the method comprising: generating a response text based on a first text and a second text matching the first text; performing a logical evaluation on the response text using a preset logical template based on the first text to obtain a first score for the response text; determining a third text matching the response text from the second text, and determining a second score for the response text based on the third text; determining a fourth text matching the first text from the second text, and determining a third score for the response text based on the fourth text; determining a tag for the first text based on the second text, the response text, the first score, the second score, and the third score, and constructing a dataset based on the first text and the tag for the first text.

[0005] A second aspect of this application provides a text processing apparatus, comprising: a generation unit, configured to generate a response text based on a first text and a second text matching the first text; a determination unit, configured to perform a logical evaluation on the response text using a preset logical template based on the first text to obtain a first score for the response text; the determination unit is further configured to determine a third text matching the response text from the second text, and determine a second score for the response text based on the third text; the determination unit is further configured to determine a fourth text matching the first text from the second text, and determine a third score for the response text based on the fourth text; and a construction unit, configured to determine a tag for the first text based on the second text, the response text, the first score, the second score, and the third score, and construct a dataset based on the first text and the tags of the first text.

[0006] A third aspect of this application provides an electronic device, the electronic device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method provided in the first aspect above.

[0007] A fourth aspect of this application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the method provided in the first aspect above.

[0008] A fifth aspect of this application provides a computer program product, the computer program product including a computer program, which, when executed by a processor, implements the steps in the method provided in the first aspect above.

[0009] In the text processing method of this embodiment, the response text is logically evaluated using the first text, the second score of the response text is determined using the third text in the second text that matches the response text, and the third score of the response text is determined using the fourth text in the second text that matches the first text. This allows the response text to be scored from multiple different perspectives, improving the accuracy of the response text scoring, thereby improving the accuracy and objectivity of text annotation, and ultimately improving the accuracy of dataset construction. Attached Figure Description

[0010] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0011] Figure 1 This is a schematic diagram illustrating an application scenario of a text processing method provided in an embodiment of this application; Figure 2 This is a flowchart of a text processing method provided in an embodiment of this application; Figure 3 This is a flowchart illustrating the implementation of the response text generation method provided in this application embodiment; Figure 4 This is a schematic diagram of the framework of the comprehensive scoring determination method provided in the embodiments of this application; Figure 5 This is a functional block diagram of a text processing device provided in an embodiment of this application; Figure 6 This is a schematic diagram of the structure of an electronic device that implements a text processing method according to an embodiment of this application. Detailed Implementation

[0012] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0013] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Specifically, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0014] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. The terminology used in this application's specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. It should be understood that, unless otherwise stated, " / " in this application means "or". For example, A / B can mean A or B. "And / or" in this application is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. "At least one" refers to one or more. "More than one" refers to two or more. For example, at least one of a, b, or c can represent: a, b, c, a and b, a and c, b and c, and a, b, and c (seven cases).

[0015] Explanation of some terms: Large Language Models (LLMs) are language models with an extremely large parameter scale, reaching tens of billions or even more. Due to their massive size, the training process typically requires a large amount of data and computational resources. LLMs can usually generate high-quality natural language text, such as articles, dialogues, and poems. In addition, these models have excellent generalization capabilities and can demonstrate high efficiency on multiple natural language processing tasks, such as text classification, language translation, and question answering systems, through "few-shot learning" or "zero-shot learning."

[0016] Few-shot thinking chain: This is a model that, in a few-shot learning environment, mimics the step-by-step thinking process of humans when solving the first text and generates intermediate reasoning steps, enabling the model to demonstrate logical reasoning ability and thus solve more complex tasks.

[0017] Human preference learning, also known as human preference alignment, is a crucial stage in training large language models. Typically following supervised fine-tuning (SFT), aligning with human preferences can further enhance the user experience. Common human preference alignment algorithms (including RLHF, RLAIF, and Reject Sampling) all rely on a reward model or preference model representing human preferences. Current preference models primarily consider two aspects: helpfulness and harmlessness. By aligning with these two preference directions, researchers hope that the responses from large models will be both useful and harmless.

[0018] In the field of natural language processing, high-quality text is crucial for model training and optimization. Currently, text annotation is mainly done manually. However, with the continuous growth of data demand, the manpower required for this manual annotation method is increasing, and the accuracy of manual annotation is difficult to guarantee when dealing with large amounts of data.

[0019] In related technical solutions, question-and-answer text can typically be labeled using models. However, existing models are limited by their capabilities, making it impossible to accurately score the answer text within the question-and-answer text. Furthermore, existing models fail to align their scoring of answer text with human preferences, resulting in low-quality datasets.

[0020] Based on the aforementioned first text, embodiments of this application provide a text processing method. This method performs a logical evaluation of the response text using the first text, determines a second score for the response text using a third text that matches the response text in the second text, and determines a third score for the response text using a fourth text that matches the first text in the second text. This allows for scoring the response text from multiple different perspectives, improving the accuracy of the score and consequently enhancing the accuracy and objectivity of text annotation, thereby improving the accuracy of dataset construction. Furthermore, embodiments of this application score the response text from dimensions such as logicality, fidelity, and completeness, mimicking human scoring methods. This aligns the scoring with human preferences, thus contributing to the construction of a dataset aligned with human preferences.

[0021] Please see Figure 1 , Figure 1 This is a schematic diagram illustrating an application scenario of a text processing method provided in an embodiment of this application. The scenario may include various electronic devices 100 and servers 200.

[0022] Electronic device 100 can be a mobile phone, tablet computer, desktop computer, laptop computer, handheld computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, as well as cellular phone, personal digital assistant (PDA), augmented reality (AR) device, virtual reality (VR) device, artificial intelligence (AI) device, wearable device, in-vehicle device, smart home device and / or smart city device. This application embodiment does not impose any special limitations on the specific type of electronic device 100. The electronic device 100 may have a dataset construction client installed. Through the dataset construction client, it can access the model deployed on server 200, thereby calling the model to construct a dataset based on the first text input by the user.

[0023] Server 200 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms, but it is not limited to these. Server 200 can deploy models that can be used to generate response texts corresponding to the first text, score response texts from different perspectives, and construct datasets using the first text, response texts, first score, second score, and third score.

[0024] In some embodiments of this application, the text processing method can be executed by either the electronic device 100 or the server 200 alone, or by both the server 200 and the electronic device 100 together. When executed by either the electronic device 100 or the server 200 alone, the text processing procedure can be implemented independently by either device 100 or server 200. For example, on the electronic device 100, first text input by the user can be received, and a dataset can be constructed based on the first text using a locally deployed model. This process can also be executed by the server 200 alone. When executed jointly by the server 200 and the electronic device 100, the server 200 can train the model and then deploy the trained model to the electronic device 100, where the electronic device 100 implements the text processing procedure. Alternatively, some procedures can be implemented by the electronic device 100, and some by the server 200, with both working together to achieve the text processing procedure. Specific configurations can be made according to the actual application, and no specific limitations are made here.

[0025] In some embodiments of this application, when the text processing method provided in this application is executed by either server 200 or electronic device 100 alone, the above application scenario may also include only a single device, either server 200 or electronic device 100. Alternatively, server 200 and electronic device 100 may be considered as the same device. In practical applications, when the text processing method provided in this application is executed jointly by server 200 and electronic device 100, server 200 and electronic device 100 may also be the same device. That is, server 200 and electronic device 100 may be different functional modules of the same device, or a virtual device virtualized by the same physical device.

[0026] In one possible implementation, a user can provide first text through electronic device 100, and server 200 can use the text processing method of this application embodiment to construct a dataset and return it to electronic device 100 for presentation.

[0027] In this embodiment, the electronic device 100 and the server 200 can communicate directly or indirectly through one or more networks. This network can be a wired network or a wireless network; for example, the wireless network can be a mobile cellular network or a Wireless-Fidelity (Wi-Fi) network, and of course, it can be other possible networks. This embodiment does not limit this. It should be noted that... Figure 1 The examples shown are merely illustrative; in reality, the number of terminal devices and servers is unlimited and is not specifically limited in the embodiments of this application.

[0028] The text processing method provided in the embodiments of this application will be described below with reference to the accompanying drawings and the application scenarios described above. It should be noted that the application scenarios described above are only shown to facilitate understanding of the spirit and principle of the embodiments of this application, and the embodiments of this application are not limited in any way in this respect.

[0029] like Figure 2 The diagram shown is a flowchart of a text processing method provided in an embodiment of this application. The text processing method is applied in electronic devices, for example... Figure 1 Electronic device 100. Depending on different needs, the order of steps in this flowchart can be changed, and some steps can be omitted.

[0030] S201, Generate a response text based on the first text and the second text that matches the first text.

[0031] In at least one embodiment of this application, the first text may include text data from any field. For example, the first text may be text data from the financial services field, or text data from the healthcare field, etc.

[0032] In at least one embodiment of this application, the second text matches the first text. Before determining the second text, the electronic device can pre-create a database storing multiple preset texts and a first feature code corresponding to each preset text. During the process of determining the second text, the electronic device performs feature encoding on the first text to obtain a second feature code. The electronic device calculates the similarity between the second feature code and the multiple first feature codes, and selects the second text from the multiple preset texts based on the similarity between the second feature code and the multiple first feature codes.

[0033] In some embodiments, the electronic device can use a first model to perform feature encoding on multiple preset texts to obtain a first feature code corresponding to each preset text. The electronic device can also use the first model to perform feature encoding on the first text to obtain a second feature code. The first model can be a Roberta model, a Word2Vec model, a Transformer model, etc. This embodiment encodes both the preset texts and the first text using the same model, ensuring that the second feature code corresponding to the first text has the same dimension as the first feature code corresponding to the preset text.

[0034] In some embodiments, the similarity between the second feature code and the plurality of first feature codes can be calculated using the cosine similarity formula. The similarity between the second feature code and the plurality of first feature codes can also be calculated using other formulas, and this application does not limit this.

[0035] In some embodiments, the electronic device may select the M preset texts with the highest similarity between the second feature code and multiple first feature codes as the second text, where M can be an integer greater than or equal to 1, for example, M can be 50.

[0036] In other embodiments, the electronic device may select a preset text whose similarity to a first preset threshold is greater than or equal to the second text based on the similarity between the second feature code and a plurality of first feature codes.

[0037] In other embodiments, the electronic device may also select M preset texts as the second texts from preset texts with similarity greater than or equal to a first preset threshold, based on the similarity between the second feature code and multiple first feature codes.

[0038] This application embodiment uses the similarity between the second feature code and multiple first feature codes to determine the second text that matches the first text from multiple preset texts, thereby improving the accuracy of the second text.

[0039] In at least one embodiment of this application, during the process of generating response text by an electronic device, the text sequence obtained by concatenating the first text and the second text can be used as the input of a second model. The second model is then used to learn the relationship between the first text and the second text, thereby generating the response text corresponding to the first text.

[0040] In some embodiments, the second model can be a neural network model based on a cross-attention mechanism, such as the GPT4 model. The structure of the second model (e.g., the number of layers and neurons in the neural network) can be designed according to the training task requirements and the characteristics of the training sample data. The initial parameters of the second model (e.g., weights, biases, etc.) can be randomly generated or custom-set. During the training process of the second model, the electronic device can use the training samples to iteratively train the second model according to a preset loss function and optimization algorithm to optimize the initial parameters, thereby enabling the second model to have better text generation capabilities.

[0041] Please see Figure 3 , Figure 3 This is a flowchart illustrating the implementation of the response text generation method provided in an embodiment of this application. Figure 3 As shown, the electronic device generates a response text based on the first text and the second text that matches the first text, including steps S2011 to S2014, the specific steps of which are as follows.

[0042] S2011, concatenate the first text and the second text to obtain the text sequence.

[0043] In at least one embodiment of this application, an electronic device concatenates first text and second text based on a preset identifier to obtain a text sequence. The preset identifier can be used to distinguish between the first text and the second text, and can be a specified identifier, for example, the preset identifier may include the identifier Q and / or the identifier TEXT. In one example, the text sequence may be represented as: first text [TEXT] second text; in another example, the text sequence may be represented as: [Q] first text [TEXT] second text.

[0044] S2012, feature encoding is performed on the text sequence to obtain the first vector.

[0045] In at least one embodiment of this application, the electronic device can perform feature encoding on the text sequence through the encoding layer in the second model. Specifically, the electronic device encodes each word in the text sequence through the encoding layer to obtain a third feature code corresponding to each word. The electronic device concatenates the third feature codes corresponding to each word according to the order of each word in the text sequence to obtain a first vector. This embodiment improves the representation accuracy of the first vector by sequentially concatenating the third feature codes corresponding to each word according to the order of each word in the text sequence.

[0046] S2013, perform multi-head attention analysis on the first vector to obtain the second vector.

[0047] In at least one embodiment of this application, the second model further includes an attention layer, which comprises a multi-head attention mechanism and a feedforward neural network layer. The electronic device performs multi-head attention analysis on the first vector through the attention layer to obtain the second vector.

[0048] In some embodiments, the multi-head attention mechanism includes a query matrix, a key matrix, and a value matrix corresponding to each head. The electronic device calculates the query vector corresponding to each word using the query matrix corresponding to each head and the third feature encoding corresponding to each word in the first vector. It calculates the key vector corresponding to each word using the key matrix corresponding to each head and the third feature encoding corresponding to each word. It calculates the value vector corresponding to each word using the value matrix corresponding to each head and the third feature encoding corresponding to each word. Based on the query vector of the i-th word and the key vector of the j-th word, the electronic device calculates the relevance between the i-th word and the j-th word.

[0049] The electronic device normalizes the relevance between the i-th and j-th words to obtain their attention weights. Based on these attention weights, the electronic device performs a weighted summation operation on the value matrix of the j-th word to obtain the first output vector of the i-th word in each header.

[0050] The electronic device concatenates the first output vector of the i-th word in each head to obtain the second output vector of the i-th word. It then concatenates the second output vectors of all words in the text sequence to obtain the third output vector of the multi-head attention mechanism.

[0051] The electronic device performs feature transformation on the third output vector through a feedforward neural network layer to obtain a second vector. This feedforward neural network layer can include L1 linear transformation layers and L2 nonlinear activation functions, where L1 and L2 are determined by the training results of the second model. Taking an example with L1 = 2, L2 = 1, and the nonlinear activation function being ReLU, the second vector can be expressed as: W2RELU(W1X+b1)+b2, where W1 and W2 are the weight matrices in the linear transformation layers, and b1 and b2 are the bias vectors in the linear transformation layers.

[0052] This embodiment performs multi-head attention analysis on the first vector using a single attention layer, which can quickly obtain the semantic representation of the text sequence and improve the efficiency of obtaining the second vector.

[0053] In other embodiments, the second model may include multiple attention layers, each of which may include a multi-head attention mechanism and a feedforward neural network layer, with any two attention layers connected via residuals. The electronic device analyzes the input vector of the Kth attention layer through the Kth attention layer to obtain the fourth output vector of the feedforward neural network layer in the Kth attention layer. The method for obtaining the fourth output vector can refer to the method for obtaining the second vector in the above embodiments, and will not be repeated here.

[0054] The electronic device uses the residual connection between the Kth attention layer and the (K+1)th attention layer to perform bitwise addition on the fourth output vector of the Kth attention layer and the input vector of the Kth attention layer to obtain the input vector of the (K+1)th attention layer. The electronic device then performs multi-head attention analysis on the first vector until all attention layers have completed their attention analysis, thus obtaining the second vector.

[0055] This embodiment performs multi-head attention analysis on the first vector through multiple attention layers, which can extract deep semantic features of the text sequence, reduce the internal semantic deviation of the first text, and thus improve the accuracy of the second vector.

[0056] S2014, decode the second vector to obtain the response text.

[0057] In at least one embodiment of this application, the second model may further include a decoder. The electronic device predicts the second vector output by the attention layer through the decoder to obtain probability values ​​for multiple preset words. The electronic device uses the preset words with probability values ​​greater than a second preset threshold as the first word in the response text. The second preset threshold and the preset words can be set and adjusted according to actual needs.

[0058] The electronic device concatenates the second vector output from the attention layer with the feature encoding corresponding to the first word in the response text to obtain the second vector after the first update. The decoder then predicts the probability values ​​of several preset words. The electronic device selects the preset word with a probability value greater than a second preset threshold as the second word in the response text. This process continues until the response text meets preset conditions. The preset conditions can be set as follows: the text length of the response text reaches a third preset threshold. The third preset threshold can be set and adjusted according to actual needs. Alternatively, the preset conditions can be set as follows: the preset word with a probability value greater than the second preset threshold is a specified character. For example, the specified character could be... <end>.

[0059] For example, the electronic device predicts the first word in the response text by using the second vector output by the attention layer, where the probability value is greater than a second preset threshold. For instance, the first word in the response text might include word 1 and word 2. Further, the electronic device concatenates the second vector output by the attention layer with the feature encoding corresponding to the first word in the response text. The resulting updated second vector can include: a concatenated vector of the second vector output by the attention layer and the feature encoding corresponding to word 1 (hereinafter referred to as second vector A), and a concatenated vector of the second vector output by the attention layer and the feature encoding corresponding to word 2 (hereinafter referred to as second vector B). Further, the electronic device predicts word 3 and word 4 using the decoder for second vector A, and predicts word 5 and word 6 using second vector B. If the response text meets the preset conditions at this point, four response texts can be obtained: word 1-word 3, word 1-word 4, word 2-word 5, and word 2-word 6.

[0060] In this embodiment, the second vector is decoded by a decoder to accurately obtain the probability value of the preset words. Then, the number of response texts can be controlled by the second preset threshold, thereby obtaining diverse response texts.

[0061] This embodiment of the application obtains a complete first vector by feature encoding the text sequence obtained by concatenating the first and second texts. By performing multi-head attention analysis on the first vector, deep semantic features of the text sequence can be extracted, reducing the internal semantic shift of the first text and improving the accuracy of the second vector. Furthermore, by decoding the second vector, a response text that matches both the first and second texts can be obtained.

[0062] S202, Based on the first text, the response text is logically evaluated using a preset logic template to obtain the first score of the response text.

[0063] In at least one embodiment of this application, the first score may represent the quantitative result of the response text in the logical dimension, wherein the information measured in the logical dimension may include: whether the response text is related to the first text, whether there are contradictions in different parts of the response text, whether the response text conforms to common sense or known facts, etc.

[0064] In at least one embodiment of this application, the electronic device performs a logical evaluation of the response text based on the first text using a preset logical template to obtain a first score for the response text, including: generating a prompt text based on the first text and the response text; extracting keywords and sentences containing keywords from the prompt text; connecting multiple sentences based on the preset logical template to obtain a thought chain; and determining the first score based on the semantic coherence of adjacent sentence pairs in the thought chain.

[0065] In some embodiments, the electronic device generates a prompt text Prompt1 based on a preset template, a first text, and a response text. Specifically, the electronic device can fill the first text and the response text into the preset template to obtain the prompt text Prompt1. The prompt text Prompt1 can be used to instruct a third model to perform a logical evaluation of the response text. The third model can be a GPT4 model, a Qwen2-72B model, etc., and the training method of the third model is not specifically limited in this application.

[0066] For example, the prompt text Prompt1 could be: "You are an expert in evaluating text quality. Please evaluate the logical consistency of the response text with the first text. Specific evaluation points are as follows:" 1. Whether the response text is related to the first text.

[0067] 2. Are the different parts of the response text logically consistent?

[0068] 3. Does the response text conform to common sense or known facts?

[0069] You must strictly adhere to the following format when scoring your responses, using a scale of 1 to 5. Ensure that only the logical coherence of the response text is evaluated during the assessment process.

[0070] Example as follows: Response Text 1 Response Text 2 … Reply text N Please output the results in the following format: First text: {question} Reply text: {answer} Rating: {First Rating}. The Prompt2 text can also take other forms; this application makes no restrictions on this.

[0071] In some embodiments, the electronic device can extract keywords from the prompt text Prompt1. These keywords may include logical connectors, such as "because," "therefore," "if," "then," "however," "and," and "or." Keywords may also include words representing entity information. For example, if the prompt text Prompt1 includes "Apples are red, therefore they are sweet, and everyone loves to eat them," then the words representing entity information may include "apple," "red," and "sweet," and the logical connector includes "therefore." Therefore, the keywords may include "apple," "red," "sweet," and "so." The electronic device can extract sentences containing these keywords from the prompt text Prompt1. Continuing with the above example, the sentences extracted from the prompt text Prompt1 may include "Apples are red" and "Therefore they are sweet."

[0072] In some embodiments, a preset logic template can be constructed based on example samples, which may include text with explicit logical relationships and structures. The electronic device can determine the linguistic expressions of various logical relationships from the example samples, where these relationships may include, but are not limited to, causal relationships, parallel relationships, and adversative relationships. Furthermore, the electronic device can extract a preset logic template from the linguistic expressions of various logical relationships. For example, the preset logic template corresponding to a causal relationship could be: "Cause event → Leads to → Result event," and the preset logic template corresponding to an adversative relationship could be: "Previous viewpoint → However → Opposite viewpoint." Preset logic templates may differ across different fields. For example, the preset logic template for the financial field could be: "Investment needs survey → Target fundamental analysis → Tool quantitative evaluation," and the preset logic template for the medical field could be: "Chief complaint and medical history → Physical examination → Auxiliary examinations." Each field may have multiple preset logic templates; for example, the preset logic template for the financial field may also include: "Abnormal stock price fluctuations → Investment needs survey → Target fundamental analysis."

[0073] In some embodiments, the electronic device connects multiple statements based on a preset logic template to obtain a thought chain. The thought chain represents the processing order of statements containing keywords in the prompt text Prompt1.

[0074] In some embodiments, the electronic device determines a first score based on the similarity of adjacent sentence pairs in a thought chain. The first score is proportional to the similarity of adjacent sentence pairs. For example, for the thought chain "Little A ate a lot of chocolate, so he might have a toothache," the first score is higher because the similarity between "Little A ate a lot of chocolate" and "so he might have a toothache" is higher. Similarly, for the thought chain "Apples are red, so the moon is round," the first score is lower because the similarity between "Apples are red" and "so the moon is round" is lower.

[0075] This application embodiment uses a preset logic template to connect sentences containing keywords in the prompt text Prompt1, which can reasonably construct the thought chain corresponding to each response text. Then, through the adjacent sentence pairs in the thought chain, the quantitative result of the response text in terms of logic can be accurately determined, thus improving the accuracy of the first score.

[0076] In at least one embodiment of this application, adjacent sentence pairs include a first sentence and a second sentence. An electronic device determines a first score based on adjacent sentence pairs in a thought chain, including: identifying a third word element from a plurality of second word elements in the second sentence whose similarity to each first word element in the first sentence is greater than a first similarity threshold; calculating a first similarity of the adjacent sentence pair based on each first word element and the third word element; identifying a fourth word element from a plurality of first word elements in the first sentence whose similarity to each second word element in the second sentence is greater than a second similarity threshold; calculating a second similarity of the adjacent sentence pair based on each second word element and the fourth word element; and determining a first score based on the first similarity and the second similarity. The first and second similarity thresholds can be set and adjusted according to actual needs, and this application does not impose any restrictions on them.

[0077] In some embodiments, during the process of determining the third term, the electronic device performs feature encoding on multiple first terms to obtain a fourth feature code corresponding to each first term, performs feature encoding on multiple second terms to obtain a fifth feature code corresponding to each second term, calculates the similarity between each fourth feature code and multiple fifth feature codes, and determines the second term corresponding to the fifth feature code with a similarity greater than a first similarity threshold as the third term.

[0078] In some embodiments, during the calculation of the first similarity, the electronic device calculates the first similarity based on the similarity between each first word and a third word. The formula for calculating the first similarity can be expressed as follows: ,in, This can represent the first similarity. It can represent the first The first word element and the first Similarity between third-order words It can indicate the number of the first word in the first sentence.

[0079] In some embodiments, the electronic device determines the fourth word in a similar way to determine the third word, and the electronic device calculates the second similarity in a similar way to calculate the first similarity; these will not be repeated here.

[0080] In some embodiments, the electronic device calculates a weighted sum of the first similarity and the second similarity of all adjacent sentence pairs in the thought chain to obtain a first score.

[0081] This application's embodiments calculate the first similarity of adjacent sentence pairs using each first word element and its corresponding third word element, and calculate the second similarity using each second word element and its corresponding fourth word element. This avoids the inability to accurately quantify the first and second similarities due to different word orders, thus improving the accuracy of the first and second similarities. Furthermore, by combining the first and second similarities to determine the first score, adjacent sentence pairs can be evaluated from different dimensions, further improving the accuracy of the first score. Moreover, since the first score is based on a logical dimension, mimicking human scoring methods, it aligns with human preferences.

[0082] S203, determine a third text from the second text that matches the response text, and determine a second score for the response text based on the third text.

[0083] In at least one embodiment of this application, during the process of determining the third text, the electronic device divides the response text to obtain multiple sub-response texts corresponding to the response text, and determines a second text whose similarity to each sub-response text is greater than or equal to a third similarity threshold as the third text corresponding to each sub-response text. The third similarity threshold can be set and adjusted according to actual needs.

[0084] In some embodiments, the electronic device may divide the response text into multiple sub-response texts based on preset symbols, wherein the preset symbols may include, but are not limited to, commas, periods, exclamation marks, and question marks.

[0085] In some embodiments, the electronic device calculates the similarity between each sub-response text and a plurality of second texts, and uses the second texts whose similarity to each sub-response text is greater than or equal to a third similarity threshold as the third text corresponding to each sub-response text.

[0086] This application embodiment divides the response text and determines the third text from the second text based on multiple sub-response texts in the response text. This allows for a more detailed analysis of the semantics of each sub-response text in the response text, thereby improving the accuracy of the third text.

[0087] In at least one embodiment of this application, the second score can represent a quantitative result of the response text's fidelity to the second text. In determining the second score of the response text, the electronic device determines the score of each sub-response text based on the similarity between each sub-response text and the corresponding third text, and calculates the second score based on the score of each sub-response text, the number of sub-response texts, and a preset multiplier.

[0088] In some embodiments, the electronic device may set a fourth preset threshold and a fifth preset threshold, wherein the fourth preset threshold is greater than the fifth preset threshold. The electronic device may also set a first preset score, a second preset score, and a third preset score, wherein the first preset score is greater than the second preset score, and the second preset score is greater than the third preset score. If the similarity between the t-th sub-response text and the corresponding third text is greater than or equal to the fourth preset threshold, the electronic device determines the score of the t-th sub-response text as the first preset score. If the similarity between the t-th sub-response text and the corresponding third text is less than the fourth preset threshold, and the similarity between the t-th sub-response text and the corresponding third text is greater than the fifth preset threshold, the electronic device determines the score of the t-th sub-response text as the second preset score. If the similarity between the t-th sub-response text and the corresponding third text is less than or equal to the fifth preset threshold, the electronic device determines the score of the t-th sub-response text as the third preset score.

[0089] In some embodiments, the formula for calculating the second score can be expressed as: ,in, It can represent the second rating. This can represent the score of the t-th sub-response text. It can represent the number of sub-response texts in a response text. It can represent a preset multiplier, which can be set and adjusted according to actual needs.

[0090] This application embodiment determines the score of each sub-response text by comparing its similarity to the corresponding third text. Then, it calculates the second score of the response text based on the scores of each sub-response text, ensuring that each sub-response text participates in the scoring and thus improving the accuracy of the second score.

[0091] In other embodiments, the electronic device generates a prompt text Prompt2 based on the response text and all third texts, and evaluates the level corresponding to the response text using a third model based on the prompt text Prompt2, and determines a second score for the response text based on the level corresponding to the response text. Different levels correspond to different second scores; for example, the second score for the level "fully supports" is 1, the second score for the level "partially supports" is 0.5, and the second score for the level "does not support" is 0. For example, the prompt text Prompt2 could be: "You are an expert in evaluating text quality. Your task is to carefully evaluate whether these fragments support the statement. Please use the following ratings to generate your evaluation:" Full support: Almost all information in the statement is extracted from the fragment.

[0092] Partial support: More than half of the content in the statement is supported by the fragment, but a small portion of the content is not in the fragment or is inconsistent with the fragment.

[0093] Not supported: Statements that are largely unrelated to the passage, or where most key points in the statement are inconsistent with the passage.

[0094] Ensure that you do not use any information or knowledge outside of the provided snippet; only check if the snippet supports the statement. You must provide the analysis before providing the rating.

[0095] Example as follows: Response Text 1 Response Text 2 … Reply text N Please rate the following statement according to the scoring rules and the example above: Statement: {statement} Segment list: {Third Text 1} {Third Text 2} {Third Text K} Analysis: "{Level}". The prompt text Prompt2 can also take other forms, and this application makes no restrictions on this.

[0096] This embodiment can quickly quantify the fidelity of the response text to the second text through the third model. At the same time, since the second score scores the response text from the fidelity dimension by imitating human scoring methods, the second score can be aligned with human preferences.

[0097] S204, determine a fourth text from the second text that matches the first text, and determine a third score for the response text based on the fourth text.

[0098] In at least one embodiment of this application, when the length of the second text is long, the large language model may easily overlook some information in the second text. To solve the above problem, in the process of determining the fourth text, the electronic device divides the second text into multiple fifth texts, and selects the fourth text from the multiple fifth texts based on the similarity between the first text and each fifth text. The length of each fifth text is less than or equal to a preset length, which can be set and adjusted according to actual needs. For example, the preset length can be set to 2048.

[0099] In some embodiments, the electronic device can select a fifth text whose similarity to each fifth text is greater than a sixth preset threshold as the fourth text, based on the similarity between the first text and each fifth text. For example, the first text is "Where was this performance held?", and the second text is "On October 1, 2023, a performance was held at KK Plaza. Xiaoming gave a speech at this performance." By segmenting the second text, multiple fifth texts can be obtained, including: "October 1, 2023", "A performance was held at KK Plaza", and "Xiaoming gave a speech at this performance". The electronic device calculates the similarity between the first text and each fifth text. Since the fifth text "A performance was held at KK Plaza" has a similarity to the first text "Where was this performance held?" greater than the sixth preset threshold, the fifth text "A performance was held at KK Plaza" is determined as the fourth text.

[0100] In at least one embodiment of this application, the third score can represent the quantitative result of the response text in the dimension of completeness. In determining the third score of the response text, the electronic device extracts key information from the fourth text and determines the third score based on a first quantity of key information in the fourth text and a second quantity of key information in the response text.

[0101] In some embodiments, the electronic device can extract key information from a fourth text using a recurrent neural network. Specifically, the electronic device performs feature encoding on the fourth text to obtain a sixth feature code, and processes the sixth feature code through a hidden layer in the recurrent neural network to obtain a seventh feature code. The seventh feature code is then mapped through a fully connected layer in the recurrent neural network to obtain the key information. This embodiment analyzes the fourth text using a recurrent neural network, which can adaptively focus on different parts of the fourth text, thereby accurately extracting key information.

[0102] In some embodiments, the first quantity may represent the total number of key information items in the fourth text. For example, the key information items in the fourth text include: key information item 1 to key information item 8. If the fourth text includes key information item 1 to key information item 8, the first quantity is determined to be 8.

[0103] In some embodiments, during the process of determining the second quantity, the electronic device calculates the semantic similarity between each key piece of information and the response text, and identifies key pieces of information with a semantic similarity greater than a seventh preset threshold as target key pieces of information. The electronic device determines the total number of target key pieces of information as the second quantity.

[0104] In some embodiments, the electronic device determines a third score based on a first quantity of key information in the fourth text, a second quantity of key information in the response text, and a preset multiple. The formula for calculating the third score can be expressed as: ,in, It can represent the third rating. This can indicate the first number of key information items in the fourth text. This can indicate the second number of key information items in the response text. It can represent a preset multiple.

[0105] In other embodiments, a prompt text Prompt3 is generated based on the fourth text and the response text, and a third score is evaluated on the response text using a third model based on Prompt3. For example, Prompt3 could be: "You are an expert in evaluating text quality. Your task is to evaluate the completeness of the response text based on the given information, i.e., whether the response text contains key information highly relevant to the first text. You need to score the response text strictly according to the following format, with a score range of 1 to 5."

[0106] Example as follows: Response Text 1 Response Text 2 … Reply text N Please refer to the scoring rules and the above example to score your response text: First text: {question} List of related information: {Fourth Text 1} {Fourth Text 2} {Fourth Text K} Reply text: {answer} Analysis: "{Third Rating}". The prompt text Prompt3 can also take other forms, and this application does not impose any restrictions on it.

[0107] This embodiment can quickly quantify the response text in terms of completeness through the third model. At the same time, since the third scoring is based on human scoring methods to score the response text in terms of completeness, it can align with human preferences.

[0108] S205, based on the second text, the response text, the first rating, the second rating, and the third rating, determine the label of the first text, and construct a dataset based on the first text and the label of the first text.

[0109] In at least one embodiment of this application, during the process of determining the tag of the first text, the electronic device determines the comprehensive score of the response text based on the first score, the second score, and the third score, and determines the comprehensive score of the second text, the response text, and the response text as the tag of the first text.

[0110] In some embodiments, the electronic device may calculate a weighted sum of a first score, a second score, and a third score to obtain a comprehensive score. In other embodiments, the electronic device may also calculate the product of the first score, the second score, and the third score to obtain a comprehensive score. This application does not limit the method for determining the comprehensive score.

[0111] This application embodiment improves the accuracy of the comprehensive score by scoring the response text from multiple perspectives, thereby improving the accuracy and objectivity of the first text's label and ultimately enhancing the accuracy and objectivity of the dataset.

[0112] In at least one embodiment of this application, the electronic device constructs a dataset by using a first text as sample text and a second text, a response text, and a comprehensive score of the response text as labels for the first text.

[0113] In the text processing method of this embodiment, the response text is logically evaluated using the first text, the second score of the response text is determined using the third text in the second text that matches the response text, and the third score of the response text is determined using the fourth text in the second text that matches the first text. This allows the response text to be scored from multiple different perspectives, improving the accuracy of the response text scoring, thereby improving the accuracy and objectivity of text annotation, and ultimately improving the accuracy of dataset construction.

[0114] like Figure 4 The diagram shown is a schematic representation of the framework of the comprehensive scoring determination method provided in an embodiment of this application. Figure 4 In this process, based on the similarity between the second feature code corresponding to the first text and the first feature codes corresponding to multiple preset texts in the database, M text fragments (e.g., the second text in step S201) are selected from the multiple preset texts. The electronic device inputs the title and the M text fragments into a large language model (e.g., the second model in step S201) to obtain N response texts.

[0115] The electronic device inputs the first text and N response texts into the evaluation model (e.g., the third model in steps S202 to S204), and performs a logical evaluation on each response text through the evaluation model to obtain a logical score (e.g., the first score in step S202).

[0116] The electronic device divides each response text into multiple sub-response texts based on preset symbols. For example, dividing response text 1 yields Q sub-response texts. Based on the similarity between each sub-response text and M text segments, the electronic device selects K text segments (e.g., the third text in step S203) that are most similar to each sub-response text from the M text segments. The electronic device inputs the multiple sub-response texts and the K text segments most similar to each sub-response text into an evaluation model (e.g., the third model in steps S202 to S204), and uses the evaluation model to score the fidelity of the response text, obtaining a fidelity score (e.g., the second score in step S203).

[0117] The electronic device divides each of the M text segments into P coarse-grained text segments based on a preset length, resulting in P coarse-grained text segments (e.g., the multiple fifth texts in step S204). The electronic device inputs the first text and the P coarse-grained text segments into an evaluation model (e.g., the third model in steps S202 to S204), and extracts P related information segments (e.g., the fourth text in step S204) from the P coarse-grained text segments. The electronic device merges the P related information segments and inputs the merged information and the response text into the evaluation model (e.g., the third model in steps S202 to S204), and scores the response text for completeness using the evaluation model, obtaining a completeness score (e.g., the third score in step S204).

[0118] The electronic device performs a weighted sum of the logical reasoning score, fidelity score, and completeness score to obtain a comprehensive score for the response text.

[0119] This application embodiment improves the accuracy of the comprehensive score by scoring the response text from multiple perspectives. At the same time, by scoring the response text from the dimensions of logic, fidelity and completeness, just like human scoring, the comprehensive score can be aligned with human preferences.

[0120] like Figure 5 The diagram shown is a functional block diagram of a text processing device provided in an embodiment of this application. The text processing device 51 includes a generation unit 510, a determination unit 511, and a construction unit 512. The module / unit referred to in this application refers to a module / unit that can be processed by a processor (e.g., ...). Figure 6 A series of computer-readable instruction segments acquired by the processor 1101 shown, and capable of performing a fixed function, which are stored in memory (e.g., a processor 1101) and are stored in memory (e.g., a processor 1101) to perform a fixed function. Figure 6 In the memory 1102 shown.

[0121] In one embodiment, the generation unit 510 is used to generate a response text based on a first text and a second text matching the first text; the determination unit 511 is used to perform a logical evaluation of the response text based on the first text using a preset logical template to obtain a first score for the response text; the determination unit 511 is also used to determine a third text matching the response text from the second text, and to determine a second score for the response text based on the third text; the determination unit 511 is also used to determine a fourth text matching the first text from the second text, and to determine a third score for the response text based on the fourth text; the construction unit 512 is used to determine the label of the first text based on the second text, the response text, the first score, the second score, and the third score, and to construct a dataset based on the first text and the label of the first text.

[0122] In one embodiment, the generation unit 510 is specifically used for: concatenating the first text and the second text to obtain a text sequence; performing feature encoding on the text sequence to obtain a first vector; performing multi-head attention analysis on the first vector to obtain a second vector; and decoding the second vector to obtain a response text.

[0123] In one embodiment, the determining unit 511 is further configured to: generate prompt text based on the first text and the response text; extract keywords and sentences containing keywords from the prompt text; connect multiple sentences based on a preset logic template to obtain a thought chain; and determine a first score based on adjacent sentence pairs in the thought chain.

[0124] In one embodiment, the adjacent statement pair includes a first statement and a second statement. The determining unit 511 is further configured to: determine a second word element from a plurality of second word elements in the second statement whose similarity to each first word element in the first statement is greater than a first similarity threshold as a third word element; calculate a first similarity of the adjacent statement pair based on each first word element and the third word element; determine a first word element from a plurality of first word elements in the first statement whose similarity to each second word element in the second statement is greater than a second similarity threshold as a fourth word element; calculate a second similarity of the adjacent statement pair based on each second word element and the fourth word element; and determine a first score based on the first similarity and the second similarity.

[0125] In one embodiment, the determining unit 511 is further configured to: divide the response text to obtain multiple sub-response texts corresponding to the response text; and determine a second text whose similarity to each sub-response text is greater than or equal to a third similarity threshold, as the third text corresponding to each sub-response text.

[0126] In one embodiment, the determining unit 511 is further configured to: determine the score of each sub-response text based on the similarity between each sub-response text and the third text corresponding to each sub-response text; and calculate a second score based on the score of each sub-response text, the number of multiple sub-response texts, and a preset multiple.

[0127] In one embodiment, the determining unit 511 is further configured to: divide the second text to obtain a plurality of fifth texts, wherein the text length of each fifth text is less than or equal to a preset length; and select a fourth text from the plurality of fifth texts based on the similarity between the first text and each fifth text.

[0128] In one embodiment, the determining unit 511 is further configured to: extract key information from the fourth text; and determine a third score based on a first quantity of key information in the fourth text and a second quantity of key information in the response text.

[0129] In one embodiment, the construction unit 512 is specifically used to: determine a comprehensive score of the response text based on the first score, the second score, and the third score; and determine the comprehensive score of the second text, the response text, and the response text as a tag of the first text.

[0130] In several embodiments of this application, the response text is logically evaluated using a first text, a second score is determined using a third text in the second text that matches the response text, and a third score is determined using a fourth text in the second text that matches the first text. This allows the response text to be scored from multiple different perspectives, improving the accuracy of the response text scoring, thereby improving the accuracy and objectivity of the text annotation, and ultimately improving the accuracy of the dataset construction.

[0131] Figure 6 This is a schematic diagram of the structure of an electronic device implementing the text processing method provided in an embodiment of this application. Optionally, Figure 6 The electronic device 100 shown is used to perform Figure 2 , Figure 3 and Figure 4 The method shown.

[0132] The electronic device 100 includes at least one processor 1101, a memory 1102, and at least one network interface 1103.

[0133] Processor 1101 may be, for example, a general-purpose central processing unit (CPU), a network processor (NP), a graphics processing unit (GPU), a neural-network processing unit (NPU), a data processing unit (DPU), a microprocessor, or one or more integrated circuits for implementing the embodiments of this application. For example, processor 1101 may include an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. A PLD may be, for example, a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0134] Memory 1102 may be, for example, read-only memory (ROM) or other types of static storage devices capable of storing static information and instructions; random access memory (RAM) or other types of dynamic storage devices capable of storing information and instructions; electrically erasable programmable read-only memory (EEPROM); compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed discs, laser discs, optical discs, digital universal discs, Blu-ray discs, etc.); magnetic disk storage media or other magnetic storage devices; or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto. Optionally, memory 1102 exists independently and is connected to processor 1101 via internal connection 1104. Alternatively, memory 1102 and processor 1101 may be integrated together.

[0135] Network interface 1103 uses any transceiver-like device for communicating with other devices or communication networks. Network interface 1103 includes at least one of a wired network interface or a wireless network interface. The wired network interface is, for example, an Ethernet interface. The Ethernet interface is, for example, an optical interface, an electrical interface, or a combination thereof. The wireless network interface is, for example, a wireless local area network (WLAN) interface, a cellular network interface, or a combination thereof.

[0136] In some embodiments, processor 1101 includes one or more CPUs, such as Figure 6 CPU0 and CPU1 are shown in the diagram.

[0137] In some embodiments, the electronic device 100 may optionally include a plurality of processors, such as Figure 6 The processors 1101 and 1105 shown are illustrated. Each of these processors is, for example, a single-core processor (CPU) or a multi-core processor (CPU). Here, "processor" may optionally refer to one or more devices, circuits, and / or processing cores used to process data (such as computer program instructions).

[0138] In some embodiments, the electronic device 100 further includes an internal connection 1104. The processor 1101, memory 1102, and at least one network interface 1103 are connected via the internal connection 1104. The internal connection 1104 includes pathways for transmitting information between the aforementioned components. Optionally, the internal connection 1104 is a single board or a bus. Optionally, the internal connection 1104 may be divided into an address bus, a data bus, a control bus, etc.

[0139] In some embodiments, the electronic device 100 further includes an input / output interface 1106. The input / output interface 1106 is connected to the internal connection 1104.

[0140] Optionally, the processor 1101 implements the method in the above embodiments by reading the program code 1107 stored in the memory 1102, or the processor 1101 implements the method in the above embodiments by internally stored program code. When the processor 1101 implements the method in the above embodiments by reading the program code 1107 stored in the memory 1102, the memory 1102 stores program code that implements the method provided in the embodiments of this application.

[0141] For more details on how processor 1101 implements the above functions, please refer to the descriptions in the previous method embodiments, which will not be repeated here.

[0142] This embodiment also provides a computer storage medium storing computer instructions. When the computer instructions are executed on an electronic device, the electronic device performs the aforementioned method steps to implement the text processing method in the above embodiment.

[0143] This embodiment also provides a computer program product that, when run on an electronic device, causes the electronic device to perform the aforementioned related steps to implement the text processing method in the above embodiment.

[0144] In addition, embodiments of this application also provide an apparatus, which may specifically be a chip, component, or module. The apparatus may include a connected processor and a memory; wherein the memory is used to store computer execution instructions, and when the apparatus is running, the processor may execute the computer execution instructions stored in the memory to cause the chip to execute the text processing methods in the above-described method embodiments.

[0145] In this embodiment, the electronic device, computer storage medium, computer program product or chip are all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding method provided above, and will not be repeated here.

[0146] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0147] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0148] The unit described as a separate component may or may not be physically separate. The component shown as a unit can be one physical unit or multiple physical units, that is, it can be located in one place or distributed in multiple different places. Some or all of the units can be selected to achieve the purpose of the solution in this embodiment according to actual needs.

[0149] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0150] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially or in other words, the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0151] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.< / end>

Claims

1. A text processing method, characterized in that, The method includes: Generate a response text based on the first text and the second text that matches the first text; Based on the first text, the response text is logically evaluated using a preset logic template to obtain a first score for the response text; Determine a third text from the second text that matches the response text, and determine a second score for the response text based on the third text; Determine a fourth text from the second text that matches the first text, and determine a third score for the response text based on the fourth text; Based on the second text, the response text, the first rating, the second rating, and the third rating, the label of the first text is determined, and a dataset is constructed based on the first text and the label of the first text.

2. The text processing method according to claim 1, characterized in that, The step of generating a response text based on the first text and a second text matching the first text includes: By concatenating the first text and the second text, a text sequence is obtained; The text sequence is feature-encoded to obtain a first vector; Perform multi-head attention analysis on the first vector to obtain the second vector; The second vector is decoded to obtain the response text.

3. The text processing method according to claim 1, characterized in that, The step of performing a logical evaluation of the response text based on the first text using a preset logical template to obtain a first score for the response text includes: Generate a prompt text based on the first text and the response text; Extract keywords and sentences containing the keywords from the prompt text; Based on a preset logic template, multiple statements are connected to obtain a thought chain; The first score is determined based on adjacent statement pairs in the thought chain.

4. The text processing method according to claim 3, characterized in that, The adjacent statement pair includes a first statement and a second statement. Determining the first score based on the adjacent statement pairs in the thought chain includes: From the multiple second word elements of the second statement, the second word element whose similarity to each first word element in the first statement is greater than the first similarity threshold is determined as the third word element; Based on each first word element and the third word element, calculate the first similarity of the adjacent sentence pairs; From the multiple first word elements of the first statement, the first word element whose similarity to each second word element in the second statement is greater than the second similarity threshold is determined as the fourth word element; Based on each second word element and the fourth word element, the second similarity of the adjacent sentence pairs is calculated; The first score is determined based on the first similarity and the second similarity.

5. The text processing method according to claim 1, characterized in that, The step of determining the third text that matches the response text from the second text includes: The response text is divided into multiple sub-response texts corresponding to the response text; A second text with a similarity greater than or equal to a third similarity threshold is determined as the third text corresponding to each sub-response text.

6. The text processing method according to claim 5, characterized in that, The second score for determining the response text based on the third text includes: The score of each sub-response text is determined based on the similarity between each sub-response text and the corresponding third text. The second score is calculated based on the score of each sub-response text, the number of sub-response texts, and a preset multiplier.

7. The text processing method according to claim 1, characterized in that, The step of determining the fourth text that matches the first text from the second text includes: The second text is divided into multiple fifth texts, and the length of each fifth text is less than or equal to a preset length; The fourth text is selected from the plurality of fifth texts based on the similarity between the first text and each fifth text.

8. The text processing method according to claim 7, characterized in that, The determination of the third score for the response text based on the fourth text includes: Extract key information from the fourth text; The third score is determined based on the first quantity of the key information in the fourth text and the second quantity of the key information in the response text.

9. The text processing method according to claim 1, characterized in that, The step of determining the tag of the first text based on the second text, the response text, the first rating, the second rating, and the third rating includes: Based on the first score, the second score, and the third score, a comprehensive score is determined for the response text; The combined score of the second text, the response text, and the response text is used as the tag for the first text.

10. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the text processing method as described in any one of claims 1 to 9.

11. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the text processing method as described in any one of claims 1 to 9.