Automatic construction method and device of instruction data set, storage medium and electronic equipment
By initializing the instruction pool in the financial field and training on the instruction pool in the financial field, we generate and optimize the instruction data sets applicable to the financial field, and solve the problems of insufficient instruction understanding ability and high collection costs of open source models in the financial field, achieving high efficiency and low Cost instruction data construction.
Patent Information
- Application Number
- CN202411411341.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-10
- Publication Date
- 2025-01-03
AI Technical Summary
The existing open source model has insufficient instruction understanding capabilities in the financial field, cannot generate high-quality output, and depends on feedback from business personnel and data collection costs, so it cannot cover business needs in a timely manner.
By initializing the instruction pool, using the initial open source model for training with few samples, generating candidate instructions, and filtering according to the similarity between the candidate instructions and the seed instructions, generating target new instructions, and optimizing the initial open source model for application in the financial field.
It realizes the automated construction of instruction data sets suitable for the financial field, which reduces costs and time, improves the diversity and quality of instructions, and solves the problems of insufficient open source model capabilities and high collection costs.
Smart Images

Figure CN119250230A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of financial big models, and in particular, to a method for automatically constructing an instruction data set, an automatic construction device for an instruction data set, a computer-readable storage medium, and an electronic device. Background Art
[0002] The artificial intelligence model product ChatGPT can understand and generate natural language, handle complex conversation tasks, and even create and program. The big model has a very important ability: command-following ability, that is, the big model can understand the instructions given to it by people and respond to the content that meets the requirements according to the requirements of the instructions.
[0003] Although commercial big models are powerful, there is a risk of data insecurity when using them directly, which may lead to internal data leakage. The cost of developing a big model directly from 0 to 1 is high, and the mainstream method in the industry is to build an enterprise model based on the open source big model. However, the existing open source big models are relatively weak, and do not fully understand the instructions of vertical field scenarios. They are not suitable for processing professional scenarios and cannot generate high-quality outputs. Therefore, for the implementation of financial big models, it is necessary to use financial-related instruction data to fine-tune the model before it can be actually applied to the business. However, this requires the collection of a large amount of financial task instruction data, and the collection cost is very high. Summary of the invention
[0004] The main purpose of the present application is to provide a method for automatically constructing an instruction data set, an automatic construction device for an instruction data set, a computer-readable storage medium and an electronic device, so as to at least solve the problem in the prior art that the open source instructions of the open source large model are poorly related to the business field, are highly dependent on the feedback of business personnel, have high collection costs, and cannot cover business needs in a timely manner.
[0005] In order to achieve the above-mentioned purpose, according to one aspect of the present application, there is provided a method for automatically constructing an instruction data set, comprising: initializing an instruction pool to obtain an initialized instruction pool, wherein the initialized instruction pool includes multiple initialized seed instructions; inputting the initialized seed instructions into an initial open source model for few-sample learning training to obtain multiple candidate instructions, and inputting the candidate instructions, each of the initialized seed instructions, and the instruction type with the initialized seed into the initial open source model for the few-sample learning training to obtain the instruction type of each of the candidate instructions; filtering the candidate instructions according to the similarity between the candidate instructions and the initialized seed instructions to obtain a target new instruction, and generating an instruction response for the target new instruction; adding the target new instruction, the instruction type of the target new instruction, and the instruction response of the target new instruction to the initialized instruction pool to obtain a target instruction pool, and optimizing the initial open source model according to the instruction data in the target instruction pool to obtain a target artificial intelligence model.
[0006] Optionally, the initialization seed instruction includes a first initialization instruction and a second initialization instruction, and the instruction pool is initialized to obtain an initialization instruction pool, including: constructing the initialization seed instruction based on three parts: instruction description, instruction response and instruction type, the instruction description is the Chinese description of the initialization seed instruction, the instruction response is at least one response corresponding to the initialization seed instruction, and the instruction type is the type of the initialization seed instruction; determining a first number of the first initialization instructions and a second number of the second initialization instructions according to business data, the first initialization instruction is the initialization seed instruction whose instruction type is a target type, and the second initialization instruction is the initialization seed instruction whose instruction type is a non-target type; initializing the instruction pool based on all of the first initialization instructions and all of the second initialization instructions to obtain the initialization instruction pool.
[0007] Optionally, the initialization seed instruction includes a first initialization instruction and a second initialization instruction, and the initialization seed instruction is input into the initial open source model for few-sample learning training to obtain multiple candidate instructions, including: step S2021, randomly selecting a third number of the first initialization instructions and a fourth number of the second initialization instructions from the initialization instruction pool, and randomly arranging the first initialization instructions and the second initialization instructions and inputting them into the initial open source model for the few-sample learning training to obtain one candidate instruction, wherein the first initialization instruction is the initialization seed instruction whose instruction type is the target type, and the second initialization instruction is the initialization seed instruction whose instruction type is the non-target type; step S2022, repeating step S2021 for a preset number of times to obtain multiple candidate instructions, and the preset number of times is related to the number of the first initialization instructions and the number of the second initialization instructions in the initialization instruction pool.
[0008] Optionally, according to the similarity between the candidate instructions and the initialization seed instructions, the candidate instructions are filtered to obtain target new instructions, including: each of the candidate instructions and the initialization seed instructions is segmented by a word segmentation tool to construct a corresponding word segmentation sequence; according to the word segmentation sequence of the candidate instructions and the word segmentation sequence of the initialization seed instructions, the similarity between the candidate instructions and the initialization seed instructions is determined; when the similarity is greater than a preset similarity, the candidate instructions are removed, and when the similarity is less than or equal to the preset similarity, the candidate instructions are determined as the target new instructions, and the preset similarity is related to the number of the initialization seed instructions in the initialization instruction pool.
[0009] Optionally, the similarity between the candidate instruction and the initialization seed instruction is determined according to the word segmentation sequence of the candidate instruction and the word segmentation sequence of the initialization seed instruction, including: calculating the number of repeated words and the number of different words between the candidate instruction and the initialization seed instruction according to the word segmentation sequence of the candidate instruction and the word segmentation sequence of the initialization seed instruction; determining the similarity between the candidate instruction and the initialization seed instruction according to the similarity calculation formula sim(i, j)=a / (a+b), wherein sim(i, j) is the similarity between the i-th candidate instruction and the j-th initialization seed instruction, a is the number of repeated words between the i-th candidate instruction and the j-th initialization seed instruction, and b is the number of different words between the i-th candidate instruction and the j-th initialization seed instruction.
[0010] Optionally, before removing the candidate instructions, the method also includes: when the number of the initialization seed instructions in the initialization instruction pool is less than the minimum number, setting the preset similarity to a maximum preset value; when the number of the initialization seed instructions in the initialization instruction pool is greater than the maximum number, setting the preset similarity to a minimum preset value; when the number of the initialization seed instructions in the initialization instruction pool is greater than or equal to the minimum number and less than or equal to the maximum number, using a similarity calculation formula f=m×g+b to determine the preset similarity, wherein f is the preset similarity, m is the first coefficient, b is the second coefficient, and g is the number of the initialization seed instructions in the initialization instruction pool.
[0011] Optionally, the target new instruction corresponds to at least one of the instruction responses, and the target new instruction, the instruction type of the target new instruction, and the instruction response of the target new instruction are added to the initialization instruction pool to obtain the target instruction pool, including: calculating the number of instructions in the target instruction pool, stopping generating new instructions when the number of instructions is greater than or equal to a preset number, and continuing to generate the target new instruction when the number of instructions is less than the preset number.
[0012] According to another aspect of the present application, there is provided an automatic construction device for an instruction data set, comprising: a first processing unit, for initializing an instruction pool to obtain an initialized instruction pool, wherein the initialized instruction pool includes a plurality of initialized seed instructions; a second processing unit, for inputting the initialized seed instructions into an initial open source model for few-sample learning training to obtain a plurality of candidate instructions, and inputting the candidate instructions, each of the initialized seed instructions, and the instruction type with the initialized seed into the initial open source model for the few-sample learning training to obtain the instruction type of each of the candidate instructions; a third processing unit, for filtering the candidate instructions according to the similarity between the candidate instructions and the initialized seed instructions to obtain a target new instruction, and generating an instruction response of the target new instruction; a fourth processing unit, for adding the target new instruction, the instruction type of the target new instruction, and the instruction response of the target new instruction to the initialized instruction pool to obtain a target instruction pool, and optimizing the initial open source model according to the instruction data in the target instruction pool to obtain a target artificial intelligence model.
[0013] According to another aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute any one of the methods for automatically constructing an instruction data set.
[0014] According to another aspect of the present application, an electronic device is provided, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include an automatic construction method for executing any one of the above-mentioned instruction data sets.
[0015] Applying the technical solution of the present application, the method for automatically constructing the above-mentioned instruction data set first initializes the instruction pool to obtain an initialized instruction pool, which includes multiple initialized seed instructions; then, the initialized seed instructions are input into the initial open source model for few-sample learning training to obtain multiple candidate instructions, and the candidate instructions, each initialized seed instruction, and the instruction type with the initialized seed are input into the initial open source model for few-sample learning training to obtain the instruction type of each candidate instruction; then, according to the similarity between the candidate instructions and the initialized seed instructions, the candidate instructions are filtered to obtain the target new instruction, and the instruction response of the target new instruction is generated; finally, the target new instruction, the instruction type of the target new instruction, and the instruction response of the target new instruction are added to the initialized instruction pool to obtain the target instruction pool, and the initial open source model is optimized according to the instruction data in the target instruction pool to obtain the target artificial intelligence model. This method can automatically generate instruction data suitable for the financial field in the entire process with low cost and high efficiency, and can ensure the diversity of instructions. The instructions include financial and non-financial instructions, which improves the diversity of generated instructions and solves the problem that the open source instructions of the open source large model in the existing technology are poorly related to the business field, and are highly dependent on the feedback of business personnel, with high collection costs and inability to cover business needs in a timely manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings constituting part of the present application are used to provide a further understanding of the present application. The exemplary embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0017] Figure 1 A hardware structure block diagram of a mobile terminal according to an automatic construction method of an execution instruction data set provided in an embodiment of the present application is shown;
[0018] Figure 2 A schematic diagram of a flow chart of a method for automatically constructing an instruction data set provided according to an embodiment of the present application is shown;
[0019] Figure 3 A schematic diagram of generating candidate instructions according to an embodiment of the present application is shown;
[0020] Figure 4A schematic diagram of generating a type of candidate instruction provided according to an embodiment of the present application is shown;
[0021] Figure 5 A schematic diagram of generating a command response for a target new command provided in accordance with an embodiment of the present application is shown;
[0022] Figure 6 A schematic diagram showing a flow chart of another method for automatically constructing an instruction data set provided according to an embodiment of the present application;
[0023] Figure 7 A structural block diagram of an automatic construction device for an instruction data set provided according to an embodiment of the present application is shown.
[0024] The above drawings include the following reference numerals:
[0025] 102, processor; 104, memory; 106, transmission device; 108, input and output devices. DETAILED DESCRIPTION
[0026] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0027] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising 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.
[0029] For the convenience of description, some nouns or terms involved in the embodiments of the present application are explained below:
[0030] Instruction: A prompt input used to instruct the large model to perform a corresponding task. For example: Please write a poem for me.
[0031] Response: The large model will generate corresponding output according to user instructions.
[0032] Fine-tuning: It means further training the model using new task data based on the pretrained model to adapt to the new task.
[0033] Instruction tuning: Use instruction and response data to fine-tune large models.
[0034] Few-shot learning: Use a small number of examples of a specific task as input to the large model, and the large model generates task samples based on the examples.
[0035] As introduced in the background technology, the open source large model in the existing technology is weak in capability, does not fully understand the instructions of vertical field scenarios, is not suitable for processing professional scenarios, and cannot generate high-quality output. Therefore, it is necessary to use financial-related instruction data to fine-tune the model to meet business requirements. However, the instruction fine-tuning model requires the collection of a large amount of financial task instruction data.
[0036] At present, there are mainly two methods for instruction collection in the prior art:
[0037] 1) Collect various open source instruction data sets;
[0038] 2) Collect task instructions based on feedback from various business personnel and specific business needs.
[0039] However, the above two methods have the following problems:
[0040] 1) Method 1: The open source instructions involved are poor and not highly relevant to the financial field;
[0041] 2) Method 2 relies heavily on feedback from business personnel, has high collection costs, and cannot cover business needs in a timely manner.
[0042] In order to solve the problems in the prior art that the open source instructions of open source large models are poorly related to the business field, are highly dependent on the feedback of business personnel, have high collection costs, and cannot cover business needs in a timely manner, the embodiments of the present application provide a method for automatically constructing an instruction data set, an automatic construction device for an instruction data set, a computer-readable storage medium, and an electronic device.
[0043] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0044] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal of an automatic construction method of an instruction data set according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0045] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the automatic construction method of the instruction data set in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, the above method is implemented. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. The transmission device 106 is used to receive or send data via a network. The above-mentioned specific examples of the network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0046] In this embodiment, a method for automatically constructing an instruction data set running on a mobile terminal, a computer terminal or a similar computing device is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0047] Figure 2 FIG. 1 is a flow chart of a method for automatically constructing an instruction data set according to an embodiment of the present application. Figure 2 As shown, the method comprises the following steps:
[0048] Step S201, initializing the instruction pool to obtain an initialization instruction pool, wherein the initialization instruction pool includes a plurality of initialization seed instructions;
[0049] Specifically, the system is cold-started by manually constructing initialization instructions. The data in the instruction pool consists of three parts: instruction: the Chinese description of the instruction itself; response: one or more responses to the corresponding instruction; type: whether to output financial instructions. Among them, the type of instruction can be set differently according to business needs and is not limited to financial instructions.
[0050] The data structure of the initialization instruction is shown in Table 1 below:
[0051] Table 1. Initialization instruction data composition table
[0052]
[0053] The above-mentioned initialization seed instruction includes a first initialization instruction and a second initialization instruction, and initializing the instruction pool to obtain the initialization instruction pool includes the following steps:
[0054] Step S301, constructing the above-mentioned initialization seed instruction based on the three parts of instruction description, instruction response and instruction type, wherein the above-mentioned instruction description is the Chinese description of the above-mentioned initialization seed instruction, the above-mentioned instruction response is at least one response corresponding to the above-mentioned initialization seed instruction, and the above-mentioned instruction type is the type of the above-mentioned initialization seed instruction;
[0055] Step S302, determining a first number of the first initialization instructions and a second number of the second initialization instructions according to the business data, the first initialization instructions being the initialization seed instructions whose instruction type is the target type, and the second initialization instructions being the initialization seed instructions whose instruction type is the non-target type;
[0056] Step S303: Initialize the instruction pool based on all the first initialization instructions and all the second initialization instructions to obtain the initialization instruction pool.
[0057] Specifically, the first number may be 4, 5, or 6, and the second number may be 2, 3, or 4. By constructing a small number of first initialization instructions and second initialization instructions, the generalization capability of the large model is ensured, and the diversity of generated instructions is improved.
[0058] In some instances, K (K>3) financial instructions are manually written based on business data, each instruction has one or more responses; N (N>1) non-financial instructions are manually collected, each instruction has one or more responses. These instructions are used as the initialization seed instructions of the instruction pool.
[0059] Step S202, inputting the above-mentioned initialization seed instruction into the initial open source model for few-sample learning training to obtain multiple candidate instructions, and inputting the above-mentioned candidate instructions, each of the above-mentioned initialization seed instructions, and the instruction type of the above-mentioned initialization seed into the above-mentioned initial open source model for the above-mentioned few-sample learning training to obtain the instruction type of each of the above-mentioned candidate instructions;
[0060] Specifically, combined with professional instruction samples (initialization seed instructions), the generalization ability of the large model is used to directly generate high-quality instruction sets. At the same time, the generated instruction sets can be used again to adjust the large model, reducing the workload of manually writing instructions.
[0061] Among them, few-shot learning means that the model only needs a few examples (usually a few to dozens) to learn a task. The "shot" here can be understood as an example or sample.
[0062] The above-mentioned initialization seed instruction includes a first initialization instruction and a second initialization instruction. The above-mentioned initialization seed instruction is input into the initial open source model for few-sample learning training to obtain multiple candidate instructions, including:
[0063] Step S2021, randomly selecting a third number of the first initialization instructions and a fourth number of the second initialization instructions from the initialization instruction pool, and randomly arranging the first initialization instructions and the second initialization instructions and inputting them into the initial open source model for the few-sample learning training, to obtain one of the candidate instructions, wherein the first initialization instruction is the initialization seed instruction whose instruction type is the target type, and the second initialization instruction is the initialization seed instruction whose instruction type is the non-target type;
[0064] Step S2022, repeatedly executing the above step S2021 a preset number of times to obtain multiple above-mentioned candidate instructions, and the above-mentioned preset number of times is related to the number of the above-mentioned first initialization instructions and the number of the above-mentioned second initialization instructions in the above-mentioned initialization instruction pool.
[0065] Specifically, through few-sample learning training, a large number of candidate instructions can be generated based on a small number of initialization seed instructions, reducing the workload of manually writing instructions. The third number can be 3, and the fourth number can be 1.
[0066] In some examples, the specific steps of generating candidate instructions include:
[0067] 2.1. Randomly select 3 financial instructions (which can be dynamically determined according to the actual situation) and 1 non-financial instruction (which can be dynamically determined according to the actual situation) from the initialization instruction pool, and randomly arrange these instructions to form the input of the calling model. The input format is "Instruction: Please write a text message notification of salary arrival\nInstruction: Please write an article on the theme of ensuring financial security\nInstruction: Please write a poem about spring\nInstruction: Please write a notification copy about transfer arrival\nInstruction:", \n represents a line break symbol, such as Figure 3 shown.
[0068] 2.2. Use the model input constructed in 2.1 as the request parameter, call the model service, use the large model's few-sample learning ability to obtain the output as a candidate new instruction, and add it to the candidate new instruction set.
[0069] 2.3. Repeat 2.1 to 2.2r times. To avoid generating new instructions that are too similar, the number of r is related to the number of instructions in the instruction pool.
[0070] Among them, the determination of r value (preset number) includes: selecting 3 from K financial instructions (this data can be adjusted according to actual conditions), according to the permutation and combination formula, there are a total of T = C (K, 3) cases, for example, 4 cases are selected from 3 (this data can be adjusted according to actual conditions); similarly, selecting 1 from N non-financial instructions, there are M = C (N, 1), that is, M cases. In order to avoid duplication, the maximum number of r cannot exceed the minimum value of T and M, that is, r <= min (T, M). When T and M are both small (<10, this data can be adjusted according to actual conditions), the initial instruction pool is small. When r <= min (T, M) is satisfied, the maximum value in the value range is used as the r value, so that the model can generate as many new instructions as possible; when T and M are both relatively large (>50, this data can be adjusted according to actual conditions), the initial instruction pool is large. In order to ensure the diversity of instructions as much as possible, the r value should not be too large. It is recommended that the maximum value of r be set to 50 (this data can be adjusted according to actual conditions).
[0071] It should be noted that the data of each parameter in the process of determining the above r value (preset number of times) can be set differently according to actual needs and is not limited to the above values.
[0072] In some implementations, for the candidate instruction set generated in the above steps, it is necessary to determine the type of each candidate instruction (financial, non-financial), randomly select multiple instructions + types from the instruction pool, and sample "Instruction: Please write a text message notification of salary arrival\nType: Financial\nInstruction: Please write a poem about spring\nType: Non-financial\nInstruction: Please write an article on the theme of ensuring financial security\nType: Financial\nInstruction: {new instruction}\nType:" format to build model input, call the model service as a request parameter, use the large model's few-sample learning ability to obtain output, and generate new instruction categories, such as Figure 4 shown.
[0073] Step S203, filtering the candidate instructions according to the similarity between the candidate instructions and the initialization seed instructions to obtain a target new instruction, and generating an instruction response for the target new instruction;
[0074] Specifically, for similar instruction tasks, the large model (initial open source model) may generate language descriptions with the same semantics. In order to ensure the diversity of instructions generated by the large model, similar instructions are filtered and instructions with differences are retained to ensure the diversity of the instruction pool.
[0075] According to the similarity between the candidate instructions and the initialization seed instructions, the candidate instructions are filtered to obtain the target new instructions, including the following steps:
[0076] Step S401, segmenting each of the candidate instructions and the initialization seed instruction using a segmentation tool to construct a corresponding segmentation sequence;
[0077] For example: "Please write a poem about spring", the participles are ["please", "write", "a", "about", "spring", "of", "poem"].
[0078] Step S402, determining the similarity between the candidate instruction and the initialization seed instruction according to the word segmentation sequence of the candidate instruction and the word segmentation sequence of the initialization seed instruction;
[0079] Wherein, according to the word segmentation sequence of the candidate instruction and the word segmentation sequence of the initialization seed instruction, determining the similarity between the candidate instruction and the initialization seed instruction comprises the following steps:
[0080] Step S501, calculating the number of repeated words and the number of different words of the candidate instructions and the initialization seed instructions according to the word segmentation sequence of the candidate instructions and the word segmentation sequence of the initialization seed instructions;
[0081] Step S502, determine the similarity between the above candidate instructions and the above initialization seed instructions according to the similarity calculation formula sim(i, j)=a / (a+b), wherein sim(i, j) is the similarity between the i-th candidate instruction and the j-th initialization seed instruction, a is the number of repeated words between the i-th candidate instruction and the j-th initialization seed instruction, and b is the number of different words between the i-th candidate instruction and the j-th initialization seed instruction.
[0082] Specifically, in this way, the similarity between the candidate instructions and the initialization seed instruction can be accurately determined for subsequent filtering of the candidate instructions.
[0083] Step S403, when the above similarity is greater than the preset similarity, the above candidate instruction is removed; when the above similarity is less than or equal to the above preset similarity, the above candidate instruction is determined as the above target new instruction; the above preset similarity is related to the number of the above initialization seed instructions in the above initialization instruction pool.
[0084] Specifically, similar unnecessary instructions can be filtered out, and instructions with differences can be retained, thereby ensuring the diversity of the instruction pool and saving instruction pool space.
[0085] Before removing the candidate instructions, the method further includes the following steps:
[0086] Step S601, when the number of the initialization seed instructions in the initialization instruction pool is less than the minimum number, setting the preset similarity to a maximum preset value;
[0087] Step S602, when the number of the initialization seed instructions in the initialization instruction pool is greater than the maximum number, setting the preset similarity to a minimum preset value;
[0088] Among them, when the number of instructions in the instruction pool is small, the newly generated instructions are more likely to be similar. If the preset similarity is set too high in the initial stage, it is easy to cause all the newly generated instructions to be filtered out. Therefore, a larger preset similarity should be set, high_f. At the same time, when the number of instructions in the instruction pool is large, the preset similarity should be smaller, and the minimum cannot be lower than low_f to avoid adding too many similar instructions.
[0089] In some examples, the minimum number of initialization seed instructions in the initialization instruction pool is 20, and the maximum number is 100, that is, when the number of instructions in the instruction pool is less than 20, high_f (maximum preset value) is used; when the number of instructions in the instruction pool is greater than 100, low_f (minimum preset value) is used. Generally, low_f = 0.2, hight_f = 0.8. It should be noted that the number of initialization seed instructions, the maximum preset value, and the minimum preset value in the above-mentioned initialization instruction pool can be set differently according to actual needs, and are not limited to the above-mentioned values.
[0090] Step S603, when the number of the above-mentioned initialization seed instructions in the above-mentioned initialization instruction pool is greater than or equal to the above-mentioned minimum number and less than or equal to the above-mentioned maximum number, the similarity calculation formula f=m×g+b is used to determine the above-mentioned preset similarity, wherein f is the above-mentioned preset similarity, m is the first coefficient, b is the second coefficient, and g is the number of the above-mentioned initialization seed instructions in the above-mentioned initialization instruction pool.
[0091] Specifically, in this way, the value of the preset similarity can be dynamically adjusted according to the number of initialization seed instructions in the initialization instruction pool, thereby avoiding the problem that all the newly generated instructions are filtered out, or cannot be filtered out at all.
[0092] Among them, the preset similarity is a decreasing function, that is, for the 20-100 stage, f decreases as the number of instruction pools increases dynamically, the maximum value interval of the first coefficient m and the second coefficient b is [20, high_f], and the minimum value interval is [100, low_f]. Then according to the 80 / 20 rule, m = (low_f-high_f) / (80), b = high_f-(low_f-high_f) / (4), when low_f = 0.2, hight_f = 0.8, m = -3 / 400, b = 19 / 20. It should be noted that the above-mentioned first coefficient, second coefficient, maximum preset value and minimum preset value can be set differently according to actual needs, and are not limited to the above-mentioned values. The above-mentioned decreasing function takes a linear function as an example, and other decreasing functions can also be selected according to actual needs.
[0093] In some instances, the candidate instruction set obtained by filtering in the above steps is used to generate one or more responses for each instruction. The new instruction is used as the model request parameter, and the model output is obtained as the response. The specific process is as follows Figure 5 shown.
[0094] Step S204, add the above-mentioned target new instruction, the instruction type of the above-mentioned target new instruction and the instruction response of the above-mentioned target new instruction to the above-mentioned initialization instruction pool to obtain the target instruction pool, and optimize the above-mentioned initial open source model according to the instruction data in the above-mentioned target instruction pool to obtain the target artificial intelligence model.
[0095] Specifically, the instructions include financial and non-financial instructions, which ensures the generalization ability of the large model and improves the diversity of generated instructions. The above steps can automatically generate instruction data suitable for the financial field throughout the entire process, with low cost, high efficiency, and can ensure instruction diversity.
[0096] Among them, the above-mentioned target new instruction corresponds to at least one of the above-mentioned instruction responses, and the above-mentioned target new instruction, the instruction type of the above-mentioned target new instruction and the instruction response of the above-mentioned target new instruction are added to the above-mentioned initialization instruction pool to obtain the target instruction pool, including: calculating the number of instructions in the above-mentioned target instruction pool, and stopping generating new instructions when the above-mentioned instruction number is greater than or equal to the preset number, and continuing to generate the above-mentioned target new instruction when the above-mentioned instruction number is less than the above-mentioned preset number.
[0097] Specifically, this can generate instructions and instruction quantities that meet business needs, making the target artificial intelligence model more accurate in practical applications.
[0098] Generally, the data for fine-tuning instructions is in the tens of thousands. It is necessary to combine the actual business judgment. It is recommended that the data volume of instructions + responses should be at least 10,000. The instruction data accumulated in the instruction pool is used for fine-tuning the self-developed large model to improve the model capabilities.
[0099] The automatic construction method of the above-mentioned instruction data set of the present application first initializes the instruction pool to obtain an initialized instruction pool, which includes multiple initialized seed instructions; then the initialized seed instructions are input into the initial open source model for few-sample learning training to obtain multiple candidate instructions, and the candidate instructions, each initialized seed instruction, and the instruction type with the initialized seed are input into the initial open source model for few-sample learning training to obtain the instruction type of each candidate instruction; then the candidate instructions are filtered according to the similarity between the candidate instructions and the initialized seed instructions to obtain the target new instruction, and the instruction response of the target new instruction is generated; finally, the target new instruction, the instruction type of the target new instruction, and the instruction response of the target new instruction are added to the initialized instruction pool to obtain the target instruction pool, and the initial open source model is optimized according to the instruction data in the target instruction pool to obtain the target artificial intelligence model. This method can automatically generate instruction data suitable for the financial field in the entire process with low cost and high efficiency, and can ensure the diversity of instructions. The instructions include financial and non-financial instructions, which improves the diversity of generated instructions and solves the problem that the open source instructions of the open source large model in the existing technology are poorly related to the business field, and are highly dependent on the feedback of business personnel, with high collection costs and inability to cover business needs in a timely manner.
[0100] In order to enable those skilled in the art to more clearly understand the technical solution of the present application, the implementation process of the method for automatically constructing an instruction data set of the present application will be described in detail below in conjunction with specific embodiments.
[0101] This embodiment relates to a specific method for automatically constructing an instruction data set, such as Figure 6 As shown, the following steps are included:
[0102] Step S1: Initialize the instruction pool and manually construct the initialization instruction to cold start the system;
[0103] Step S2: generating new instructions and generating a candidate set of new instructions;
[0104] Step S3: new instruction classification;
[0105] Step S4: Diversity filtering of new instructions: filtering new instructions based on their similarity to instructions in the instruction pool.
[0106] Step S5: Using the candidate instruction set obtained by filtering in step S4, generate one or more responses for each instruction;
[0107] Step S6: New instructions are added to the instruction pool. If the number of instructions meets the requirement, instruction generation is stopped; otherwise, new instructions continue to be generated;
[0108] Step S7: Determine whether the number of instructions in the instruction pool meets the requirements. If not, return to step S2; if satisfied, exit the process.
[0109] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0110] The present application embodiment also provides an automatic construction device for an instruction data set. It should be noted that the automatic construction device for the instruction data set of the present application embodiment can be used to execute the automatic construction method for the instruction data set provided by the present application embodiment. The device is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions have been made and will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceived.
[0111] The following is an introduction to the automatic construction device of the instruction data set provided in the embodiment of the present application.
[0112] Figure 7Schematic diagram of an automatic construction device for an instruction data set according to an embodiment of the present application. Figure 7 As shown, the device includes: a first processing unit 10, a second processing unit 20, a third processing unit 30 and a fourth processing unit 40, the first processing unit 10 is used to initialize the instruction pool to obtain an initialized instruction pool, and the initialized instruction pool includes multiple initialized seed instructions; the second processing unit 20 is used to input the initialized seed instruction into the initial open source model for few-sample learning training to obtain multiple candidate instructions, and input the candidate instructions, each of the initialized seed instructions and the instruction type with the initialized seed into the initial open source model for the few-sample learning training to obtain the instruction type of each of the candidate instructions; the third processing unit 30 is used to filter the candidate instructions according to the similarity between the candidate instructions and the initialized seed instructions to obtain the target new instruction, and generate the instruction response of the target new instruction; the fourth processing unit 40 is used to add the target new instruction, the instruction type of the target new instruction and the instruction response of the target new instruction to the initialized instruction pool to obtain the target instruction pool, and optimize the initial open source model according to the instruction data in the target instruction pool to obtain the target artificial intelligence model.
[0113] The automatic construction device of the above-mentioned instruction data set of the present application includes: a first processing unit, a second processing unit, a third processing unit and a fourth processing unit, the first processing unit is used to initialize the instruction pool to obtain an initialized instruction pool, and the initialized instruction pool includes multiple initialized seed instructions; the second processing unit is used to input the initialized seed instruction into the initial open source model for few-sample learning training to obtain multiple candidate instructions, and input the candidate instructions, each initialized seed instruction, and the instruction type with the initialized seed into the initial open source model for few-sample learning training to obtain the instruction type of each candidate instruction; the third processing unit is used to filter the candidate instructions according to the similarity between the candidate instructions and the initialized seed instruction, obtain the target new instruction, and generate the instruction response of the target new instruction; the fourth processing unit is used to add the target new instruction, the instruction type of the target new instruction and the instruction response of the target new instruction to the initialized instruction pool to obtain the target instruction pool, and optimize the initial open source model according to the instruction data in the target instruction pool to obtain the target artificial intelligence model. The device can automatically generate instruction data suitable for the financial field in the entire process with low cost and high efficiency, and can ensure the diversity of instructions. The instructions include financial and non-financial instructions, which improves the diversity of generated instructions and solves the problem that the open source instructions of the open source large model in the prior art are poorly related to the business field, and are highly dependent on the feedback of business personnel, with high collection costs and inability to cover business needs in a timely manner.
[0114] In some examples, the first processing unit includes a first processing module, a first determining module, and a second processing module. The first processing module is used to construct the above-mentioned initialization seed instruction based on the three parts of instruction description, instruction response, and instruction type. The above-mentioned instruction description is the Chinese description of the above-mentioned initialization seed instruction, the above-mentioned instruction response is at least one response corresponding to the above-mentioned initialization seed instruction, and the above-mentioned instruction type is the type of the above-mentioned initialization seed instruction; the first determining module is used to determine the first number of the above-mentioned first initialization instructions and the second number of the above-mentioned second initialization instructions according to business data, the above-mentioned first initialization instruction is the above-mentioned initialization seed instruction of the above-mentioned instruction type being the above-mentioned target type, and the above-mentioned second initialization instruction is the above-mentioned initialization seed instruction of the above-mentioned instruction type being the above-mentioned non-target type; the second processing module is used to initialize the above-mentioned instruction pool based on all the above-mentioned first initialization instructions and all the above-mentioned second initialization instructions to obtain the above-mentioned initialization instruction pool. By constructing a small number of first initialization instructions and second initialization instructions, the generalization ability of the large model is guaranteed and the diversity of generated instructions is improved.
[0115] In some instances, the second processing unit includes a third processing module and a fourth processing module step, S2021, the third processing module is used to randomly select a third number of the first initialization instructions and a fourth number of the second initialization instructions from the initialization instruction pool, and randomly arrange the first initialization instructions and the second initialization instructions and input them into the initial open source model for the above-mentioned few-sample learning training to obtain the above-mentioned candidate instruction, the above-mentioned first initialization instruction is the above-mentioned initialization seed instruction whose instruction type is the target type, and the above-mentioned second initialization instruction is the above-mentioned initialization seed instruction whose instruction type is the non-target type; step S2022, the fourth processing module is used to repeat the above-mentioned step S2021 for a preset number of times to obtain multiple above-mentioned candidate instructions, and the above-mentioned preset number of times is related to the number of the first initialization instructions and the number of the second initialization instructions in the above-mentioned initialization instruction pool. Through few-sample learning training, a large number of candidate instructions can be generated based on a small number of initialization seed instructions, reducing the workload of manually writing instructions.
[0116] In some examples, the third processing module includes a first construction module, a second determination module and a fifth processing module, wherein the first construction module is used to segment each of the candidate instructions and the initialization seed instruction through a segmentation tool to construct a corresponding segmentation sequence; the second determination module is used to determine the similarity between the candidate instruction and the initialization seed instruction according to the segmentation sequence of the candidate instruction and the segmentation sequence of the initialization seed instruction; the fifth processing module is used to remove the candidate instruction when the similarity is greater than the preset similarity, and to determine the candidate instruction as the target new instruction when the similarity is less than or equal to the preset similarity, and the preset similarity is related to the number of the initialization seed instructions in the initialization instruction pool. In this way, similar unnecessary instructions can be filtered out, instructions with differences can be retained, the diversity of the instruction pool can be ensured, and the instruction pool space can be saved.
[0117] In some examples, the second determination module includes a first calculation module and a third determination module, wherein the first calculation module is used to calculate the number of repeated words and the number of different words of the candidate instructions and the initialization seed instructions according to the word segmentation sequence of the candidate instructions and the word segmentation sequence of the initialization seed instructions; the third determination module is used to determine the similarity between the candidate instructions and the initialization seed instructions according to the similarity calculation formula sim(i, j)=a / (a+b), wherein sim(i, j) is the similarity between the i-th candidate instruction and the j-th initialization seed instruction, a is the number of repeated words between the i-th candidate instruction and the j-th initialization seed instruction, and b is the number of different words between the i-th candidate instruction and the j-th initialization seed instruction. In this way, the similarity between the candidate instructions and the initialization seed instructions can be accurately determined for subsequent filtering of the candidate instructions.
[0118] In some examples, before removing the candidate instructions, the device further includes a first setting module, a second setting module and a sixth processing module, wherein the first setting module is used to set the preset similarity to a maximum preset value when the number of the initialization seed instructions in the initialization instruction pool is less than the minimum number; the second setting module is used to set the preset similarity to a minimum preset value when the number of the initialization seed instructions in the initialization instruction pool is greater than the maximum number; the sixth processing module is used to determine the preset similarity by using a similarity calculation formula f=m×g+b when the number of the initialization seed instructions in the initialization instruction pool is greater than or equal to the minimum number and less than or equal to the maximum number, wherein f is the preset similarity, m is the first coefficient, b is the second coefficient, and g is the number of the initialization seed instructions in the initialization instruction pool. In this way, similar unnecessary instructions can be filtered out, instructions with differences can be retained, the diversity of the instruction pool can be ensured, and the instruction pool space can be saved.
[0119] In some examples, the fourth processing unit includes a second calculation module, which is used to calculate the number of instructions in the target instruction pool, and stop generating new instructions when the number of instructions is greater than or equal to the preset number, and continue to generate the target new instructions when the number of instructions is less than the preset number. In this way, instructions and instruction quantities that meet business needs can be generated, making the target artificial intelligence model more accurate in practical applications.
[0120] The automatic construction device of the instruction data set includes a processor and a memory, and the first processing unit and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions. The modules are all located in the same processor; or, the modules are located in different processors in any combination.
[0121] The processor contains a kernel, which calls the corresponding program unit from the memory. One or more kernels can be set, and the kernel parameters can be adjusted to solve the problem that the open source instructions of the open source large model in the prior art are poorly related to the business field, and are highly dependent on the feedback of business personnel, with high collection costs and unable to cover business needs in a timely manner.
[0122] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0123] An embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method for automatically constructing the instruction data set.
[0124] Specifically, the method for automatically constructing the instruction data set includes:
[0125] Step S201, initializing the instruction pool to obtain an initialization instruction pool, wherein the initialization instruction pool includes a plurality of initialization seed instructions;
[0126] Specifically, the system is cold-started by manually constructing initialization instructions. The data in the instruction pool consists of three parts: instruction: the Chinese description of the instruction itself; response: one or more responses to the corresponding instruction; type: whether to output financial instructions. Among them, the type of instruction can be set differently according to business needs and is not limited to financial instructions.
[0127] Step S202, inputting the above-mentioned initialization seed instruction into the initial open source model for few-sample learning training to obtain multiple candidate instructions, and inputting the above-mentioned candidate instructions, each of the above-mentioned initialization seed instructions, and the instruction type of the above-mentioned initialization seed into the above-mentioned initial open source model for the above-mentioned few-sample learning training to obtain the instruction type of each of the above-mentioned candidate instructions;
[0128] Specifically, combined with professional instruction samples (initialization seed instructions), the generalization ability of the large model is used to directly generate high-quality instruction sets. At the same time, the generated instruction sets can be used again to adjust the large model, reducing the workload of manually writing instructions.
[0129] Step S203, filtering the candidate instructions according to the similarity between the candidate instructions and the initialization seed instructions to obtain a target new instruction, and generating an instruction response for the target new instruction;
[0130] Specifically, for similar instruction tasks, the large model (initial open source model) may generate language descriptions with the same semantics. In order to ensure the diversity of instructions generated by the large model, similar instructions are filtered and instructions with differences are retained to ensure the diversity of the instruction pool.
[0131] Step S204, add the above-mentioned target new instruction, the instruction type of the above-mentioned target new instruction and the instruction response of the above-mentioned target new instruction to the above-mentioned initialization instruction pool to obtain the target instruction pool, and optimize the above-mentioned initial open source model according to the instruction data in the above-mentioned target instruction pool to obtain the target artificial intelligence model.
[0132] Specifically, the instructions include financial and non-financial instructions, which ensures the generalization ability of the large model and improves the diversity of generated instructions. The above steps can automatically generate instruction data suitable for the financial field throughout the entire process, with low cost, high efficiency, and can ensure instruction diversity.
[0133] An embodiment of the present invention provides a processor, which is used to run a program, wherein the program executes the automatic construction method of the instruction data set when running.
[0134] Specifically, the method for automatically constructing the instruction data set includes:
[0135] Step S201, initializing the instruction pool to obtain an initialization instruction pool, wherein the initialization instruction pool includes a plurality of initialization seed instructions;
[0136] Specifically, the system is cold-started by manually constructing initialization instructions. The data in the instruction pool consists of three parts: instruction: the Chinese description of the instruction itself; response: one or more responses to the corresponding instruction; type: whether to output financial instructions. Among them, the type of instruction can be set differently according to business needs and is not limited to financial instructions.
[0137] Step S202, inputting the above-mentioned initialization seed instruction into the initial open source model for few-sample learning training to obtain multiple candidate instructions, and inputting the above-mentioned candidate instructions, each of the above-mentioned initialization seed instructions, and the instruction type of the above-mentioned initialization seed into the above-mentioned initial open source model for the above-mentioned few-sample learning training to obtain the instruction type of each of the above-mentioned candidate instructions;
[0138] Specifically, combined with professional instruction samples (initialization seed instructions), the generalization ability of the large model is used to directly generate high-quality instruction sets. At the same time, the generated instruction sets can be used again to adjust the large model, reducing the workload of manually writing instructions.
[0139] Step S203, filtering the candidate instructions according to the similarity between the candidate instructions and the initialization seed instructions to obtain a target new instruction, and generating an instruction response for the target new instruction;
[0140] Specifically, for similar instruction tasks, the large model (initial open source model) may generate language descriptions with the same semantics. In order to ensure the diversity of instructions generated by the large model, similar instructions are filtered and instructions with differences are retained to ensure the diversity of the instruction pool.
[0141] Step S204, add the above-mentioned target new instruction, the instruction type of the above-mentioned target new instruction and the instruction response of the above-mentioned target new instruction to the above-mentioned initialization instruction pool to obtain the target instruction pool, and optimize the above-mentioned initial open source model according to the instruction data in the above-mentioned target instruction pool to obtain the target artificial intelligence model.
[0142] Specifically, the instructions include financial and non-financial instructions, which ensures the generalization ability of the large model and improves the diversity of generated instructions. The above steps can automatically generate instruction data suitable for the financial field throughout the entire process, with low cost, high efficiency, and can ensure instruction diversity.
[0143] An embodiment of the present invention provides a device, the device including a processor, a memory, and a program stored in the memory and executable on the processor, and when the processor executes the program, at least the following steps are implemented:
[0144] Step S201, initializing the instruction pool to obtain an initialization instruction pool, wherein the initialization instruction pool includes a plurality of initialization seed instructions;
[0145] Step S202, inputting the above-mentioned initialization seed instruction into the initial open source model for few-sample learning training to obtain multiple candidate instructions, and inputting the above-mentioned candidate instructions, each of the above-mentioned initialization seed instructions, and the instruction type of the above-mentioned initialization seed into the above-mentioned initial open source model for the above-mentioned few-sample learning training to obtain the instruction type of each of the above-mentioned candidate instructions;
[0146] Step S203, filtering the candidate instructions according to the similarity between the candidate instructions and the initialization seed instructions to obtain a target new instruction, and generating an instruction response for the target new instruction;
[0147] Step S204, add the above-mentioned target new instruction, the instruction type of the above-mentioned target new instruction and the instruction response of the above-mentioned target new instruction to the above-mentioned initialization instruction pool to obtain the target instruction pool, and optimize the above-mentioned initial open source model according to the instruction data in the above-mentioned target instruction pool to obtain the target artificial intelligence model.
[0148] The devices in this article can be servers, PCs, PADs, mobile phones, etc.
[0149] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program for initializing at least the following method steps:
[0150] Step S201, initializing the instruction pool to obtain an initialization instruction pool, wherein the initialization instruction pool includes a plurality of initialization seed instructions;
[0151] Step S202, inputting the above-mentioned initialization seed instruction into the initial open source model for few-sample learning training to obtain multiple candidate instructions, and inputting the above-mentioned candidate instructions, each of the above-mentioned initialization seed instructions, and the instruction type of the above-mentioned initialization seed into the above-mentioned initial open source model for the above-mentioned few-sample learning training to obtain the instruction type of each of the above-mentioned candidate instructions;
[0152] Step S203, filtering the candidate instructions according to the similarity between the candidate instructions and the initialization seed instructions to obtain a target new instruction, and generating an instruction response for the target new instruction;
[0153] Step S204, add the above-mentioned target new instruction, the instruction type of the above-mentioned target new instruction and the instruction response of the above-mentioned target new instruction to the above-mentioned initialization instruction pool to obtain the target instruction pool, and optimize the above-mentioned initial open source model according to the instruction data in the above-mentioned target instruction pool to obtain the target artificial intelligence model.
[0154] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0155] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0156] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0157] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0158] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0159] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0160] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0161] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0162] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0163] From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:
[0164] 1) The automatic construction method of the above-mentioned instruction data set of the present application first initializes the instruction pool to obtain an initialized instruction pool, which includes multiple initialized seed instructions; then the initialized seed instructions are input into the initial open source model for few-sample learning training to obtain multiple candidate instructions, and the candidate instructions, each initialized seed instruction, and the instruction type with the initialized seed are input into the initial open source model for few-sample learning training to obtain the instruction type of each candidate instruction; then, according to the similarity between the candidate instructions and the initialized seed instructions, the candidate instructions are filtered to obtain the target new instruction, and the instruction response of the target new instruction is generated; finally, the target new instruction, the instruction type of the target new instruction, and the instruction response of the target new instruction are added to the initialized instruction pool to obtain the target instruction pool, and the initial open source model is optimized according to the instruction data in the target instruction pool to obtain the target artificial intelligence model. This method can automatically generate instruction data suitable for the financial field in the entire process with low cost and high efficiency, and can ensure the diversity of instructions. The instructions include financial and non-financial instructions, which improves the diversity of generated instructions and solves the problem that the open source instructions of the open source large model in the existing technology are poorly related to the business field, and are highly dependent on the feedback of business personnel, with high collection costs and inability to cover business needs in a timely manner.
[0165] 2) The automatic construction device of the above-mentioned instruction data set of the present application includes: a first processing unit, a second processing unit, a third processing unit and a fourth processing unit, the first processing unit is used to initialize the instruction pool to obtain an initialized instruction pool, and the initialized instruction pool includes multiple initialization seed instructions; the second processing unit is used to input the initialization seed instruction into the initial open source model for few-sample learning training to obtain multiple candidate instructions, and input the candidate instructions, each initialization seed instruction, and the instruction type with the initialization seed into the initial open source model for few-sample learning training to obtain the instruction type of each candidate instruction; the third processing unit is used to filter the candidate instructions according to the similarity between the candidate instructions and the initialization seed instruction, obtain the target new instruction, and generate the instruction response of the target new instruction; the fourth processing unit is used to add the target new instruction, the instruction type of the target new instruction and the instruction response of the target new instruction to the initialization instruction pool to obtain the target instruction pool, and optimize the initial open source model according to the instruction data in the target instruction pool to obtain the target artificial intelligence model. The device can automatically generate instruction data suitable for the financial field in the entire process with low cost and high efficiency, and can ensure the diversity of instructions. The instructions include financial and non-financial instructions, which improves the diversity of generated instructions and solves the problem that the open source instructions of the open source large model in the prior art are poorly related to the business field, and are highly dependent on the feedback of business personnel, with high collection costs and inability to cover business needs in a timely manner.
[0166] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A method for automatically constructing an instruction data set, characterized in that: include: Initializing the instruction pool to obtain an initialized instruction pool, wherein the initialized instruction pool includes a plurality of initialized seed instructions; Inputting the initialization seed instruction into the initial open source model for few-sample learning training to obtain a plurality of candidate instructions, and inputting the candidate instructions, each of the initialization seed instructions, and the instruction type of the initialization seed into the initial open source model for the few-sample learning training to obtain the instruction type of each of the candidate instructions; According to the similarity between the candidate instructions and the initialization seed instruction, the candidate instructions are filtered to obtain a target new instruction, and an instruction response of the target new instruction is generated; The target new instruction, the instruction type of the target new instruction and the instruction response of the target new instruction are added to the initialization instruction pool to obtain a target instruction pool, and the initial open source model is optimized according to the instruction data in the target instruction pool to obtain a target artificial intelligence model.
2. The method according to claim 1, characterized in that The initialization seed instruction includes a first initialization instruction and a second initialization instruction, and the instruction pool is initialized to obtain an initialization instruction pool, including: The initialization seed instruction is constructed based on the three parts of instruction description, instruction response and instruction type, wherein the instruction description is the Chinese description of the initialization seed instruction, the instruction response is at least one response corresponding to the initialization seed instruction, and the instruction type is the type of the initialization seed instruction; Determine a first number of the first initialization instructions and a second number of the second initialization instructions according to the business data, the first initialization instructions being the initialization seed instructions whose instruction type is a target type, and the second initialization instructions being the initialization seed instructions whose instruction type is a non-target type; The instruction pool is initialized based on all the first initialization instructions and all the second initialization instructions to obtain the initialized instruction pool.
3. The method according to claim 1, characterized in that The initialization seed instruction includes a first initialization instruction and a second initialization instruction. The initialization seed instruction is input into the initial open source model for few-sample learning training to obtain multiple candidate instructions, including: Step S2021, randomly selecting a third number of the first initialization instructions and a fourth number of the second initialization instructions from the initialization instruction pool, and randomly arranging the first initialization instructions and the second initialization instructions and inputting them into the initial open source model for the few-sample learning training to obtain a candidate instruction, wherein the first initialization instruction is the initialization seed instruction whose instruction type is the target type, and the second initialization instruction is the initialization seed instruction whose instruction type is the non-target type; Step S2022, repeatedly executing step S2021 a preset number of times to obtain a plurality of candidate instructions, wherein the preset number of times is related to the number of the first initialization instructions and the number of the second initialization instructions in the initialization instruction pool.
4. The method according to claim 1, characterized in that: According to the similarity between the candidate instructions and the initialization seed instructions, the candidate instructions are filtered to obtain target new instructions, including: Segment each of the candidate instructions and the initialization seed instruction using a segmentation tool to construct a corresponding segmentation sequence; Determining the similarity between the candidate instruction and the initialization seed instruction according to the word segmentation sequence of the candidate instruction and the word segmentation sequence of the initialization seed instruction; When the similarity is greater than a preset similarity, the candidate instruction is removed; when the similarity is less than or equal to the preset similarity, the candidate instruction is determined as the target new instruction; the preset similarity is related to the number of initialization seed instructions in the initialization instruction pool.
5. The method according to claim 4, characterized in that Determining the similarity between the candidate instruction and the initialization seed instruction according to the word segmentation sequence of the candidate instruction and the word segmentation sequence of the initialization seed instruction includes: According to the word segmentation sequence of the candidate instruction and the word segmentation sequence of the initialization seed instruction, the number of repeated words and the number of different words of the candidate instruction and the initialization seed instruction are calculated; According to the similarity calculation formula sim(i, j)=a / (a+b), the similarity between the candidate instruction and the initialization seed instruction is determined, wherein sim(i, j) is the similarity between the i-th candidate instruction and the j-th initialization seed instruction, a is the number of repeated words between the i-th candidate instruction and the j-th initialization seed instruction, and b is the number of different words between the i-th candidate instruction and the j-th initialization seed instruction.
6. The method according to claim 4, characterized in that Before removing the candidate instruction, the method further includes: When the number of the initialization seed instructions in the initialization instruction pool is less than a minimum number, setting the preset similarity to a maximum preset value; When the number of the initialization seed instructions in the initialization instruction pool is greater than the maximum number, setting the preset similarity to a minimum preset value; When the number of the initialization seed instructions in the initialization instruction pool is greater than or equal to the minimum number and less than or equal to the maximum number, the similarity calculation formula f=m×g+b is used to determine the preset similarity, wherein f is the preset similarity, m is the first coefficient, b is the second coefficient, and g is the number of the initialization seed instructions in the initialization instruction pool.
7. The method according to claim 1, characterized in that The target new instruction corresponds to at least one of the instruction responses, and the target new instruction, the instruction type of the target new instruction, and the instruction response of the target new instruction are added to the initialization instruction pool to obtain a target instruction pool, including: The number of instructions in the target instruction pool is calculated, and when the number of instructions is greater than or equal to a preset number, generation of new instructions is stopped; when the number of instructions is less than the preset number, generation of the target new instructions is continued.
8. An automatic construction device for an instruction data set, characterized in that: include: A first processing unit is used to initialize the instruction pool to obtain an initialized instruction pool, wherein the initialized instruction pool includes a plurality of initialized seed instructions; A second processing unit is used to input the initialization seed instruction into the initial open source model for few-sample learning training to obtain multiple candidate instructions, and input the candidate instructions, each of the initialization seed instructions, and the instruction type of the initialization seed into the initial open source model for the few-sample learning training to obtain the instruction type of each of the candidate instructions; a third processing unit, configured to filter the candidate instructions according to the similarity between the candidate instructions and the initialization seed instruction, obtain a target new instruction, and generate an instruction response of the target new instruction; The fourth processing unit is used to add the target new instruction, the instruction type of the target new instruction and the instruction response of the target new instruction to the initialization instruction pool to obtain a target instruction pool, and optimize the initial open source model according to the instruction data in the target instruction pool to obtain a target artificial intelligence model.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method for automatically constructing an instruction data set as described in any one of claims 1 to 7.
10. An electronic device, characterized in that: include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include an automatic construction method for executing the instruction data set described in any one of claims 1 to 7.
