Model training method, address classification method, device, equipment and storage medium

CN116522918BActive Publication Date: 2026-08-21THE PEOPLES BANK OF CHINA DIGITAL CURRENCY INST
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310217565.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-08
Publication Date
2026-08-21
Estimated Expiration
2043-03-08

AI Technical Summary

Technical Problem

[0003]但是,手工提取交易模式特征的方式,由于运维人员的业务经验有限,难以直接找到隐藏业务特征,且各训练样本间的特征较为独立,特征互信息缺乏,针对群体性特征难以捕捉,导致目前分类方式的准确度较低

Benefits of technology

[0032]本申请的实施例提供的第一方面的技术方案至少带来以下有益效果:在需要对区块链地址进行分类时,可以预先训练目标分类模型,以通过预先训练得到的目标分类模型对待分类区块链地址进行分类。具体的,可以基于从区块链上获取的目标智能合约对应的多条历史交易的交易信息,构建多条历史交易对应的多个区块链地址中,每个区块链地址对应的行为词;从而可以通过行为词表征每个区块链地址对应的历史交易调用的行为函数、历史交易的相邻历史交易调用的行为函数、历史交易对应的智能合约信息、历史交易与相邻历史交易之间的时间间隔,以通过行为词表征相邻交易之间对应的关联信息。进一步的,再确定每个区块链地址对应的行为词的表征向量,并结合每个区块链地址的分类标签,从特征和向量的角度对预设模型进行迭代训练,以在满足训练结束条件后得到用于对区块链地址进行分类的目标分类模型。因此,基于上述方法,可以通过行为词表征相邻交易之间对应的关联信息,充分考虑账户在区块链上的多个交易对应的操作行为以及操作的时间顺序,充分挖掘了丰富的链上行为特征和时间特征,并通过表征向量的形式指代行为词,对模型进行训练,训练得到的用于对区块链地址进行分类的目标分类模型,能够充分学习到相邻交易之间对应的关联信息,因而当采用目标分类模型对区块链地址进行分类的准确度更高。而且,采用目标分类模型进行分类,可以基于待分类区块链地址对应的行为词的表征向量,从特征和向量的角度进行分类,因而分类效率更高。可以提高对区块链地址进行分类的效率和准确度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116522918B_ABST
    Figure CN116522918B_ABST
Patent Text Reader

Abstract

The application relates to a model training method, an address classification method, a device, equipment and a storage medium, and relates to the technical field of blockchains. The method comprises the following steps: obtaining transaction information of a plurality of historical transactions corresponding to a target smart contract from a blockchain; constructing behavior words corresponding to each blockchain address in the plurality of blockchain addresses corresponding to the plurality of historical transactions based on the transaction information; determining a representation vector of the behavior words corresponding to each blockchain address; iteratively training a preset model based on the representation vector of the behavior words corresponding to each blockchain address and a classification label of each blockchain address, and obtaining a target classification model after a training end condition is met, wherein the target classification model is used for classifying blockchain addresses. The application can improve the accuracy and efficiency of classifying blockchain addresses.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of blockchain technology, and in particular to a model training method, an address classification method, a device, an equipment, and a storage medium. Background Technology

[0002] In a blockchain system, all participating nodes maintain a shared ledger. Due to the decentralized and anonymous nature of blockchain tokens, access by abnormal behaviors can occur. Therefore, it is necessary to classify blockchain addresses and identify addresses exhibiting abnormal behavior. However, existing blockchain address classification methods primarily construct features directly from the perspective of transaction relationship networks, failing to fully explore other effective features. Specifically, classic machine learning methods typically involve manual feature engineering based on business understanding, followed by inputting the resulting feature vectors into classifier algorithms such as random forests for model training. Transaction graph networks utilize transaction records between accounts to construct a transaction network relationship graph. By viewing transaction addresses as nodes and transaction behaviors as edges connecting nodes, a graph network is constructed to represent the transaction patterns between address communities.

[0003] However, manually extracting transaction pattern features is difficult because maintenance personnel have limited business experience, making it hard to directly find hidden business features. Furthermore, the features between training samples are relatively independent, lacking mutual information, and struggle to capture group-like features, resulting in low accuracy for current classification methods. Moreover, classification methods like transaction graph networks only consider transaction relationships and neglect other important factors, leading to low efficiency and poor accuracy in classifying blockchain addresses. Summary of the Invention

[0004] This application provides a model training method, an address classification method, an apparatus, a device, and a storage medium to improve the efficiency and accuracy of classifying blockchain addresses. The technical solution of this application is as follows:

[0005] According to a first aspect of the embodiments of this application, a classification model training method is provided. The method includes: obtaining transaction information of multiple historical transactions corresponding to a target smart contract from a blockchain; constructing a behavior word corresponding to each blockchain address among multiple blockchain addresses corresponding to the multiple historical transactions based on the transaction information; a behavior word includes: a behavior function called by the historical transaction, a behavior function called by adjacent historical transactions, smart contract information corresponding to the historical transaction, and a time interval between the historical transaction and adjacent historical transactions; determining a representation vector of the behavior word corresponding to each blockchain address; iteratively training a preset model based on the representation vector of the behavior word corresponding to each blockchain address and the classification label of each blockchain address, and obtaining a target classification model after satisfying the training termination condition, wherein the target classification model is used to classify blockchain addresses.

[0006] In one possible implementation, the method further includes: dividing the behavioral words corresponding to the blockchain address into multiple behavioral sequences corresponding to the blockchain address based on a preset time window, wherein each behavioral sequence includes at least one behavioral word; obtaining the representation vector of each behavioral sequence among the multiple behavioral sequences based on the representation vector of the behavioral words corresponding to the blockchain address; and iteratively training a preset model based on the representation vector of the behavioral words corresponding to each blockchain address and the classification label of each blockchain address, including: iteratively training the preset model based on the representation vector of the behavioral sequence corresponding to each blockchain address and the classification label of each blockchain address.

[0007] In one possible implementation, based on the representation vector of the behavior word corresponding to the blockchain address, the representation vector of each behavior sequence in a plurality of behavior sequences is obtained, including: for any behavior sequence in a plurality of behavior sequences corresponding to the blockchain address, the representation vectors of at least one behavior word included in any behavior sequence are weighted and averaged to obtain an average representation vector; the average representation vector is input into a neural network model based on an attention mechanism to obtain the representation vector of any behavior sequence.

[0008] In one possible implementation, determining the representation vector of the behavior word corresponding to each blockchain address includes: inputting the behavior word corresponding to each blockchain address into a first model algorithm to obtain the representation vector of the behavior word corresponding to each blockchain address. The first model algorithm is used to extract a representation vector of a preset number of dimensions for the input content.

[0009] In one possible implementation, the behavioral words corresponding to each blockchain address are input into the first model algorithm to obtain the representation vector of the behavioral words corresponding to each blockchain address. This includes: sorting and numbering the multiple behavioral words based on the word frequency of each behavioral word among the multiple behavioral words corresponding to each blockchain address, and determining the sequence number corresponding to each behavioral word, wherein the multiple behavioral words are the behavioral words corresponding to each blockchain address among the multiple blockchain addresses; representing the sequence number corresponding to each behavioral word among the multiple behavioral words through a vector of the same dimension to obtain a sparse matrix; and inputting the sparse matrix into the first model algorithm to obtain the representation vector of the behavioral words corresponding to each blockchain address.

[0010] In one possible implementation, the transaction information includes at least one of the following: external transaction data, internal transaction data, and behavioral functions for transaction calls; external transaction data includes at least one of the following: external transaction input address, external transaction output address, external transaction quantity, and external transaction time; internal transaction data includes at least one of the following: internal transaction input address, internal transaction output address, internal transaction quantity, and internal transaction time; behavioral functions for transaction calls include at least one of the following: transaction function, authorization function, exchange function, query function, staking function, withdrawal function, lending function, and minting function; the target smart contract is a smart contract on the blockchain with a usage frequency greater than a preset frequency, and the behavioral functions in the behavioral terms are the operation functions called by the target smart contract with a call frequency greater than a preset threshold and corresponding to business processing.

[0011] In one possible implementation, a preset model is iteratively trained based on the representation vector of the behavior word corresponding to each blockchain address and the classification label of each blockchain address, and a target classification model is obtained after the training termination condition is met. This includes: inputting the representation vector of each behavior sequence and the classification label of each blockchain address into the preset model, and determining the first and second derivatives corresponding to the representation vector of each behavior sequence; splitting the decision tree based on the first and second derivatives corresponding to the representation vector of each behavior sequence to obtain a weak learner and update the strong learner; iteratively training the weak learner; and determining the obtained strong learner as the target classification model after the training termination condition is met.

[0012] According to a second aspect of the embodiments of this application, a blockchain address classification method is provided. The method includes: constructing a behavior word corresponding to a blockchain address to be classified, wherein a behavior word includes: a behavior function called by a historical transaction, a behavior function called by an adjacent historical transaction, smart contract information corresponding to the historical transaction, and a time interval between the historical transaction and the adjacent historical transaction; determining a representation vector of the behavior word corresponding to the blockchain address to be classified; and obtaining a classification result corresponding to the blockchain address to be classified based on the representation vector of the behavior word corresponding to the blockchain address to be classified and a target classification model, wherein the target classification model is obtained based on the method described in the first aspect and any possible implementation thereof.

[0013] In one possible implementation, determining the representation vector of the behavioral word corresponding to the blockchain address to be classified includes: inputting the behavioral word corresponding to each blockchain address to be classified into a first model algorithm to obtain the representation vector of the behavioral word corresponding to each blockchain address to be classified, wherein the first model algorithm is used to extract a representation vector of a preset number of dimensions for the input content.

[0014] In one possible implementation, the above method further includes: dividing the behavioral words corresponding to the blockchain address to be classified based on a preset time window to obtain multiple behavioral sequences corresponding to the blockchain address to be classified, wherein each behavioral sequence includes at least one behavioral word; and obtaining the representation vector of each behavioral sequence among the multiple behavioral sequences based on the representation vector of the behavioral words corresponding to the blockchain address to be classified.

[0015] In one possible implementation, based on the representation vector of the behavior word corresponding to the blockchain address to be classified, the representation vector of each behavior sequence in a plurality of behavior sequences is obtained, including: for any behavior sequence in a plurality of behavior sequences corresponding to the blockchain address to be classified, the representation vectors of at least one behavior word included in any behavior sequence are weighted and averaged to obtain an average representation vector; the average representation vector is input into a neural network model based on an attention mechanism to obtain the representation vector of any behavior sequence.

[0016] In one possible implementation, the classification result of the blockchain address to be classified is obtained based on the representation vector of the behavior word corresponding to the blockchain address to be classified and the target classification model, including: inputting the representation vector of each behavior sequence in multiple behavior sequences into the target classification model to obtain the classification result of the blockchain address to be classified.

[0017] According to a third aspect of the embodiments of this application, a classification model training apparatus is provided. The apparatus includes: an acquisition unit and a processing unit; the acquisition unit is used to acquire transaction information of multiple historical transactions corresponding to a target smart contract from a blockchain; the processing unit is used to construct a behavior word corresponding to each blockchain address among multiple blockchain addresses corresponding to the multiple historical transactions based on the transaction information; a behavior word includes: a behavior function called by the historical transaction, a behavior function called by adjacent historical transactions of the historical transaction, smart contract information corresponding to the historical transaction, and a time interval between the historical transaction and adjacent historical transactions; the processing unit is used to determine the representation vector of the behavior word corresponding to each blockchain address; the processing unit is used to iteratively train a preset model based on the representation vector of the behavior word corresponding to each blockchain address and the classification label of each blockchain address, and obtain a target classification model after satisfying the training termination condition, the target classification model being used to classify blockchain addresses.

[0018] In one possible implementation, the processing unit is used to divide the behavioral words corresponding to the blockchain address based on a preset time window to obtain multiple behavioral sequences corresponding to the blockchain address, and each behavioral sequence includes at least one behavioral word; the processing unit is used to obtain the representation vector of each behavioral sequence among the multiple behavioral sequences based on the representation vector of the behavioral words corresponding to the blockchain address; the processing unit is used to iteratively train the preset model based on the representation vector of the behavioral sequence corresponding to each blockchain address and the classification label of each blockchain address.

[0019] In one possible implementation, the processing unit is configured to perform a weighted average of the representation vectors of at least one behavior word included in any behavior sequence among multiple behavior sequences corresponding to a blockchain address, to obtain an average representation vector; the processing unit is configured to input the average representation vector into a neural network model based on an attention mechanism to obtain a representation vector for any behavior sequence.

[0020] In one possible implementation, the processing unit is used to input the behavioral words corresponding to each blockchain address into the first model algorithm to obtain the representation vector of the behavioral words corresponding to each blockchain address. The first model algorithm is used to extract a representation vector of a preset number of dimensions for the input content.

[0021] In one possible implementation, the processing unit is used to sort and number the multiple action words based on the word frequency of each action word among the multiple action words corresponding to each blockchain address, and determine the sequence number corresponding to each action word, wherein the multiple action words are the action words corresponding to each blockchain address among the multiple blockchain addresses; the processing unit is used to represent the sequence number corresponding to each action word among the multiple action words through a vector of the same dimension to obtain a sparse matrix; the processing unit is used to input the sparse matrix into the first model algorithm to obtain the representation vector of the action word corresponding to each blockchain address.

[0022] In one possible implementation, the transaction information includes at least one of the following: external transaction data, internal transaction data, and behavioral functions for transaction calls; external transaction data includes at least one of the following: external transaction input address, external transaction output address, external transaction quantity, and external transaction time; internal transaction data includes at least one of the following: internal transaction input address, internal transaction output address, internal transaction quantity, and internal transaction time; behavioral functions for transaction calls include at least one of the following: transaction function, authorization function, exchange function, query function, staking function, withdrawal function, lending function, and minting function; the target smart contract is a smart contract on the blockchain with a usage frequency greater than a preset frequency, and the behavioral functions in the behavioral terms are the operation functions called by the target smart contract with a call frequency greater than a preset threshold and corresponding to business processing.

[0023] In one possible implementation, a processing unit is configured to input the representation vector of each behavior sequence and the classification label of each blockchain address into a preset model, respectively, to determine the first and second derivatives corresponding to the representation vector of each behavior sequence; a processing unit is configured to split the decision tree based on the first and second derivatives corresponding to the representation vector of each behavior sequence to obtain a weak learner and update the strong learner; a processing unit is configured to iteratively train the weak learner; and a processing unit is configured to determine the obtained strong learner as the target classification model after the training termination condition is met.

[0024] According to a fourth aspect of the embodiments of this application, a blockchain address classification apparatus is provided. The apparatus includes: a processing unit; the processing unit is configured to construct behavioral terms corresponding to a blockchain address to be classified, wherein a behavioral term includes: behavioral functions invoked by historical transactions, behavioral functions invoked by adjacent historical transactions of the historical transaction, smart contract information corresponding to the historical transaction, and time interval between the historical transaction and adjacent historical transactions; the processing unit is configured to determine a representation vector of the behavioral terms corresponding to the blockchain address to be classified; and the processing unit is configured to obtain a classification result corresponding to the blockchain address to be classified based on the representation vector of the behavioral terms corresponding to the blockchain address to be classified and a target classification model, wherein the target classification model is obtained based on the method described in the first aspect and any possible implementation thereof.

[0025] In one possible implementation, the processing unit is used to input the behavioral words corresponding to each blockchain address to be classified into the first model algorithm to obtain the representation vector of the behavioral words corresponding to each blockchain address to be classified. The first model algorithm is used to extract a representation vector of a preset number of dimensions for the input content.

[0026] In one possible implementation, the processing unit is used to divide the behavioral words corresponding to the blockchain address to be classified based on a preset time window to obtain multiple behavioral sequences corresponding to the blockchain address to be classified, and each behavioral sequence includes at least one behavioral word; the processing unit is used to obtain the representation vector of each behavioral sequence among the multiple behavioral sequences based on the representation vector of the behavioral words corresponding to the blockchain address to be classified.

[0027] In one possible implementation, the processing unit is configured to perform a weighted average of the representation vectors of at least one behavior word included in any behavior sequence among multiple behavior sequences corresponding to the blockchain address to be classified, to obtain an average representation vector; the processing unit is configured to input the average representation vector into a neural network model based on an attention mechanism to obtain the representation vector of any behavior sequence.

[0028] In one possible implementation, the processing unit is used to input the representation vector of each behavior sequence in the multiple behavior sequences into the target classification model to obtain the classification result corresponding to the blockchain address to be classified.

[0029] According to a fifth aspect of the embodiments of this application, an electronic device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute instructions to implement the first aspect and any possible implementation thereof, or the method in the second aspect.

[0030] According to a sixth aspect of the embodiments of this application, a computer-readable storage medium is provided, which, when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the methods described in the first aspect and any possible implementation thereof, or the methods described in the second aspect.

[0031] According to a seventh aspect of the present application, a computer program product is provided, the computer program product including computer instructions that, when executed on an electronic device, cause the electronic device to perform the methods described in the first aspect and any possible implementation thereof, or the second aspect.

[0032] The technical solution of the first aspect provided by the embodiments of this application brings at least the following beneficial effects: When it is necessary to classify blockchain addresses, a target classification model can be pre-trained to classify the blockchain addresses to be classified using the pre-trained target classification model. Specifically, based on the transaction information of multiple historical transactions corresponding to the target smart contract obtained from the blockchain, behavioral words corresponding to each blockchain address can be constructed. Thus, behavioral words can characterize the behavioral functions called by historical transactions corresponding to each blockchain address, the behavioral functions called by adjacent historical transactions, the smart contract information corresponding to the historical transactions, and the time interval between historical transactions and adjacent historical transactions, thereby characterizing the corresponding association information between adjacent transactions. Further, the representation vector of the behavioral words corresponding to each blockchain address is determined, and combined with the classification label of each blockchain address, the preset model is iteratively trained from the perspective of features and vectors to obtain a target classification model for classifying blockchain addresses after the training termination condition is met. Therefore, based on the above method, behavioral words can represent the corresponding association information between adjacent transactions. This fully considers the operational behaviors and temporal order of multiple transactions on the blockchain, fully mining rich on-chain behavioral and temporal features. By using representation vectors to represent behavioral words, the model can be trained. The resulting target classification model for classifying blockchain addresses can fully learn the corresponding association information between adjacent transactions, thus achieving higher accuracy in classifying blockchain addresses. Furthermore, using the target classification model allows classification based on the representation vectors of the behavioral words corresponding to the blockchain address to be classified, performing classification from both feature and vector perspectives, thus improving classification efficiency. This enhances both the efficiency and accuracy of blockchain address classification.

[0033] It should be noted that the technical effects of any of the implementation methods in aspects two through seven can be found in the technical effects of the corresponding implementation methods in aspect one, and will not be repeated here.

[0034] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0035] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application, and do not constitute an undue limitation of this application.

[0036] Figure 1 This is a schematic diagram illustrating an implementation architecture according to an exemplary embodiment;

[0037] Figure 2This is a flowchart illustrating a classification model training method according to an exemplary embodiment;

[0038] Figure 3 This is a flowchart illustrating yet another classification model training method according to an exemplary embodiment;

[0039] Figure 4 This is a flowchart illustrating yet another classification model training method according to an exemplary embodiment;

[0040] Figure 5 This is a schematic diagram illustrating a skip-gram model structure according to an exemplary embodiment;

[0041] Figure 6 This is a flowchart illustrating yet another classification model training method according to an exemplary embodiment;

[0042] Figure 7 This is a flowchart illustrating yet another classification model training method according to an exemplary embodiment;

[0043] Figure 8 This is a flowchart illustrating yet another classification model training method according to an exemplary embodiment;

[0044] Figure 9 This is a flowchart illustrating yet another classification model training method according to an exemplary embodiment;

[0045] Figure 10 This is a flowchart illustrating yet another classification model training method according to an exemplary embodiment;

[0046] Figure 11 This is a block diagram illustrating a classification model training apparatus according to an exemplary embodiment;

[0047] Figure 12 This is a block diagram illustrating an electronic device according to an exemplary embodiment. Detailed Implementation

[0048] To enable those skilled in the art to better understand the technical solutions of this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.

[0049] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0050] Before providing a detailed introduction to the classification model training method provided in this application, let's briefly introduce the relevant elements, application scenarios, and implementation environment involved in this application.

[0051] First, a brief introduction to the relevant elements involved in this application will be given.

[0052] In essence, blockchain is a distributed, shared database. The data or information stored within it possesses characteristics such as "unforgeable," "fully traceable," "transparent," and "collectively maintained." Smart contract blockchain transactions are divided into external blockchain address transactions and internal contract transactions. External address transactions refer to transactions involving only the transfer of the blockchain's native tokens, without involving contract calls or transactions of other tokens. In a blockchain system, all participating nodes maintain a shared ledger. Due to the decentralized and anonymous nature of blockchain tokens, abnormal access behavior can occur. Therefore, it is necessary to classify blockchain addresses to identify addresses exhibiting abnormal behavior. However, existing blockchain address classifications primarily construct features directly from the perspective of transaction relationship networks, failing to fully leverage the rich on-chain behavioral characteristics expressed by addresses.

[0053] Secondly, a brief introduction to the application scenarios involved in this application will be given.

[0054] In related technologies, classic machine learning methods typically involve manual feature engineering based on business understanding, followed by inputting the resulting feature vectors into classifier algorithms such as random forests for model training. Manually extracting transaction pattern features is simple to implement, reveals clear business characteristics, and offers strong interpretability; however, human business experience is limited, making it difficult to directly identify hidden business features. Furthermore, the features between different training samples are relatively independent, lacking mutual information, and struggle to capture group-like features, resulting in low classification accuracy.

[0055] Transaction graph networks utilize transaction records between accounts to construct a transaction network relationship graph. Transaction addresses are viewed as nodes, and transaction actions are considered as edges connecting nodes, forming a graph network to represent transaction patterns between address communities. This algorithm has advantages such as preserving node neighbor information, reflecting network community information, and ease of training; however, this type of method only considers transaction relationships and does not take into account other types of on-chain operations or the temporal order of operations.

[0056] The behavioral sequences of smart contracts on the blockchain can characterize the various on-chain activities of blockchain accounts. Compared to graph networks that only contain transaction relationships, behavioral sequence attention networks can express more content and contain richer information. Constructing behavioral sequence attention networks from the internal operational data of smart contracts on the blockchain can not only improve the ability to express business characteristics, but also create a richer and more detailed profile of blockchain accounts.

[0057] To address the aforementioned issues, this application provides a classification model training method applied to a classification model training device. When it is necessary to classify blockchain addresses, a target classification model can be pre-trained to classify the blockchain addresses to be classified. Specifically, based on transaction information of multiple historical transactions corresponding to the target smart contract obtained from the blockchain, behavioral words corresponding to each blockchain address can be constructed. These behavioral words can then represent the behavioral functions invoked by historical transactions corresponding to each blockchain address, the behavioral functions invoked by adjacent historical transactions, the smart contract information corresponding to the historical transactions, and the time interval between historical transactions and adjacent historical transactions, thus representing the correlation information between adjacent transactions. Further, the representation vector of the behavioral words corresponding to each blockchain address is determined, and combined with the classification label of each blockchain address, the pre-set model is iteratively trained from the perspective of features and vectors. After meeting the training termination condition, a target classification model for classifying blockchain addresses is obtained. Therefore, based on the above method, behavioral words can represent the corresponding association information between adjacent transactions. This fully considers the operational behaviors and temporal order of multiple transactions on the blockchain, fully mining rich on-chain behavioral and temporal features. By using representation vectors to represent behavioral words, the model can be trained. The resulting target classification model for classifying blockchain addresses can fully learn the corresponding association information between adjacent transactions, thus achieving higher accuracy in classifying blockchain addresses. Furthermore, using the target classification model allows classification based on the representation vectors of the behavioral words corresponding to the blockchain address to be classified, performing classification from both feature and vector perspectives, thus improving classification efficiency. This enhances both the efficiency and accuracy of blockchain address classification.

[0058] Finally, a brief introduction is given to the implementation environment (implementation architecture) involved in the method provided in this application.

[0059] Figure 1 This is an implementation architecture diagram of this application. The classification model training device 110 is used to execute the classification model training method. The classification model training device 110 is used to obtain transaction information of multiple historical transactions corresponding to the target smart contract from the blockchain 120, and construct the behavior words corresponding to each blockchain address in the multiple blockchain addresses corresponding to the multiple historical transactions based on the transaction information.

[0060] In some embodiments, the classification model training device 110 can be an application (APP), which can be deployed on a terminal device, such as a smartphone, tablet, handheld computer, vehicle terminal, desktop computer, and laptop computer.

[0061] In some embodiments, blockchain 120 is a network of computer devices consisting of multiple blockchain nodes, serving as a distributed shared database. Blockchain 120 includes multiple trading platforms, each used to execute different trading tasks, generating and storing corresponding transaction information.

[0062] In some embodiments, the classification model training device 110 can determine the representation vector of the behavior word corresponding to each blockchain address; and based on the representation vector of the behavior word corresponding to each blockchain address and the classification label of each blockchain address, iteratively train the preset model, and obtain the target classification model after the training termination condition is met. The target classification model is used to classify blockchain addresses.

[0063] Furthermore, it should be noted that the user information involved in this application (including but not limited to user device information, user personal information, user bank card information, etc.) is all information authorized by the user or fully authorized by all parties.

[0064] To facilitate understanding, the classification model training method provided in this application will be described in detail below with reference to the accompanying drawings.

[0065] Figure 2 This is a flowchart illustrating a classification model training method according to an exemplary embodiment. The method is applied to a classification model training device. Simultaneously, the method can also be applied to a client installed on the classification model training device, or it can also be applied to an application installed on the classification model training device. The following description uses the application of this method to a classification model training device as an example to illustrate the method. Figure 2 As shown, the training method for this classification model includes the following steps S201-S204:

[0066] S201. Obtain transaction information of multiple historical transactions corresponding to the target smart contract from the blockchain.

[0067] As one possible implementation, transaction information includes at least one of the following: external transaction data, internal transaction data, and behavioral functions of transaction calls. Compared with related technologies that only consider external transaction data or a small amount of related data when classifying blockchain addresses, the embodiments of this application, when training a target classification model to classify blockchain addresses, not only consider external transaction data but also combine internal transaction data and behavioral functions, etc., thus making full use of various effective information on the chain. Therefore, the accuracy of the target classification model trained based on transaction information will be higher, and the accuracy of blockchain address classification based on the target classification model will also be higher.

[0068] For example, external transaction data includes at least one of the following: external transaction input address, external transaction output address, external transaction quantity, and external transaction time. For example, internal transaction data includes at least one of the following: internal transaction input address, internal transaction output address, internal transaction quantity, and internal transaction time. For example, the behavioral functions invoked in a transaction include at least one of the following: transaction function, authorization function, exchange function, query function, staking function, withdrawal function, lending function, and minting function. The target smart contract is a smart contract on the blockchain with a usage frequency greater than a preset frequency. The behavioral functions in the behavioral terms are the operation functions invoked by the target smart contract that have a call frequency greater than a preset threshold and correspond to business processing.

[0069] As one possible implementation, during the data preparation phase (i.e., obtaining transaction information of multiple historical transactions corresponding to the target smart contract from the blockchain), blockchain ledger transaction records can be extracted from the blockchain ledger transaction records to extract transaction information of each transaction among the multiple historical transactions corresponding to the target smart contract.

[0070] Optionally, the historical transactions corresponding to a preset historical time period can be used as the multiple historical transactions to be acquired. The preset historical time period can be one year before the current time, or six months before the current time, etc. This application does not limit the specific time of the preset historical time period.

[0071] Optionally, the target smart contract may include any of the following: trading platform (Uniswap), lending platform (Aave), stablecoin exchange platform (Curve), lending platform (Compound), staking platform (Lido), trading platform (dYdX), market maker (Sushi), trading platform (Oasis), etc.

[0072] As a possible implementation, it is also necessary to extract the behavioral functions called in transactions related to the addresses of mainstream contracts (i.e., target smart contracts) within a preset historical time period, and filter out the operation function records that are used frequently and have specific business meanings. Specifically, these may include behavioral functions such as transaction function (transfer), authorization function (approve), swap function (swap), query function (allowance), staking function (staking), withdrawal function (withdraw), borrow function (borrow), and mint function (mint).

[0073] S202. Based on transaction information, construct the behavioral words corresponding to each blockchain address among multiple blockchain addresses corresponding to multiple historical transactions.

[0074] One of the behavioral terms includes: the behavioral function invoked by the historical transaction, the behavioral function invoked by the adjacent historical transaction, the smart contract information corresponding to the historical transaction, and the time interval between the historical transaction and the adjacent historical transaction.

[0075] As one possible implementation, the behavior function of a historical transaction call can be the behavior function of the final historical transaction call, and the behavior function of a historical transaction's adjacent historical transaction call can also be the behavior function of the final historical transaction call of the adjacent historical transaction.

[0076] As one possible implementation, behavioral terms can be constructed based on a preset template. This preset template could be: the behavioral function ultimately called in the previous transaction, the behavioral function ultimately called in this transaction, the smart contract information corresponding to this transaction, and the time interval between this transaction and the previous transaction. For example, the behavioral terms corresponding to a historical transaction constructed using the preset template could be: query function, staking function, staking platform, and 3 minutes.

[0077] In this embodiment of the application, since the transactions of blockchain smart contract account addresses not only include basic external transactions, but may also include a large number of internal transactions, the rich behavioral data contained in the internal transactions can be utilized. In this way, behavioral words can describe the corresponding correlation information between adjacent transactions, and various effective information on the chain can be fully utilized to improve the accuracy of the target classification model obtained through training.

[0078] S203. Determine the representation vector of the behavior word corresponding to each blockchain address.

[0079] In this embodiment of the application, blockchain addresses are trained through a model to reconstruct word text, and a representation vector corresponding to each blockchain address is obtained. The representation vector is used to represent the relationship between words.

[0080] S204. Based on the representation vector of the behavior word corresponding to each blockchain address and the classification label of each blockchain address, the preset model is iteratively trained, and the target classification model is obtained after the training termination condition is met.

[0081] The target classification model is used to classify blockchain addresses.

[0082] As one possible implementation, the classification label of a blockchain address is a pre-determined label used to indicate the category of the blockchain address. The classification label of a blockchain address can be a normal transaction address or an abnormal transaction address.

[0083] As one possible implementation, the training termination condition can be that the number of iterations reaches a preset number of iterations, or that the parameters during the iteration process (such as the score mentioned below) are preset parameters.

[0084] This application provides a classification model training method. When it is necessary to classify blockchain addresses, a target classification model can be pre-trained to classify the blockchain addresses to be classified. Specifically, based on transaction information of multiple historical transactions corresponding to the target smart contract obtained from the blockchain, behavioral words corresponding to each blockchain address can be constructed. These behavioral words can then represent the behavioral functions of historical transactions called by each blockchain address, the behavioral functions of adjacent historical transactions, the smart contract information corresponding to the historical transactions, and the time interval between historical transactions and adjacent historical transactions, thus representing the correlation information between adjacent transactions. Further, the representation vector of the behavioral words corresponding to each blockchain address is determined, and combined with the classification label of each blockchain address, the pre-trained model is iteratively trained from the perspective of features and vectors. After meeting the training termination condition, a target classification model for classifying blockchain addresses is obtained. Therefore, based on the above method, behavioral words can represent the corresponding association information between adjacent transactions. This fully considers the operational behaviors and temporal order of multiple transactions on the blockchain, fully mining rich on-chain behavioral and temporal features. By using representation vectors to represent behavioral words, the model can be trained. The resulting target classification model for classifying blockchain addresses can fully learn the corresponding association information between adjacent transactions, thus achieving higher accuracy in classifying blockchain addresses. Furthermore, using the target classification model allows classification based on the representation vectors of the behavioral words corresponding to the blockchain address to be classified, performing classification from both feature and vector perspectives, thus improving classification efficiency. This enhances both the efficiency and accuracy of blockchain address classification.

[0085] In some embodiments, such as Figure 3As shown, in order to determine the representation vector of the behavior word corresponding to each blockchain address, step S203 in the classification model training method provided in this application embodiment specifically includes the following step S2031:

[0086] S2031. Input the behavioral words corresponding to each blockchain address into the first model algorithm to obtain the representation vector of the behavioral words corresponding to each blockchain address. The first model algorithm is used to extract a representation vector of a preset number of dimensions for the input content.

[0087] As can be seen from the above, the behavior words corresponding to each blockchain address can be processed by the first model algorithm to obtain the representation vector of the behavior words corresponding to each blockchain address with a preset number of dimensions. This can improve the efficiency of determining the representation vector of the behavior words, and improve the uniformity of determining the representation vector by determining the representation vector with a preset number of dimensions.

[0088] In some embodiments, such as Figure 4 As shown, in order to determine the representation vector of the behavior word corresponding to each blockchain address, step S2031 in the classification model training method provided in this application embodiment specifically includes the following steps S301-S303:

[0089] S301. Based on the word frequency of each action word among multiple action words corresponding to each blockchain address, sort and number the multiple action words to determine the sequence number corresponding to each action word.

[0090] Among them, multiple action words are the action words corresponding to each of the multiple blockchain addresses.

[0091] One possible approach is to sort and number multiple action words according to their frequency to determine the sequence number of each action word.

[0092] Determining the sequence number of each behavior word among multiple behavior words can be understood as establishing a mapping dictionary to indicate the sequence number of each behavior word. Specifically, this can be achieved by statistically analyzing the frequency of behavior words, sorting multiple behavior words according to their occurrence count, and assigning each sequence number to a behavior word, thereby constructing a mapping dictionary that establishes the correspondence between sequence numbers and behavior words.

[0093] It should be noted that one action word corresponds to one blockchain address (i.e., transaction address, which can be an external transaction input address, an external transaction output address, an internal transaction input address, or an internal transaction output address), and one action word corresponds to one sequence number. That is, there is a correspondence between one action word, one transaction address, and one sequence number.

[0094] Optionally, behavior words that appear less frequently can be removed from multiple behavior words based on their frequency of occurrence, such as removing behavior words that appear less than three times.

[0095] S302. Represent the index corresponding to each action word in the multiple action words by using a vector of the same dimension to obtain a sparse matrix.

[0096] One possible implementation is to use one-hot encoding to represent the index corresponding to each action word with a vector of the same dimension to obtain a sparse matrix; where each vector has only one component that is 1 and the other components that are 0, and the position of component 1 in the vector corresponds to the position of the address vertex in the action word.

[0097] S303. Input the sparse matrix into the first model algorithm to obtain the representation vector of the behavior word corresponding to each blockchain address.

[0098] It is understandable that the first model algorithm can be used to train each action word to obtain the representation vector of the action word corresponding to each blockchain address. The first model is used to generate the representation vector based on the action words.

[0099] Optionally, the first model algorithm can be the Word2vec (word to vector) algorithm. Unsupervised learning using the Word2vec algorithm can train the representation vectors of action words. The Word2vec algorithm mainly has two forms: CBOW and Skip-gram. CBOW predicts the word at the current position based on the context, while Skip-gram predicts the context based on the current word.

[0100] It's important to note that the Word2vec algorithm is a group of related models used to generate word vectors. These models are shallow, two-layer neural networks trained to reconstruct linguistic word text. The network represents words and needs to guess the input words in adjacent positions. Under the bag-of-words assumption in Word2vec, the order of words is unimportant. After training, the Word2vec model can be used to map each word to a vector, which represents the relationship between words; this vector is the hidden layer of the neural network.

[0101] In the Word2vec algorithm, the variables are defined as follows: (a) the size of the dictionary consisting of all words is D; (b) the word vector dimension of the words to be learned is N; (c) a word is initially represented using one-hot encoding (also known as one-bit effective encoding); (d) a training sample consists of word pairs (w I ,w O ). w I These are called input words, which can be understood as features in machine learning. OCalled the output word, which can be understood as the label in machine learning. Our goal is to use w I to predict w O . In the Skip-Gram model, w I is the center word, and w O are several context words. Therefore, Skip-Gram needs to use the center word to predict the context words; (e) Input vector: The input vector of the input word w I is represented as v wI ; (f) Output vector: The output vector of the output word w O is represented as v' wO . For a given input word w I , there are D possible output words. Let the subscript of the possible output word be j (0 ≤ j < D). Then the output vector of the output word w j is represented as v' wj . Usually, j is used to represent the subscript of the possible output word. Therefore, usually, p(w j |w I ) needs to be calculated; (g) For a word w, there is an input vector v w , and there is also an output vector v' w . Because this word can appear as both the center word and the context word. Usually, only the learned input word vector is adopted, and the output word vector is not used.

[0102] As a possible implementation, the skip-gram model in the first model algorithm can be used to train the sparse matrix to obtain the vector corresponding to each transaction address vertex number in the sparse matrix, so as to obtain the representation vector of each behavior word.

[0103] It should be noted that the skip-gram model is a simple neural network model. As Figure 5 shown, it only contains an input layer, a hidden layer, and an output layer. The input is a word w(t). Assuming the context window size C = 2, the output is several words w(t - 2), w(t - 1), w(t + 1), w(t + 2) around w(t).

[0104] Specifically, first calculate the output of the hidden layer h through Equation 1:

[0105]

[0106] Among them, the input x is in the one-hot encoding form, and the subscript of this word in the dictionary is k. Therefore, only the Kth column of W T is used, which is the input word vector of the Kth word, equivalent to directly copying the Kth row of W to the hidden layer unit h. W represents the weight matrix between the input layer and the hidden layer. The vector representing the i-th column of W.

[0107] Furthermore, the input at each node in the output layer is calculated using Equation 2:

[0108]

[0109] Where W′ represents the weight matrix between the hidden layer and the output layer, u c,j v represents the input value of the j-th word predicted at the c-th context position of the output layer. W′j Let be the j-th column vector of W′, representing the output vector of the j-th word in the vocabulary. Since each output node shares the same W′, u c,j =u j .

[0110] Then, the output y of each node in the output layer is calculated using Equation 3. c,j The hidden layer outputs C multinomial distributions from the output layer, each representing the probability distribution of all words at the c-th context word position. Furthermore, W′ is shared by all C context word positions.

[0111]

[0112] Among them, w c,j This represents the j-th word predicted by the output layer at the c-th context position; w O,c This indicates the actual word appearing at the c-th context position; w I Indicates the input's central word; y c,j p(w) represents the output value of the j-th word at the c-th context position in the output layer. c,j =w o,c |w I Let f(c) represent the probability that, given a given input word as the center word, the word at the c-th context position output by the model is indeed the word at the c-th context position. The training objective is to maximize the probability that, given a center word, the C context words output by the model are the actual C context words.

[0113] Furthermore, the loss function needs to be defined using Equation 4:

[0114]

[0115] in, It is the index of the c-th actual output word in the vocabulary.

[0116] Furthermore, the update rule for the output weight matrix W′ is determined by Equation 5:

[0117]

[0118] And, the update rule for weight W is obtained through Equation 6:

[0119]

[0120] Finally, after training is complete, the vector obtained by multiplying each word in the input layer with matrix W is the required address vertex vector (i.e., the representation vector of each action word) as v = W·x.

[0121] In this embodiment, the Word2vec algorithm is used to obtain the representation vector of the behavior word corresponding to each blockchain address. The Word2vec algorithm has fewer model parameters and faster training speed, which can improve the speed of determining the representation vector of the behavior word corresponding to the blockchain address. Furthermore, this application combines and expresses the behavior data on the blockchain smart contract chain (i.e., behavior words), and fully expresses the implicit transaction characteristics of the blockchain address by utilizing rich internal transactions, thereby improving the accuracy of the obtained target classification model.

[0122] As shown above, by sorting and numbering multiple action words according to their frequency, and representing each action word's index using a vector of the same dimension, the resulting sparse matrix is ​​input into the first model algorithm to obtain the representation vector of the action word corresponding to each blockchain address. Obtaining a reasonable sparse matrix based on ordered action words, and then using the first model algorithm to obtain the representation vector of the action words, can improve the accuracy of obtaining the representation vector of the action words.

[0123] In some embodiments, it is necessary to segment multiple action words according to a time window to obtain multiple action sequences and a representation vector for each action sequence. Therefore, in order to obtain multiple action sequences and the representation vector for each action sequence, as follows... Figure 6 As shown, the method provided in this application embodiment further includes the following steps S401-S402, and step S204 in the above method specifically includes the following step S2041:

[0124] S401. Based on a preset time window, divide the behavioral words corresponding to the blockchain address to obtain multiple behavioral sequences corresponding to the blockchain address.

[0125] In this sequence of actions, there is at least one action word.

[0126] As one possible implementation, the behavioral words corresponding to the defined blockchain addresses can be divided into behavioral sequences according to time windows based on the blockchain account address (which can be one of external transaction input address, external transaction output address, internal transaction input address, or internal transaction output address) included in the transaction information of each transaction.

[0127] Specifically, the time window can be 24 hours or 12 hours, that is, multiple behavioral words can be segmented into 24-hour time windows to form multiple behavioral sequences in chronological order.

[0128] Optionally, each of the multiple behavior sequences obtained above corresponds to a known label, which is used to indicate the type of transaction address corresponding to the behavior sequence. The type of transaction address can be a normal transaction address or an abnormal transaction address.

[0129] S402. Based on the representation vector of the behavior word corresponding to the blockchain address, obtain the representation vector of each behavior sequence in multiple behavior sequences.

[0130] In some embodiments, such as Figure 7 As shown, since the representation vector of each behavior sequence is obtained based on the representation vector of each behavior word, in order to obtain the representation vector of each behavior sequence, step S402 in the classification model training method provided in this application embodiment specifically includes the following steps S4021-S4022:

[0131] S4021. For any behavior sequence among multiple behavior sequences corresponding to a blockchain address, the representation vectors of at least one behavior word included in any behavior sequence are weighted and averaged to obtain an average representation vector.

[0132] S4022. Input the average representation vector into the attention-based neural network model to obtain the representation vector of any behavior sequence.

[0133] As one possible implementation, the representation vectors of the behavior words corresponding to the blockchain addresses included in each behavior sequence are weighted and averaged to obtain an average representation vector; then, the average representation vector is input into a neural network model based on an attention mechanism to train and obtain the representation vector of the entire behavior sequence, generating the corresponding behavior sequence representation vector of the same dimension.

[0134] S2041. Based on the representation vector of the behavior sequence corresponding to each blockchain address and the classification label of each blockchain address, the preset model is iteratively trained, and the target classification model is obtained after the training termination condition is met.

[0135] As shown above, the behavioral words corresponding to blockchain addresses can be divided into multiple behavioral sequences based on a preset time window. Behavioral words with related relationships can be grouped into the same behavioral sequence, and a representation vector for each behavioral sequence can be obtained based on the representation vector of the behavioral words. Furthermore, the preset model can be iteratively trained based on the representation vector of each behavioral sequence and the classification label of each blockchain address. By iteratively training the preset model from the perspective of behavioral sequences, a more accurate target classification model can be obtained based on the representation vectors of related behavioral words.

[0136] In some embodiments, such as Figure 8 As shown, in order to obtain the target classification model, step S204 in the classification model training method provided in this application embodiment specifically includes the following steps S501-S504:

[0137] S501. Input the representation vector of each behavior sequence and the classification label of each blockchain address into the preset model to determine the first and second derivatives corresponding to the representation vector of each behavior sequence.

[0138] As one possible implementation, the preset model can be a boosting decision tree algorithm model, specifically the XGBoost (Extreme Gradient Boosting) algorithm model, which is an efficient gradient boosting decision tree algorithm model.

[0139] It should be noted that the input to the XGBoost algorithm model is the training set samples T = {(x1, y1), (x2, y2), ... (x... m ,y m The maximum number of iterations is T, the loss function is L, and the regularization coefficients are γ and γ.

[0140] λ; the output is a strong learner f(x).

[0141] Specifically, the main flow of the XGBoost algorithm model is shown below, for iteration rounds t = 1, 2, ... T:

[0142] First, calculate the loss function L for the i-th sample (i-1,2,...m) in the current round based on f. t-1 (x i The first derivative of g) ti Second derivative h ti Calculate the first derivative of all samples. and second derivative

[0143] S502. Based on the first and second derivatives corresponding to the representation vector of each behavior sequence, split the decision tree to obtain the weak learner and update the strong learner.

[0144] Furthermore, based on the current node, an attempt is made to split the decision tree, with a default score of 0. G and H are the sum of the first and second derivatives of the node to be split. For feature indices k = 1, 2...K, we have: G L =0,H L =0. Arrange the samples according to feature k in ascending order, and take out the i-th sample in turn. Calculate the sum of the first and second derivatives of the left and right subtrees after the current sample is placed in the left subtree, as shown in Equations 7 and 8:

[0145] G L =G L +g ti G R =GG L Formula 7

[0146] H L =H L +h ti H R =HH L Formula 8

[0147] Furthermore, attempt to update the maximum score using Formula 9:

[0148]

[0149] Therefore, the subtree is split based on the splitting feature and feature value corresponding to the highest score; if the highest score is 0, the current decision tree is completed, and w is calculated for all leaf regions. tj We obtain the weak learner h t (x), update the strong learner f t (x).

[0150] S503, Iteratively train the weak learner.

[0151] S504. After the training termination condition is met, the obtained strong learner is determined as the target classification model.

[0152] Further, proceed to the next round of weak learner iteration; if the maximum score is not 0, continue to try splitting the decision tree and iteratively training the weak learner.

[0153] As one possible implementation, when the maximum score is 0, the training termination condition is determined, and the latest strong learner f is obtained. t (x).

[0154] As one possible implementation, the resulting strong learner f t(x) is the target classification model, which can be obtained by inputting the behavioral sequence representation vector of the address to be classified into the trained strong learner f. t In (x), the required classification result is obtained, thereby determining whether the address to be classified is a normal transaction address or an abnormal transaction address.

[0155] As shown above, by inputting the representation vector of each behavior sequence and the classification label of each blockchain address into a preset model for training, the first and second derivatives corresponding to the representation vector of each behavior sequence are determined. The decision tree is then split based on the first and second derivatives of the representation vector of each behavior sequence to obtain a weak learner and update the strong learner. Thus, if the training termination condition is not met, the weak learner continues to be iteratively trained, further updating the strong learner. Finally, when the training termination condition is met, the obtained strong learner is determined as the target classification model. By continuously iterating through the representation vectors of multiple behavior sequences, the accuracy of the obtained target classification model can be improved.

[0156] This application presents a method for training a classification model based on a smart contract behavior sequence attention network, such as... Figure 9 As shown, by collecting relevant transaction data of mainstream blockchain contracts (i.e., external transaction data of blockchain contracts and internal smart contract call data of blockchain), the relevant behavioral functions of these contract calls (i.e., transaction functions, authorization functions, exchange functions, query functions, staking functions, withdrawal functions, lending functions, and minting functions) are extracted and filtered; mainstream contracts with high transaction volume on the blockchain are selected; and contract call functions are extracted from massive amounts of internal transaction data of blockchain smart contracts. Then, account-specific behavioral sequences are synthesized and separated, and the final operation functions of contract calls in internal transactions are extracted. Behavioral words are formed by combining the time interval between the behavioral function and the previous behavioral function call. A behavioral word library is built according to word frequency, and the representation vector of the behavioral words is trained using the Word2vec algorithm; further, the behavior is segmented according to time windows, and multiple behaviors are concatenated in chronological order to form a behavioral sequence. The vectors of the behavioral representation words are weighted and averaged, and input into an attention-based neural network to train the representation vector of the entire behavioral sequence, generating corresponding vectors of the same dimension; thus, the behavioral sequence representation of addresses with existing labels is trained using the XGBoost algorithm to generate a classification model, and then the addresses to be classified are classified. This model has fewer parameters and faster training speed. Based on the characteristics of internal contract calls in the blockchain, it combines and expresses the on-chain behavioral data of blockchain smart contracts, and fully expresses the implicit transaction characteristics of blockchain addresses by utilizing rich internal transactions.

[0157] In some embodiments, such as Figure 10As shown, in order to obtain the classification result corresponding to the blockchain address to be classified, the classification model training method provided in this application embodiment specifically includes the following steps S601-S602:

[0158] S601. Construct the behavioral words corresponding to the blockchain addresses to be classified, and determine the representation vectors of the behavioral words corresponding to the blockchain addresses to be classified.

[0159] One of the behavioral terms includes: the behavioral function invoked by the historical transaction, the behavioral function invoked by the adjacent historical transaction, the smart contract information corresponding to the historical transaction, and the time interval between the historical transaction and the adjacent historical transaction.

[0160] It should be noted that for a blockchain address to be classified, it is necessary to construct the behavioral words corresponding to the blockchain address to be classified and determine the representation vector of the behavioral words corresponding to the blockchain address to be classified before the category (i.e., normal transaction address or abnormal transaction address) of the blockchain address to be classified can be determined through the target classification model.

[0161] S602. Based on the representation vector of the behavioral word corresponding to the blockchain address to be classified and the target classification model, the classification result corresponding to the blockchain address to be classified is obtained.

[0162] The target classification model is obtained based on the classification model training method in steps S201-S204 above.

[0163] In one possible implementation, determining the representation vector of the behavioral word corresponding to the blockchain address to be classified includes: inputting the behavioral word corresponding to each blockchain address to be classified into a first model algorithm to obtain the representation vector of the behavioral word corresponding to each blockchain address to be classified, wherein the first model algorithm is used to extract a representation vector of a preset number of dimensions for the input content.

[0164] The above method can process the behavioral words corresponding to the blockchain addresses to be classified using the first model algorithm to obtain the representation vectors of the behavioral words corresponding to the blockchain addresses to be classified with a preset number of dimensions. This can improve the efficiency of determining the representation vectors of behavioral words, and improve the uniformity of determining the representation vectors by determining the representation vectors with a preset number of dimensions.

[0165] It should be noted that the specific process of determining the representation vector of the behavioral word corresponding to the blockchain address to be classified is similar to the process of determining the representation vector of the behavioral word corresponding to the blockchain address during model training, and will not be analyzed in detail here.

[0166] In one possible implementation, the above method further includes: dividing the behavioral words corresponding to the blockchain address to be classified based on a preset time window to obtain multiple behavioral sequences corresponding to the blockchain address to be classified, wherein each behavioral sequence includes at least one behavioral word; and obtaining the representation vector of each behavioral sequence among the multiple behavioral sequences based on the representation vector of the behavioral words corresponding to the blockchain address to be classified.

[0167] It should be noted that the specific process of determining multiple behavioral sequences and the representation vector of each behavioral sequence here is similar to the process of determining multiple behavioral sequences corresponding to blockchain addresses and the representation vector of each behavioral sequence during model training, and will not be analyzed in detail here.

[0168] In one possible implementation, based on the representation vector of the behavior word corresponding to the blockchain address to be classified, the representation vector of each behavior sequence in a plurality of behavior sequences is obtained, including: for any behavior sequence in a plurality of behavior sequences corresponding to the blockchain address to be classified, the representation vectors of at least one behavior word included in any behavior sequence are weighted and averaged to obtain an average representation vector; the average representation vector is input into a neural network model based on an attention mechanism to obtain the representation vector of any behavior sequence.

[0169] The above method can divide the behavioral words corresponding to the blockchain address to be classified into multiple behavioral sequences based on a preset time window, so as to classify the behavioral words with related relationships into the same behavioral sequence, and obtain the representation vector of each behavioral sequence based on the representation vector of the behavioral words; then, the blockchain address to be classified can be classified based on the representation vector of each behavioral sequence and the target classification model.

[0170] It should be noted that the specific process of determining the representation vector of the behavior sequence here is similar to the process of determining the representation vector of the behavior sequence during model training, and will not be analyzed in detail here.

[0171] In one possible implementation, the classification result of the blockchain address to be classified is obtained based on the representation vector of the behavior word corresponding to the blockchain address to be classified and the target classification model, including: inputting the representation vector of each behavior sequence in multiple behavior sequences into the target classification model to obtain the classification result of the blockchain address to be classified.

[0172] It can be understood that after obtaining the representation vector of the behavioral word corresponding to the blockchain address to be classified, the representation vector of the behavioral word corresponding to the blockchain address to be classified is input into the target classification model, and the category of the blockchain address to be classified can be determined.

[0173] As shown above, when using a target classification model, it is necessary to first construct the behavioral terms corresponding to the blockchain address to be classified and determine the representation vectors of these behavioral terms. Then, by inputting these representation vectors into the target classification model, the classification result for the blockchain address can be obtained. Determining the category of the blockchain address to be classified through the target classification model from the dimension of the representation vector can improve the accuracy of classifying the blockchain address.

[0174] In this embodiment, the above method can directly identify hidden business features, and the features among the training samples are relatively independent with sufficient mutual information, enabling the capture of group characteristics and improving the accuracy of blockchain address classification. By characterizing the various on-chain behaviors of blockchain accounts, behavioral sequence attention networks can express more content and contain richer information compared to graph networks that only contain transfer relationships. By constructing behavioral sequence attention networks from the internal operational data of smart contracts on the blockchain, not only can the expressive power of business features be improved, but also a richer and more detailed profile of blockchain accounts can be created.

[0175] The foregoing mainly describes the solutions provided by the embodiments of this application from a methodological perspective. To achieve the above functions, the classification model training device, address classification device, or electronic device includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0176] This application embodiment can, based on the above method, exemplarily divide a classification model training device, an address classification device, or an electronic device into functional modules. For example, the classification model training device, address classification device, or electronic device may include functional modules corresponding to each functional division, or two or more functions may be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division; in actual implementation, there may be other division methods.

[0177] For example, embodiments of this application also provide a classification model training device.

[0178] Figure 11This is a block diagram illustrating a classification model training apparatus according to an exemplary embodiment. (Refer to...) Figure 11 The classification model training device 1100 includes an acquisition unit 1101 and a processing unit 1102.

[0179] The acquisition unit 1101 is used to acquire transaction information of multiple historical transactions corresponding to the target smart contract from the blockchain;

[0180] Processing unit 1102 is used to construct behavioral terms corresponding to each blockchain address among multiple blockchain addresses corresponding to multiple historical transactions based on transaction information; a behavioral term includes: behavioral functions called by historical transactions, behavioral functions called by adjacent historical transactions of historical transactions, smart contract information corresponding to historical transactions, and time intervals between historical transactions and adjacent historical transactions;

[0181] Processing unit 1102 is used to determine the representation vector of the behavior word corresponding to each blockchain address;

[0182] The processing unit 1102 is used to iteratively train the preset model based on the representation vector of the behavior word corresponding to each blockchain address and the classification label of each blockchain address, and obtain the target classification model after the training termination condition is met. The target classification model is used to classify blockchain addresses.

[0183] Optionally, the processing unit 1102 is used to divide the behavioral words corresponding to the blockchain address based on a preset time window to obtain multiple behavioral sequences corresponding to the blockchain address, and a behavioral sequence includes at least one behavioral word.

[0184] Processing unit 1102 is used to obtain the representation vector of each behavior sequence in multiple behavior sequences based on the representation vector of the behavior word corresponding to the blockchain address;

[0185] The processing unit 1102 is used to iteratively train a preset model based on the representation vector of the behavior sequence corresponding to each blockchain address and the classification label of each blockchain address.

[0186] Optionally, the processing unit 1102 is used to perform a weighted average of the representation vectors of at least one behavior word included in any behavior sequence among multiple behavior sequences corresponding to a blockchain address, to obtain an average representation vector.

[0187] The processing unit 1102 is used to input the average representation vector into the neural network model based on the attention mechanism to obtain the representation vector of any behavior sequence.

[0188] Optionally, the processing unit 1102 is used to input the behavioral words corresponding to each blockchain address into the first model algorithm to obtain the representation vector of the behavioral words corresponding to each blockchain address. The first model algorithm is used to extract a representation vector of a preset number of dimensions for the input content.

[0189] Optionally, the processing unit 1102 is used to sort and number the multiple action words based on the word frequency of each action word among the multiple action words corresponding to each blockchain address, and determine the sequence number corresponding to each action word, wherein the multiple action words are the action words corresponding to each blockchain address among the multiple blockchain addresses;

[0190] Processing unit 1102 is used to represent the sequence number corresponding to each of the multiple action words through a vector of the same dimension to obtain a sparse matrix;

[0191] The processing unit 1102 is used to input the sparse matrix into the first model algorithm to obtain the representation vector of the behavior word corresponding to each blockchain address.

[0192] Optionally, the transaction information includes at least one of the following: external transaction data, internal transaction data, and transaction call behavior functions; external transaction data includes at least one of the following: external transaction input address, external transaction output address, external transaction quantity, and external transaction time; internal transaction data includes at least one of the following: internal transaction input address, internal transaction output address, internal transaction quantity, and internal transaction time; transaction call behavior functions include at least one of the following: transaction function, authorization function, exchange function, query function, staking function, withdrawal function, lending function, and minting function; the target smart contract is a smart contract on the blockchain with a usage frequency greater than a preset frequency, and the behavior function in the behavior term is an operation function of the target smart contract that has a call frequency greater than a preset threshold and corresponds to a business processing operation function.

[0193] Optionally, the processing unit 1102 is used to input the representation vector of each behavior sequence in the multiple behavior sequences and the classification label of each blockchain address into the preset model to determine the first derivative and second derivative corresponding to the representation vector of each behavior sequence.

[0194] The processing unit 1102 is used to split the decision tree based on the first and second derivatives corresponding to the representation vector of each behavior sequence, to obtain a weak learner and update the strong learner.

[0195] Processing unit 1102 is used for iterative training of the weak learner;

[0196] The processing unit 1102 is used to determine the obtained strong learner as the target classification model after the training termination condition is met.

[0197] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0198] Figure 12 This is a block diagram illustrating an electronic device according to an exemplary embodiment. Figure 12 As shown, the electronic device 1200 includes, but is not limited to, a processor 1201 and a memory 1202.

[0199] The memory 1202 described above is used to store the executable instructions of the processor 1201. It is understood that the processor 1201 is configured to execute instructions to implement the classification model training method in the above embodiments.

[0200] It should be noted that those skilled in the art will understand that Figure 12 The electronic device structure shown does not constitute a limitation on the electronic device; the electronic device may include, but is not limited to, other electronic devices. Figure 12 This may indicate more or fewer components, or combinations of certain components, or different component arrangements.

[0201] Processor 1201 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines. By running or executing software programs and / or modules stored in memory 1202, and by calling data stored in memory 1202, it performs various functions and processes data, thereby providing overall monitoring of the electronic device. Processor 1201 may include one or more processing units. Optionally, processor 1201 may integrate an application processor and a modem processor. The application processor mainly handles the operating system, user interface, and applications, while the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into processor 1201.

[0202] The memory 1202 can be used to store software programs and various data. The memory 1202 may primarily include a program storage area and a data storage area. The program storage area may store the operating system, application programs required by at least one functional module (such as a determination unit, processing unit, etc.), etc. Furthermore, the memory 1202 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0203] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 1202 including instructions, which can be executed by a processor 1201 of an electronic device 1200 to implement the classification model training method in the above embodiments.

[0204] In actual implementation, the processing functions of both the acquisition unit 1101 and the processing unit 1102 can be handled by... Figure 12 The processor 1201 calls the computer program stored in the memory 1202 to implement the process. The specific execution process can be found in the description of the classification model training method in the previous embodiment, and will not be repeated here.

[0205] Optionally, the computer-readable storage medium may be a non-transitory computer-readable storage medium, such as a read-only memory (ROM), random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device.

[0206] In an exemplary embodiment, this application also provides a computer program product including one or more instructions, which can be executed by the processor 1201 of the electronic device 1200 to complete the classification model training method in the above embodiments.

[0207] It should be noted that when one or more instructions in the computer-readable storage medium or computer program product are executed by the processor of the electronic device, they implement the various processes of the above-described classification model training method embodiment and achieve the same technical effect as the above-described classification model training method. To avoid repetition, they will not be described again here.

[0208] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0209] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0210] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the classified units can be selected to achieve the purpose of this embodiment, depending on actual needs.

[0211] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0212] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, essentially, or the part that contributes to the prior art, or a complete or partial classification of the technical solution, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.

[0213] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A classification model training method, characterized in that, The method includes: Obtain transaction information from multiple historical transactions corresponding to the target smart contract on the blockchain; Based on the transaction information, a behavioral term is constructed for each blockchain address corresponding to the multiple historical transactions; each behavioral term includes: the behavioral function called by the historical transaction, the behavioral function called by the adjacent historical transactions of the historical transaction, the smart contract information corresponding to the historical transaction, and the time interval between the historical transaction and the adjacent historical transaction; Determine the representation vector of the action word corresponding to each blockchain address; Based on the representation vector of the behavioral word corresponding to each blockchain address and the classification label of each blockchain address, the preset model is iteratively trained, and the target classification model is obtained after the training termination condition is met. The target classification model is used to classify blockchain addresses.

2. The classification model training method according to claim 1, characterized in that, The method further includes: The behavioral words corresponding to the blockchain address are divided based on a preset time window to obtain multiple behavioral sequences corresponding to the blockchain address. Each behavioral sequence includes at least one behavioral word. Based on the representation vector of the behavior word corresponding to the blockchain address, the representation vector of each behavior sequence in the plurality of behavior sequences is obtained; The iterative training of the preset model based on the representation vector of the behavior word corresponding to each blockchain address and the classification label of each blockchain address includes: The preset model is iteratively trained based on the representation vector of the behavior sequence corresponding to each blockchain address and the classification label of each blockchain address.

3. The classification model training method according to claim 2, characterized in that, The process of obtaining the representation vector for each behavior sequence among the plurality of behavior sequences based on the representation vector of the behavior word corresponding to the blockchain address includes: For any behavior sequence among multiple behavior sequences corresponding to the blockchain address, the representation vectors of at least one behavior word included in the any behavior sequence are weighted and averaged to obtain the average representation vector. The average representation vector is input into an attention-based neural network model to obtain the representation vector of any behavioral sequence.

4. The classification model training method according to any one of claims 1-3, characterized in that, The process of determining the representation vector of the behavior word corresponding to each blockchain address includes: The behavioral words corresponding to each blockchain address are input into the first model algorithm to obtain the representation vector of the behavioral words corresponding to each blockchain address. The first model algorithm is used to extract a representation vector of a preset number of dimensions for the input content.

5. The classification model training method according to claim 4, characterized in that, The step of inputting the behavior word corresponding to each blockchain address into the first model algorithm to obtain the representation vector of the behavior word corresponding to each blockchain address includes: Based on the word frequency of each behavioral word among multiple behavioral words corresponding to each blockchain address, the multiple behavioral words are sorted and numbered to determine the sequence number corresponding to each behavioral word. The multiple behavioral words are the behavioral words corresponding to each blockchain address among the multiple blockchain addresses. The index corresponding to each of the multiple action words is represented by a vector of the same dimension to obtain a sparse matrix; The sparse matrix is ​​input into the first model algorithm to obtain the representation vector of the behavior word corresponding to each blockchain address.

6. The classification model training method according to any one of claims 1-3, characterized in that, The transaction information includes at least one of the following: external transaction data, internal transaction data, and behavioral functions invoked during transactions; The external transaction data includes at least one of the following: external transaction input address, external transaction output address, external transaction quantity, and external transaction time; The internal transaction data includes at least one of the following: internal transaction input address, internal transaction output address, internal transaction quantity, and internal transaction time; The behavioral functions invoked in the transaction call include at least one of the following: transaction function, authorization function, exchange function, query function, staking function, withdrawal function, lending function, and minting function; The target smart contract is a smart contract on the blockchain with a usage frequency greater than a preset frequency, and the behavior function in the behavior term is the operation function that is called more frequently than a preset threshold and corresponds to the business processing among the behavior functions called by the target smart contract.

7. The classification model training method according to claim 2 or 3, characterized in that, The process involves iteratively training a pre-defined model based on the representation vector of the behavior word corresponding to each blockchain address and the classification label of each blockchain address, and obtaining the target classification model after meeting the training termination condition. This includes: The representation vector of each behavior sequence and the classification label of each blockchain address are input into the preset model to determine the first and second derivatives corresponding to the representation vector of each behavior sequence. The decision tree is split based on the first and second derivatives corresponding to the representation vector of each behavior sequence to obtain the weak learner and update the strong learner. The weak learner is trained iteratively; After the training termination condition is met, the resulting strong learner is determined as the target classification model.

8. A blockchain address classification method, characterized in that, The method includes: Construct behavioral terms corresponding to the blockchain addresses to be classified. Each behavioral term includes: the behavioral function invoked by the historical transaction, the behavioral function invoked by the adjacent historical transactions of the historical transaction, the smart contract information corresponding to the historical transaction, and the time interval between the historical transaction and the adjacent historical transactions. Determine the representation vector of the behavior word corresponding to the blockchain address to be classified; Based on the representation vector of the behavioral word corresponding to the blockchain address to be classified and the target classification model, the classification result corresponding to the blockchain address to be classified is obtained, wherein the target classification model is obtained based on the classification model training method as described in any one of claims 1 to 7.

9. A classification model training device, characterized in that, The device includes: an acquisition unit and a processing unit; The acquisition unit is used to acquire transaction information of multiple historical transactions corresponding to the target smart contract from the blockchain; The processing unit is configured to construct, based on the transaction information, a behavior term corresponding to each blockchain address among the multiple blockchain addresses corresponding to the multiple historical transactions; each behavior term includes: the behavior function invoked by the historical transaction, the behavior function invoked by the adjacent historical transactions of the historical transaction, the smart contract information corresponding to the historical transaction, and the time interval between the historical transaction and the adjacent historical transactions; The processing unit is used to determine the representation vector of the behavior word corresponding to each blockchain address; The processing unit is used to iteratively train a preset model based on the representation vector of the behavior word corresponding to each blockchain address and the classification label of each blockchain address, and obtain a target classification model after the training termination condition is met. The target classification model is used to classify blockchain addresses.

10. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the method as described in any one of claims 1 to 7, or to implement the method as described in claim 8.

11. A computer-readable storage medium, characterized in that, When the computer-executable instructions stored in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device is capable of performing the method as claimed in any one of claims 1 to 7, or the electronic device performs the method as claimed in claim 8.

Citation Information

Patent Citations

  • Method and device for identifying abnormal transactions

    CN108053318A

  • Block chain address classification method and device

    CN114911925A