Statement rewriting method and device, electronic equipment and storage medium
By using a pre-trained rewriting model to distinguish between business instructions and non-business instructions, and performing targeted optimization rewriting, the problem of over-rewriting caused by insufficient intent recognition in human-computer interaction systems is solved, thereby improving the system's response accuracy and user experience.
Patent Information
- Application Number
- CN202511330093.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-17
- Publication Date
- 2026-01-13
AI Technical Summary
In existing human-computer interaction systems, insufficient recognition of the intent of user input statements leads to over-rewriting, causing abnormal system responses and affecting user experience.
The pre-trained rewriting model determines the instruction labels of user input statements, distinguishes between business instructions and non-business instructions, and only performs targeted optimization rewriting on business instructions, strictly adhering to the semantic boundaries defined by the instruction labels.
It significantly suppressed overwriting, avoided the illusion problem, improved the accuracy of system response and interaction efficiency, and optimized the user experience.
Smart Images

Figure CN121328474A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically to a method, apparatus, electronic device, and storage medium for rewriting statements. Background Technology
[0002] Current human-computer interaction systems, supported by natural language processing technology, can generate corresponding responses or perform operations by analyzing user input, providing personalized services. However, when user statements are ambiguous or intentions are unclear, the system often struggles to accurately match the response content based solely on the original input, leading to a decline in the interactive experience. To address this, systems typically rewrite and optimize user statements to generate new expressions that better reflect the user's actual needs. However, existing rewriting techniques suffer from the flaw of over-rewriting, which can create illusions. Regardless of whether the user inputs an interactive command or ordinary social dialogue (such as casual phrases like "navigate to xx"), the system performs standardized rewriting (e.g., rewriting it as "navigate to xx"). This over-rewriting mechanism, lacking intent recognition, can not only distort the original semantics but also incorrectly send non-interactive content into the command execution model, causing abnormal system responses and ultimately severely impacting the user's actual experience. Summary of the Invention
[0003] The purpose of this invention is to provide a method, apparatus, electronic device, and storage medium for rewriting statements, which can effectively solve the above-mentioned technical problems.
[0004] To achieve the above objectives, the technical solution adopted by the present invention is as follows: A method for rewriting statements, the method comprising: In a specified business scenario, obtain the first statement input by the user; The first statement is input into a pre-trained rewriting model. The rewriting model determines the instruction label corresponding to the first statement and determines whether the instruction label is a business instruction label. If the instruction label is determined to be a business instruction label, the first statement is rewritten based on the instruction label. The rewriting model outputs the instruction label and the rewritten second statement. Here, the business instruction label is the instruction category corresponding to the operation instruction predefined for a specified business scenario.
[0005] Furthermore, determining whether an instruction tag is a business instruction tag includes: Retrieve the business instruction tag library corresponding to the specified business scenario; the business instruction tag library contains multiple business instruction tags pre-stored. The instruction tag is compared one by one with each business instruction tag in the business instruction tag library to obtain the comparison results; Determine whether the comparison result is a successful comparison.
[0006] Furthermore, the first statement is rewritten based on the instruction tags, including: Extract information from the first statement to obtain key information for rewriting; The rewrite rules are determined based on the instruction tags; Rewrite the first statement based on key information and rewriting rules.
[0007] Furthermore, the rewriting rules are determined based on the instruction tags, including: The rewriting rule is determined by querying the rewriting rule base; the rewriting rule base pre-stores the correspondence between business instruction tags and rewriting rules.
[0008] Furthermore, after determining the rewrite rules based on the instruction tags, the method also includes: Combine key information to obtain combined statements; Determine whether the combined statements conform to the rewriting rules; If the combined statement is determined to meet the rewriting rules, the rewriting model will output the combined statement as the second statement. If the combined statement is determined not to conform to the rewriting rules, the first statement is rewritten according to the key information and the rewriting rules.
[0009] Furthermore, the first statement is rewritten based on key information and rewriting rules, including: Rewrite the combined statements according to the rewriting rules.
[0010] Furthermore, the method also includes: If the instruction label is determined not to be a business instruction label, the model outputs the first statement and the corresponding invalid instruction label.
[0011] Furthermore, the method also includes: The first statement corresponding to a valid instruction label will not be input into the instruction execution model; the instruction execution module is a model for instruction execution and / or question-and-answer interaction.
[0012] Furthermore, the rewritten model is trained through the following steps: Obtain a training sample set related to a specified business scenario; the samples in the training sample set are triples, each triple including a first sample statement, a second sample statement, and an instruction label corresponding to the first sample statement. The first sample statement and the second sample statement have the same semantics, and the second sample statement is a rewritten statement. The rewriting model is obtained by training the large language base model based on the training sample set.
[0013] Furthermore, the large language foundation model is trained based on the training sample set to obtain the rewriting model, including: The training sample set is split into a fine-tuning training sample set and an activation training sample set; The first sample sentence in the fine-tuning training sample set is used as input, and the second sample sentence and instruction label in the sample are used as output. LoRa fine-tuning training is performed on the large language base model, and the large language base model with the highest accuracy in the test is determined as the initial rewriting model. The first sample statement in the activated training sample set is used as input, and the second sample statement and instruction label in the sample are used as output. The initial rewriting model is fine-tuned using LoRa, and the initial rewriting model with the highest accuracy in the test is determined as the rewriting model.
[0014] An apparatus for rewriting statements, the apparatus comprising: The acquisition module is used to acquire the first statement entered by the user in a specified business scenario; The rewriting module is used to input the first statement into a pre-trained rewriting model. Using the rewriting model, the module determines the instruction label corresponding to the first statement, determines whether the instruction label is a business instruction label, and if the instruction label is determined to be a business instruction label, rewrites the first statement based on the instruction label. The rewriting model outputs the instruction label and the rewritten second statement. The business instruction label is an instruction category corresponding to a predefined operation instruction for a specified business scenario.
[0015] An electronic device includes a processor and a memory, the processor being configured to execute a statement rewriting program stored in the memory to implement the statement rewriting method described above.
[0016] A storage medium storing one or more programs that can be executed by one or more processors to implement the above-described statement rewriting method.
[0017] The beneficial effects of this invention are: This invention provides a method, apparatus, electronic device, and storage medium for rewriting statements. The method includes: acquiring a first statement input by a user in a specified business scenario; inputting the first statement into a pre-trained rewriting model; using the rewriting model to determine the instruction label corresponding to the first statement; determining whether the instruction label is a business instruction label; if the instruction label is determined to be a business instruction label; rewriting the first statement based on the instruction label; and outputting the instruction label and the rewritten second statement from the rewriting model. The business instruction label is an instruction category corresponding to a predefined operation instruction for a specified business scenario. In this solution, a pre-trained rewriting model is introduced to determine the instruction labels of user input statements. First, business instruction labels (such as navigation category, vehicle control category, etc.) are distinguished from non-business instruction labels (such as social category, casual chat category). Only statements marked with business instruction labels are rewritten in a targeted manner, and the semantic boundaries defined by the instruction labels are strictly followed during the rewriting process. This achieves targeted optimization and rewriting of statements. This mechanism not only significantly suppresses the existing over-rewriting phenomenon, but also fundamentally avoids the illusion problem caused by it. This effectively improves the accuracy of system response and simultaneously optimizes the core indicators of interaction efficiency and user experience. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating an embodiment of a statement rewriting method according to the present invention; Figure 2 This is a flowchart illustrating an embodiment of another method for rewriting statements according to the present invention. Figure 3 This is a flowchart illustrating an embodiment of the rewritten model training process of the present invention; Figure 4 This is a block diagram illustrating an embodiment of a statement rewriting apparatus according to the present invention; Figure 5 This is a schematic diagram of the structure of an electronic device according to the present invention. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, 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.
[0020] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0021] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0022] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.
[0023] Foundational technologies in artificial intelligence generally include sensors, dedicated AI chips, cloud computing, storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0024] It should be understood that the sequence number of each step in the following embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0025] This embodiment proposes a method for rewriting statements. This method can be applied to human-computer interaction devices, including but not limited to: smartphones, tablets, e-book readers, MP3 (Moving Picture Experts Group Audio Layer III) players, MP4 (Moving Picture Experts Group Audio Layer IV) players, laptops, in-vehicle computers, desktop computers, set-top boxes, smart TVs, wearable devices, home appliances, and other electronic devices capable of human-computer interaction.
[0026] See Figure 1 , Figure 1 This is a flowchart illustrating an embodiment of a statement rewriting method provided in this example. Figure 1 The process shown may include the following steps: Step 101: Under the specified business scenario, obtain the first statement input by the user; In practical applications, the aforementioned execution entity can be applied to specific business scenarios (such as automotive business scenarios, home business scenarios, etc.) to acquire in real time the first sentence entered by the user in text or language on the input method component (including but not limited to the input method editor, input method software, input method platform, input method framework, or input method interface) in that specific business scenario. This step must ensure low-latency acquisition to provide raw input data for subsequent processing.
[0027] Step 102: Input the first statement into the pre-trained rewriting model. Use the rewriting model to determine the instruction label corresponding to the first statement and determine whether the instruction label is a business instruction label. If the instruction label is determined to be a business instruction label, rewrite the first statement based on the instruction label. The rewriting model outputs the instruction label and the rewritten second statement. After the first statement is input into the pre-trained rewriting model, the model determines the corresponding instruction label through semantic parsing. This instruction label is essentially a predefined semantic classification result, used to identify the category of the operation instruction to which the user's intent belongs. For example, in the automotive business scenario, if the first statement is "I'm so hot, the air conditioning in the car isn't on, please turn it on," the rewriting model will obtain the corresponding instruction label as "vehicle control." If the first statement is "Can you navigate to xx?", the rewriting model will determine its instruction label as "casual chat" through semantic analysis.
[0028] Next, it is determined whether the identified instruction tags belong to a predefined set of business instruction tags. These business instruction tags are instruction categories corresponding to predefined operation instructions for specific business scenarios. This can be understood as follows: scenario-differentiated design is the core principle in constructing the business instruction tag system. Different specified business scenarios correspond to different operation instructions, therefore, the corresponding business instruction tags also differ across scenarios. For example, in the automotive business scenario, the business instruction tags must include exclusive tags such as "vehicle control" (integrating functions like in-vehicle air conditioning and seat adjustment), "music Q&A" (voice interaction), "music control" (playback operation), and "volume control." In contrast, the home business scenario corresponds to independent sets of home appliance instruction tags such as "air conditioning control," "TV control," and "speaker control." The key difference lies in the fact that when the same function (such as air conditioning control) appears in different specified business scenarios, semantic isolation must be achieved through tag naming—the automotive business scenario uses the integrated "vehicle control" tag, while the home scenario uses the directly functional "air conditioning control" tag, thus ensuring the uniqueness of instruction recognition across business scenarios and the robustness of the system.
[0029] The specific process for determining whether an instruction tag is a business instruction tag is as follows: obtain the business instruction tag library corresponding to the specified business scenario; compare the instruction tag with each business instruction tag in the business instruction tag library one by one to obtain the comparison result; and determine whether the comparison result is a successful comparison result.
[0030] In practical applications, the above-mentioned business instruction tag library pre-stores multiple business instruction tags. Specifically, the business instruction tag library can be constructed using a two-level classification system of theme + tag. For example, automotive business scenario - ["vehicle control", "music Q&A", "music control", "volume control"]; home business scenario - ["air conditioning control", "TV control", "speaker control"].
[0031] The above comparison results are obtained by comparing the content of the instruction tag with each business instruction tag. Each comparison result is determined to determine whether there is a successful comparison result. If there is, the instruction tag is determined to be a business instruction tag. If not, the instruction tag is determined to be a non-business instruction tag. When the instruction tag is determined to be a business instruction tag (i.e., a successful match is found in the comparison results, such as "vehicle control" in the automotive business scenario, where the instruction tag for the first statement is "vehicle control," which matches the business instruction tag "vehicle control" in the automotive business scenario), the first statement is rewritten based on this instruction tag. Since the instruction tag clearly defines the rewriting scenario, the semantic boundaries defined by the instruction tag are strictly followed during the rewriting process. This achieves targeted rewriting of the first statement to generate a second statement with clearer semantics and more suitable for the specified business scenario, effectively overcoming the problem of illusions in existing rewriting methods. Finally, the rewriting model outputs both the identified instruction tag and the rewritten second statement, providing structured input for subsequent business processing. This can be understood as inputting the instruction tag and the second statement into the instruction execution model to execute user requests. This instruction execution module is a model for instruction execution and / or question-and-answer interaction.
[0032] Furthermore, due to the limitations of the basic model, multi-turn dialogues sometimes involve self-answering questions. For example: First turn: "Introduce some local hotels." Response: (1.xx...phone: 12345678; 2.xxx....phone: 23456789). Second turn: "What is the phone number for the first hotel?" Existing rewriting might rewrite this as: "The phone number for xx restaurant is 12345678." However, once the statement is identified as a phone query instruction, this instruction label can help the rewriting model recognize that this is a rewriting of a query intent rather than an intent-solving rewriting, thus making the rewriting more accurate.
[0033] When the instruction label is determined to be a non-business instruction label (i.e., there is no successful comparison result, such as in the automotive business scenario, the instruction label determined for the first statement is "chat" or "TV control," which does not match any of the business instruction labels in the automotive business scenario), the rewriting model will not rewrite the first statement. In order to mark the first statement as invalid in the specified business scenario, the rewriting model needs to output the first statement and the corresponding invalid instruction label. The invalid instruction label clearly indicates that the first statement is not a business-related statement in the specified business scenario. If related control is performed based on this statement, it may lead to abnormal response. Therefore, in practical applications, the first statement corresponding to the invalid instruction label can be excluded from the above instruction execution model. This method of handling statements that are not business-related in the specified business scenario can greatly improve the accuracy of system response and bring a good user experience.
[0034] In this solution, a pre-trained rewriting model is introduced to determine the instruction labels of user input statements. First, it distinguishes between business instruction labels (such as "navigation" and "vehicle control") and non-business instruction labels (such as "social" and "casual chat"). Only statements marked with business instruction labels are rewritten in a targeted manner, and the semantic boundaries defined by the instruction labels are strictly followed during the rewriting process. This achieves targeted optimization and rewriting of statements. This mechanism not only significantly suppresses the existing over-rewriting phenomenon, but also fundamentally avoids the illusion problem caused by it. This effectively improves the accuracy of system response and simultaneously optimizes the core indicators of interaction efficiency and user experience.
[0035] like Figure 2 As shown, as an optional implementation, the method described above, step 102, which involves rewriting the first statement based on the instruction label, includes the following steps: Step 201: Extract information from the first statement to obtain key information for rewriting; First, entity recognition is performed on the first sentence, such as identifying core actions (e.g., "search", "query", "control"), object entities (e.g., products, maps, volume, car windows, weather), and environmental parameters (time, location). Then, the first sentence is segmented according to the identified entities to obtain key information.
[0036] For example, in the automotive business scenario, the first sentence is "I'm so hot, what's the weather like today?" Entity recognition can identify two entities: "today" and "weather." Therefore, word segmentation of the first sentence yields the two key pieces of information: "today" and "weather."
[0037] Step 202: Determine the rewrite rules based on the instruction tags; Specifically, the rewriting rule is determined by querying the rewriting rule base to find the rewriting rule corresponding to the instruction tag. The rewriting rule base is a table that pre-stores the correspondence between business instruction tags and rewriting rules. This table could be a database table, an Excel spreadsheet, a configuration file, or other data structure; no specific limitation is made here. For ease of understanding, we will use the business instruction tags corresponding to the automotive business scenario as an example, as shown in Table 1: Table 1
[0038] This can be understood as different rewriting rules corresponding to different business instruction tags. It should be noted that the above-listed correspondence between business instruction tags and rewriting rules is only an example. The specific correspondence between business instruction tags and rewriting rules can be set according to actual needs, and is not limited here.
[0039] If the instruction label determined by the first statement is "vehicle control", then by referring to Table 1, we can see that the rewriting rule corresponding to the instruction label "vehicle control" is "if there is an implicit verb, a verb needs to be added; if there is a clear object entity".
[0040] Step 203: Rewrite the first statement according to the key information and rewriting rules.
[0041] The purpose of rewriting the first statement is to make the user's intent clearer and the statement more concise, so as to ensure that the subsequent instruction execution model can execute accurately and meet the user's needs.
[0042] However, before rewriting, it is necessary to combine the key information to obtain a combined statement; determine whether the combined statement conforms to the rewriting rules; if the combined statement conforms to the rewriting rules, the rewriting model outputs the combined statement as the second statement; if the combined statement does not conform to the rewriting rules, the step of rewriting the first statement according to the key information and the rewriting rules is executed.
[0043] Specifically, the key information extracted in step 201 is recombined according to grammatical rules to obtain a combined statement. Then, the combined statement is compared with the rewriting rules determined in step 202 to check whether the combined statement meets the rewriting rules. If it does, it means that the combined statement has met the requirements of semantic clarity and conciseness of expression. Then the rewriting module can directly output the combined statement as the rewritten second statement. If it does not meet the requirements, it means that the combined statement does not meet the requirements of semantic clarity and / or conciseness of expression. Then it needs to be further rewritten according to the rewriting rules so that the second statement output by the rewriting module meets the requirements of semantic clarity and conciseness of expression.
[0044] To facilitate understanding and continue from the previous example, for the first statement "I'm so hot, today's weather", the extracted key information "today" and "weather" are combined to obtain the combined statement "today's weather". Since the rewriting model determines that the instruction label corresponding to the first statement is "vehicle control", the corresponding rewriting rule obtained through step 202 is "implied verbs need to be added; there is a clear object entity". Then, by comparison, it is found that "today's weather" does not have a verb, so a verb needs to be added to the combined statement according to the rewriting rule. The rewritten second statement is "query today's weather".
[0045] In the automotive business scenario, if the three key pieces of information extracted from the first statement "I'm so hot, check today's weather" are combined to obtain the combined statement "Check today's weather", since the rewriting model determines that the instruction label corresponding to the first statement is "vehicle control", the corresponding rewriting rule obtained through step 202 is "implied verbs need to be added; there is a clear object entity". Then, by comparison, it is found that "Check today's weather" has no implicit verbs and has a clear object entity. Therefore, there is no need to rewrite the combined statement according to the rewriting rule. The rewriting model can directly output the combined statement "Check today's weather" as the rewritten second statement.
[0046] This intelligent rewriting solution employs a tiered processing mechanism, significantly optimizing system performance while ensuring rewriting quality. For combined statements that conform to the rewriting rules, they are directly used as the final output. This "pass if qualified" approach saves conventional computing resources, significantly improving user experience, especially in high-frequency interaction scenarios. For combined statements that do not conform to the rewriting rules, they are precisely rewritten according to the rules. This rule-guided deep rewriting effectively improves instruction executability. In actual deployment, the solution demonstrates dual advantages: it ensures system throughput through a fast channel while guaranteeing the reliability of critical instructions through precise rewriting, making it particularly suitable for intelligent interaction scenarios that require a balance between efficiency and accuracy.
[0047] like Figure 3 As shown, as an optional implementation method, the rewritten model in step 102 is trained through the following steps: Step 301: Obtain a training sample set related to the specified business scenario; Each sample in the above training sample set is obtained by acquiring case data (including the original statements and responses input by the user) from the following aspects and then processing it. Case data acquisition includes: 1. Acquiring complex semantic cases from various business verticals and from log cases that are manually generalized; 2. Acquiring complex semantic cases from example cases in the function definition list and then manually generalizing them; 3. Automatically acquiring combined instructions based on custom corpus information; 4. Acquiring data from corpora that have semantic overlap with other specified business scenarios (such as smart home and mobile office) and the specified business scenario (such as automotive business scenario); 5. Acquiring relevant data from high-quality casual conversation data fields in various fields.
[0048] The data processing includes manual annotation and data structure modification. Manual annotation refers to rewriting the original statements of each case obtained above and annotating the statements and instructions. For ease of understanding, the annotated data is shown in Table 2:
[0049] However, it's easy to see that its format differs significantly from the input information question-answer pairs of the basic large model (e.g., q: What does 1+1 equal? S: 1+1 equals 2). The task is no longer simply answering user questions, but rather summarizing and categorizing user questions into simpler content. Therefore, the above-labeled content is constructed into the data format shown in Table 3:
[0050] As shown in the table above, <|device_output_start|>, <|device_output_end|>, and <|seg|> are custom special tokens. <|device_output_start|> and <|device_output_end|> wrap the response content; if there is no previous round or no response in the previous round, the wrapper is empty. <|seg|> separates the rewritten statement and the instruction tag.
[0051] After the above data processing, a training sample set is obtained. The samples in the training sample set are triples. Each triple includes a first sample statement (only the original statement is included when there is no previous round reply, and both the original statement and the previous round reply are included when there is a previous round reply), a second sample statement (a rewritten statement), and the instruction label corresponding to the first sample statement. The first sample statement and the second sample statement have the same semantics, and the second sample statement is the rewritten statement.
[0052] Step 302: Train the large language base model based on the training sample set to obtain the rewriting model.
[0053] The specific training process can be implemented through steps A1 to A3: Step A1: Split the training sample set into a fine-tuning training sample set and an activation training sample set; In practical applications, the above sample data can be further divided into single-round data and multi-round data. In order to better adapt the model to the business scenario, the training sample set needs to be divided into two parts according to whether it is single-round data or multi-round data: fine-tuning training sample set and activation training sample set. Fine-tuning training sample set is used to fine-tune the model to make the model more suitable for the task, and activation training sample set is used to activate the model's business capabilities.
[0054] The splitting method is as follows: 50% of the single-round data, representing 50% of the total training sample set, is used as the fine-tuning training sample set, while the remaining training sample set is used as the activation training sample set. This method aims to ensure that the multi-round data and single-round data are not imbalanced when activating the training sample set, preventing the model from losing its multi-round capabilities.
[0055] Assuming the total number of training samples is N, and 80% of them are single-round data, then the number of training samples to be fine-tuned is: N1 = 1 / 2 × N × 80%, and the number of training samples to be activated is N2 = 1 / 2 × N × 80% + N × (1 - 80%).
[0056] Step A2: Take the first sample sentence of the sample in the fine-tuning training sample set as input, and take the second sample sentence and instruction label in the sample as output to perform LoRa fine-tuning training on the large language base model. The large language base model with the highest accuracy in the test is determined as the initial rewriting model. The aforementioned large language base model can be the qwen1.5-14B (Qanwen 1.5-14 Billion parameters, Tongyi Qianwen 1.5 version 14 billion parameter model) base model, the Qwen (Qianwen Base Model, Tongyi Qianwen Base Model) base model, the baichuan (Baichuan Base Mode, Baichuan Intelligent Base Model) base model, the ChatGLM (ChatGenerative Language Model Base, Zhipu Dialogue Generation Language Model Base) base model, etc., and is not limited here.
[0057] This training step mainly focuses on ensuring the correct training format. The format includes: (1) whether the instruction label is valid. For example, for "open the car window," the instruction label can be either "window control" or "vehicle control instruction." If the actual definition is "vehicle control instruction," then "window control" is not acceptable. (2) whether the output format satisfies "rewrite case<|seg|> instruction label." When calculating the accuracy, both (1) and (2) must be correct. The large language base model with the highest accuracy is selected as the initial rewriting model and used as the base model for step A3.
[0058] Step A3: Take the first sample statement from the activated training sample set as input, and the second sample statement and instruction label from the sample as output, and perform LoRa fine-tuning training on the initial rewriting model. The initial rewriting model with the highest accuracy in the test is determined as the rewriting model.
[0059] When calculating accuracy, the format, rewritten statements, and instruction labels must all be correct, and the initial rewrite model with the highest accuracy is selected as the rewrite model.
[0060] This training method focuses on building the basic capabilities of the base model in the first stage and optimizes for specific tasks in the second stage, forming a progressive training structure. The two-stage training enables the model to first master general rewriting capabilities and then enhance its performance on specific tasks, thereby making the rewriting model more powerful and accurate.
[0061] This embodiment provides a statement rewriting apparatus, see [link to previous document]. Figure 4 This is a block diagram illustrating an embodiment of a statement rewriting apparatus provided by an embodiment of the present invention. Figure 4 As shown, the device may include: The acquisition module 401 is used to acquire the first statement input by the user in a specified business scenario; The rewriting module 402 is used to input the first statement into the pre-trained rewriting model, use the rewriting model to determine the instruction label corresponding to the first statement, determine whether the instruction label is a business instruction label, and if the instruction label is determined to be a business instruction label, rewrite the first statement based on the instruction label. The rewriting model outputs the instruction label and the rewritten second statement. The business instruction label is the instruction category corresponding to the operation instruction predefined for a specified business scenario.
[0062] In this solution, a pre-trained rewriting model is introduced to determine the instruction labels of user input statements. First, business instruction labels (such as navigation category, vehicle control category, etc.) are distinguished from non-business instruction labels (such as social category, casual chat category). Only statements marked with business instruction labels are rewritten in a targeted manner, and the semantic boundaries defined by the instruction labels are strictly followed during the rewriting process. This achieves targeted optimization and rewriting of statements. This mechanism not only significantly suppresses the existing over-rewriting phenomenon, but also fundamentally avoids the illusion problem caused by it. This effectively improves the accuracy of system response and simultaneously optimizes the core indicators of interaction efficiency and user experience.
[0063] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 5 The illustrated electronic device 1200 includes at least one processor 1201, a memory 1202, at least one network interface 1204, and other user interfaces 1203. The various components in the electronic device 1200 are coupled together via a bus system 1205. It is understood that the bus system 1205 is used to implement communication between these components. In addition to a data bus, the bus system 1205 also includes a power bus, a control bus, and a status signal bus. However, for clarity, ... Figure 5 The general labeled all buses as Bus System 1205.
[0064] The user interface 1203 may include a display, keyboard, or clicking device (e.g., mouse, trackball, touchpad, or touchscreen).
[0065] It is understood that the memory 1202 in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The memory 1202 described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0066] In some implementations, memory 1202 stores elements, executable units or data structures, or subsets thereof, or extended sets thereof: operating system 12021 and application program 12022.
[0067] The operating system 12021 includes various system programs, such as the framework layer, core library layer, and driver layer, used to implement various basic business functions and handle hardware-based tasks. The application program 12022 includes various applications, such as a media player and a browser, used to implement various application functions. The program implementing the method of this application embodiment can be included in the application program 12022.
[0068] In this embodiment of the application, the processor 1201 executes the method steps provided by each method embodiment by calling the program or instructions stored in the memory 1202, specifically the program or instructions stored in the application program 12022.
[0069] The methods disclosed in the embodiments of this application can be applied to or implemented by the processor 1201. The processor 1201 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware or by instructions in the form of software in the processor 1201. The processor 1201 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software units in the decoding processor. The software unit can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 1202. Processor 1201 reads the information in memory 1202 and, in conjunction with its hardware, completes the steps of the above method.
[0070] It is understood that the embodiments described herein can be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or combinations thereof.
[0071] For software implementation, the techniques described herein can be implemented by units that perform the functions described herein. The software code can be stored in memory and executed by a processor. The memory can be implemented in the processor or external to the processor.
[0072] The electronic device provided in this embodiment may be as follows: Figure 5 The electronic device shown can perform the following: Figure 1-2 All steps of the method for rewriting Chinese statements, thereby achieving Figure 1-2 For details on the technical effects of the statement rewriting method shown, please refer to [link / reference]. Figure 1-2 The relevant descriptions are presented concisely and will not be elaborated upon here.
[0073] This embodiment provides a storage medium (computer-readable storage medium). The storage medium stores one or more programs. The storage medium may include volatile memory, such as random access memory; it may also include non-volatile memory, such as read-only memory, flash memory, hard disk, or solid-state drive; and it may also include combinations of the above types of memory.
[0074] When one or more programs in the storage medium can be executed by one or more processors, the above-mentioned method of statement rewriting can be implemented.
[0075] The processor is used to execute a statement rewriting program stored in the memory to implement the steps of the statement rewriting method.
[0076] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0077] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented in hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0078] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for rewriting statements, characterized in that, The method includes: In a specified business scenario, obtain the first statement input by the user; The first statement is input into a pre-trained rewriting model. The rewriting model is used to determine the instruction tag corresponding to the first statement, and to determine whether the instruction tag is a business instruction tag. If the instruction tag is determined to be a business instruction tag, the first statement is rewritten based on the instruction tag. The rewriting model outputs the instruction tag and the rewritten second statement. The business instruction tag is an instruction category corresponding to a predefined operation instruction for the specified business scenario.
2. The method according to claim 1, characterized in that, The determination of whether the instruction tag is a business instruction tag includes: Obtain the business instruction tag library corresponding to the specified business scenario; wherein, the business instruction tag library pre-stores multiple business instruction tags; The instruction tag is compared one by one with each business instruction tag in the business instruction tag library to obtain the comparison result; Determine whether the comparison result is a successful comparison result.
3. The method according to claim 1, characterized in that, The rewriting of the first statement based on the instruction tag includes: Extract information from the first statement to obtain key information for rewriting; The rewriting rules are determined based on the instruction tags; The first statement is rewritten based on the key information and the rewriting rules.
4. The method according to claim 3, characterized in that, The step of determining the rewrite rule based on the instruction tag includes: The rewriting rule is determined by querying the rewriting rule base to find the rewriting rule corresponding to the instruction tag; wherein the rewriting rule base stores the correspondence between business instruction tags and rewriting rules in advance.
5. The method according to claim 3, characterized in that, After determining the rewrite rule based on the instruction label, the method further includes: The key information is combined to obtain a combined statement; Determine whether the combined statement conforms to the rewriting rules; If the combined statement is determined to conform to the rewriting rules, the rewriting model will output the combined statement as the second statement. If it is determined that the combined statement does not conform to the rewriting rules, the step of rewriting the first statement according to the key information and the rewriting rules is executed.
6. The method according to claim 5, characterized in that, The step of rewriting the first statement according to the key information and the rewriting rules includes: The combined statement is rewritten according to the rewriting rules.
7. The method according to claim 1, characterized in that, The method further includes: If it is determined that the instruction tag is not the business instruction tag, the rewriting model outputs the first statement and the invalid instruction tag corresponding to the first statement.
8. The method according to claim 7, characterized in that, The method further includes: The first statement corresponding to the one without a valid instruction label is not input into the instruction execution model; wherein, the instruction execution module is a model for instruction execution and / or question-and-answer interaction.
9. The method according to claim 1, characterized in that, The rewriting model is trained through the following steps, which include: Obtain a training sample set related to the specified business scenario; the samples in the training sample set are triples, and the triples include a first sample statement, a second sample statement, and an instruction label corresponding to the first sample statement. The first sample statement and the second sample statement have the same semantics, and the second sample statement is a rewritten statement. The rewriting model is obtained by training the large language base model based on the training sample set.
10. The method according to claim 9, characterized in that, The process of training the large language foundation model based on the training sample set to obtain the rewriting model includes: The training sample set is split into a fine-tuning training sample set and an activation training sample set; The first sample statement in the fine-tuning training sample set is used as input, and the second sample statement and the instruction label in the sample are used as output to perform LoRa fine-tuning training on the large language base model. The large language base model with the highest accuracy in the test is determined as the initial rewriting model. The first sample statement from the activated training sample set is used as input, and the second sample statement and the instruction label are used as output. The initial rewriting model is then fine-tuned using LoRa, and the initial rewriting model with the highest accuracy in the test is determined as the rewriting model.
11. A device for rewriting statements, characterized in that, The device includes: The acquisition module is used to acquire the first statement entered by the user in a specified business scenario; The rewriting module is used to input the first statement into a pre-trained rewriting model, use the rewriting model to determine the instruction tag corresponding to the first statement, determine whether the instruction tag is a business instruction tag, and if the instruction tag is determined to be a business instruction tag, rewrite the first statement based on the instruction tag. The rewriting model outputs the instruction tag and the rewritten second statement. The business instruction tag is an instruction category corresponding to a predefined operation instruction for the specified business scenario.
12. An electronic device, characterized in that, include: A processor and a memory, the processor being configured to execute a statement rewriting program stored in the memory to implement the statement rewriting method according to any one of claims 1 to 10.
13. A storage medium, characterized in that, The storage medium stores one or more programs, which can be executed by one or more processors to implement the statement rewriting method according to any one of claims 1 to 10.