Text editing method and device and related equipment
By filling in text editing information into the large language model prompt template and generating and executing the target code, the problem of inefficiency when the large language model directly processes a large amount of text is solved, and text editing efficiency is improved.
Patent Information
- Application Number
- CN202510167756.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-14
- Publication Date
- 2025-06-06
AI Technical Summary
In the prior art, the use of large language models to directly implement text editing is less efficient, especially when the text to be edited is too large.
By obtaining text editing information, filling it into the large language model prompt template, generating a large language model prompt, and entering the target large language model for code generation, obtaining the target code, and executing the code to edit the edited text.
It improves text editing efficiency, avoids the inefficiency problem of large language models when directly processing large amounts of text, and realizes efficient processing of complex text editing operations.
Smart Images

Figure CN120106035A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a text editing method, apparatus and related equipment. Background Art
[0002] In traditional text editing systems such as notepad and text code editors (notepad), relatively simple text editing operations, such as text replacement, can be implemented. However, more complex text editing operations, such as replacing the text background editing code or replacing the local content of the text, cannot be implemented. In the solutions in the prior art, the text is generally edited by directly inputting the text into a large language model (LLM). When the text is too large, the large language model needs to process more content, so the processing efficiency of the large language model is low, which leads to the problem of low efficiency when the large language model is used to directly implement text editing. Summary of the invention
[0003] The embodiments of the present disclosure provide a text editing method, apparatus and related devices to solve the problem of low efficiency of text editing using a large language model in the prior art.
[0004] To solve the above problems, the present disclosure is implemented as follows:
[0005] In a first aspect, an embodiment of the present disclosure provides a text editing method, the method comprising:
[0006] Acquire text editing information, where the text editing information is a natural language text for instructing to perform text editing on the text to be edited;
[0007] Filling the text editing information into a large language model prompt template to obtain a large language model prompt, wherein the large language model prompt is used to prompt a target large language model to generate a code corresponding to the text editing information;
[0008] Inputting the large language model prompt into the target large language model for code generation to obtain a target code, wherein the target code is used to execute the text editing operation indicated by the text editing information;
[0009] The target text is obtained by executing the target code to edit the text to be edited.
[0010] Optionally, filling the text editing information into a large language model prompt template to obtain a large language model prompt includes:
[0011] Matching a target large language model according to the text editing information, wherein the target large language model is used to convert the text editing information into a code corresponding to the text editing information;
[0012] Acquire the large language model prompt template that matches the target large language model, wherein the large language model prompt template includes a template text and a fill-in text area, wherein the template text is pre-generated text content, and the fill-in text area is used to fill in text for which code needs to be generated;
[0013] The text editing information is filled into the fill-in text area and combined with the template text to obtain the large language model prompt.
[0014] Optionally, the step of inputting the large language model prompt into the target large language model for code generation to obtain the target code includes:
[0015] Inputting the large language model prompt into the target large language model for code generation to obtain initial code;
[0016] Performing accuracy verification on the initial code, wherein the accuracy verification is used to verify whether the initial code can operate normally;
[0017] If the accuracy of the initial code is verified to be passed, determining the initial code as the target code;
[0018] When the accuracy verification of the initial code fails, the initial code is adjusted to obtain the target code.
[0019] Optionally, the acquiring text editing information includes:
[0020] Acquire a selected text editing requirement, where the text editing requirement includes at least one text editing operation selected from a plurality of text editing operations, where the plurality of text editing operations are used to perform text editing processing on a text to be edited;
[0021] Obtaining an input editing target, wherein the editing target is the text content to be edited in the text to be edited;
[0022] The text editing requirement and the editing target are combined and converted into text information expressed in a natural language to obtain the text editing information.
[0023] Optionally, the step of executing the target code to edit the text to be edited to obtain the target text includes:
[0024] Deploy the target code in a first code platform, or build a second code platform based on the target code, wherein the first code platform or the second code platform is used to execute the target code on the text to be edited;
[0025] Sending the text to be edited to the first code platform or the second code platform;
[0026] The target text generated by the first code platform or the second code platform performing text editing on the edit text by executing the target code is received.
[0027] Optionally, sending the to-be-edited text to the first code platform or the second code platform includes:
[0028] Generate a target call request, where the target call request is used to request the first code platform or the second code platform to call the target code;
[0029] The target call request and the text to be edited are sent to the first code platform or the second code platform.
[0030] Optionally, the first code platform or the second code platform includes a target database, the target database includes a plurality of candidate codes, and the deploying the target code in the first code platform, or building the second code platform based on the target code, includes:
[0031] matching the plurality of candidate codes with the target code;
[0032] In the case where the target code is the same as the target candidate code, in the first code platform or the second code platform, the target candidate code is determined as the target code, and the target candidate code is any one of the multiple candidate codes;
[0033] In the case where the target code is different from the target candidate code, the target code is deployed in the first code platform, or a second code platform is built based on the target code.
[0034] Optionally, the target large language model is obtained by training with training samples, the training samples include training text and text labels corresponding to the training text, the training text is natural language text for text editing, and the text label is a code for executing the text editing operation indicated by the training text.
[0035] In a second aspect, the present disclosure also provides a text editing device, including:
[0036] An acquisition module, used for acquiring text editing information, wherein the text editing information is a natural language text for indicating that text editing should be performed on the text to be edited;
[0037] A filling module, used to fill the text editing information into the large language model prompt template to obtain a large language model prompt, wherein the large language model prompt is used to prompt the target large language model to generate a code corresponding to the text editing information;
[0038] A generating module, configured to input the large language model prompt into the target large language model to generate code, and obtain a target code, wherein the target code is used to execute the text editing operation indicated by the text editing information;
[0039] The execution module is used to edit the text to be edited by executing the target code to obtain the target text.
[0040] In a third aspect, an embodiment of the present disclosure further provides an electronic device, comprising: a transceiver, a memory, a processor, and a program stored in the memory and executable on the processor; the processor is used to read the program in the memory to implement the steps in the method described in the first aspect above.
[0041] In a fourth aspect, an embodiment of the present disclosure further provides a readable storage medium for storing a program, wherein the program, when executed by a processor, implements the steps in the method described in the first aspect.
[0042] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the steps in the method described in the first aspect.
[0043] The present disclosure provides a text editing method, device and related equipment, the method comprising: obtaining text editing information, the text editing information being a natural language text for indicating text editing of a text to be edited; filling the text editing information into a large language model prompt template to obtain a large language model prompt, the large language model prompt being used to prompt a target large language model to generate code corresponding to the text editing information; inputting the large language model prompt into the target large language model for code generation to obtain a target code, the target code being used to perform the text editing operation indicated by the text editing information; and performing text editing on the text to be edited by executing the target code to obtain a target text. The present disclosure obtains text editing information for text editing of a text to be edited, fills the text editing information into a large language model prompt template to obtain a large language model prompt, then inputs the large language model prompt to generate a target code, and executes the target code to edit the text to be edited, thereby avoiding the problem of low editing efficiency when the text to be edited is too large and the large language model is used to directly perform text editing on the text to be edited, thereby improving the text editing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the description of the embodiments of the present disclosure will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0045] Figure 1 A flowchart of a text editing method provided by an embodiment of the present disclosure;
[0046] Figure 2 A structural schematic diagram of a text editing device provided by an embodiment of the present disclosure;
[0047] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0049] The terms "first", "second", etc. in the embodiments of the present disclosure are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. In addition, the terms "include" and "have" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices. In addition, "and / or" is used in the present disclosure to represent at least one of the connected objects, such as A and / or B and / or C, which means including 7 situations including single A, single B, single C, and both A and B exist, both B and C exist, both A and C exist, and both A, B and C exist.
[0050] See also Figure 1 , Figure 1 It is a flowchart of the text editing method provided by an embodiment of the present disclosure. Figure 1 The text editing method shown can be executed by a computer such as a server. Figure 1 As shown, the text editing method may include the following steps:
[0051] Step 101: Acquire text editing information, where the text editing information is a natural language text for instructing to perform text editing on a text to be edited.
[0052] In the present embodiment, the text to be edited is the text in a traditional text editing system, such as the text in a notepad and the text in a text code editor. Relatively simple text editing operations can be implemented in the text editing system, but complex text editing operations such as replacing the text background editing code cannot be directly implemented. It should be noted that the text background editing code is used to set and change the text format or other information. It is necessary to enter instructions or open the background page before browsing and editing. Therefore, it is impossible to directly rewrite the text background editing code through the text editing system. In the present disclosure, the text editing information input by the user and the text to be edited that needs to be edited are obtained. Specifically, the user can enter the text to be edited and the text editing information that needs to be edited in the display interface of the server, thereby obtaining the user's need for text editing.
[0053] It should be noted that the text to be edited and the text editing information input by the user are both natural language texts, that is, commonly used language texts. For example, the text editing information input by the user is "1. Replace all "hello" in the text to be edited with "world". 2. Replace W_if_MSSG_TYPE with W_if_PROD_CD, and W_ex_MSSG_TYPE with W_ex_PROD_CD in all texts from lines 5 to 10." It can be seen from the above examples that the user's text editing requirement 1 is a text replacement operation, and text editing requirement 2 is a code replacement operation, wherein the replacement objects of text editing requirement 1 and text editing requirement 2 are different, text editing requirement 1 is to directly replace the text content, and text editing requirement 2 is to replace the text background editing code. In actual application, text editing can also be in other ways, which are not specifically limited in this embodiment.
[0054] Step 102: Fill the text editing information into a large language model prompt template to obtain a large language model prompt, where the large language model prompt is used to prompt a target large language model to generate a code corresponding to the text editing information.
[0055] In this embodiment, a large language model prompt refers to a structured input method that a user can use when interacting with a large language model (LLM). These templates can help users more effectively guide the model to generate the desired response. By providing clear and specific prompts, users can increase the possibility of obtaining relevant and high-quality answers. In this embodiment, the large language model prompt template is a pre-generated template. In actual use, the user only needs to enter the text editing information, and the text editing information can be filled into the large language model prompt template to generate a large language model prompt.
[0056] In the present disclosure, the large language model prompt is used to prompt the target large language model to generate code corresponding to the text editing information, that is, the target large language model is used to generate corresponding code content according to the input large language model prompt.
[0057] It should be noted that the large language model prompt template is generally a pre-generated template and matches the target large language model, so you only need to fill in the text editing information into the large language model prompt template to get the large language model prompt.
[0058] Step 103: input the large language model prompt into the target large language model for code generation to obtain a target code, wherein the target code is used to execute the text editing operation indicated by the text editing information.
[0059] In this embodiment, the target large language model is a pre-trained large language model, which can generate corresponding code content according to the input large language model prompt. Among them, the large language model can use a closed-source basic model service or call an open-source model service, which is not specifically limited in this embodiment.
[0060] The generated large language model prompt is input into the target large language model for processing, thereby generating a target code. After the target code is executed, a text editing operation can be performed on the text to be edited, thereby obtaining the processed text to be edited.
[0061] It should be noted that since the text editing information is much less than the text content of the entire text to be edited, the number of lines of target code generated by the target large language model in the present disclosure will be relatively small, generally only a few dozen lines, so the time required for processing by the target large language model will be relatively short. Compared with the existing solution of inputting the entire text to be edited into the large language model for replacement, the present disclosure can significantly improve the processing efficiency of the large language model, thereby improving the text editing efficiency.
[0062] Step 104: Edit the text to be edited by executing the target code to obtain a target text.
[0063] In this embodiment, the target code generally needs to be deployed on a related code platform for operation, or the code operation environment needs to be established by itself. For example, in this disclosure, the deployment service called can use the code platform, or the function code platform can be built by itself. Specifically, after the target code is generated, the target code is deployed on the code platform. When the text needs to be edited, the text to be edited is sent to the code platform to request the target code to be called to edit the text to be edited, and the processed target text is received, thereby realizing the text editing of the text to be edited.
[0064] It should be noted that the target text is the completed text editing version of the text to be edited, that is, the relevant content therein has been processed accordingly according to the text editing information, thereby quickly completing the text editing of the text to be edited, and realizing related text editing operations that cannot be realized in the text editing system, thereby improving the efficiency of text editing.
[0065] The present disclosure obtains text editing information for editing a text to be edited, fills the text editing information into a large language model prompt template, obtains a large language model prompt, and then inputs the text editing information into the large language model to generate a target code, and executes the target code to edit the text to be edited, thereby avoiding the problem of low editing efficiency when the text to be edited is too large and using the large language model to directly edit the text to be edited, thereby improving the text editing efficiency.
[0066] In some feasible implementations, optionally, filling the text editing information into a large language model prompt template to obtain a large language model prompt includes:
[0067] Matching a target large language model according to the text editing information, wherein the target large language model is used to convert the text editing information into a code corresponding to the text editing information;
[0068] Acquire the large language model prompt template that matches the target large language model, wherein the large language model prompt template includes a template text and a fill-in text area, wherein the template text is pre-generated text content, and the fill-in text area is used to fill in text for which code needs to be generated;
[0069] The text editing information is filled into the fill-in text area and combined with the template text to obtain the large language model prompt.
[0070] In this embodiment, the target large language model is a large language model for code generation. In this embodiment, a large language model that can convert text editing information into code is sufficient. Therefore, after obtaining the text editing information, it can be matched among multiple open source large language models, and a large language model that can realize the function of converting text into code can be selected and determined as the target large language model. The large language model prompt template in this embodiment needs to match the target large language model, so it is necessary to obtain a large language model prompt template that matches the target large language model.
[0071] Exemplarily, the template text in the large language model prompt template in this embodiment may be the following content:
[0072] "Write a text processing program in Python with a method called process. The program reads a text file and outputs the processed file. The processing logic is as follows:
[0073] {-User Demand 1}
[0074] {-User Demand 2}
[0075] Please output the specific program"
[0076] After filling in the large language model prompt template in the fill-in text area, the large language model prompt can be the following:
[0077] ""Write a text processing program in Python with the method name process. The program reads a text file and outputs the processed file. The processing logic is as follows:
[0078] -Replace all occurrences of "hello" with "world" in the text
[0079] -Replace W_if_MSSG_TYPE with W_if_PROD_CD and W_ex_MSSG_TYPE with W_ex_PROD_CD in all texts from lines 5 to 10. There may be other texts in the same format as W_abc_MSSG_TYPE, and there may be others. Replace them with the format of W_abc_PROD_TYPE.
[0080] Please output the specific program"
[0081] The above example is a large language model prompt directly input into the large language model. After receiving the prompt, the large language model will generate relevant code according to the prompt. Through the large language model prompt template, the large language model prompt can be quickly generated, thereby improving the generation efficiency of the target code.
[0082] Optionally, the step of inputting the large language model prompt into the target large language model for code generation to obtain the target code includes:
[0083] Inputting the large language model prompt into the target large language model for code generation to obtain initial code;
[0084] Performing accuracy verification on the initial code, wherein the accuracy verification is used to verify whether the initial code can operate normally;
[0085] If the accuracy of the initial code is verified to be passed, determining the initial code as the target code;
[0086] When the accuracy verification of the initial code fails, the initial code is adjusted to obtain the target code.
[0087] In this embodiment, the generated large language model prompt is input into the pre-trained target large language model to generate the initial code. Exemplarily, the result returned by the target large language model is:
[0088] The following is a text processing program implemented in Python:
[0089]
[0090]
[0091] The above initial code is used to implement the text editing information of "replace all "hello" in the text with "world", replace W_if_MSSG_TYPE in all texts from lines 5 to 10 with W_if_PROD_CD, and replace W_ex_MSSG_TYPE with W_ex_PROD_CD. There may be styles like W_abc_MSSG_TYPE, and there may be others, which are replaced with the format of W_abc_PROD_TYPE".
[0092] It should be noted that, in this embodiment, after obtaining the initial code, the initial code needs to be verified for accuracy, and the accuracy verification is used to verify whether the initial code can run normally. Specifically, the verification can be performed manually or by a machine, which is not specifically limited in this embodiment.
[0093] If the accuracy verification of the initial code passes, it indicates that the initial code can run normally, that is, the initial code is determined as the target code. If the accuracy verification of the initial code fails, it indicates that the initial code cannot run normally. At this time, the initial code can be adjusted by manual rewriting or machine rewriting to obtain the target code that can run normally.
[0094] In this embodiment, since the code generated by the large language model may not be able to run, it is necessary to verify it after the initial code is generated. The code is used when the verification passes, ensuring the accuracy of editing the text by executing the code.
[0095] Optionally, the acquiring text editing information includes:
[0096] Acquire a selected text editing requirement, where the text editing requirement includes at least one text editing operation selected from a plurality of text editing operations, where the plurality of text editing operations are used to perform text editing processing on a text to be edited;
[0097] Obtaining an input editing target, wherein the editing target is the text content to be edited in the text to be edited;
[0098] The text editing requirement and the editing target are combined and converted into text information expressed in a natural language to obtain the text editing information.
[0099] In this embodiment, the user can select at least one text editing operation in the display interface to generate the user's selected text editing requirements. Among them, the text editing operation includes at least one of the following: text expansion of the text to be edited, text deletion of the text to be edited, text replacement of the text to be edited, text annotation of the text to be edited, text format change of the text to be edited, and text code command change of the text to be edited. There may also be other contents, which are not specifically limited in this embodiment.
[0100] The editing target is the text content in the text to be edited that needs to be edited. Specifically, for example, a certain paragraph or a certain sentence. Exemplarily, for example, if the text editing operation selected by the user is the replacement operation, then the user needs to input the content to be replaced. For example, replace "hello" in the text with "你好". At this time, "hello" and "你好" are the editing targets that the user needs to input.
[0101] After receiving the user's selected text editing requirements and editing targets, the above contents are combined to form text information represented in natural language. For example, the text information is "Replace all 'hello' in the text with '你好'". That is, the user only needs to select the replacement operation and input "hello" and "你好" at the corresponding positions to automatically generate the corresponding text editing information. Through the operations of selecting text editing operations and inputting editing targets in this embodiment, it can quickly help the user select the text editing function to be implemented, without the user having to input the complete text editing information by themselves, improving the acquisition efficiency of natural language editing information, enhancing the user experience, and saving user operations.
[0102] Optionally, the text editing of the text to be edited by executing the target code to obtain the target text includes:
[0103] Deploy the target code in the first code platform, or build a second code platform based on the target code. The first code platform or the second code platform is used to execute the target code on the text to be edited;
[0104] Send the text to be edited to the first code platform or the second code platform;
[0105] Receive the target text generated by the first code platform or the second code platform through executing the target code to perform text editing on the edited text.
[0106] In this embodiment, the code needs to be deployed in the code platform for use. Specifically, when the target code is executed locally without a configuration environment, the target code can be deployed in the first code platform, such as a function-as-a-service platform. Therefore, it is only necessary to deploy the target code in the first code platform to send the text to be edited to the first code platform. After executing the target code on the text to be edited, the first code platform will feedback the target code executed locally.
[0107] In addition, you can also build a second code platform based on the target code, for example, based on Kubernetes. After the second code platform is built locally, the text to be edited is sent to the second code platform, just like the first code platform, so that the second code platform will feedback the target code executed locally after executing the target code on the edited text.
[0108] In this embodiment, by deploying the target code on an existing code platform or rebuilding the code platform, the normal operation of the code can be guaranteed, avoiding the situation where the code cannot be run normally locally. When running the code on the code platform, the user only needs to send the text to be edited to the code platform to get feedback, without any other operations, thus saving the user's local resources.
[0109] Optionally, sending the to-be-edited text to the first code platform or the second code platform includes:
[0110] Generate a target call request, where the target call request is used to request the first code platform or the second code platform to call the target code;
[0111] The target call request and the text to be edited are sent to the first code platform or the second code platform.
[0112] In this embodiment, before sending the text to be edited to the first code platform or the second code platform, it is necessary to generate a target call request, wherein the target call request is used to request to call the target code in the first code platform or the second code platform. Specifically, since multiple codes are stored in the first code platform or the second code platform, the user needs to accurately propose the target code to be called to the first code platform or the second code platform to improve the calling efficiency of the code platform.
[0113] Specifically, when a user sends a request to the first code platform or the second code platform, the target call request and the text to be edited need to be sent at the same time. After receiving the request, the first code platform or the second code platform calls the target code to process the text to be edited, and finally feeds back the processed target text, thereby improving the calling efficiency of the first code platform or the second code platform.
[0114] Optionally, the first code platform or the second code platform includes a target database, the target database includes a plurality of candidate codes, and the deploying the target code in the first code platform, or building the second code platform based on the target code, includes:
[0115] matching the plurality of candidate codes with the target code;
[0116] In the case where the target code is the same as the target candidate code, in the first code platform or the second code platform, the target candidate code is determined as the target code, and the target candidate code is any one of the multiple candidate codes;
[0117] In the case where the target code is different from the target candidate code, the target code is deployed in the first code platform, or a second code platform is built based on the target code.
[0118] In this embodiment, the first code platform or the second code platform includes a target database, wherein the target database stores multiple candidate codes in advance based on historical data. When a user requests to deploy the generated target code in the first code platform or to build a second code platform based on the target code, it is necessary to match the generated code with the multiple candidate codes to determine whether the target code is the same as the multiple candidate codes. For example, the target code is used to replace the text content in the full text, and the target candidate code in the database is also used to replace the text content in the full text. For example, the target code is used to replace the code content in the text background editing code, and the target candidate code in the database is also used to replace the code content in the text background editing code. At this time, the target candidate code can be determined as the target code without redeploying the target code, thereby reducing the code deployment operation and improving processing efficiency.
[0119] When the target code is different from the target candidate code, it indicates that the target code is a new type of code. At this time, it is necessary to deploy the target code in the first code platform, or build a second code platform based on the target code, otherwise the target code cannot be run.
[0120] In this embodiment, before deploying the code, determining whether there is a target candidate code identical to the target code in the first code platform or the second code platform can avoid repeated deployment of the same code, thereby improving the processing efficiency of the code platform.
[0121] Optionally, the target large language model is obtained by training with training samples, the training samples include training text and text labels corresponding to the training text, the training text is natural language text for text editing, and the text label is a code for executing the text editing operation indicated by the training text.
[0122] In this embodiment, the target large language model is obtained by training with training samples, wherein the training samples include training text and text labels corresponding to the training text. Specifically, the training text is a natural language text for text editing. For example, the training text is "Replace "hello" in the full text with "hello"", and the text label is represented by a code representation of replacing "hello" in the full text with "hello". In this embodiment, the code representation is not specifically limited, and it is sufficient to realize the function of replacing the full text.
[0123] By training the target large language model with training text and text labels, the code generation capability of the target large language model can be improved, so that the result of the code generated by the target large language model is more accurate and meets the needs of users.
[0124] The present disclosure obtains text editing information for editing a text to be edited, fills the text editing information into a large language model prompt template, obtains a large language model prompt, and then inputs the large language model to generate a target code, and executes the target code to edit the text to be edited, thereby avoiding the problem of low editing efficiency when the text to be edited is too large and using the large language model to directly edit the text to be edited, thereby improving the text editing efficiency.
[0125] See also Figure 2 , Figure 2 is a structural diagram of a text editing device provided by an embodiment of the present disclosure. Figure 2 As shown, the text editing device 200 includes:
[0126] An acquisition module 210 is used to acquire text editing information, where the text editing information is a natural language text for instructing to perform text editing on the text to be edited;
[0127] A filling module 220 is used to fill the text editing information into the large language model prompt template to obtain a large language model prompt, wherein the large language model prompt is used to prompt the target large language model to generate a code corresponding to the text editing information;
[0128] A generating module 230, configured to input the large language model prompt into the target large language model to generate code, and obtain a target code, wherein the target code is used to execute the text editing operation indicated by the text editing information;
[0129] The execution module 240 is used to execute the target code to edit the text to be edited, so as to obtain a target text.
[0130] Optionally, the filling module 220 includes:
[0131] A matching submodule, used for matching a target large language model according to the text editing information, wherein the target large language model is used for converting the text editing information into a code corresponding to the text editing information;
[0132] A first acquisition submodule is used to acquire the large language model prompt template that matches the target large language model, wherein the large language model prompt template includes a template text and a fill-in text area, wherein the template text is pre-generated text content, and the fill-in text area is used to fill in text for which code generation is required;
[0133] The filling submodule is used to fill the text editing information into the filling text area and combine it with the template text to obtain the large language model prompt.
[0134] Optionally, the generating module 230 includes:
[0135] A generation submodule, used for inputting the large language model prompt into the target large language model to generate code and obtain initial code;
[0136] A verification submodule, used to verify the accuracy of the initial code, wherein the accuracy verification is used to verify whether the initial code can run normally;
[0137] A determination submodule, configured to determine the initial code as the target code if the accuracy verification of the initial code passes;
[0138] The adjustment submodule is used to adjust the initial code to obtain the target code when the accuracy verification of the initial code fails.
[0139] Optionally, the acquisition module 210 includes:
[0140] A second acquisition submodule is used to acquire a selected text editing requirement, wherein the text editing requirement includes at least one text editing operation selected from a plurality of text editing operations, wherein the plurality of text editing operations are used to perform text editing processing on the text to be edited;
[0141] A third acquisition submodule is used to acquire an input editing target, where the editing target is the text content that needs to be edited in the text to be edited;
[0142] The conversion submodule is used to convert the text editing requirement and the editing target combination into text information represented by natural language to obtain the text editing information.
[0143] Optionally, the execution module 240 includes:
[0144] A deployment submodule, used for deploying the target code in a first code platform, or building a second code platform based on the target code, wherein the first code platform or the second code platform is used for executing the target code on the text to be edited;
[0145] A sending submodule, used for sending the text to be edited to the first code platform or the second code platform;
[0146] A receiving submodule is used to receive the target text generated by the first code platform or the second code platform by executing the target code to perform text editing on the edit text.
[0147] Optionally, the sending submodule includes:
[0148] A generating unit, configured to generate a target calling request, wherein the target calling request is used to request the first code platform or the second code platform to call the target code;
[0149] A sending unit is used to send the target call request and the text to be edited to the first code platform or the second code platform.
[0150] Optionally, the first code platform or the second code platform includes a target database, the target database includes a plurality of candidate codes, and the deployment submodule includes:
[0151] A matching unit, configured to match the plurality of candidate codes with the target code;
[0152] a determination unit, configured to determine, in the first code platform or the second code platform, the target candidate code as the target code when the target code is the same as the target candidate code, the target candidate code being any one of the multiple candidate codes;
[0153] A deployment unit is used to deploy the target code in a first code platform when the target code is different from the target candidate code, or to build a second code platform based on the target code.
[0154] Optionally, the target large language model is obtained by training with training samples, the training samples include training text and text labels corresponding to the training text, the training text is natural language text for text editing, and the text label is a code for executing the text editing operation indicated by the training text.
[0155] The present disclosure obtains text editing information for editing a text to be edited, fills the text editing information into a large language model prompt template, obtains a large language model prompt, and then inputs the large language model to generate a target code, and executes the target code to edit the text to be edited, thereby avoiding the problem of low editing efficiency when the text to be edited is too large and using the large language model to directly edit the text to be edited, thereby improving the text editing efficiency.
[0156] The present disclosure also provides an electronic device. Figure 3 , the electronic device may include a processor 301, a memory 302, and a program 3021 stored in the memory 302 and executable on the processor 301.
[0157] When the program 3021 is executed by the processor 301, it can achieve Figure 1 Any step in the corresponding method embodiment:
[0158] Acquire text editing information, where the text editing information is a natural language text for instructing to perform text editing on the text to be edited;
[0159] Filling the text editing information into a large language model prompt template to obtain a large language model prompt, wherein the large language model prompt is used to prompt a target large language model to generate a code corresponding to the text editing information;
[0160] Inputting the large language model prompt into the target large language model for code generation to obtain a target code, wherein the target code is used to execute the text editing operation indicated by the text editing information;
[0161] The target text is obtained by executing the target code to edit the text to be edited.
[0162] Optionally, filling the text editing information into a large language model prompt template to obtain a large language model prompt includes:
[0163] Matching a target large language model according to the text editing information, wherein the target large language model is used to convert the text editing information into a code corresponding to the text editing information;
[0164] Acquire the large language model prompt template that matches the target large language model, wherein the large language model prompt template includes a template text and a fill-in text area, wherein the template text is pre-generated text content, and the fill-in text area is used to fill in text for which code needs to be generated;
[0165] The text editing information is filled into the fill-in text area and combined with the template text to obtain the large language model prompt.
[0166] Optionally, the step of inputting the large language model prompt into the target large language model for code generation to obtain the target code includes:
[0167] Inputting the large language model prompt into the target large language model for code generation to obtain initial code;
[0168] Performing accuracy verification on the initial code, wherein the accuracy verification is used to verify whether the initial code can operate normally;
[0169] If the accuracy of the initial code is verified to be passed, determining the initial code as the target code;
[0170] When the accuracy verification of the initial code fails, the initial code is adjusted to obtain the target code.
[0171] Optionally, the acquiring text editing information includes:
[0172] Acquire a selected text editing requirement, where the text editing requirement includes at least one text editing operation selected from a plurality of text editing operations, where the plurality of text editing operations are used to perform text editing processing on a text to be edited;
[0173] Obtaining an input editing target, wherein the editing target is the text content to be edited in the text to be edited;
[0174] The text editing requirement and the editing target are combined and converted into text information expressed in a natural language to obtain the text editing information.
[0175] Optionally, the step of executing the target code to edit the text to be edited to obtain the target text includes:
[0176] Deploy the target code in a first code platform, or build a second code platform based on the target code, wherein the first code platform or the second code platform is used to execute the target code on the text to be edited;
[0177] Sending the text to be edited to the first code platform or the second code platform;
[0178] The target text generated by the first code platform or the second code platform performing text editing on the edit text by executing the target code is received.
[0179] Optionally, sending the to-be-edited text to the first code platform or the second code platform includes:
[0180] Generate a target call request, where the target call request is used to request the first code platform or the second code platform to call the target code;
[0181] The target call request and the text to be edited are sent to the first code platform or the second code platform.
[0182] Optionally, the first code platform or the second code platform includes a target database, the target database includes a plurality of candidate codes, and the deploying the target code in the first code platform, or building the second code platform based on the target code, includes:
[0183] matching the plurality of candidate codes with the target code;
[0184] In the case where the target code is the same as the target candidate code, in the first code platform or the second code platform, the target candidate code is determined as the target code, and the target candidate code is any one of the multiple candidate codes;
[0185] In the case where the target code is different from the target candidate code, the target code is deployed in the first code platform, or a second code platform is built based on the target code.
[0186] Optionally, the target large language model is obtained by training with training samples, the training samples include training text and text labels corresponding to the training text, the training text is natural language text for text editing, and the text label is a code for executing the text editing operation indicated by the training text.
[0187] The present disclosure obtains text editing information for editing a text to be edited, fills the text editing information into a large language model prompt template, obtains a large language model prompt, and then inputs the large language model to generate a target code, and executes the target code to edit the text to be edited, thereby avoiding the problem of low editing efficiency when the text to be edited is too large and using the large language model to directly edit the text to be edited, thereby improving the text editing efficiency.
[0188] The embodiment of the present disclosure also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the above-mentioned text editing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0189] The embodiments of the present disclosure further provide a computer program product, which is stored in a storage medium. The computer program product is executed by at least one processor to implement the various processes of the above-mentioned text editing method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0190] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0191] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present disclosure, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present disclosure.
[0192] The embodiments of the present disclosure are described above in conjunction with the accompanying drawings, but the present disclosure is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present disclosure, ordinary technicians in this field can also make many forms without departing from the scope of protection of the purpose of the present disclosure and the claims, all of which are within the protection of the present disclosure.
Claims
1. A text editing method, characterized in that: The method comprises: Acquire text editing information, where the text editing information is a natural language text for instructing to perform text editing on the text to be edited; Filling the text editing information into a large language model prompt template to obtain a large language model prompt, wherein the large language model prompt is used to prompt a target large language model to generate a code corresponding to the text editing information; Inputting the large language model prompt into the target large language model for code generation to obtain a target code, wherein the target code is used to execute the text editing operation indicated by the text editing information; The target text is obtained by executing the target code to edit the text to be edited.
2. The method according to claim 1, characterized in that Filling the text editing information into a large language model prompt template to obtain a large language model prompt includes: Matching a target large language model according to the text editing information, wherein the target large language model is used to convert the text editing information into a code corresponding to the text editing information; Acquire the large language model prompt template that matches the target large language model, wherein the large language model prompt template includes a template text and a fill-in text area, wherein the template text is pre-generated text content, and the fill-in text area is used to fill in text for which code needs to be generated; The text editing information is filled into the fill-in text area and combined with the template text to obtain the large language model prompt.
3. The method according to claim 2, characterized in that The inputting the large language model prompt into the target large language model to generate code to obtain the target code comprises: Inputting the large language model prompt into the target large language model for code generation to obtain initial code; Performing accuracy verification on the initial code, wherein the accuracy verification is used to verify whether the initial code can operate normally; If the accuracy of the initial code is verified to be passed, determining the initial code as the target code; When the accuracy verification of the initial code fails, the initial code is adjusted to obtain the target code.
4. The method according to claim 1, characterized in that: The obtaining of text editing information includes: Acquire a selected text editing requirement, where the text editing requirement includes at least one text editing operation selected from a plurality of text editing operations, where the plurality of text editing operations are used to perform text editing processing on a text to be edited; Obtaining an input editing target, wherein the editing target is the text content to be edited in the text to be edited; The text editing requirement and the editing target are combined and converted into text information expressed in a natural language to obtain the text editing information.
5. The method according to claim 1, characterized in that The step of executing the target code to edit the text to be edited to obtain the target text comprises: Deploy the target code in a first code platform, or build a second code platform based on the target code, wherein the first code platform or the second code platform is used to execute the target code on the text to be edited; Sending the text to be edited to the first code platform or the second code platform; The target text generated by the first code platform or the second code platform performing text editing on the edit text by executing the target code is received.
6. The method according to claim 5, characterized in that The sending the to-be-edited text to the first code platform or the second code platform includes: Generate a target call request, where the target call request is used to request the first code platform or the second code platform to call the target code; The target call request and the text to be edited are sent to the first code platform or the second code platform.
7. The method according to claim 5, characterized in that The first code platform or the second code platform includes a target database, the target database includes a plurality of candidate codes, and the deploying the target code in the first code platform, or building the second code platform based on the target code, includes: matching the plurality of candidate codes with the target code; In the case where the target code is the same as the target candidate code, in the first code platform or the second code platform, the target candidate code is determined as the target code, and the target candidate code is any one of the multiple candidate codes; In the case where the target code is different from the target candidate code, the target code is deployed in the first code platform, or a second code platform is built based on the target code.
8. The method according to claim 1, characterized in that The target large language model is obtained by training with training samples, wherein the training samples include training text and text labels corresponding to the training text, the training text is a natural language text for text editing, and the text label is a code for executing the text editing operation indicated by the training text.
9. A text editing device, characterized in that: The device comprises: An acquisition module, used for acquiring text editing information, wherein the text editing information is a natural language text for indicating that text editing should be performed on the text to be edited; A filling module, used to fill the text editing information into the large language model prompt template to obtain a large language model prompt, wherein the large language model prompt is used to prompt the target large language model to generate a code corresponding to the text editing information; A generating module, configured to input the large language model prompt into the target large language model to generate code, and obtain a target code, wherein the target code is used to execute the text editing operation indicated by the text editing information; The execution module is used to edit the text to be edited by executing the target code to obtain the target text.
10. An electronic device, comprising: A memory, a processor, and a program stored in the memory and executable on the processor; wherein the processor is used to read the program in the memory to implement the steps in the text editing method as described in any one of claims 1 to 8.