Method and system for constructing and fine-tuning model based on search-enhanced generated carbon finance field instruction data
By constructing an external knowledge base and vector index library to retrieve context and generate structured instruction data, the problem of external knowledge constraints in the generation of instruction data in the field of carbon finance is solved, and the model can achieve multi-step reasoning and stability improvement in carbon finance tasks.
Patent Information
- Application Number
- CN202610750441.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-28
- Publication Date
- 2026-08-25
AI Technical Summary
In the field of carbon finance, existing technologies lack external knowledge constraints in the generation of instruction data, making it difficult to guarantee the consistency of data facts. Single-step instructions are insufficient to express complex reasoning processes, and the lack of contextual constraints during model training leads to the generation results deviating from domain knowledge.
An external knowledge base for the carbon finance field is constructed to generate single-step and multi-step instruction data based on retrieval enhancement. Context is retrieved through a vector index library to construct a structured instruction dataset. In model training, the parameter update amount is constrained, and the conditional generation relationship between instruction, context, and output is learned first.
It improves the factual consistency of the generated data, enhances the model's multi-step reasoning ability in carbon finance tasks, and improves the model's stability and adaptability in complex analysis tasks.
Smart Images

Figure CN122633728A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of artificial intelligence technology, specifically relating to a method for constructing large language model instruction data and fine-tuning the model for carbon finance scenarios, and particularly to a method and system for enhancing instruction generation and reasoning capabilities in the carbon finance field based on Retrieval-Augmented Generation (RAG). Background Technology
[0002] The scale of data in the carbon finance sector is growing rapidly. The relevant data mainly comes from corporate carbon emission reports, environmental information disclosure documents, carbon trading market data, and policy and regulatory texts. This type of data is primarily unstructured text, characterized by dense technical terminology, complex logical relationships, and long reasoning chains, placing high demands on the semantic understanding and multi-step reasoning capabilities of large language models.
[0003] In existing technologies, large language models typically improve their performance on specific tasks through instruction fine-tuning. Traditional methods rely on manually constructing instruction datasets, but due to the highly specialized and knowledge-intensive nature of the carbon finance field, manual annotation is costly and makes it difficult to obtain large-scale, high-quality training data. To alleviate this problem, existing technologies have developed methods for automatically generating instruction data based on large language models. These methods utilize the model itself to generate training samples, thereby improving the scale and diversity of the data to some extent.
[0004] However, such methods mainly rely on existing knowledge within the model for generation, lacking effective constraints from external knowledge. In carbon finance scenarios, the following problems are likely to occur: First, the generated content is inconsistent with real carbon emission data, carbon trading rules, or policy texts, resulting in factual deviations; second, the model may amplify the biases in pre-trained knowledge, producing generated results that do not conform to the facts of the domain; and third, the generated data lacks a clear logical structure, making it difficult to accurately reflect the relationship between the carbon emission calculation process, the policy matching process, and the trading decision-making process.
[0005] On the other hand, retrieval-enhanced generation methods, by introducing external knowledge bases, utilize retrieval results to assist model generation during the inference phase, which helps improve the factual consistency of the generated content. However, existing retrieval-enhanced generation methods are mainly applied to the model inference phase, and still rely heavily on unconstrained automatically generated data during the training data construction phase, failing to fully address the problem of unstable training data quality at the data source.
[0006] Furthermore, in practical applications of carbon finance, tasks such as carbon emission data analysis, emission indicator assessment, policy compliance judgment, and carbon trading decision-making typically involve multiple interdependent reasoning steps. For example, it may require extracting emission-related data, performing calculations and analysis, assessing indicators, and finally making a judgment based on policy rules. These tasks exhibit clear multi-step reasoning characteristics, while existing instruction data often exists in a single-step question-and-answer format, making it difficult to effectively express the step dependencies in complex tasks.
[0007] In terms of model training, while automatically generated instruction data can expand the training scale, it may also cause the model to further reinforce the general generation tendencies formed in the pre-training stage. When the training data lacks explicit contextual constraints, the model is prone to generating data freely, deviating from the current input text and domain knowledge, resulting in generated results that deviate from the retrieval context or prior inference information. Especially in multi-step instruction chain training, if the model cannot continuously rely on the current context and historical step information, subsequent inference results are prone to factual bias or logical breaks.
[0008] In summary, existing technologies still have the following shortcomings: the instruction data generation process lacks external knowledge constraints, making it difficult to guarantee the consistency of data facts; the instruction data structure is relatively simple, making it difficult to support multi-step reasoning modeling; and the model training process lacks a parameter update control mechanism for contextual constraints, which can easily lead to the model generating data freely outside the current domain context. Therefore, it is necessary to propose an instruction data construction and model training method that can introduce external knowledge constraints during the data construction stage, support the construction of multi-step reasoning chains, and strengthen the model's dependence on the current context during training. Summary of the Invention
[0009] To overcome the shortcomings of existing technologies, this invention provides a method and system for constructing and fine-tuning instruction data and models in the carbon finance field based on retrieval enhancement generation. This addresses the problems of lack of external knowledge constraints, difficulty in expressing complex reasoning processes with single-step instructions, and the tendency for models to freely generate data outside the current domain context during training.
[0010] To achieve the above objectives, this invention constructs an external knowledge base in the field of carbon finance and uses this external knowledge base as a source of factual constraints to generate retrieval-enhanced single-step instruction data, namely RAG-SoI, where SoI stands for Single-step Instruction, used to represent the single-step instruction generation method; simultaneously, it constructs retrieval-enhanced multi-step instruction chain data, namely RAG-CoI, where CoI stands for Chain-of-Instruction, used to represent the multi-step instruction chain generation method consisting of multiple instruction steps with contextual dependencies.
[0011] This invention further constructs a structured instruction dataset based on the single-step instruction data and multi-step instruction chain data, and trains a large language model on it. During training, by constraining the update amount of model parameters, the model prioritizes learning the conditional generation relationship between "instruction-context-output," thereby improving the factual consistency of the generated data and enhancing the model's multi-step reasoning ability in carbon finance tasks such as carbon emission analysis, policy matching, compliance judgment, and carbon trading decisions.
[0012] The technical solution of the present invention is as follows: A method for constructing and fine-tuning instruction data and models in the carbon finance field based on retrieval enhancement includes the following steps: Step 1: Text data acquisition and knowledge base construction in the carbon finance field: Obtain relevant text data in the carbon finance field from carbon emission databases, carbon trading market data sources, policy and regulatory texts, and industry analysis reports. Preprocess the text data, including text cleaning, segmentation, and structuring, to obtain a set of text fragments. Vectorize the set of text fragments and build a vector index library based on the vectorized representation to serve as an external knowledge source and factual constraint source for the generation of subsequent enhanced search instructions. Step 2, generation of single-step instruction data based on retrieval enhancement: Seed text fragments are obtained from external carbon finance text data or the text fragment set. Based on the seed text fragments, the retrieval context is retrieved from the vector index library. Single-step instructions and their output results are generated based on the retrieval context. After similarity filtering and consistency filtering, single-step instruction data is formed. Step 3, generating multi-step instruction chain data based on retrieval enhancement and context concatenation: Obtain an initial seed text fragment from external carbon finance text data or the text fragment set; retrieve an initial context from the vector index library based on the initial seed text fragment; and generate multiple instruction data units sequentially based on the initial context; when generating subsequent instruction data units, concatenate the initial context with the preceding instruction data units to construct the input context of the current step, thereby forming multi-step instruction chain data with step dependencies. Step 4, Instruction Dataset Construction and Large Language Model Fine-tuning: The single-step instruction data and multi-step instruction chain data are organized in a unified manner to construct a structured instruction dataset. The structured instruction data includes instructions, outputs, and corresponding context information. The large language model is fine-tuned and trained based on the structured instruction dataset. The model parameter update amount is calculated according to the gradient of the loss function, and the magnitude of the model parameter update amount is constrained so that the model prioritizes learning the conditional generation relationship between instructions, context, and output during training, thereby reducing the probability of the model generating freely without the current input context.
[0013] Furthermore, step one, the process of acquiring textual data and constructing a knowledge base in the field of carbon finance, is as follows: Collect carbon finance-related data, including but not limited to: carbon emission data, corporate ESG reports, carbon trading market data, policy documents, etc. Then, preprocess the collected raw text, including segmentation, cleaning, and noise reduction, to obtain a set of semantically complete text fragments. ,in, Indicates the first j Each text segment is mapped to a vector representation. ,in For text embedding models, a vector index library is finally built. Used for subsequent semantic retrieval.
[0014] Furthermore, in step two, the process of generating search-enhanced single-step instruction data (SoI), i.e., generating search-enhanced single-step instruction data (SoI), is as follows: 2.1 Seed Text Fragment Acquisition: Obtain a seed text fragment from external carbon finance text data or the text fragment library constructed in step one, denoted as . ,in This indicates the seed text fragment selected in the current single generation process. The seed text fragment comes from external text data in the carbon finance field or the text fragment library constructed in step one, rather than being generated internally by the large language model. 2.2 Retrieval Context Construction: The seed text fragments... Encoded as query vector ,in This represents a text embedding function in the vector index library. Perform similarity retrieval to obtain the top-k related text fragments. ,in Query vector to preset search quantity and text fragment vectors The similarity is expressed as: ; in, Vector representation of candidate text fragments, Represents the vector norm; 2.3 Single-step instruction generation and similarity filtering: based on the retrieved context Construct prompt template and generate instructions For the generated single-step instructions Perform ROUGE-L-based similarity screening, compare the similarity with the generated historical single-step instructions, discard the instruction and return to step 2.1 to regenerate when the similarity is higher than the preset threshold, retain the instruction and enter the response generation process when the similarity is not higher than the preset threshold; 2.4 Response Generation and Candidate Data Unit Construction: Based on Reserved Single-Step Instructions Context And reply generation prompt template Generate corresponding reply The generated single-step instructions, responses, and corresponding search contexts are organized into candidate single-step instruction data units. The system determines whether the data meets the constraints of carbon finance facts, calculation logic, and policy rules. If it passes the screening, it is added to the single-step instruction dataset. Candidate data units that fail the screening are discarded, and the system returns to step 2.1 to regenerate. 2.5 Loop Generation and Dataset Output: Determine if the conditions for continuing generation are met. If they are, return to step 2.1, reacquire new seed text fragments, and generate new single-step instruction data units. If the conditions for continuing generation are not met, aggregate the multiple single-step instruction data units that have passed consistency filtering to obtain the single-step instruction dataset. The conditions for continuing generation may be at least one of the following: a preset data volume threshold, a text fragment coverage requirement, and a generation quality requirement.
[0015] Furthermore, in step three, the generation process of multi-step instruction chain data based on retrieval enhancement and context concatenation, i.e., multi-step instruction chain data (CoI) based on retrieval enhancement and context concatenation, is as follows: 3.1 Initial Context Acquisition: Obtain a seed text fragment for multi-step instruction chain generation from external carbon finance text data or the text fragment library constructed in step one, denoted as . ,in This refers to the initial seed text fragment selected in the current multi-step instruction chain generation process. The seed text fragment originates from external text data in the carbon finance field or the text fragment library constructed in step one, rather than being generated internally by the large language model. Encoded as query vector Subsequently in the vector index library Perform similarity retrieval to obtain the top-k related text fragments. Based on the initial context Multiple instruction data units are generated sequentially according to the reasoning order, forming a multi-step instruction chain: ,in Indicates the number of reasoning steps, per data unit ,in, For the first j Step instructions, For the first j The output of the step, For the first j The context information corresponding to the step; 3.2 Context Sequential Concatenation Mechanism: In the first... The context of a step is constructed as follows: ; in, This represents the initial context information retrieved from an external knowledge base. This indicates a text concatenation operation. Indicates the first The instructions and outputs of each step are converted into a text representation in a unified format, and when At that time, since there is no preceding step data unit, the first step input context is... This sequential splicing mechanism enables the model to acquire complete historical reasoning information at each step, gradually completing complex reasoning tasks. 3.3 Multi-step Inference Chain Design: The inference chain is used to model complex inference tasks in the field of carbon finance. Its inference process is dynamically constructed based on task logic, including but not limited to the following steps: carbon emission data extraction, emission calculation, indicator analysis, policy matching, compliance judgment, and carbon trading decision-making. Each step forms a sequential or conditional dependency relationship according to specific task requirements, enabling subsequent steps to utilize the output results of preceding steps for further analysis and inference; in the... In the reasoning of the first step, based on the first step Step input context Generate the first Step instructions and corresponding output And construct the first data unit according to the data unit format defined in step 3.1. Step instruction data unit By organizing the instruction data units generated in each step according to the reasoning order, a multi-step instruction chain with contextual dependencies is formed. 3.4 Instruction Data Construction Constraints: The generated data must meet the following requirements. ,in, This represents a consistency determination function used to determine the consistency of instructions. Output With context Whether the semantics satisfy semantic consistency, data consistency and logical consistency is taken as 1 when the consistency constraint is met, otherwise it is 0. The consistency includes: the output result is consistent with the carbon emission data in the context, the calculation process is correct and complies with relevant carbon finance policies and rules; 3.5 Multi-step instruction chain data generation: Determine whether the current instruction chain meets the conditions for continuing generation. If the conditions are met, return to step 3.2, and continue to build the next context and generate new instructions and outputs based on the generated historical steps. If the conditions are not met, organize the multiple data units that have passed the consistency screening according to the generation order to form a multi-step instruction chain. ; 3.6 Output of Multi-Step Instruction Chain Dataset: Repeat steps 3.1 to 3.5 to generate multiple multi-step instruction chains and summarize them to obtain the multi-step instruction chain dataset. The conditions for continuing generation include at least one of the following: a preset maximum chain length, a task completion status, generation quality requirements, or a context length limit.
[0016] In step four, the process of constructing the instruction dataset and fine-tuning the large language model is as follows: 4.1 Model Input Representation: The mixed dataset (including...) and In this model, instructions and context information are uniformly encoded as input, and the input text is encoded by a word segmenter to obtain an input vector representation. Then the input vector Input the base model to obtain the feature representation. ,in This represents a text encoding function used to encode instructions. With context Converted into a vector sequence representation that the model can process. This represents a pre-trained large language model; 4.2 Model Optimization Objective: The large language model is trained using maximum likelihood estimation, and its optimization objective is as follows: ; in, For model parameters, In a given instruction and context Output generated under certain conditions The probability of; 4.3 Parameter Update Constraints Based on Instruction Chain Structure: Low-Rank Adaptive Adapter (LoRA) fine-tuning is employed, the pre-trained parameters of the large language model are frozen, and the model parameter update amount is calculated based on the gradient of the loss function. ,in, This indicates a low learning rate. This represents the gradient of the loss function with respect to the model parameters, and constrains the parameter update amount to satisfy... When the parameter update amount exceeds the update threshold At that time, the parameter update amount is scaled: ; Update the amount using the scaled parameters Update the model parameters to reduce the possibility of the model deviating from the current instructions and context constraints during training. This makes the model generate results more dependent on carbon finance knowledge information in the input context, rather than simply calling general knowledge in the pre-trained parameters, thereby improving the factual consistency and training stability of the model's generated results.
[0017] This invention also provides a system for constructing instruction data and training models in the field of carbon finance based on retrieval enhancement, the system comprising: An external knowledge base module is used to acquire and store data related to the carbon finance field, including but not limited to carbon emission data, corporate carbon disclosure reports, carbon trading market data, policy and regulatory texts, and industry analysis materials. The external knowledge base module is used to provide factual constraint information for instruction generation and as a data source to enhance retrieval. The text processing module is used to preprocess the raw text in the external knowledge base, including text segmentation, cleaning and structuring, to obtain a set of text fragments that can be used for subsequent instruction generation. The text fragments output by this module are used to construct the input context for instruction generation. The prompt word construction module is used to generate prompt words based on input text fragments. It includes: single-step instruction prompt word construction, used to generate instructions based on a single question, and multi-step instruction prompt word construction, used to generate a multi-step question chain with a progressive relationship. The prompt word construction module selects the corresponding prompt word template according to the task type. The large language model module is used to generate instruction data based on prompts and context, including single-step instruction generation and multi-step instruction chain generation. In the multi-step instruction chain generation process, the output of the current step serves as the input context for the next step, enabling the sequential construction of the reasoning process. The instruction data construction module is used to organize the generated results into structured instruction data, including: single-step instruction data (RAG-SoI) and multi-step instruction chain data (RAG-CoI). The multi-step instruction chain data consists of multiple instruction units with context dependencies. The model fine-tuning module is used to train the large language model using the constructed instruction data. It includes an input encoding unit, a forward computation unit, a loss calculation unit, and a parameter optimization unit. During parameter optimization, a low learning rate adaptive mechanism based on the instruction chain structure is employed to control the magnitude of model parameter updates. The model output module is used to apply the trained large language model to carbon finance tasks, analyze the input text and output results, including carbon emission analysis, policy matching, risk assessment and decision support information.
[0018] The technical concept of this invention is as follows: Addressing the shortcomings of existing instruction data construction methods in terms of factual basis and complex reasoning capabilities, this invention introduces external knowledge constraints and a multi-step instruction chain structure to unify the modeling of knowledge retrieval and reasoning processes. In the data construction phase, an external knowledge base constrains the generation process, reducing model illusion problems. In terms of structural design, a multi-step instruction chain decomposes complex tasks into multiple dependent sub-steps, enabling the model to learn a step-by-step reasoning process. In the model training phase, a low-learning-rate adaptive optimization mechanism based on the instruction chain structure is designed to control the parameter update amplitude, thereby maintaining the stability of the reasoning structure. Through these methods, a shift from single-step question answering to multi-step reasoning modeling is achieved, enabling the model to handle complex decision-making problems in carbon finance.
[0019] The beneficial effects of this invention are as follows: It enhances data authenticity by introducing an external knowledge base as a constraint source, ensuring the instruction generation process is based on real data, significantly reducing illusions in the model's generated content, and improving data quality. It improves complex reasoning capabilities by constructing a multi-step instruction chain structure, enabling the model to learn multi-step reasoning processes, thus making it suitable for complex analytical tasks in the carbon finance field. It improves training stability by using a low-learning-rate adaptive optimization mechanism based on the instruction chain structure to effectively reduce gradient oscillations during training, avoiding disruption of the learned reasoning structure. It enhances domain adaptability by combining knowledge and task structures in the carbon finance field, enabling the model to adapt to professional scenarios with strong rule constraints and complex logical relationships. It improves model generalization ability by unifying the modeling of single-step and multi-step instruction data, thereby improving the model's generalization ability in different task scenarios. Attached Figure Description
[0020] Figure 1 This is a flowchart of the method of the present invention.
[0021] Figure 2 This diagram illustrates a comparison of the instruction generation mechanisms of Self-Instruct, RAG-SoI, and RAG-CoI.
[0022] Figure 3 This diagram illustrates the process of generating single-step instructions and multi-step instruction chains. Detailed Implementation
[0023] The invention will now be further described with reference to the accompanying drawings.
[0024] Reference Figures 1-3 A method for constructing instruction data and training models in the field of carbon finance based on retrieval enhancement includes the following steps: Step one, text data acquisition and knowledge base construction in the carbon finance field, involves the following process: Collect carbon finance-related data, including but not limited to: carbon emission data, corporate ESG reports, carbon trading market data, policy documents, etc. Then, preprocess the collected raw text, including segmentation, cleaning, and noise reduction, to obtain a set of semantically complete text fragments. ,in, Indicates the first j Each text segment is mapped to a vector representation. ,in For text embedding models, a vector index library is finally built. Used for subsequent semantic retrieval; In this embodiment, taking corporate ESG reports and carbon trading policy documents as examples, the original text is first formatted and cleaned of noise, removing headers and footers, table of contents numbers, duplicate declarations and irrelevant table descriptions, etc.; then the text is segmented according to paragraphs, clause numbers or semantic boundaries to obtain text fragments with relatively complete semantics.
[0025] For example, a text containing "enterprise's carbon emissions, carbon quotas, compliance requirements, and carbon trading costs in 2025" can be treated as a text segment. If the original paragraph is too long, it is further segmented according to the maximum length threshold and semantic integrity requirements, so that each text fragment can independently express a relatively complete carbon finance fact or rule. Then, each text fragment is input into a text embedding model to obtain its corresponding vector representation, and all text fragment vectors are written into a vector index library for subsequent semantic retrieval. Through this process, unstructured carbon finance text can be transformed into a searchable and constrained external knowledge source.
[0026] Step two, generating Search-Enhanced Single-Step Instruction Data (SoI), the process is as follows: 2.1 Seed Text Fragment Acquisition Obtain a seed text fragment from external carbon finance text data or the text fragment library constructed in step one, denoted as . ,in This indicates the seed text fragment selected in the current single generation process. The seed text fragment comes from external text data in the carbon finance field or the text fragment library constructed in step one, rather than being generated internally by the large language model. 2.2 Retrieval Context Construction The seed text fragment Encoded as query vector ,in This represents a text embedding function in the vector index library. Perform similarity retrieval to obtain the top-k related text fragments. ,in Query vector to preset search quantity and text fragment vectors The similarity is expressed as: ; in, Vector representation of candidate text fragments, Represents the vector norm; 2.3 Single-step instruction generation and similarity filtering Based on the retrieved context Construct prompt template and generate instructions For the generated single-step instructions Perform ROUGE-L-based similarity screening, compare the similarity with the generated historical single-step instructions, discard the instruction and return to step 2.1 to regenerate when the similarity is higher than the preset threshold, retain the instruction and enter the response generation process when the similarity is not higher than the preset threshold; 2.4 Response Generation and Candidate Data Unit Construction Based on reserved single-step instructions Context And reply generation prompt template Generate corresponding reply The generated single-step instructions, responses, and corresponding search contexts are organized into candidate single-step instruction data units. The system determines whether the data meets the constraints of carbon finance facts, calculation logic, and policy rules. If it passes the screening, it is added to the single-step instruction dataset. Candidate data units that fail the screening are discarded, and the system returns to step 2.1 to regenerate. 2.5 Loop Generation and Dataset Output Determine if the conditions for continuing generation are met. If they are, return to step 2.1 to obtain a new seed text fragment and generate a new single-step instruction data unit. If the conditions are not met, aggregate the multiple single-step instruction data units that have passed the consistency screening to obtain the single-step instruction dataset. The conditions for continuing generation may be at least one of the following: a preset data volume threshold, a text fragment coverage requirement, and a generation quality requirement. In this embodiment, the generation of a single-step instruction data is used as an example for explanation. First, a seed text fragment is selected from the text fragment library. For example: "The National Greenhouse Gas Voluntary Emission Reduction Trading Market, through a certified emission reduction trading mechanism, expands the participants to include non-controlled emission enterprises and the public, and complements the mandatory carbon market." This seed text fragment is input into a text embedding model to obtain the query vector. It also retrieves several semantically related text fragments from the vector index library to form a retrieval context. .
[0027] In obtaining the search context Next, a prompt template is generated by constructing an instruction, such as prompting the large language model to "generate a factual single-step question based on the given carbon finance text." The large language model generates a single-step instruction based on the retrieval context, such as: "How can the voluntary emission reduction trading market expand the participants in carbon emission reduction?" Subsequently, this single-step instruction and the retrieval context are input together to generate a prompt template for the response, and a corresponding response is generated, such as: "Through the certified emission reduction trading mechanism, the voluntary emission reduction trading market expands the participants to non-controlled emission enterprises and the public, and forms a complementary mechanism with the mandatory carbon market."
[0028] After generating the instruction and response, the instruction is compared with previously generated historical instructions for similarity. If the similarity exceeds a preset threshold, the instruction is discarded and a new seed text fragment is selected; if the similarity does not exceed the preset threshold, the response content is further assessed to determine whether it aligns with the carbon finance facts in the retrieval context, conforms to policy rules, and contains any content that deviates from the context. After filtering, the instruction, response, and retrieval context are combined into a single-step instruction data unit. This data is then added to the single-step instruction dataset. The above process is repeated until the preset data volume threshold, text fragment coverage requirement, or generation quality requirement is met, resulting in the single-step instruction dataset. .
[0029] Step 3: Generation of multi-step instruction chain data (CoI) based on retrieval enhancement and context concatenation. The process is as follows: 3.1 Initial Context Acquisition Obtain a seed text fragment for multi-step instruction chain generation from external carbon finance text data or the text fragment library constructed in step one. Let this be denoted as... ,in This refers to the initial seed text fragment selected in the current multi-step instruction chain generation process. The seed text fragment originates from external text data in the carbon finance field or the text fragment library constructed in step one, rather than being generated internally by the large language model. Encoded as query vector Subsequently in the vector index library Perform similarity retrieval to obtain the top-k related text fragments. Based on the initial context Multiple instruction data units are generated sequentially according to the reasoning order, forming a multi-step instruction chain: ,in Indicates the number of reasoning steps, per data unit ,in, For the first j Step instructions, For the first j The output of the step, For the first j The context information corresponding to the step; 3.2 Context Sequential Concatenation Mechanism In the The context of a step is constructed as follows: ; in, This represents the initial context information retrieved from an external knowledge base. This indicates a text concatenation operation. Indicates the first The instructions and outputs of each step are converted into a text representation in a unified format, and when At that time, since there is no preceding step data unit, the first step input context is... This sequential splicing mechanism enables the model to acquire complete historical reasoning information at each step, gradually completing complex reasoning tasks. 3.3 Multi-step inference chain design The inference chain is used to model complex inference tasks in the field of carbon finance. Its inference process is dynamically constructed based on task logic, including but not limited to the following steps: carbon emission data extraction, emission calculation, indicator analysis, policy matching, compliance assessment, and carbon trading decision-making. Each step forms a sequential or conditional dependency relationship according to specific task requirements, enabling subsequent steps to utilize the output results of preceding steps for further analysis and inference; in the... In the reasoning of the first step, based on the first step Step input context Generate the first Step instructions and corresponding output And construct the first data unit according to the data unit format defined in step 3.1. Step instruction data unit By organizing the instruction data units generated in each step according to the reasoning order, a multi-step instruction chain with contextual dependencies is formed. 3.4 Instruction Data Construction Constraints The generated data must meet the following requirements: ,in, This represents a consistency determination function used to determine the consistency of instructions. Output With context Whether the semantics satisfy semantic consistency, data consistency and logical consistency is taken as 1 when the consistency constraint is met, otherwise it is 0. The consistency includes: the output result is consistent with the carbon emission data in the context, the calculation process is correct and complies with relevant carbon finance policies and rules; 3.5 Multi-step instruction chain data generation Determine if the current instruction chain meets the conditions for continuing generation. If it does, return to step 3.2 to continue building the next context and generating new instructions and outputs based on the previously generated historical steps. If the conditions do not meet, organize the multiple data units that have passed the consistency screening according to the generation order to form a multi-step instruction chain. ; 3.6 Multi-step instruction chain dataset output Repeat steps 3.1 to 3.5 to generate multiple multi-step instruction chains, and then summarize them to obtain a multi-step instruction chain dataset. The conditions for continuing generation include at least one of the following: a preset maximum chain length, a task completion status, generation quality requirements, or a context length limit. In this embodiment, the generation of a multi-step instruction chain is used as an example for explanation. First, an initial seed text fragment is selected from the text fragment library. For example: "Key emitting entities improve their carbon emission management capabilities through actual measurement of fuel element carbon content, monthly storage of key data, big data early warning platforms, third-party verification services, and carbon trading mechanisms." Encode this initial seed text fragment as... The initial context is retrieved from the vector index library. .
[0030] For the first step of the generation process, since the data units from the preceding steps do not yet exist, the first step input context is... equal to the initial context .based on Generate the first step instruction and output For example, the first step instruction. For example: "What carbon emission management measures has this key emitting entity taken?" The corresponding output is... The measures include: "actual measurement of fuel elemental carbon content, monthly storage of key data, a big data early warning platform, third-party verification services, and a carbon trading mechanism." The first step will then be instructed. and output Perform formatting and context. Concatenate the data to form the input context for the second step. .
[0031] Based on the input context of the second step Generate the second step instruction and output For example, the second step instruction. The question asks: "Based on the above measures, in which aspects of carbon emission management do these measures primarily affect?" The corresponding output is... The instructions state: "It primarily functions in data collection, data storage, anomaly monitoring, verification, and market regulation." The second step of the instruction will continue. and output After formatting and the current input context Concatenate the data to form the input context for the third step. .
[0032] Furthermore, a third instruction can be generated: "Based on the above steps, how can these measures improve the quality of carbon emission data?" The corresponding output is: "Improve data accuracy and traceability through actual measurement and evidence storage mechanisms, and enhance anomaly identification capabilities through an early warning platform." A fourth instruction can also be generated: "Based on improved data quality, how can the carbon trading mechanism support corporate emission reduction decisions?" The corresponding output is: "Reliable data can support enterprises in carrying out quota compliance, transaction cost assessment, and emission reduction strategy adjustments."
[0033] Finally, when the preset maximum chain length is reached, the task is completed, the generation quality meets the requirements, or the context length reaches the limit, the generation stops and the above multiple instruction data units are organized into a multi-step instruction chain according to the generation order.
[0034] In the above process, the input context of each step is composed of the initial context and the instructions and outputs of the preceding steps, so subsequent steps can continue the analysis using the results of the preceding reasoning. In this way, the generated data is no longer an isolated question and answer, but can represent the multi-step reasoning process of "measure identification - process induction - data quality analysis - decision support" in the carbon finance task.
[0035] Step four, instruction dataset construction and large language model fine-tuning, the process is as follows: 4.1 Model Input Representation Mixed datasets (including) and In this model, instructions and context information are uniformly encoded as input, and the input text is encoded by a word segmenter to obtain an input vector representation. Then the input vector Input the base model to obtain the feature representation. ,in This represents a text encoding function used to encode instructions. With context Converted into a vector sequence representation that the model can process. This represents a pre-trained large language model; 4.2 Model Optimization Objective The large language model is trained using maximum likelihood estimation, and its optimization objective is: ; in, For model parameters, In a given instruction and context Output generated under certain conditions The probability of; 4.3 Parameter Update Constraints Based on Instruction Chain Structure Low-rank adaptive adapter (LoRA) fine-tuning is employed, freezing the pre-trained parameters of the large language model, and calculating the model parameter update amount based on the gradient of the loss function. ,in, This indicates a low learning rate. This represents the gradient of the loss function with respect to the model parameters, and constrains the parameter update amount to satisfy... When the parameter update amount exceeds the update threshold At that time, the parameter update amount is scaled: ; Update the amount using the scaled parameters Update the model parameters to reduce the possibility of the model deviating from the current instructions and context constraints during training. This makes the model generate results more dependent on carbon finance knowledge information in the input context, rather than simply calling general knowledge in the pre-trained parameters, thereby improving the factual consistency and training stability of the model's generated results.
[0036] In this embodiment, the single-step instruction dataset generated in step two is... and the multi-step instruction chain dataset generated in step three The data is merged to form a hybrid structured instruction dataset.
[0037] When organizing training samples, for single-step instruction data, "context, instruction, and response" can be concatenated into training samples; for multi-step instruction chain data, "initial context, historical steps, current instruction, and current response" can be concatenated into training samples, so that the model can learn to generate target output under given context and historical reasoning information during training.
[0038] Subsequently, the training samples were input into a large language model for fine-tuning. To reduce the risk of the model relying solely on pre-trained general knowledge to generate data without considering the current context, update magnitude constraints were set during parameter updates. When the parameter update amount obtained from the loss function gradient exceeded a preset threshold, the parameter update amount was scaled down before updating the model parameters. This approach encourages the model to utilize carbon finance knowledge from the input context and historical reasoning information from multi-step instruction chains during training, thereby improving the factual consistency and training stability of the generated results.
[0039] In one application example, a finely tuned large language model is applied to a carbon finance text analysis task. When inputting corporate carbon emission reports, carbon trading policy texts, or carbon quota compliance instructions, the model can generate corresponding analysis results based on external knowledge context. For example, it can extract corporate carbon emission-related data, interpret carbon trading policy requirements, determine whether a company has a quota shortfall, analyze the impact of emission reduction measures on compliance costs, or provide suggestions related to carbon trading decisions.
[0040] Compared to methods that rely solely on the knowledge of a large language model to generate results, this embodiment constrains the generation process by retrieving context and trains the model to learn the step dependencies in carbon finance tasks through multi-step instruction chains. This makes the model output results more consistent with the input text and policy rules, reduces freely generated content that is out of context, and improves the factual consistency and interpretability in carbon finance text analysis tasks.
[0041] This invention also provides a system for constructing instruction data and training models in the carbon finance field based on retrieval enhancement for implementing the above-mentioned methods, the system comprising: An external knowledge base module is used to acquire and store data related to the carbon finance field, including but not limited to carbon emission data, corporate carbon disclosure reports, carbon trading market data, policy and regulatory texts, and industry analysis materials. The external knowledge base module is used to provide factual constraint information for instruction generation and as a data source to enhance retrieval. The text processing module is used to preprocess the raw text in the external knowledge base, including text segmentation, cleaning and structuring, to obtain a set of text fragments that can be used for subsequent instruction generation. The text fragments output by this module are used to construct the input context for instruction generation. The prompt word construction module is used to generate prompt words based on input text fragments. It includes: single-step instruction prompt word construction, used to generate instructions based on a single question, and multi-step instruction prompt word construction, used to generate a multi-step question chain with a progressive relationship. The prompt word construction module selects the corresponding prompt word template according to the task type. The large language model module is used to generate instruction data based on prompts and context, including single-step instruction generation and multi-step instruction chain generation. In the multi-step instruction chain generation process, the output of the current step serves as the input context for the next step, enabling the sequential construction of the reasoning process. The instruction data construction module is used to organize the generated results into structured instruction data, including: single-step instruction data (RAG-SoI) and multi-step instruction chain data (RAG-CoI). The multi-step instruction chain data consists of multiple instruction units with context dependencies. The model fine-tuning module is used to train the large language model using the constructed instruction data. It includes an input encoding unit, a forward computation unit, a loss calculation unit, and a parameter optimization unit. During parameter optimization, a low learning rate adaptive mechanism based on the instruction chain structure is employed to control the magnitude of model parameter updates. The model output module applies the trained large language model to carbon finance tasks, analyzes the input text, and outputs results, including carbon emission analysis, policy matching, risk assessment, and decision support information. As described above, the specific implementation steps of this patent make the invention clearer. Any modifications and changes made to this invention within the spirit and scope of the claims fall within the protection scope of this invention.
Claims
1. A method for constructing instruction data and training models in the carbon finance field based on retrieval enhancement, characterized in that, The method includes the following steps: Step 1: Text data acquisition and knowledge base construction in the carbon finance field: Obtain relevant text data in the carbon finance field from carbon emission databases, carbon trading market data sources, policy and regulatory texts, and industry analysis reports. Preprocess the text data, including text cleaning, segmentation, and structuring, to obtain a set of text fragments. Vectorize the set of text fragments and build a vector index library based on the vectorized representation to serve as an external knowledge source and factual constraint source for the generation of subsequent enhanced search instructions. Step 2, generation of single-step instruction data based on retrieval enhancement: Seed text fragments are obtained from external carbon finance text data or the text fragment set. Based on the seed text fragments, the retrieval context is retrieved from the vector index library. Single-step instructions and their output results are generated based on the retrieval context. After similarity filtering and consistency filtering, single-step instruction data is formed. Step 3, generating multi-step instruction chain data based on retrieval enhancement and context concatenation: Obtain an initial seed text fragment from external carbon finance text data or the text fragment set; retrieve an initial context from the vector index library based on the initial seed text fragment; and generate multiple instruction data units sequentially based on the initial context; when generating subsequent instruction data units, concatenate the initial context with the preceding instruction data units to construct the input context of the current step, thereby forming multi-step instruction chain data with step dependencies. Step 4, Instruction Dataset Construction and Large Language Model Fine-tuning: The single-step instruction data and multi-step instruction chain data are organized in a unified manner to construct a structured instruction dataset. The structured instruction data includes instructions, outputs, and corresponding context information. The large language model is fine-tuned and trained based on the structured instruction dataset. The model parameter update amount is calculated according to the gradient of the loss function, and the magnitude of the model parameter update amount is constrained so that the model prioritizes learning the conditional generation relationship between instructions, context, and output during training, thereby reducing the probability of the model generating freely without the current input context.
2. The method for constructing instruction data and training models in the carbon finance field based on retrieval enhancement as described in claim 1, characterized in that, In step two, the single-step instruction data generation process based on retrieval enhancement is as follows: 2.1 Obtain a seed text fragment from external carbon finance text data or the text fragment set constructed in step one, denoted as . ,in This indicates the seed text fragment selected in the current single generation process, which is not generated internally by the large language model; 2.2 Transfer the seed text fragment Encoded as query vector ,in This represents a text embedding function in the vector index library. Perform similarity retrieval to obtain the top-k related text fragments. ,in The preset number of searches; 2.3 Based on the retrieved context Construct prompt template and generate single-step instructions. Simultaneously, the single-step instruction is compared with the saved historical single-step instructions based on ROUGE-L similarity. When the similarity is higher than a preset threshold, the single-step instruction is discarded and the seed text fragment is re-acquired. When the similarity is not higher than the preset threshold, the single-step instruction is retained.
3. The method for constructing instruction data and training models in the carbon finance field based on retrieval enhancement as described in claim 2, characterized in that, In step two, the single-step instruction data generation process based on retrieval enhancement also includes: 2.4 Single-step instructions based on reservation Context And reply generation prompt template Generate corresponding reply The single-step instruction, response, and retrieval context are then organized into candidate single-step instruction data units. The system determines whether the candidate single-step instruction data units meet the constraints of carbon finance facts, calculation logic, and policy rules. After screening, they are added to the single-step instruction dataset. Candidate data units that fail the screening are discarded and regenerated. 2.5 Determine if the conditions for continuing generation are met; if the conditions are met, return to step 2.1; if the conditions are not met, summarize the multiple single-step instruction data units that have passed the filtering to obtain the single-step instruction dataset. .
4. The method for constructing instruction data and training models in the carbon finance field based on retrieval enhancement as described in any one of claims 1 to 3, characterized in that, In step three, the multi-step instruction chain data generation process based on retrieval enhancement and context concatenation is as follows: 3.1 Obtain an initial seed text fragment for multi-step instruction chain generation from external carbon finance text data or the text fragment set constructed in step one, denoted as . ,in This represents the initial seed text fragment selected in the current multi-step instruction chain generation process. This initial seed text fragment is not generated internally by the large language model. Encoded as query vector and in the vector index library Perform similarity retrieval to obtain the top-k related text fragments. ,in It represents the initial knowledge context of the current multi-step instruction chain, which is used to provide a source of factual constraints for the generation of subsequent multi-step instructions; 3.2 Based on the initial context Generate the first step instruction and its output, forming the first step instruction data unit. In generating the first When stepping through the instruction data unit, the initial context is... Concatenate the instruction data units from the preceding steps to construct the first... Step input context: ; in This indicates a splicing operation. Indicates the first The text representation obtained after formatting the step data unit; 3.3 Based on the first Step input context Generate the first Step instructions and corresponding output and construct the first Step instruction data unit ,in For the first Step instructions, For the first Step output, For the first The context information corresponding to each step.
5. The method for constructing instruction data and training models in the carbon finance field based on retrieval enhancement as described in claim 4, characterized in that, In step three, the multi-step instruction chain data generation process based on retrieval enhancement and context concatenation also includes: 3.4 Regarding the first Each instruction data unit undergoes consistency screening to determine whether it meets semantic consistency, data consistency, and logical consistency. Instruction data units that fail the screening are discarded or regenerated. 3.5 Determine whether the current multi-step instruction chain meets the conditions for continuing generation. If the conditions are met, return to step 3.2 to continue constructing the next input context and generating new instruction data units. If the conditions are not met, organize the multiple instruction data units that have passed the filtering according to the generation order to form a multi-step instruction chain. ,in Indicates the number of reasoning steps; 3.6 Repeat steps 3.1 to 3.5 to generate multiple multi-step instruction chains, and summarize them to obtain a multi-step instruction chain dataset. .
6. The method for constructing instruction data and training models in the carbon finance field based on retrieval enhancement as described in claim 1, characterized in that, In step four, the process of constructing the instruction dataset and fine-tuning the large language model is as follows: 4.1 Input the constructed structured instruction dataset into the large language model to be trained. The structured instruction dataset includes single-step instruction data and multi-step instruction chain data. Encode the instructions and context into the model input, denoted as: ,in Represents the model input sequence. Represents the encoding function. Indicates instructions, To represent the context, the input sequence is computed forward using a large language model to obtain the corresponding hidden representation, denoted as: ,in This represents the large language model to be trained. 4.2 Constructing the training objective function based on maximum likelihood estimation: ; in, Indicates model parameters, Indicates that in the given instruction and context Output generated under certain conditions The conditional probability; 4.3 Fine-tuning is performed using a low-rank adaptive adapter (LoRA), freezing the pre-trained parameters of the large language model, and calculating the model parameter update amount based on the gradient of the training objective function. ,in Indicates the amount of model parameter updates. Indicates the learning rate. This represents the gradient of the loss function with respect to the model parameters, and constrains the model parameter update amounts to satisfy... When the parameter update amount exceeds the update threshold At that time, the parameter update amount is scaled: ; Update the amount using the scaled parameters Update the model parameters.
7. A system for implementing the method for constructing instruction data and training models in the carbon finance field based on retrieval enhancement as described in claim , characterized in that, The system includes: An external knowledge base module is used to acquire and store data related to the carbon finance field, including but not limited to carbon emission data, corporate carbon disclosure reports, carbon trading market data, policy and regulatory texts, and industry analysis materials. The external knowledge base module is used to provide factual constraint information for instruction generation and as a data source to enhance retrieval. The text processing module is used to preprocess the raw text in the external knowledge base, including text segmentation, cleaning and structuring, to obtain a set of text fragments that can be used for subsequent instruction generation. The text fragments output by this module are used to construct the input context for instruction generation. The prompt word construction module is used to generate prompt words based on input text fragments. It includes: single-step instruction prompt word construction, used to generate instructions based on a single question, and multi-step instruction prompt word construction, used to generate a multi-step question chain with a progressive relationship. The prompt word construction module selects the corresponding prompt word template according to the task type. The large language model module is used to generate instruction data based on prompt words and context, including single-step instruction generation and multi-step instruction chain generation. In the multi-step instruction chain generation process, the output of the current step is used as the input context for the next step, realizing the sequential construction of the reasoning process. The instruction data construction module is used to organize the generated results into structured instruction data, including: single-step instruction data and multi-step instruction chain data, wherein the multi-step instruction chain data consists of multiple instruction units with context dependencies; The model fine-tuning module is used to train the large language model using the constructed instruction data. It includes an input encoding unit, a forward computation unit, a loss calculation unit, and a parameter optimization unit. In the parameter optimization process, a low learning rate adaptive mechanism based on the instruction chain structure is adopted to control the magnitude of model parameter updates. The model output module is used to apply the trained large language model to carbon finance tasks, analyze the input text and output results, including carbon emission analysis, policy matching, risk assessment and decision support information.