Data construction method, device and equipment, readable storage medium and program product

By constructing contextual learning example pairs and using prompt words to quickly generate high-quality target data pairs, the problem of low efficiency in manually constructing instruction fine-tuning data is solved, improving data construction efficiency and enhancing the performance of large language models.

CN120654798APending Publication Date: 2025-09-16BEIJING SOGOU NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410282440.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-12
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

In the existing technology, the efficiency of manually constructing instruction fine-tuning data is low, and it is difficult to efficiently construct a high-quality instruction fine-tuning dataset.

Method used

By obtaining a set of example samples and a set of original materials, contextual learning example pairs are constructed based on matching processing, and target data pairs are determined using preset prompt words, thus quickly constructing high-quality target data pairs and improving data construction efficiency.

Benefits of technology

It improves the efficiency of constructing target data pairs, generates a diverse and rich instruction fine-tuning dataset, and enhances the performance of large language models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120654798A_ABST
    Figure CN120654798A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data construction method and device, equipment, a readable storage medium and a program product, and relates to the fields of artificial intelligence, maps and the like, and application scenes include but are not limited to instruction fine adjustment data construction scenes. The method comprises the steps of obtaining an example sample set and an original material set, wherein any example sample in the example sample set comprises a sample material, an initial instruction for the sample material and initial output for the initial instruction; based on the example sample set and the original material set, a context learning example pair set is determined through matching processing, any context learning example pair in the context learning example pair set comprises a target example sample and a target material, the example sample set comprises the target example sample, and the original material set comprises the target material; based on any context learning example pair and a preset cue word, a target data pair is determined, and the target data pair comprises a target instruction for the target material and target output for the target instruction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a data construction method, apparatus, device, readable storage medium, and program product. Background Art

[0002] With the rapid development of deep learning and natural language processing technologies, large language models have achieved remarkable results in various natural language generation tasks. Large language models can be pre-trained on large amounts of unsupervised text data to acquire rich semantic knowledge and linguistic patterns. After being fine-tuned downstream with a small amount of supervised instruction fine-tuning data from specific domains, they can demonstrate higher generation quality and answer accuracy. Existing technology manually constructs instruction fine-tuning data. For example, in the medical field, medical experts construct a collection of instruction fine-tuning data for large language models, known as an instruction fine-tuning dataset. However, manually constructing instruction fine-tuning data is inefficient. Summary of the Invention

[0003] In response to the shortcomings of existing methods, the present disclosure proposes a data construction method, device, equipment, computer-readable storage medium and computer program product to solve the problem of how to improve the construction efficiency of instruction fine-tuning data.

[0004] In a first aspect, the present disclosure provides a data construction method, comprising:

[0005] Obtaining an example sample set and an original material set, wherein any example sample in the example sample set includes the sample material, an initial instruction for the sample material, and an initial output for the initial instruction, wherein the initial instruction is used to characterize a related application of the sample material, and the initial output includes an application result of the related application of the sample material;

[0006] Based on the example sample set and the original material set, determining a context learning example pair set through matching processing, wherein any context learning example pair in the context learning example pair set includes a target example sample and a target material, the example sample set includes the target example sample, and the original material set includes the target material;

[0007] Based on any context learning example pair and preset prompt words, a target data pair is determined. The target data pair includes a target instruction for the target material and a target output for the target instruction. The target instruction is used to characterize the relevant application of the target material, and the target output includes the application result of the relevant application of the target material.

[0008] In one embodiment, obtaining a set of original materials includes:

[0009] Perform matching processing based on a preset regular expression and text in a preset database to determine at least one of the chapter structure of the text, the iconic symbols of the text, and the special characters of the text;

[0010] Based on at least one item, the text is segmented to determine the material corresponding to the text, and the material corresponding to the text is determined as the original material in the original material set.

[0011] In one embodiment, based on the example sample set and the original material set, determining a context learning example pair set through matching processing includes:

[0012] Based on any original material in the original material set and the example sample set, determining at least one example sample in the example sample set through matching processing, each example sample in the at least one example sample and any original material forming a context learning example pair;

[0013] Based on any example sample in the example sample set and the original material set, at least one original material in the original material set is determined through matching processing, and each original material in the at least one original material and any example sample constitute a context learning example pair.

[0014] In one embodiment, based on any original material in the original material set and the example sample set, determining at least one example sample in the example sample set through matching processing includes:

[0015] Determine a text feature vector corresponding to any original material in the original material set and a text feature vector corresponding to the sample material of each example sample in the example sample set;

[0016] Determining a first similarity between the text feature vector corresponding to any original material and the text feature vector corresponding to the sample material of each example sample based on the text feature vector corresponding to any original material and the text feature vector corresponding to the sample material of each example sample;

[0017] At least one example sample in the example sample set is determined based on the first similarities, a preset first similarity threshold, and a preset second similarity threshold, where the second similarity threshold is greater than the first similarity threshold.

[0018] In one embodiment, determining at least one example sample in the example sample set based on the first similarities, the preset first similarity threshold, and the preset second similarity threshold includes:

[0019] Sort the first similarities from largest to smallest, and determine the top N first similarities, where N is a positive integer;

[0020] If any first similarity among the N first similarities is greater than the first similarity threshold and less than the second similarity threshold, determining the example sample corresponding to any first similarity as the example sample among the at least one example sample;

[0021] If any first similarity is equal to the first similarity threshold or the second similarity threshold, the example sample corresponding to any first similarity is determined as the example sample in the at least one example sample.

[0022] In one embodiment, determining at least one original material in the original material set through matching based on any example sample in the example sample set and the original material set includes:

[0023] Determine a text feature vector corresponding to a sample material of any example sample in the example sample set and a text feature vector corresponding to each original material in the original material set;

[0024] Determining a second similarity between the text feature vector corresponding to the sample material of any example sample and the text feature vector corresponding to each original material based on the text feature vector corresponding to the sample material of any example sample and the text feature vector corresponding to each original material;

[0025] Based on the second similarities, the preset first similarity threshold and the preset second similarity threshold, it is determined that at least one original material in the original material set has the second similarity threshold greater than the first similarity threshold.

[0026] In one embodiment, determining at least one original material in the original material set based on the second similarities, the preset first similarity threshold, and the preset second similarity threshold includes:

[0027] Sort the second similarities from largest to smallest, and determine the top M second similarities, where M is a positive integer;

[0028] If any second similarity among the M second similarities is greater than the first similarity threshold and less than the second similarity threshold, determining the original material corresponding to any second similarity as the original material among the at least one original material;

[0029] If any of the second similarities is equal to the first similarity threshold or the second similarity threshold, the original material corresponding to any of the second similarities is determined as the original material in the at least one original material.

[0030] In one embodiment, determining a target data pair based on any context learning example pair and a preset prompt word includes:

[0031] Write any context learning example pair into the preset prompt word to obtain the updated prompt word;

[0032] The updated prompt word is input into the preset large language model, and the target data pair is determined through context learning.

[0033] In one embodiment, after determining a target data pair based on any context learning example pair and a preset prompt word, the method further includes:

[0034] Based on each target data pair, a large language model or another large language model is trained to obtain a trained large language model.

[0035] In one embodiment, before determining a target data pair based on any context learning example pair and a preset prompt word, the method further includes:

[0036] Get the initial prompt word;

[0037] Based on the initial prompt words, the preset prompt words are determined through the prompt word engineering. The preset prompt words are texts describing the data construction task.

[0038] In one embodiment, the preset prompt words include at least one of a role set for the large language model, an operating procedure for related applications of the role, specific requirements for related applications of the role, an example sample template, an original material template, and an instruction for the large language model. The example sample template is used to fill in the target example sample into the example sample template, the original material template is used to fill in the target material into the original material template, and the instruction for the large language model is used to instruct the large language model to output a target data pair.

[0039] In a second aspect, the present disclosure provides a data construction device, comprising:

[0040] a first processing module configured to obtain a sample set and an original material set, wherein any sample in the sample set includes the sample material, an initial instruction for the sample material, and an initial output for the initial instruction, wherein the initial instruction is used to represent a related application of the sample material, and the initial output includes an application result of the related application of the sample material;

[0041] a second processing module, configured to determine, based on the example sample set and the original material set, a context learning example pair set through matching processing, wherein any context learning example pair in the context learning example pair set includes a target example sample and a target material, the example sample set includes the target example sample, and the original material set includes the target material;

[0042] The third processing module is used to determine the target data pair based on any context learning example pair and the preset prompt word. The target data pair includes a target instruction for the target material and a target output for the target instruction. The target instruction is used to characterize the relevant application of the target material, and the target output includes the application result of the relevant application of the target material.

[0043] In a third aspect, the present disclosure provides an electronic device, comprising: a processor, a memory, and a bus;

[0044] Bus, used to connect the processor and memory;

[0045] a memory for storing operation instructions;

[0046] The processor is used to execute the data construction method of the first aspect of the present disclosure by calling an operation instruction.

[0047] In a fourth aspect, the present disclosure provides a computer-readable storage medium storing a computer program, which is used to execute the data construction method of the first aspect of the present disclosure.

[0048] In a fifth aspect, the present disclosure provides a computer program product, comprising a computer program, which implements the steps of the data construction method in the first aspect of the present disclosure when the computer program is executed by a processor.

[0049] The technical solutions provided by the embodiments of the present disclosure have at least the following beneficial effects:

[0050] Obtain an example sample set and an original material set, wherein any example sample in the example sample set includes the sample material, an initial instruction for the sample material, and an initial output for the initial instruction, the initial instruction is used to characterize the relevant application of the sample material, and the initial output includes the application result of the relevant application of the sample material; based on the example sample set and the original material set, determine a context learning example pair set through matching processing, wherein any context learning example pair in the context learning example pair set includes a target example sample and a target material, the example sample set includes the target example sample, and the original material set includes the target material; based on any context learning example pair and a preset prompt word, determine a target data pair, the target data pair includes a target instruction for the target material and a target output for the target instruction, the target instruction is used to characterize the relevant application of the target material, and the target output includes the application result of the relevant application of the target material. In this way, example samples are obtained, and original materials that are highly relevant to the application scenario are mined from the corpus; based on the example samples and the original materials, context learning example pairs are constructed; based on the context learning example pairs and the prompt words, high-quality target data pairs ((instruction, output) pairs, i.e., instruction fine-tuning data) are quickly constructed; thereby improving the efficiency of constructing the target data pairs, i.e., improving the quantity, quality, controllability, etc. of the target data pairs; further, for example, multiple target data pairs can constitute an instruction fine-tuning dataset with diverse types and rich content, and the performance of the large language model can be greatly enhanced by fine-tuning the large language model based on the instruction fine-tuning dataset. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the following briefly introduces the drawings required for describing the embodiments of the present disclosure.

[0052] Figure 1 A schematic diagram of the architecture of a data construction system provided in an embodiment of the present disclosure;

[0053] Figure 2 A flowchart of a data construction method provided in an embodiment of the present disclosure;

[0054] Figure 3 A schematic diagram of data construction provided for an embodiment of the present disclosure;

[0055] Figure 4 A schematic diagram of data construction provided for an embodiment of the present disclosure;

[0056] Figure 5 A schematic diagram of data construction provided for an embodiment of the present disclosure;

[0057] Figure 6 A schematic diagram of data construction provided for an embodiment of the present disclosure;

[0058] Figure 7 A flowchart of a data construction method provided in an embodiment of the present disclosure;

[0059] Figure 8 A schematic diagram of the structure of a data construction device provided in an embodiment of the present disclosure;

[0060] Figure 9 A schematic structural diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0061] The following describes embodiments of the present disclosure in conjunction with the accompanying drawings. It should be understood that the embodiments described below in conjunction with the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present disclosure and do not constitute a limitation on the technical solutions of the embodiments of the present disclosure.

[0062] Those skilled in the art will understand that, unless otherwise stated, the singular forms "a", "an", "said", and "the" used herein may also include plural forms. It should be further understood that the terms "including" and "comprising" used in the embodiments of the present disclosure mean that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements, and / or components, but do not exclude implementation as other features, information, data, steps, operations, elements, components, and / or combinations thereof supported by the present technical field. It should be understood that when we say that an element is "connected" or "coupled" to another element, the element can be directly connected or coupled to the other element, or it can refer to the connection relationship between the element and the other element established through an intermediate element. In addition, the "connection" or "coupling" used here can include wireless connection or wireless coupling. The term "and / or" used here indicates at least one of the items defined by the term, for example, "A and / or B" indicates implementation as "A", or implementation as "B", or implementation as "A and B".

[0063] It is understandable that in the specific implementation of the present disclosure, data related to data construction is involved. When the above embodiments of the present disclosure are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0064] In order to make the objectives, technical solutions and advantages of the present disclosure more clear, the embodiments of the present disclosure will be further described in detail below with reference to the accompanying drawings.

[0065] The embodiment of the present disclosure is a data construction method provided by a data construction system, which relates to fields such as artificial intelligence and maps.

[0066] Artificial Intelligence (AI) refers to the theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. AI also studies the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.

[0067] Artificial intelligence (AI) technology is a comprehensive discipline encompassing a wide range of fields, encompassing both hardware and software technologies. Foundational AI technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, speech processing, natural language processing, as well as machine learning / deep learning, autonomous driving, and smart transportation.

[0068] Intelligent Traffic System (ITS), also known as Intelligent Transportation System, effectively integrates advanced science and technology (information technology, computer technology, data communication technology, sensor technology, electronic control technology, automatic control theory, operations research, artificial intelligence, etc.) into transportation, service control and vehicle manufacturing, strengthens the connection between vehicles, roads and users, and thus forms a comprehensive transportation system that ensures safety, improves efficiency, improves the environment and saves energy.

[0069] In order to better understand and illustrate the solutions of the embodiments of the present disclosure, some technical terms involved in the embodiments of the present disclosure are briefly explained below.

[0070] LLM: LLM (Large Language Model), also known as a large language model, is an artificial intelligence model designed to understand and generate human language; LLM can be trained on large amounts of text data and can perform a wide range of tasks such as text summarization, translation, and sentiment analysis.

[0071] Transformer: Transformer is a deep learning model for feature extraction and time series modeling.

[0072] Instruction Tuning: Instruction tuning is the process of further training a large language model on a dataset consisting of (instruction, output) pairs; where instructions represent human instructions to the model and outputs represent the expected outcome of following the instructions.

[0073] In-context Learning: In-context Learning is a learning paradigm that allows large language models to learn tasks through several examples or instructions organized in the form of demonstrations.

[0074] Prompt: Prompt is a text describing the task entered when the user interacts with the large language model.

[0075] COT: COT (Chain-of-Thought) is an improved prompting strategy that improves the performance of large language models in complex reasoning tasks such as arithmetic reasoning, commonsense reasoning, and symbolic reasoning by supplementing a series of logically related thinking steps.

[0076] GPT-4: GPT-4 (Generative Pre-trained Transformer 4) is an autoregressive language model.

[0077] Baichuan-2: Baichuan-2 is an open-source large language model trained with 2.6 trillion tokens of high-quality corpus.

[0078] Prompt Engineering: Prompt Engineering is a method for optimizing language models. Its goal is to guide the language model to generate more accurate and targeted output text by designing and adjusting the input prompts.

[0079] The solutions provided by the embodiments of the present disclosure involve data construction technology. The technical solutions of the present disclosure are described in detail below using specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present disclosure will be described below in conjunction with the accompanying drawings.

[0080] In order to better understand the solution provided by the embodiment of the present disclosure, the solution is described below in conjunction with a specific application scenario.

[0081] In one embodiment, Figure 1 FIG. 1 shows a schematic diagram of the architecture of a data construction system applicable to an embodiment of the present disclosure. It can be understood that the data construction method provided by the embodiment of the present disclosure can be applied to, but not limited to, Figure 1 In the application scenario shown.

[0082] In this example, Figure 1 As shown, the architecture of the data construction system in this example may include but is not limited to a server 10, a terminal 20 and a database 30. The server 10, the terminal 20 and the database 30 may interact with each other via a network 40.

[0083] The server 10 obtains an example sample set and an original material set, wherein any example sample in the example sample set includes a sample material, an initial instruction for the sample material, and an initial output for the initial instruction, the initial instruction is used to characterize the relevant application of the sample material, and the initial output includes the application result of the relevant application of the sample material; based on the example sample set and the original material set, the server 10 determines a context learning example pair set through matching processing, wherein any context learning example pair in the context learning example pair set includes a target example sample and a target material, the example sample set includes the target example sample, and the original material set includes the target material; based on any context learning example pair and a preset prompt word, the server 10 determines a target data pair, the target data pair includes a target instruction for the target material and a target output for the target instruction, the target instruction is used to characterize the relevant application of the target material, and the target output includes the application result of the relevant application of the target material; the server 10 sends the target data pair to the terminal 20 for display, and the server 10 sends the target data pair to the database 30 for storage.

[0084] It is understood that the above is only an example and is not limited to this embodiment.

[0085] Among them, terminals include but are not limited to smartphones (such as Android phones, iOS phones, etc.), mobile phone simulators, tablet computers, laptops, digital broadcast receivers, MIDs (Mobile Internet Devices), PDAs (Personal Digital Assistants), intelligent voice interaction devices, smart home appliances, car terminals, etc.

[0086] The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server or server cluster that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms.

[0087] Cloud computing is a computing model that distributes computing tasks across a resource pool consisting of a large number of computers, enabling various application systems to access computing power, storage space, and information services as needed. The network that provides these resources is called the "cloud." To users, these resources appear infinitely scalable and can be accessed at any time, used on demand, expanded at any time, and paid for on a per-use basis.

[0088] As a provider of cloud computing infrastructure, a cloud computing resource pool (referred to as a cloud platform, generally referred to as an IaaS (Infrastructure as a Service) platform) is established. Various types of virtual resources are deployed in the resource pool for external customers to choose and use. The cloud computing resource pool mainly includes: computing devices (virtualized machines, including operating systems), storage devices, and network devices.

[0089] Based on logical functional divisions, the PaaS (Platform as a Service) layer can be deployed on top of the IaaS (Infrastructure as a Service) layer, and the SaaS (Software as a Service) layer can be deployed on top of the PaaS layer. SaaS can also be deployed directly on top of IaaS. PaaS is a platform for software execution, such as databases and web containers. SaaS is a variety of business software, such as web portals and text messaging apps. Generally speaking, SaaS and PaaS are upper layers relative to IaaS.

[0090] Artificial intelligence cloud services, also known as AIaaS (AI as a Service), are a mainstream AI platform offering. Specifically, AIaaS platforms break down several common AI services and provide them as standalone or packaged services in the cloud. This service model is similar to an AI-themed marketplace: all developers can access one or more of the platform's AI services through APIs. Experienced developers can also use the platform's AI framework and infrastructure to deploy and maintain their own cloud AI services.

[0091] The aforementioned networks may include, but are not limited to, wired networks and wireless networks. Wired networks include local area networks, metropolitan area networks, and wide area networks, and wireless networks include Bluetooth, Wi-Fi, and other wireless communication networks. The specific network type may be determined based on actual application scenarios and is not limited here.

[0092] The present disclosure can be applied to specific products such as intelligent question-and-answer assistants in multiple fields such as taxation, finance, real estate, and cloud computing to provide safe and efficient intelligent services to more users. It can be used specifically to build training data for intelligent question-and-answer assistants.

[0093] See also Figure 2 , Figure 2The flowchart of a construction method provided by an embodiment of the present disclosure is shown, wherein the method can be executed by any electronic device, such as a server, etc. As an optional implementation, the method can be executed by a server. For the convenience of description, in the description of some optional embodiments below, the server will be used as an example to illustrate the execution subject of the method. Figure 2 As shown, the data construction method provided by the embodiment of the present disclosure includes the following steps:

[0094] S201, obtaining an example sample set and an original material set, wherein any example sample in the example sample set includes a sample material, an initial instruction for the sample material, and an initial output for the initial instruction, wherein the initial instruction is used to characterize a related application of the sample material, and the initial output includes an application result of the related application of the sample material.

[0095] Specifically, a sample set is manually constructed, comprising multiple sample examples. Each sample includes sample material, initial instructions for the sample material, and initial output for the initial instructions. The sample material may be, for example, a tax regulation involving numerical calculations. The initial instructions for the sample material may be, for example, a manually conceived application case related to the regulation, i.e., the initial instructions are used to characterize the relevant application of the sample material. For example, based on the sample material and the initial instructions, the initial output for the initial instructions is determined by manually listing analysis processes, formulas, etc. The initial output includes the application results of the relevant application of the sample material.

[0096] Based on the corpus, a raw material set is constructed through pattern matching. The raw material set includes multiple raw materials. Raw materials such as the individual income tax calculation method in the tax scenario and the cloud computing server charging standards in the cloud computing scenario.

[0097] S202, based on the example sample set and the original material set, determine the context learning example pair set through matching processing, any context learning example pair in the context learning example pair set includes the target example sample and the target material, the example sample set includes the target example sample, and the original material set includes the target material.

[0098] Specifically, the context learning example pair set includes multiple context learning example pairs; a context learning example pair consists of an example sample and an original material, and the example sample and the original material match each other.

[0099] S203, based on any context learning example pair and preset prompt words, determine the target data pair, the target data pair includes a target instruction for the target material and a target output for the target instruction, the target instruction is used to characterize the relevant application of the target material, and the target output includes the application result of the relevant application of the target material.

[0100] Specifically, the target data pair, such as the (instruction, output) pair, the (instruction, output) pair is the instruction fine-tuning data; the instruction in the (instruction, output) pair is the target instruction for the target material, and the output in the (instruction, output) pair is the target output for the target instruction.

[0101] In an embodiment of the present disclosure, an example sample set and an original material set are obtained, wherein any example sample in the example sample set includes the sample material, an initial instruction for the sample material, and an initial output for the initial instruction, the initial instruction is used to characterize the relevant application of the sample material, and the initial output includes the application result of the relevant application of the sample material; based on the example sample set and the original material set, a context learning example pair set is determined through matching processing, wherein any context learning example pair in the context learning example pair set includes a target example sample and a target material, the example sample set includes the target example sample, and the original material set includes the target material; based on any context learning example pair and a preset prompt word, a target data pair is determined, the target data pair includes a target instruction for the target material and a target output for the target instruction, the target instruction is used to characterize the relevant application of the target material, and the target output includes the application result of the relevant application of the target material. In this way, example samples are obtained, and original materials that are highly relevant to the application scenario are mined from the corpus; based on the example samples and the original materials, context learning example pairs are constructed; based on the context learning example pairs and the prompt words, high-quality target data pairs ((instruction, output) pairs, i.e., instruction fine-tuning data) are quickly constructed; thereby improving the efficiency of constructing the target data pairs, i.e., improving the quantity, quality, controllability, etc. of the target data pairs; further, for example, multiple target data pairs can constitute an instruction fine-tuning dataset with diverse types and rich content, and the performance of the large language model can be greatly enhanced by fine-tuning the large language model based on the instruction fine-tuning dataset.

[0102] In one embodiment, the sample set is constructed manually, and the sample set includes multiple sample examples. Figure 3 As shown, example sample 1, example sample 2, example sample 3, etc. are manually constructed through the original corpus, and example sample 1, example sample 2, example sample 3, etc. constitute an example sample set.

[0103] For example, based on a numerical calculation question in a tax scenario, we construct an example sample:

[0104] "Material (sample material): Small-scale taxpayers are subject to the simplified collection method of 3% and are not eligible for the deduction of special value-added tax invoices."

[0105] "Instruction (initial instruction): Farmer Uncle Zhang grows vegetables, and Aunt Zhang runs a small shop. In the first quarter of this year, Uncle Zhang sold 310,000 yuan worth of cabbage he grew, and Aunt Zhang's shop sold goods worth 290,000 yuan. How much value-added tax do Uncle Zhang and Aunt Zhang need to pay in total?"

[0106] Output (initial output): Based on the known information, Mr. Zhang and Mrs. Zhang are both small-scale taxpayers, and the simplified tax rate of 3% applies to them. Therefore, the VAT they need to pay is:

[0107] Mr. Zhang: 310,000 yuan x 3% = 9,300 yuan

[0108] Aunt Zhang: 290,000 yuan x 3% = 8,700 yuan

[0109] The total VAT they need to pay is: 9,300 yuan + 8,700 yuan = 18,000 yuan.

[0110] Among them, the material (sample material) is a tax law or regulation involving numerical calculations; the regulations need to be kept complete, and the instructions (initial instructions) are a specific application case artificially conceived, which is related to the content of the regulations; based on the material (sample material) and instructions (initial instructions), the output (initial output) is determined by manually listing the analysis process, formulas, etc.

[0111] The example sample set is for example a scenario computing reasoning evaluation dataset. For example, 100 example samples are manually constructed from the original corpus based on different application scenarios. These 100 example samples constitute a scenario computing reasoning evaluation dataset for self-testing. The scenario distribution of the scenario computing reasoning evaluation dataset is as follows: Figure 4 As shown, the scenario calculates the reasoning evaluation dataset and question types as follows Figure 5 As shown. Figure 4 The scene distribution shown includes tax scenes, cloud computing scenes, code scenes, property scenes, economic scenes, government scenes, legal scenes, historical scenes, life scenes, education scenes and sports scenes; tax scenes correspond to 42 example samples, cloud computing scenes correspond to 21 example samples, code scenes correspond to 10 example samples, property scenes correspond to 8 example samples, economic scenes correspond to 5 example samples, government scenes correspond to 5 example samples, legal scenes correspond to 3 example samples, historical scenes correspond to 2 example samples, life scenes correspond to 2 example samples, education scenes correspond to 1 example sample, and sports scenes correspond to 1 example sample. Figure 5 The question types shown include numerical calculation, category comprehension, numerical comparison, logical reasoning and date reasoning; there are 39 example samples corresponding to numerical calculation, 33 example samples corresponding to category comprehension, 26 example samples corresponding to numerical comparison, 19 example samples corresponding to logical reasoning, and 17 example samples corresponding to date reasoning.

[0112] It should be noted that in the stage of constructing the example sample set, a large language model can be used to output answers in steps based on the original materials and questions, and then manually check and correct them, thereby reducing labor costs.

[0113] In one embodiment, obtaining a set of original materials includes:

[0114] Perform matching processing based on a preset regular expression and text in a preset database to determine at least one of the chapter structure of the text, the iconic symbols of the text, and the special characters of the text;

[0115] Based on at least one item, the text is segmented to determine the material corresponding to the text, and the material corresponding to the text is determined as the original material in the original material set.

[0116] Specifically, for example, Figure 3 As shown, original material 1, original material 2, original material 3, etc. are automatically mined from the original corpus through pattern matching. Original material 1, original material 2, original material 3, etc. constitute the original material set. The pattern matching method is, for example, a preset regular expression.

[0117] The pattern matching method may be a preset regular expression, and the original corpus may be a preset database; for example, based on the preset database, a raw material set is constructed through a preset regular expression, and the raw material set includes multiple raw materials; the raw materials may be, for example, the individual income tax calculation method in a tax scenario, the server charging standard for cloud computing in a cloud computing scenario, etc.

[0118] For example, a regular expression can be matched against a text to determine the chapter and paragraph structure of the text; the regular expression is used to describe the chapter and paragraph structure to be matched. For example, for a text with a clear chapter and paragraph structure, the regular expression can be used to locate the chapter and paragraph structure, segment the text into paragraphs and sentences, and extract the original material one by one.

[0119] For example, the following text is from the Interim Measures for the Administration of Accounting for Individual Business Owners:

[0120] "Tax authorities should also take effective measures to consolidate existing accounting achievements and actively guide individual businesses to establish and improve their accounting books, conduct correct accounting, and declare and pay taxes truthfully.

[0121] Article 3

[0122] Individual business owners who meet any of the following conditions shall set up double-entry accounts:

[0123] (1) The registered capital is more than RMB 200,000.

[0124] (2) The monthly sales (business) turnover of a taxpayer who sells VAT taxable services or a business tax taxpayer is RMB 40,000 or more; the monthly sales turnover of a VAT taxpayer who engages in the production of goods is RMB 60,000 or more; the monthly sales turnover of a VAT taxpayer who engages in the wholesale or retail of goods is RMB 80,000 or more.

[0125] (3) Other circumstances where the provincial tax authorities determine that double-entry accounting should be set up.

[0126] Article 4

[0127] Individual industrial and commercial households that meet any of the following circumstances shall set up simple accounts and actively create conditions for setting up double-entry accounts:

[0128] (1) The registered capital is between RMB 100,000 and RMB 200,000.

[0129] (2) The monthly sales (business) turnover of taxpayers who sell VAT taxable services or business tax taxpayers is between RMB 15,000 and RMB 40,000; the monthly sales turnover of VAT taxpayers who engage in the production of goods is between RMB 30,000 and RMB 60,000; the monthly sales turnover of VAT taxpayers who engage in the wholesale or retail of goods is between RMB 40,000 and RMB 80,000.

[0130] (3) Other circumstances where the provincial tax authorities determine that simplified accounts should be set up.

[0131] Among them, "Article 3" and "Article 4" are clear chapter and article structures (the chapter and article structure of the text). Through the preset regular expression, this text is split into two original materials, "Article 3" and "Article 4".

[0132] It should be noted that corresponding regular expressions are written for common chapter and article structures, so that different texts can be processed automatically to determine the corresponding original materials.

[0133] For example, for texts without a clear chapter and article structure, regular expressions are used to match iconic symbols (text iconic symbols) and / or characters with special meanings (text special characters); iconic symbols in the text include book title marks << ", etc., and characters with special meanings include "XXX Notice", "XXX Regulations", "Finance and Taxation

[2019] No. 20", etc. For example, laws and regulations are usually enclosed in book title marks << ", and some sentences in laws and regulations mention calculation methods, calculation formulas, etc.; based on the book title marks << ", calculation methods, calculation formulas, etc., this paragraph or sentence is segmented. For example, the following text:

[0134] The VAT policies for leasing state-owned agricultural land are hereby announced as follows:

[0135] Taxpayers who lease state-owned agricultural land to agricultural producers for agricultural production are exempt from value-added tax.

[0136] General taxpayers in real estate development companies who purchase unfinished old real estate projects for further development and then sell the real estate under their own name are considered old real estate projects. They can choose to apply the simplified tax calculation method and pay value-added tax at a rate of 5%.

[0137] Insurance companies may offset the VAT payable in subsequent months in accordance with Article 4, Item (3) of the "Notice of the Ministry of Finance and the State Administration of Taxation on Clarifying the VAT Exemption Policies for Nursing Homes" (Cai Shui

[2019] No. 20). If the VAT cannot be fully offset by December 31, 2020, they may apply to the competent tax authorities for a one-time refund."

[0138] Among them, "you can choose to apply the simplified tax calculation method and calculate the value-added tax at a rate of 5%" mentions the calculation method of value-added tax, and "The Notice of the Ministry of Finance and the State Administration of Taxation on Clarifying the Policies of Exemption of Value-Added Tax for Nursing Homes" is a certain notification document. Therefore, two original materials can be located and extracted.

[0139] It should be noted that corresponding regular expressions are written for common iconic symbols and characters with special meanings, so different texts can be processed automatically to determine the corresponding original materials.

[0140] For example, after obtaining a set of original materials, each original material in the set is subjected to scenario classification and question type classification; scenario classification can be determined based on the source of the text. For example, if a certain original material comes from the "Interim Measures for the Management of Accounting for Individual Industrial and Commercial Households", the original material is classified as a "tax scenario"; question type classification is determined based on certain keywords appearing in the original material. For example, if the original material contains keywords indicating dates such as ['year', 'month', 'day', 'day'], the original material is classified as a "date reasoning" question type; if the original material contains keywords indicating amounts such as ['yuan', 'RMB'], the original material is classified as a "numerical calculation" or "numerical comparison" question type.

[0141] It should be noted that in order to ensure the quality of the original materials, the original materials that are too short or too long can be filtered. In the original material mining, by accessing the search engine, inputting the corresponding keywords for different scenes to recall the corresponding original materials, thus obtaining richer and more comprehensive original materials.

[0142] In one embodiment, based on the example sample set and the original material set, determining a context learning example pair set through matching processing includes:

[0143] Based on any original material in the original material set and the example sample set, determining at least one example sample in the example sample set through matching processing, each example sample in the at least one example sample and any original material forming a context learning example pair;

[0144] Based on any example sample in the example sample set and the original material set, at least one original material in the original material set is determined through matching processing, and each original material in the at least one original material and any example sample constitute a context learning example pair.

[0145] Specifically, in order to increase the number of contextual learning example pairs while maintaining the relevance between the original material and the example samples, similarity text retrieval can be performed in parallel; for example, Figure 3 As shown, matching example samples are retrieved based on the original material and matching original materials are retrieved based on the example samples to obtain context learning example pairs.

[0146] Similarity text retrieval, for example Figure 6 As shown, target materials that are similar to the materials to be retrieved are retrieved in the target material set, and the target material set includes target material 1, target material 2, target material 3, ... target material N, where N is a positive integer; for example, the original material is the target material, and each example sample in the example sample set is the material to be retrieved. Based on the original material, matching example samples are retrieved from the example sample set; for example, the example sample is the target material, and each original material in the original material set is the material to be retrieved. Based on the example samples, matching original materials are retrieved from the original material set.

[0147] For example, based on the original material retrieval matching sample or based on the sample retrieval matching original material, for a certain type of question in a certain application scenario, the text features of the original material (the text feature vector corresponding to the original material) and the text features of the material in the sample (the text feature vector corresponding to the sample material of the sample) are extracted through the pre-trained text representation model (such as BERT). The text features of the original material are recorded as E i (i=0,1…n), the text features of the material in the sample are recorded as E j (j=0,1…m); for each original material text feature E i , calculate the text features E of the material in each example sample respectively j The cosine similarity between ij , assuming that the dimension of the text feature vector is D, E i and E j The cosine similarity between ij The formula (1) is as follows:

[0148]

[0149] Among them, i = 0, 1…n, j = 0, 1…m, n and m are both positive integers, k represents the dimension, and the value range of k is [1, D].

[0150] For example, matrix operations are performed on text feature vectors through tool libraries such as faiss to quickly obtain the similarity between all text feature vectors; for each original material in the original material set, the material (sample material) from the topM example samples that are most similar to the original material is selected from the example sample set, where M is a positive integer; a similarity (first similarity) threshold range [min_sim, max_sim] is set, and example samples whose similarity falls within the threshold range are retained from the topM example samples. Example samples whose similarity (first similarity) is less than min_sim (first similarity threshold) are example samples with too large differences, which will affect the generation effect of the large language model; example samples whose similarity (first similarity) is greater than max_sim (second similarity threshold) are highly similar example samples, and there is a risk of test data leakage. Therefore, example samples whose similarity (first similarity) is less than min_sim and example samples whose similarity (first similarity) is greater than max_sim need to be filtered out; the filtered example samples (example samples that fall within the threshold range) can be paired with the original material to form context learning example pairs, and the context learning example pairs are saved.

[0151] For example, for each example sample in the example sample set, the topM original materials that are most similar to the example sample are selected from the original material set, where M is a positive integer; a similarity threshold range [min_sim, max_sim] is set, and the original materials whose similarity (second similarity) falls within the threshold range are retained from the topM original materials. The original materials whose similarity (second similarity) is less than min_sim (first similarity threshold) are original materials with too large differences, which will affect the generation effect of the large language model; the original materials whose similarity (second similarity) is greater than max_sim (second similarity threshold) are highly similar original materials, and there is a risk of test data leakage. Therefore, the original materials whose similarity (second similarity) is less than min_sim and the original materials whose similarity (second similarity) is greater than max_sim need to be filtered out; the filtered original materials (original materials that fall within the threshold range) can be paired with the example sample to form a context learning example pair, and the context learning example pair is saved.

[0152] For example, in a tax context, the original material A is as follows:

[0153] "Material: According to the "Announcement of the Ministry of Finance and the State Administration of Taxation on Further Strengthening the Implementation of the VAT End-of-Period Refund Policy" (Announcement No. 14 of 2022 by the Ministry of Finance and the State Administration of Taxation)," VII. "For the purposes of this announcement, manufacturing and other industries refer to taxpayers engaged in the "manufacturing," "scientific research and technical services," "electricity, heat, gas, and water production and supply," "software and information technology services," "ecological protection and environmental management," and "transportation, warehousing, and postal services" sectors of the National Economic Industry Classification, where VAT sales corresponding to these businesses account for more than 50% of total VAT sales. The aforementioned sales percentage is calculated based on the taxpayer's sales for the 12 consecutive months prior to the refund application. If the operating period prior to the refund application is less than 12 months but more than 3 months, the sales percentage is calculated based on the actual operating period." XVI. This announcement will take effect on April 1, 2022."

[0154] The original material A and the example sample B constitute a context learning example pair, and the example sample B is as follows:

[0155] "Material: 'According to the 'Administrative Measures for the Tax Counseling Period for General VAT Taxpayers' (Guo Shui Fa

[2010] No. 40),' the tax counseling period for newly designated small-scale commercial and wholesale enterprises as general taxpayers is three months; the tax counseling period for other general taxpayers is six months. 2. 'Small-scale commercial and wholesale enterprises' refers to wholesale enterprises with a registered capital of RMB 800,000 or less and 10 or fewer employees. Enterprises solely engaged in export trade and not requiring special VAT invoices are excluded. 'Other general taxpayers' refers to general taxpayers who meet any of the following circumstances: (1) the amount of VAT evasion accounts for more than 10% of the tax payable and the amount of evasion is more than RMB 100,000; (2) fraudulently obtaining export tax rebates; (3) falsely issuing VAT deduction certificates; (4) other circumstances specified by the State Administration of Taxation.',

[0156] Instruction: 'A certain commercial and wholesale enterprise has a registered capital of 1 million yuan and 20 employees. Does it qualify as a "small commercial and wholesale enterprise"?'

[0157] Output: 'Based on the known information, a "small commercial wholesale enterprise" refers to a wholesale enterprise with a registered capital of 800,000 yuan or less and 10 employees or less. A certain commercial wholesale enterprise has a registered capital of 1 million yuan and 20 employees, both of which exceed the definition of a "small commercial wholesale enterprise." Therefore, this commercial wholesale enterprise does not fall under the category of "small commercial wholesale enterprise."'"

[0158] In one embodiment, based on any original material in the original material set and the example sample set, determining at least one example sample in the example sample set through matching processing includes:

[0159] Determine a text feature vector corresponding to any original material in the original material set and a text feature vector corresponding to the sample material of each example sample in the example sample set;

[0160] Determining a first similarity between the text feature vector corresponding to any original material and the text feature vector corresponding to the sample material of each example sample based on the text feature vector corresponding to any original material and the text feature vector corresponding to the sample material of each example sample;

[0161] At least one example sample in the example sample set is determined based on the first similarities, a preset first similarity threshold, and a preset second similarity threshold, where the second similarity threshold is greater than the first similarity threshold.

[0162] Specifically, for example, based on the original material retrieval matching example samples; for a certain type of question in a certain application scenario, the text features of the original material (the text feature vector corresponding to the original material) and the text features of the material in the example sample (the text feature vector corresponding to the sample material of the example sample) are extracted through a pre-trained text representation model (such as BERT). The text features of the original material are recorded as E i (i=0,1...n), the text features of the material in the sample are recorded as E j (j=0,1...m); for each text feature E of the original material i , calculate the text features E of the material in each example sample respectively j The cosine similarity between ij , cosine similarity ij is the first similarity, assuming that the dimension of the text feature vector is D, E i and E j The cosine similarity between ij The calculation of is shown in formula (1).

[0163] For example, matrix operations are performed on text feature vectors through tool libraries such as faiss to quickly obtain the similarity between all text feature vectors; for each original material in the original material set, the material (sample material) from the topM example samples that are most similar to the original material is selected from the example sample set, where M is a positive integer; a similarity (first similarity) threshold range [min_sim, max_sim] is set, and example samples whose similarity falls within the threshold range are retained from the topM example samples. Example samples whose similarity (first similarity) is less than min_sim (first similarity threshold) are example samples with too large differences, which will affect the generation effect of the large language model; example samples whose similarity (first similarity) is greater than max_sim (second similarity threshold) are highly similar example samples, and there is a risk of test data leakage. Therefore, example samples whose similarity (first similarity) is less than min_sim and example samples whose similarity (first similarity) is greater than max_sim need to be filtered out; the filtered example samples (example samples that fall within the threshold range) can be paired with the original material to form context learning example pairs, and the context learning example pairs are saved.

[0164] In one embodiment, determining at least one example sample in the example sample set based on the first similarities, the preset first similarity threshold, and the preset second similarity threshold includes:

[0165] Sort the first similarities from largest to smallest, and determine the top N first similarities, where N is a positive integer;

[0166] If any first similarity among the N first similarities is greater than the first similarity threshold and less than the second similarity threshold, determining the example sample corresponding to any first similarity as the example sample among the at least one example sample;

[0167] If any first similarity is equal to the first similarity threshold or the second similarity threshold, the example sample corresponding to any first similarity is determined as the example sample in the at least one example sample.

[0168] Specifically, for each original material in the original material set, the material (sample material) from the topM example samples that are most similar to the original material is selected from the example sample set, where M is a positive integer; a threshold range of similarity (first similarity) is set [min_sim, max_sim], and example samples whose similarity falls within the threshold range are retained from the topM example samples. Example samples whose similarity (first similarity) is less than min_sim (first similarity threshold) are example samples with too large differences, which will affect the generation effect of the large language model. Example samples whose similarity (first similarity) is greater than max_sim (second similarity threshold) are highly similar example samples, and there is a risk of test data leakage. Therefore, example samples whose similarity (first similarity) is less than min_sim and example samples whose similarity (first similarity) is greater than max_sim need to be filtered out; the filtered example samples (example samples that fall within the threshold range) can be paired with the original material to form context learning example pairs, and the context learning example pairs are saved.

[0169] In one embodiment, determining at least one original material in the original material set through matching based on any example sample in the example sample set and the original material set includes:

[0170] Determine a text feature vector corresponding to a sample material of any example sample in the example sample set and a text feature vector corresponding to each original material in the original material set;

[0171] Determining a second similarity between the text feature vector corresponding to the sample material of any example sample and the text feature vector corresponding to each original material based on the text feature vector corresponding to the sample material of any example sample and the text feature vector corresponding to each original material;

[0172] Based on the second similarities, the preset first similarity threshold and the preset second similarity threshold, it is determined that at least one original material in the original material set has the second similarity threshold greater than the first similarity threshold.

[0173] Specifically, for example, based on sample retrieval and matching of original materials; for a certain type of question in a certain application scenario, the text features of the original material (the text feature vector corresponding to the original material) and the text features of the material in the sample (the text feature vector corresponding to the sample material of the sample) are extracted through a pre-trained text representation model (such as BERT). The text features of the original material are recorded as E i (i=0,1…n), the text features of the material in the sample are recorded as E j (j=0,1...m); for each text feature E of the original material i, calculate the text features E of the material in each example sample respectively j The cosine similarity between ij , cosine similarity ij is the second similarity, assuming that the dimension of the text feature vector is D, E i and E j The cosine similarity between ij The calculation of is shown in formula (1).

[0174] For example, matrix operations are performed on text feature vectors through tool libraries such as faiss to quickly obtain the similarity between all text feature vectors; for each example sample in the example sample set, the topM original materials that are most similar to the example sample are selected from the original material set, where M is a positive integer; a similarity threshold range [min_sim, max_sim] is set, and original materials whose similarity (second similarity) falls within the threshold range are retained from the topM original materials. Original materials whose similarity (second similarity) is less than min_sim (first similarity threshold) are original materials with too large differences, which will affect the generation effect of the large language model; original materials whose similarity (second similarity) is greater than max_sim (second similarity threshold) are highly similar original materials, and there is a risk of test data leakage. Therefore, original materials whose similarity (second similarity) is less than min_sim and original materials whose similarity (second similarity) is greater than max_sim need to be filtered out; the filtered original materials (original materials that fall within the threshold range) can be paired with the example sample to form a context learning example pair, and the context learning example pair is saved.

[0175] In one embodiment, determining at least one original material in the original material set based on the second similarities, the preset first similarity threshold, and the preset second similarity threshold includes:

[0176] Sort the second similarities from largest to smallest, and determine the top M second similarities, where M is a positive integer;

[0177] If any second similarity among the M second similarities is greater than the first similarity threshold and less than the second similarity threshold, determining the original material corresponding to any second similarity as the original material among the at least one original material;

[0178] If any of the second similarities is equal to the first similarity threshold or the second similarity threshold, the original material corresponding to any of the second similarities is determined as the original material in the at least one original material.

[0179] Specifically, for example, for each example sample in the example sample set, the topM original materials that are most similar to the example sample are selected from the original material set, where M is a positive integer; a similarity threshold range [min_sim, max_sim] is set, and the original materials whose similarity (second similarity) falls within the threshold range are retained from the topM original materials. The original materials whose similarity (second similarity) is less than min_sim (first similarity threshold) are original materials with too large differences, which will affect the generation effect of the large language model. The original materials whose similarity (second similarity) is greater than max_sim (second similarity threshold) are highly similar original materials, and there is a risk of test data leakage. Therefore, the original materials whose similarity (second similarity) is less than min_sim and the original materials whose similarity (second similarity) is greater than max_sim need to be filtered out; the filtered original materials (original materials that fall within the threshold range) can be paired with the example sample to form a context learning example pair, and the context learning example pair is saved.

[0180] In one embodiment, determining a target data pair based on any context learning example pair and a preset prompt word includes:

[0181] Write any context learning example pair into the preset prompt word to obtain the updated prompt word;

[0182] The updated prompt word is input into the preset large language model, and the target data pair is determined through context learning.

[0183] Specifically, the preset prompt words include at least one of a role set for the large language model, an operating procedure for related applications of the role, specific requirements for related applications of the role, an example sample template, an original material template, and an instruction for the large language model. The example sample template is used to fill in the target example sample into the example sample template, the original material template is used to fill in the target material into the original material template, and the instruction for the large language model is used to instruct the large language model to output a target data pair.

[0184] For example, construct a data construction task of numerical comparison and the corresponding prompt word. The prompt word represents the data construction task of numerical comparison. {original material} refers to the replaceable original material in the prompt word, and {example sample} refers to the replaceable {example sample} in the prompt word. The prompt word is as follows:

[0185] You are an experienced teacher. Based on the given material, you will find content containing quantities and numbers, use this to formulate questions about [Numerical Comparison], and provide corresponding answers. The output content includes three parts: material, instructions, and output. The output is in JSON format, ensuring that the output can be loaded using json.loads. The following is an example.

[0186] {Sample Example}

[0187] The following is the formal question-setting process.

[0188] {Original material}.

[0189] Please write the instructions and output."

[0190] It should be noted that the prompt word sets up a question-setting teacher role for the large language model, presents the operational process, question types and specific requirements for setting questions, provides an example sample as a reference case for the large language model's contextual learning, and provides matching original materials so that the large language model can output target data pairs ((instruction, output) pairs, i.e., instruction fine-tuning data). Related applications include question setting; roles set for large language models, such as question-setting teachers; the operational process for setting questions for the role, for example, you will find content containing quantities and numbers based on the given materials, and use this to conceive questions about [numerical comparison] and give corresponding answers; question types for the role, such as numerical comparison; specific requirements for setting questions for the role, for example, conceive questions about [numerical comparison] and give corresponding answers; example sample templates, such as {example sample}, and original material templates, such as {original material}; instructions for large language models, for example, the output content includes three parts: material, instruction, and output.

[0191] For example, Figure 3 As shown, a context learning example pair (example sample A and original material B) is written into the prompt word, that is, the example sample A is filled in the prompt word {example sample}, and the original material B is filled in the prompt word {original material}, and an updated prompt word is obtained. The updated prompt word includes {example sample A} and {original material B}; the updated prompt word is input into the large language model, and the target data pair ((instruction, output) pair, i.e., instruction fine-tuning data) is determined through context learning.

[0192] It should be noted that the large language model can quickly generate batches of instruction fine-tuning data. These instruction fine-tuning data are constrained by example samples and belong to the same type as the example samples. Therefore, the controllability of the instruction fine-tuning data is significantly improved.

[0193] In one embodiment, after determining a target data pair based on any context learning example pair and a preset prompt word, the method further includes:

[0194] Based on each target data pair, a large language model or another large language model is trained to obtain a trained large language model.

[0195] Specifically, for example, multiple target data pairs can constitute a diverse and detailed instruction fine-tuning dataset. The large language model is fine-tuned based on the instruction fine-tuning dataset to obtain a trained large language model, and the performance of the trained large language model is greatly enhanced.

[0196] In one embodiment, before determining a target data pair based on any context learning example pair and a preset prompt word, the method further includes:

[0197] Get the initial prompt word;

[0198] Based on the initial prompt words, the preset prompt words are determined through the prompt word engineering. The preset prompt words are texts describing the data construction task.

[0199] Specifically, the preset prompt words are the better results obtained after multiple adjustments to the initial prompt words. In actual application, based on the initial prompt words, prompt word engineering is used to obtain better prompt words, namely the preset prompt words.

[0200] The application of the embodiments of the present disclosure has at least the following beneficial effects:

[0201] Obtain example samples and mine original materials that are highly relevant to the application scenario from the corpus; construct contextual learning example pairs based on the example samples and the original materials; quickly construct high-quality target data pairs ((instruction, output) pairs, i.e., instruction fine-tuning data) based on the contextual learning example pairs and prompt words; thereby improving the efficiency of constructing the target data pairs, i.e., improving the quantity, quality, controllability, etc. of the target data pairs; further, for example, multiple target data pairs can constitute a diverse and rich instruction fine-tuning dataset, and the performance of the large language model can be greatly enhanced by fine-tuning the large language model based on the instruction fine-tuning dataset.

[0202] In order to better understand the method provided by the embodiment of the present disclosure, the solution of the embodiment of the present disclosure is further described below with reference to examples of specific application scenarios.

[0203] In one embodiment, a numerical calculation problem in a tax scenario is used as an example to illustrate the difference in effect between the method provided in the embodiment of the present disclosure and other data construction methods.

[0204] For example, through the method provided by the embodiment of the present disclosure, the data construction task and the corresponding prompt words are designed, and the prompt words include example samples of context learning, and the prompt words are as follows:

[0205] You are an experienced teacher. Based on the given material, you will find content containing quantities and numbers, use this to formulate questions about [Numerical Calculation], and provide corresponding answers. The output content includes three parts: material, instructions, and output. The output is in JSON format, ensuring that the output can be loaded using json.loads. The following is an example.

[0206] {'material':'Calculation of personal income tax: According to the "Individual Income Tax Law of the People's Republic of China", stock grants are considered wages and salaries, and personal income tax is calculated according to progressive tax rates. The specific tax rates are: 3% for monthly taxable income not exceeding 3,000 yuan; 10% for the portion between 3,000 yuan and 12,000 yuan; 20% for the portion between 12,000 yuan and 25,000 yuan; 25% for the portion between 25,000 yuan and 35,000 yuan; 30% for the portion between 35,000 yuan and 55,000 yuan; 35% for the portion between 55,000 yuan and 80,000 yuan; and 45% for the portion over 80,000 yuan.',

[0207] 'Instruction': 'Today the company paid a salary of 100,000 yuan. How much personal income tax do I need to pay?'

[0208] Output: 'Based on the given information, your taxable income is 100,000 yuan. Using progressive tax rates, your individual income tax payable is: (3,000 yuan x 3%) + (9,000 yuan x 10%) + (13,000 yuan x 20%) + (10,000 yuan x 25%) + (20,000 yuan x 30%) + (25,000 yuan x 35%) + (20,000 yuan x 45%) = 90 yuan + 900 yuan + 2,600 yuan + 2,500 yuan + 6,000 yuan + 8,750 yuan + 9,000 yuan = 29,840 yuan. Therefore, your individual income tax payable is 29,840 yuan.'}

[0209] The following is the formal question-setting process.

[0210] {'Materials':'Government information disclosure application processing fee standards are calculated on a per-item basis: (1) No fee for applications submitted by the same applicant totaling 10 or fewer applications within a calendar month. (2) RMB 100 per application for applications submitted by the same applicant totaling 11 to 30 applications within a calendar month. (3) RMB 100 per application for applications submitted by the same applicant totaling 31 or more within a calendar month. The fee increases by RMB 100 per application for each additional application, with 10 applications as the first level.'}

[0211] Please write the instructions and output."

[0212] The target data pairs ((instruction, output) pairs, i.e., instruction fine-tuning data) output by the large language model GPT-4 in the method provided by the embodiments of the present disclosure are as follows:

[0213] {"Command":"In one calendar month, an applicant has submitted 50 applications for government information disclosure. How much does he need to pay?",

[0214] Output: "According to the charging standards, the first 10 items are free, items 11 to 30 are charged 100 yuan each, items 31 to 40 are charged 200 yuan each, and items 41 to 50 are charged 300 yuan each. Therefore, the applicant needs to pay the following fees: (30-10) × 100 yuan + (40-30) × 200 yuan + (50-40) × 300 yuan = 20 × 100 yuan + 10 × 200 yuan + 10 × 300 yuan = 2,000 yuan + 2,000 yuan + 3,000 yuan = 7,000 yuan."}

[0215] For example, in other data construction methods, the example part is removed, and the (instruction, output) pairs output by the large language model GPT-4 in other data construction methods are as follows:

[0216] {"Instruction":"If a person applies for 20 government information disclosure applications in a calendar month, how much does he need to pay?",

[0217] Output: "According to the charging standards, the applicant needs to pay 100 yuan / item x 20 items = 2,000 yuan."}

[0218] It should be noted that in the target data pairs ((instruction, output) pairs, i.e., instruction fine-tuning data) output by the large language model GPT-4 in the method provided by the embodiment of the present disclosure, since the example sample contains a segmented calculation question and detailed analysis and column calculation are performed in the output answer, the large language model GPT-4 will generate data similar to a question type based on the example sample, and also provide analysis, column calculation and the final correct answer; in the (instruction, output) pairs output by the large language model GPT-4 in other data construction methods, due to the lack of reference example samples, the large language model GPT-4 skips the intermediate analysis and reasoning steps and directly gives the column calculation answer, but the answer is not correct; in this way, the instruction fine-tuning data obtained by the method provided by the embodiment of the present disclosure contains complete analysis and reasoning steps, which helps to activate the COT capability of the large language model and significantly improves the calculation and reasoning performance of the large language model.

[0219] In one embodiment, the instruction fine-tuning data obtained by the method provided in the embodiment of the present disclosure can significantly improve the performance of the large language model. For example, the performance of the large language model in scene computational reasoning can be comprehensively and systematically evaluated from four dimensions, including semantic understanding, content positioning, computational reasoning, and answer summary; semantic understanding: refers to whether the large language model correctly understands the meaning of the material and instructions, whether it misinterprets the intention of the instructions or refuses to answer; content positioning: refers to whether the large language model quotes and repeats the relevant content in the material, and performs calculations and reasoning based on this; computational reasoning: refers to whether the large language model correctly completes the calculation and reasoning steps; answer summary: refers to whether the large language model correctly draws conclusions and answers.

[0220] For example, using GPT-4 according to the method provided in the embodiments of this disclosure, we constructed approximately 12,000 instruction fine-tuning data. The original materials came from corpora in multiple scenarios such as taxation, finance, education, and cloud computing, and the example samples came from the scenario computing reasoning evaluation dataset. We selected Baichuan-2 as the baseline model and performed one epoch of fully parameterized supervised instruction fine-tuning using the 12,000 instruction fine-tuning data. We evaluated the indicators of the original version and the fine-tuned version of Baichuan-2 (the fine-tuned version uses the instruction fine-tuning data as samples for large language model training) on ​​the scenario computing reasoning evaluation dataset. The comparison results between the original version of Baichuan-2 and the fine-tuned version of Baichuan-2 are shown in Table 1:

[0221] Table 1: Comparison results between the original version of Baichuan-2 and the fine-tuned version of Baichuan-2

[0222]

[0223] As shown in Table 1, the training data (instruction fine-tuning data) constructed using the method provided in the embodiments of the present disclosure can significantly help large language models improve their performance, especially in terms of reasoning (improvement of +14%) and answer summarization (improvement of +21%). This demonstrates that the method provided in the embodiments of the present disclosure has significant beneficial effects in enhancing the capabilities of large language models, and provides a reliable reference direction for further optimizing the performance of large language models in the future.

[0224] In one embodiment, the method provided by the embodiment of the present disclosure can quickly construct a high-quality instruction fine-tuning dataset from a massive corpus based on different application scenarios, significantly improving the performance and usage value of large language models in various industry segments, and therefore has broad application prospects.

[0225] For example, the application outlook is as follows:

[0226] In the tax field, the method provided by the embodiment of the present disclosure can mine relevant original materials, such as "personal income tax calculation method", from massive tax laws, cases, interpretations, etc., and then use the context learning ability of the large language model to construct (instruction, output) pairs that meet the tax application scenarios, such as the instruction "calculate personal income tax for an annual salary of 500,000" and the corresponding output.

[0227] In the financial field, the method provided by the embodiments of the present disclosure can mine relevant original materials from financial market data, financial product introductions, financial news and other corpora, such as "stock price-earnings ratio calculation method", etc., and construct common (instruction, output) pairs, such as the instruction "A communications equipment company is preparing to go public, how to estimate the stock price-earnings ratio based on its financial information" and the corresponding output.

[0228] In the property field, the method provided by the embodiment of the present disclosure can mine relevant original materials from corpora such as property management regulations, property service introductions, property dispute cases, etc., such as "general violations of public housing residents", etc., and construct (instruction, output) pairs that conform to actual property scenarios, such as the instruction "Is it a violation for a user to grow fruits on the rooftop?" and the corresponding output.

[0229] In the field of cloud computing, the method provided by the embodiments of the present disclosure can mine relevant original materials from cloud computing technical documents, cloud service use cases, cloud computing news and other corpora, such as "cloud storage service charging standards", etc., and construct common (instruction, output) pairs, such as the instruction "Please provide a suitable product quotation plan with a budget of 10,000" and the corresponding output.

[0230] In a specific application scenario embodiment, such as the instruction fine-tuning data construction scenario, see Figure 7, shows a processing flow of a data construction method, such as Figure 7 As shown, the processing flow of the data construction method provided by the embodiment of the present disclosure includes the following steps:

[0231] S701, the server obtains an artificially constructed sample set, and automatically mines original materials from the original corpus through pattern matching to construct an original material set.

[0232] Specifically, for example, Figure 3 As shown, through the original corpus, example sample 1, example sample 2, example sample 3, etc. are manually constructed, and example sample 1, example sample 2, example sample 3, etc. constitute the example sample set; through the pattern matching method, original material 1, original material 2, original material 3, etc. are automatically mined from the original corpus, and original material 1, original material 2, original material 3, etc. constitute the original material set, and the pattern matching method is, for example, a preset regular expression.

[0233] S702: The server retrieves matching example samples in the example sample set based on each original material in the original material set to obtain context learning example pairs.

[0234] Specifically, for example, Figure 3 As shown, based on the original material, matching example samples are retrieved to obtain context learning example pairs; that is, based on any original material and example sample set in the original material set, at least one example sample in the example sample set is determined through matching processing, and each example sample in at least one example sample and any original material constitute a context learning example pair.

[0235] S703: The server retrieves the original material in the original material set based on each example sample in the example sample set to obtain a context learning example pair.

[0236] Specifically, for example, Figure 3 As shown, based on the example sample retrieval and matching of original materials, context learning example pairs are obtained; that is, based on any example sample in the example sample set and the original material set, at least one original material in the original material set is determined through matching processing, and each original material in the at least one original material and any example sample constitute a context learning example pair.

[0237] S704: The server writes the context learning example pair into the preset prompt word to obtain an updated prompt word.

[0238] Specifically, for example, Figure 3As shown, a context learning example pair (example sample A and original material B) is written into the prompt word, that is, the example sample A is filled in the prompt word {example sample}, and the original material B is filled in the prompt word {original material}, and the updated prompt word is obtained, and the updated prompt word includes {example sample A} and {original material B}.

[0239] S705: The server inputs the updated prompt word into a preset large language model and determines the target data pair through context learning.

[0240] Specifically, for example, Figure 3 As shown, the updated prompt word is input into the large language model, and the target data pair, i.e., the (instruction, output) pair, is determined through context learning.

[0241] S706: The server trains the large language model or other large language models based on each target data pair to obtain a trained large language model.

[0242] Specifically, for example, multiple target data pairs can constitute a diverse and detailed instruction fine-tuning dataset. The large language model is fine-tuned based on the instruction fine-tuning dataset to obtain a trained large language model, and the performance of the trained large language model is greatly enhanced.

[0243] The application of the embodiments of the present disclosure has at least the following beneficial effects:

[0244] Obtain example samples and mine original materials that are highly relevant to the application scenario from the corpus; construct contextual learning example pairs based on the example samples and the original materials; quickly construct high-quality target data pairs ((instruction, output) pairs, i.e., instruction fine-tuning data) based on the contextual learning example pairs and prompt words; thereby improving the efficiency of constructing the target data pairs, i.e., improving the quantity, quality, controllability, etc. of the target data pairs; further, for example, multiple target data pairs can constitute a diverse and rich instruction fine-tuning dataset, and the performance of the large language model can be greatly enhanced by fine-tuning the large language model based on the instruction fine-tuning dataset.

[0245] The embodiment of the present disclosure also provides a data construction device. The structural diagram of the data construction device is as follows: Figure 8 As shown, the data construction device 80 includes a first processing module 801 , a second processing module 802 and a third processing module 803 .

[0246] A first processing module 801 is configured to obtain an example sample set and an original material set, wherein any example sample in the example sample set includes the sample material, an initial instruction for the sample material, and an initial output for the initial instruction, wherein the initial instruction is used to represent a related application of the sample material, and the initial output includes an application result of the related application of the sample material;

[0247] A second processing module 802 is configured to determine, based on the example sample set and the original material set, a set of context learning example pairs through matching processing, wherein any context learning example pair in the set of context learning example pairs includes a target example sample and a target material, the example sample set includes the target example sample, and the original material set includes the target material;

[0248] The third processing module 803 is used to determine a target data pair based on any context learning example pair and a preset prompt word. The target data pair includes a target instruction for the target material and a target output for the target instruction. The target instruction is used to characterize the relevant application of the target material, and the target output includes the application result of the relevant application of the target material.

[0249] In one embodiment, the first processing module 801 is specifically configured to:

[0250] Perform matching processing based on a preset regular expression and text in a preset database to determine at least one of the chapter structure of the text, the iconic symbols of the text, and the special characters of the text;

[0251] Based on at least one item, the text is segmented to determine the material corresponding to the text, and the material corresponding to the text is determined as the original material in the original material set.

[0252] In one embodiment, the second processing module 802 is specifically configured to:

[0253] Based on any original material in the original material set and the example sample set, determining at least one example sample in the example sample set through matching processing, each example sample in the at least one example sample and any original material forming a context learning example pair;

[0254] Based on any example sample in the example sample set and the original material set, at least one original material in the original material set is determined through matching processing, and each original material in the at least one original material and any example sample constitute a context learning example pair.

[0255] In one embodiment, the second processing module 802 is specifically configured to:

[0256] Determine a text feature vector corresponding to any original material in the original material set and a text feature vector corresponding to the sample material of each example sample in the example sample set;

[0257] Determining a first similarity between the text feature vector corresponding to any original material and the text feature vector corresponding to the sample material of each example sample based on the text feature vector corresponding to any original material and the text feature vector corresponding to the sample material of each example sample;

[0258] At least one example sample in the example sample set is determined based on the first similarities, a preset first similarity threshold, and a preset second similarity threshold, where the second similarity threshold is greater than the first similarity threshold.

[0259] In one embodiment, the second processing module 802 is specifically configured to:

[0260] Sort the first similarities from largest to smallest, and determine the top N first similarities, where N is a positive integer;

[0261] If any first similarity among the N first similarities is greater than the first similarity threshold and less than the second similarity threshold, determining the example sample corresponding to any first similarity as the example sample among the at least one example sample;

[0262] If any first similarity is equal to the first similarity threshold or the second similarity threshold, the example sample corresponding to any first similarity is determined as the example sample in the at least one example sample.

[0263] In one embodiment, the second processing module 802 is specifically configured to:

[0264] Determine a text feature vector corresponding to a sample material of any example sample in the example sample set and a text feature vector corresponding to each original material in the original material set;

[0265] Determining a second similarity between the text feature vector corresponding to the sample material of any example sample and the text feature vector corresponding to each original material based on the text feature vector corresponding to the sample material of any example sample and the text feature vector corresponding to each original material;

[0266] Based on the second similarities, the preset first similarity threshold and the preset second similarity threshold, it is determined that at least one original material in the original material set has the second similarity threshold greater than the first similarity threshold.

[0267] In one embodiment, the second processing module 802 is specifically configured to:

[0268] Sort the second similarities from largest to smallest, and determine the top M second similarities, where M is a positive integer;

[0269] If any second similarity among the M second similarities is greater than the first similarity threshold and less than the second similarity threshold, determining the original material corresponding to any second similarity as the original material among the at least one original material;

[0270] If any of the second similarities is equal to the first similarity threshold or the second similarity threshold, the original material corresponding to any of the second similarities is determined as the original material in the at least one original material.

[0271] In one embodiment, the third processing module 803 is specifically configured to:

[0272] Write any context learning example pair into the preset prompt word to obtain the updated prompt word;

[0273] The updated prompt word is input into the preset large language model, and the target data pair is determined through context learning.

[0274] In one embodiment, the third processing module 803 is further configured to:

[0275] Based on each target data pair, a large language model or another large language model is trained to obtain a trained large language model.

[0276] In one embodiment, the third processing module 803 is further configured to:

[0277] Get the initial prompt word;

[0278] Based on the initial prompt words, the preset prompt words are determined through the prompt word engineering. The preset prompt words are texts describing the data construction task.

[0279] In one embodiment, the preset prompt words include at least one of a role set for the large language model, an operating procedure for related applications of the role, specific requirements for related applications of the role, an example sample template, an original material template, and an instruction for the large language model. The example sample template is used to fill in the target example sample into the example sample template, the original material template is used to fill in the target material into the original material template, and the instruction for the large language model is used to instruct the large language model to output a target data pair.

[0280] The application of the embodiments of the present disclosure has at least the following beneficial effects:

[0281] Obtain an example sample set and an original material set, wherein any example sample in the example sample set includes the sample material, an initial instruction for the sample material, and an initial output for the initial instruction, the initial instruction is used to characterize the relevant application of the sample material, and the initial output includes the application result of the relevant application of the sample material; based on the example sample set and the original material set, determine a context learning example pair set through matching processing, wherein any context learning example pair in the context learning example pair set includes a target example sample and a target material, the example sample set includes the target example sample, and the original material set includes the target material; based on any context learning example pair and a preset prompt word, determine a target data pair, the target data pair includes a target instruction for the target material and a target output for the target instruction, the target instruction is used to characterize the relevant application of the target material, and the target output includes the application result of the relevant application of the target material. In this way, example samples are obtained, and original materials that are highly relevant to the application scenario are mined from the corpus; based on the example samples and the original materials, context learning example pairs are constructed; based on the context learning example pairs and the prompt words, high-quality target data pairs ((instruction, output) pairs, i.e., instruction fine-tuning data) are quickly constructed; thereby improving the efficiency of constructing the target data pairs, i.e., improving the quantity, quality, controllability, etc. of the target data pairs; further, for example, multiple target data pairs can constitute an instruction fine-tuning dataset with diverse types and rich content, and the performance of the large language model can be greatly enhanced by fine-tuning the large language model based on the instruction fine-tuning dataset.

[0282] The present disclosure also provides an electronic device. The structural diagram of the electronic device is as follows: Figure 9 As shown, Figure 9 The electronic device 4000 shown includes: a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, for example, via a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, which may be used for data exchange between the electronic device and other electronic devices, such as data transmission and / or data reception. It should be noted that in actual applications, the number of transceivers 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present disclosure.

[0283] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the present disclosure. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.

[0284] Bus 4002 may include a path for transmitting information between the above components. Bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. Bus 4002 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 9 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.

[0285] The memory 4003 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, without limitation here.

[0286] The memory 4003 is used to store the computer program for executing the embodiments of the present disclosure, and the execution is controlled by the processor 4001. The processor 4001 is used to execute the computer program stored in the memory 4003 to implement the steps shown in the above method embodiments.

[0287] Among them, electronic equipment includes but is not limited to: servers, etc.

[0288] The application of the embodiments of the present disclosure has at least the following beneficial effects:

[0289] Obtain an example sample set and an original material set, wherein any example sample in the example sample set includes the sample material, an initial instruction for the sample material, and an initial output for the initial instruction, the initial instruction is used to characterize the relevant application of the sample material, and the initial output includes the application result of the relevant application of the sample material; based on the example sample set and the original material set, determine a context learning example pair set through matching processing, wherein any context learning example pair in the context learning example pair set includes a target example sample and a target material, the example sample set includes the target example sample, and the original material set includes the target material; based on any context learning example pair and a preset prompt word, determine a target data pair, the target data pair includes a target instruction for the target material and a target output for the target instruction, the target instruction is used to characterize the relevant application of the target material, and the target output includes the application result of the relevant application of the target material. In this way, example samples are obtained, and original materials that are highly relevant to the application scenario are mined from the corpus; based on the example samples and the original materials, context learning example pairs are constructed; based on the context learning example pairs and the prompt words, high-quality target data pairs ((instruction, output) pairs, i.e., instruction fine-tuning data) are quickly constructed; thereby improving the efficiency of constructing the target data pairs, i.e., improving the quantity, quality, controllability, etc. of the target data pairs; further, for example, multiple target data pairs can constitute an instruction fine-tuning dataset with diverse types and rich content, and the performance of the large language model can be greatly enhanced by fine-tuning the large language model based on the instruction fine-tuning dataset.

[0290] An embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps and corresponding contents of the aforementioned method embodiment can be implemented.

[0291] The embodiments of the present disclosure further provide a computer program product, including a computer program, which can implement the steps and corresponding contents of the aforementioned method embodiments when executed by a processor.

[0292] It should be understood that, although the flowcharts of the embodiments of the present disclosure indicate the various operation steps by arrows, the order of implementation of these steps is not limited to the order indicated by the arrows. Unless otherwise clearly stated herein, in some implementation scenarios of the embodiments of the present disclosure, the implementation steps in each flowchart can be performed in other orders as required. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage in these sub-steps or stages can also be executed at different times. In scenarios where the execution times are different, the order of execution of these sub-steps or stages can be flexibly configured as required, and the embodiments of the present disclosure do not limit this.

[0293] The above description is only an optional implementation method for some implementation scenarios of the present disclosure. It should be pointed out that for ordinary technicians in this technical field, without departing from the technical concept of the solution of the present disclosure, other similar implementation methods based on the technical ideas of the present disclosure also fall within the protection scope of the embodiments of the present disclosure.

Claims

1. A data construction method, characterized in that: include: Acquire an example sample set and an original material set, wherein any example sample in the example sample set includes a sample material, an initial instruction for the sample material, and an initial output for the initial instruction, wherein the initial instruction is used to characterize a related application of the sample material, and the initial output includes an application result of the related application of the sample material; Based on the example sample set and the original material set, determining a context learning example pair set through matching processing, wherein any context learning example pair in the context learning example pair set includes a target example sample and a target material, the example sample set includes the target example sample, and the original material set includes the target material; Based on any of the context learning example pairs and preset prompt words, a target data pair is determined, wherein the target data pair includes a target instruction for the target material and a target output for the target instruction, wherein the target instruction is used to characterize the relevant application of the target material, and the target output includes the application result of the relevant application of the target material.

2. The method according to claim 1, characterized in that The obtaining of the original material set includes: Perform matching processing based on a preset regular expression and text in a preset database to determine at least one of the chapter and article structure of the text, the iconic symbols of the text, and the special characters of the text; Based on the at least one item, the text is segmented to determine the material corresponding to the text, and the material corresponding to the text is determined as the original material in the original material set.

3. The method according to claim 1, characterized in that The determining, based on the example sample set and the original material set, through matching processing, a context learning example pair set includes: Based on any original material in the original material set and the example sample set, determining at least one example sample in the example sample set through matching processing, each example sample in the at least one example sample and any original material forming a context learning example pair; Based on any example sample in the example sample set and the original material set, at least one original material in the original material set is determined through matching processing, and each original material in the at least one original material and any example sample constitute a context learning example pair.

4. The method according to claim 3, characterized in that The determining, based on any original material in the original material set and the example sample set, at least one example sample in the example sample set through matching processing, includes: Determine a text feature vector corresponding to any original material in the original material set and a text feature vector corresponding to the sample material of each example sample in the example sample set; Determining a first similarity between the text feature vector corresponding to any one of the original materials and the text feature vector corresponding to the sample material of each of the example samples based on the text feature vector corresponding to any one of the original materials and the text feature vector corresponding to the sample material of each of the example samples; At least one example sample in the example sample set is determined based on the first similarities, a preset first similarity threshold, and a preset second similarity threshold, where the second similarity threshold is greater than the first similarity threshold.

5. The method according to claim 4, characterized in that The determining, based on the first similarities, the preset first similarity threshold, and the preset second similarity threshold, at least one example sample in the example sample set includes: Sort the first similarities from largest to smallest, and determine the top N first similarities, where N is a positive integer; If any first similarity among the N first similarities is greater than the first similarity threshold and less than the second similarity threshold, determining the example sample corresponding to the any first similarity as the example sample among the at least one example sample; If any one of the first similarities is equal to the first similarity threshold or the second similarity threshold, the example sample corresponding to the any one of the first similarities is determined as the example sample in the at least one example sample.

6. The method according to claim 3, characterized in that The determining, based on any example sample in the example sample set and the original material set, at least one original material in the original material set through matching processing, includes: Determining a text feature vector corresponding to a sample material of any example sample in the example sample set and a text feature vector corresponding to each original material in the original material set; Determining a second similarity between the text feature vector corresponding to the sample material of any one of the example samples and the text feature vector corresponding to each of the original materials based on the text feature vector corresponding to the sample material of any one of the example samples and the text feature vector corresponding to each of the original materials; At least one original material in the original material set is determined based on the second similarities, a preset first similarity threshold, and a preset second similarity threshold, wherein the second similarity threshold is greater than the first similarity threshold.

7. The method according to claim 6, characterized in that The determining, based on the second similarities, the preset first similarity threshold, and the preset second similarity threshold, at least one original material in the original material set includes: Sort the second similarities from largest to smallest, and determine the top M second similarities, where M is a positive integer; If any second similarity among the M second similarities is greater than the first similarity threshold and less than the second similarity threshold, determining the original material corresponding to the any second similarity as the original material among the at least one original material; If any of the second similarities is equal to the first similarity threshold or the second similarity threshold, the original material corresponding to the any of the second similarities is determined as the original material in the at least one original material.

8. The method according to claim 1, characterized in that The determining of a target data pair based on any one of the context learning example pairs and the preset prompt word comprises: Writing any of the context learning example pairs into a preset prompt word to obtain an updated prompt word; The updated prompt word is input into a preset large language model, and a target data pair is determined through context learning.

9. The method according to claim 8, characterized in that After determining the target data pair based on any one of the context learning example pairs and the preset prompt words, the method further includes: Based on each target data pair, the large language model or other large language models are trained to obtain a trained large language model.

10. The method according to claim 1, characterized in that Before determining the target data pair based on any of the context learning example pairs and the preset prompt words, the method further includes: Get the initial prompt word; Based on the initial prompt word, a preset prompt word is determined through prompt word engineering, where the preset prompt word is a text describing the data construction task.

11. The method according to claim 1, wherein The preset prompt words include at least one of a role set for the large language model, an operating procedure for related applications of the role, specific requirements for related applications of the role, an example sample template, an original material template, and an instruction for the large language model. The example sample template is used to fill the target example sample into the example sample template, the original material template is used to fill the target material into the original material template, and the instruction for the large language model is used to instruct the large language model to output the target data pair.

12. A data construction device, characterized in that: include: a first processing module, configured to obtain a sample set and an original material set, wherein any sample in the sample set includes a sample material, an initial instruction for the sample material, and an initial output for the initial instruction, wherein the initial instruction is used to characterize a related application of the sample material, and the initial output includes an application result of the related application of the sample material; a second processing module, configured to determine, based on the example sample set and the original material set, a context learning example pair set through matching processing, wherein any context learning example pair in the context learning example pair set includes a target example sample and a target material, the example sample set includes the target example sample, and the original material set includes the target material; The third processing module is used to determine a target data pair based on any of the context learning example pairs and preset prompt words, wherein the target data pair includes a target instruction for the target material and a target output for the target instruction, the target instruction is used to characterize the relevant application of the target material, and the target output includes the application result of the relevant application of the target material.

13. An electronic device comprising a memory, a processor, and a computer program stored in the memory, wherein: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 11.

14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.

15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.