CN112230984B - Processing method and device of intelligent contract template of block chain - Google Patents

Processing method and device of intelligent contract template of block chain Download PDF

Info

Publication number
CN112230984B
CN112230984B CN202011144874.6A CN202011144874A CN112230984B CN 112230984 B CN112230984 B CN 112230984B CN 202011144874 A CN202011144874 A CN 202011144874A CN 112230984 B CN112230984 B CN 112230984B
Authority
CN
China
Prior art keywords
contract template
intelligent contract
category
template
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011144874.6A
Other languages
Chinese (zh)
Other versions
CN112230984A (en
Inventor
夏韵
劳晓华
裴磊
林国斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202011144874.6A priority Critical patent/CN112230984B/en
Publication of CN112230984A publication Critical patent/CN112230984A/en
Application granted granted Critical
Publication of CN112230984B publication Critical patent/CN112230984B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • G06F18/2413Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on distances to training or reference patterns
    • G06F18/24147Distances to closest patterns, e.g. nearest neighbour classification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/77Software metrics
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Computer Security & Cryptography (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses a processing method and a processing device of a blockchain intelligent contract template, which can be applied to the technical field of blockchains, wherein the method comprises the following steps: in response to receiving the new smart contract template, obtaining stored smart contract template information, the stored smart contract template information including: template category; training a classification model based on a K nearest neighbor KNN algorithm according to stored intelligent contract module information to obtain an optimal adjacent distance (K) value required by the KNN algorithm; inputting the new intelligent contract template information into the trained classification model to predict the category of the new intelligent contract template; determining a category of the new smart contract template based on a web page ranking (PageRank) algorithm in response to the predicted category of the new smart contract template being non-unique; scoring all intelligent contract templates of the belonging category to determine the optimal intelligent contract template of the belonging category. By the invention, the labor cost can be reduced.

Description

Processing method and device of intelligent contract template of block chain
Technical Field
The invention relates to the technical field of blockchains, in particular to a processing method and device of a blockchain intelligent contract template.
Background
In the development of blockchain systems, intelligent contracts are the core implementation of business logic. At present, many security audit detection schemes aiming at intelligent contracts exist in the market, but the schemes are realized based on manual audit, extra labor cost is required to be consumed, and for common small projects, cost expenditure can greatly exceed project income and does not accord with project budget planning.
Disclosure of Invention
In view of the above, the present invention provides a method and apparatus for processing a blockchain intelligent contract template to solve at least one of the above-mentioned problems.
According to a first aspect of the present invention, there is provided a method of processing a blockchain intelligent contract template, the method comprising:
in response to receiving the new smart contract template, stored smart contract template information is obtained, the stored smart contract template information comprising: template category;
training a classification model based on a K Nearest Neighbor (KNN) algorithm according to the stored intelligent contract module information to obtain an optimal proximity distance (K) value required by the KNN algorithm;
inputting the new intelligent contract template information into the trained classification model to predict the category of the new intelligent contract template;
determining a category of the new smart contract template based on a web page ranking (PageRank) algorithm in response to the predicted category of the new smart contract template being non-unique;
scoring all intelligent contract templates of the belonging category to determine the optimal intelligent contract template of the belonging category.
According to a second aspect of the present invention, there is provided an apparatus for processing a blockchain smart contract template, the apparatus comprising:
a template information acquisition unit configured to acquire stored smart contract template information in response to receiving a new smart contract template, the stored smart contract template information including: template category;
the training unit is used for training a classification model based on the KNN algorithm according to the stored intelligent contract module information so as to obtain an optimal adjacent distance K value required by the KNN algorithm;
the category prediction unit is used for inputting the information of the new intelligent contract template into the trained classification model so as to predict the category of the new intelligent contract template;
a category determining unit for determining a category of the new smart contract template based on a PageRank algorithm in response to the predicted category of the new smart contract template being not unique;
and the scoring unit is used for scoring all the intelligent contract templates of the category to determine the optimal intelligent contract template of the category.
According to a third aspect of the present invention there is provided an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the above method when the program is executed.
According to a fourth aspect of the present invention there is provided a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of the above method.
According to the technical scheme, when the new intelligent contract template is received, the classification model based on the KNN algorithm is trained according to the acquired stored intelligent contract template information to obtain the K value required by the KNN algorithm, then the new intelligent contract template information is input into the trained classification model, the classification of the new intelligent contract template is predicted, when the classification of the predicted new intelligent contract template is not unique, the classification of the new intelligent contract template is determined based on the PageRank algorithm, and then scoring operation is carried out on all intelligent contract templates of the classification to determine the optimal intelligent contract template of the classification.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a block diagram of a blockchain intelligent contract template processing device in accordance with an embodiment of the invention;
FIG. 2 is a detailed block diagram of a blockchain intelligent contract template processing device in accordance with an embodiment of the invention;
FIG. 3 is a block diagram of an example system for blockchain smart contract template processing in accordance with an embodiment of the invention;
FIG. 4 is another block diagram of an example system for blockchain smart contract template processing in accordance with an embodiment of the invention;
FIG. 5 is a flow chart of a blockchain intelligent contract template scene classification in accordance with an embodiment of the invention;
FIG. 6 is a two-dimensional plot of K values versus error rate in a KNN algorithm in accordance with an embodiment of the invention;
FIG. 7 is a two-dimensional discrete diagram of a blockchain intelligent contract template scene classification in accordance with an embodiment of the invention;
FIG. 8 is a flowchart of intelligent contract template optimization based on the example system of FIG. 4;
FIG. 9 is a flow chart of a method of processing a blockchain intelligent contract template in accordance with an embodiment of the invention
Fig. 10 is a schematic block diagram of a system configuration of an electronic device 600 according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Because the audit detection schemes of the existing intelligent contracts are basically manual audit, the manpower cost is high. Based on the above, the embodiment of the invention provides a processing scheme of a blockchain intelligent contract template, which is used for classifying intelligent contracts based on a KNN (K-Nearest Neighbor) algorithm, does not need manual auditing, and reduces labor cost. Embodiments of the present invention are described in detail below with reference to the accompanying drawings.
FIG. 1 is a block diagram of a blockchain intelligent contract template processing device, as shown in FIG. 1, according to an embodiment of the invention, including: a template information acquisition unit 11, a training unit 12, a category prediction unit 13, a category determination unit 14, and a scoring unit 15, wherein:
a template information acquisition unit 11 for acquiring stored smart contract template information in response to receiving a new smart contract template, the stored smart contract template information including: template category.
And the training unit 12 is used for training a classification model based on the KNN algorithm according to the stored intelligent contract module information so as to obtain an optimal adjacent distance K value required by the KNN algorithm.
Specifically, the training unit includes: the training device comprises a data dividing module and a training module, wherein: the data dividing module is used for dividing the stored intelligent contract module information into training set data and test set data; and the training module is used for training the classification model based on the cross-validation device according to the training set data and the testing set data so as to obtain the K value.
A category prediction unit 13 for inputting new smart contract template information into the trained classification model to predict the category of the new smart contract template.
In actual operation, the stored intelligent contract template information further includes: and (5) characteristic information. Accordingly, the category prediction unit 13 inputs the template categories and feature information of the new smart contract template information and the stored smart contract template information to the trained classification model to predict the category of the new smart contract template.
A category determining unit 14, configured to determine, based on a PageRank algorithm, a category of the new smart contract template in response to the predicted category of the new smart contract template being not unique.
In one embodiment, the category determining unit specifically includes: click information acquisition module and category determination module, wherein: the click information acquisition module is used for acquiring the predicted user click information of all intelligent contract templates of each category based on the PageRank algorithm; and the category determining module is used for determining the category of the new intelligent contract template according to the user click information of each category.
Preferably, the category determination module determines the category with the most click information of the user as the category of the new smart contract template.
The KNN algorithm is optimized based on the PageRank algorithm idea, namely, the measurement standard of the classified statistical click quantity is increased on the basis that the KNN algorithm classifies a certain sample according to the attribution categories of K most similar samples in the sample feature space, so that the accuracy of scene classification is enhanced.
And the scoring unit 15 is used for scoring all the intelligent contract templates of the category to determine the optimal intelligent contract template of the category.
In one embodiment, the new smart contract template may be stored into the smart contract template set of the category to which it belongs first; thereafter, the scoring unit 15 performs a scoring operation on each smart contract template of the category to which it belongs, based on a predetermined scoring rule.
The predetermined scoring rules herein may be existing scoring rules for smart contracts, to which the present invention is not limited.
As is apparent from the above description, by training the classification model based on the KNN algorithm according to the stored intelligent contract template information acquired by the template information acquisition unit 11 to obtain the K value required for the KNN algorithm by the training unit 12 upon receiving the new intelligent contract template, then inputting the new intelligent contract template information into the classification model after training, predicting the class of the new intelligent contract template, when the predicted class of the new intelligent contract template is not unique, the class determination unit 14 determines the class of the new intelligent contract template based on the PageRank algorithm, and then the scoring unit 15 performs the scoring operation on all intelligent contract templates of the class to determine the optimal intelligent contract template of the class.
In actual operation, as shown in fig. 2, the apparatus further includes: an updating unit 16 and an updating template processing unit 17, wherein:
an updating unit 16, configured to update the initial smart contract template according to the update information in response to receiving the update information of the stored initial smart contract template, where the update information includes: template Identification (ID). Through the template ID, a corresponding initial smart contract template may be found.
And an update template processing unit 17, configured to determine that the updated smart contract template and the initial smart contract template belong to the same category when the similarity between the feature information of the updated smart contract template and the feature information of the initial smart contract template is within a predetermined range (for example, 60%), otherwise, determine the updated smart contract template as a new smart contract template.
When the updated smart contract template is determined to be a new smart contract template, the updated smart contract template determines the category through the above-described template information acquisition unit 11, training unit 12, category prediction unit 13, category determination unit 14.
In actual operation, the units and the modules may be combined or may be singly arranged, and the present invention is not limited thereto.
For a better understanding of the present invention, embodiments of the present invention are described in detail below in conjunction with the exemplary system architecture shown in fig. 3 and 4.
As shown in fig. 3, in this example system, the following nodes are specifically involved: contract warehouse node, scene classification node, alliance voting node and template statistics report node. Wherein:
and the contract warehouse node is used for storing all intelligent contract templates, storing the templates according to scene classification and storing the optimal template report of subsequent statistics.
The scene classification node optimizes the KNN algorithm based on the click quantity sequencing thought of PageRank, applies the algorithm to machine learning of scene classification, accurately classifies all newly added templates, collects similar samples corresponding to initial templates for modified (or updated) templates, analyzes characteristic value data to form a characteristic data discrete graph, re-analyzes characteristics of the modified templates, and can identify the attribution category of the modified templates to be consistent with the category of the initial templates if 60% of characteristic values are close to the data graph, otherwise, can consider the modified templates as newly added templates, and re-performs classification operation based on the optimized KNN algorithm.
The alliance voting nodes are nodes with voting decision qualification on the blockchain, and the nodes vote for the newly added templates and the existing templates of each scene and select the best template and each template score.
And the template statistics report node performs report statistics on the sorting and scoring of all templates classified by each scene according to the voting result and the classification result, and outputs the report statistics to the contract warehouse node for storage.
Based on the nodes involved in fig. 3, as shown in fig. 4, the exemplary system specifically includes: a contract warehouse storage server 1 at a contract warehouse node, a scene classification server 2 at a scene classification node based on a KNN optimization algorithm, a verification node 3 of alliance voting (corresponding to an alliance voting node), and a non-verification node 4 for template statistics (corresponding to a template statistics report node). The following describes the respective parts in detail.
Contract warehouse storage Server 1
The contract repository storage server 1 is configured to store all intelligent contract templates, store all operation contents of the templates, and simultaneously store the templates in a sorting manner according to classification, scoring, modification time, scoring time, click quantity, and the like, and the specific storage format is shown in the following table 1, and meanwhile, the contract repository storage server 1 packages the templates which do not participate in scene classification and have recently been modified (or updated) but not re-voted, and transmits the packaged templates to the scene classification server 2 based on the KNN optimization algorithm.
Contract ID Version number Author's authors Classification Update time Scoring of Time of scoring Click volume
Contract1 1.0.0 User1 Folk life tracing 2019.09.09 80.23 2019.09.09 100
Contract2 1.0.2 User2 Funds management 2019.06.01 90.15 2019.06.01 3000
Contract3 1.0.0 User1 Supply chain finance 2020.03.07 50.12 2020.03.07 5000
Contract4 2.0.0 User3 Unclassified by classification 2020.07.19 Un-scored Un-scored 0
Contract5 1.0.1 User4 Audit supervision 2018.11.11 88.44 2018.11.11 94
Contract6 1.0.2 User2 Trade finance 2017.01.01 75.00 2017.01.01 46666
……… ……… ……… ……… ……… ……… ……… ………
TABLE 1
(II) scene classification server 2 based on KNN optimization algorithm
The scene classification server 2 based on the KNN optimization algorithm is configured to receive the template transmitted by the contract repository storage server 1, execute the flow as shown in fig. 5, and perform scene classification:
step 501: the template is received, if it is a new version, the template data is the full code content, the modified version (i.e., an updated version of the existing template), and the template data is the delta code content.
Step 502: and removing the new template, namely randomly dividing all template data of the existing warehouse into training set data and test set data of 5:1, and calculating a K value between 1 and 50 for the test set template by a cross verification method in sklearn (a machine learning library) according to six classification labels of supply chain finance, digital assets, folk traceability, asset management, audit supervision and trade finance, and label attributes of amount, mechanism category, government participation, alliance party number and the like. In actual operation, the K value and the Error rate may be plotted as a two-dimensional line graph as shown in fig. 6, and the K value when the Error value is the lowest is output, and this value is used for the proximity distance value of the KNN algorithm of step 503.
As shown in fig. 6, the Error rate calculation is performed based on all templates of the existing warehouse, and it is apparent that the Error rate Error value is minimum at k=25. In actual operation, the main codes for the calculation of the K value are as follows:
step 503: drawing a two-dimensional scatter diagram of all template data (including new templates) and tag arrays based on certain two attributes (in actual operation, other numbers of attributes can be selected) of tag attributes based on a KNN algorithm, for example, using KNN algorithm parameter definition shown in the following table 2, firstly, by importing all template data in a warehouse, adopting the first two features (other features can be selected) in a feature array, namely amount and government participation, using K=25, creating an instance of a KNN classifier, and training all templates; the trained template values are then classified for prediction, and the results are placed in a two-dimensional discrete map as shown in fig. 7.
Table 2 in actual operation, specific classification prediction codes are as follows:
step 504: according to the two-dimensional discrete diagram of fig. 7 drawn in step 503, most of the classification closest to the new template is the audit supervision class, and thus, the new template may be classified as the audit supervision class, and if there are a plurality of classifications closest to the new template, step 505 is required.
Step 505: when the new template cannot be accurately classified, the classification standard of the KNN algorithm can be optimized based on the PageRank algorithm idea, the templates near the new template are subjected to click quantity summation, the class with the largest click quantity is the class of the new template, and the scene classification of the new template is output.
(III) authentication node 3 for alliance voting
The verification node 3 of the alliance voting receives the classification result of the scene classification server 2 based on the KNN optimization algorithm and sends out an alliance voting scoring flow; then invoking the alliance voting intelligent contract, triggering the voting flow, and notifying all alliance parties of scoring; then, all alliances receive scoring invitation, and scoring is carried out between 0 and 100 according to the maturity condition of contract codes; after scoring is completed, outputting non-verification nodes 4 which are equally divided to the template statistical report.
(IV) non-validated node 4 for template statistics
The non-verification node 4 is mainly responsible for receiving the output result of the verification node 3 for alliance voting, and records the content including: the information of scene classification, alliance voting score, classification time, scoring time and the like of the new template is integrated into a report form and returned to the contract warehouse storage server 1.
FIG. 8 is a flow chart for intelligent contract template optimization based on the example system of FIG. 4, as shown in FIG. 8, the flow including:
step 801: the request of the contract template on-shelf or upgrading is accessed, and the template can be on-shelf or upgraded through a contract warehouse management interface of a BaaS (Backend as a Service, back-end as a service) platform;
step 802: determining whether the template is a new template or maintenance of an existing template according to whether a contract Identification (ID) already exists in the database, if so, performing step 803, and if so, performing step 804;
step 803: the new template, marked uncategorized and uncategorized, performs step 805;
step 804: maintenance of the old template, marking to be reclassified and to be reclassified, step 805 is performed;
step 805: the scene classification server calculates the optimal value of K according to all the existing template data based on the received templates, acquires the K value with the lowest Error value Error according to the calculation result, and outputs the K value;
step 806: according to the K value with the minimum machine learning error rate output in the step 805, learning a new template, drawing the scatter diagram of all templates, obtaining the scene classification of the most samples in the K range, and determining the classification of the new template;
step 807: judging whether the output classifications are multiple, if yes, executing step 808, if not, executing step 809;
step 808: the new template classification relates to a plurality of classifications, if the classification cannot be accurately performed, calculating the clicking amount of the templates of similar categories in the scatter diagram by using the PageRank idea, and the template category with the largest clicking amount is the scene classification of the new template;
step 809: initiating alliance voting, scoring the newly added templates, waiting for all alliance parties to finish scoring, outputting average score, sequencing the templates of all scene classifications, and outputting the best template of each classification;
step 810: and feeding back the grading result of the best template to the contract warehouse storage server.
According to the embodiment of the invention, when the template is changed or a new template is put in storage, the learning process of the optimal template and the optimal K value selection of the KNN are automatically triggered, and the accurate classification of the new template can be ensured based on the optimized KNN algorithm of the PageRank algorithm.
Based on similar inventive concepts, the embodiment of the invention also provides a processing method of the blockchain intelligent contract template, and the method is preferably applicable to the processing device of the blockchain intelligent contract template.
FIG. 9 is a flow chart of a method of processing a blockchain smart contract template, as shown in FIG. 9, according to an embodiment of the invention, the method including:
step 901, in response to receiving a new smart contract template, obtaining stored smart contract template information, the stored smart contract template information comprising: template category.
And step 902, training a classification model based on the KNN algorithm according to the stored intelligent contract module information to obtain an optimal proximity distance K value required by the KNN algorithm.
Specifically, the stored intelligent contract module information is divided into training set data and testing set data; and then training the classification model according to the training set data and the testing set data based on a cross-validation method to obtain the K value.
In step 903, the new smart contract template information is input to the trained classification model to predict the class of the new smart contract template.
In actual operation, the stored intelligent contract template information further includes: and (5) characteristic information. Accordingly, the template category and feature information of the new smart contract template information and the stored smart contract template information may be input to the trained classification model to predict the category of the new smart contract template.
In step 904, responsive to the predicted class of the new smart contract template not being unique, a class of the new smart contract template is determined based on the PageRank algorithm.
Specifically, user click information of all intelligent contract templates of each predicted category can be obtained firstly based on a PageRank algorithm; and then determining the category of the new intelligent contract template according to the user click information of each category.
In step 905, scoring operation is performed on all the smart contract templates of the category to determine the optimal smart contract template of the category.
Specifically, the new intelligent contract template can be stored into the intelligent contract template set of the category to which the new intelligent contract template belongs; and then, scoring each intelligent contract template of the category to which the intelligent contract template belongs based on a preset scoring rule.
From the above description, it can be seen that, by training a classification model based on a KNN algorithm according to the acquired stored intelligent contract template information when a new intelligent contract template is received, so as to obtain a K value required by the KNN algorithm, then inputting the new intelligent contract template information into the trained classification model, predicting the category of the new intelligent contract template, when the predicted category of the new intelligent contract template is not unique, determining the category of the new intelligent contract template based on the PageRank algorithm, and then performing scoring operation on all intelligent contract templates of the category to determine the optimal intelligent contract template of the category.
In one embodiment, when update information for a stored initial smart contract template is received, the initial smart contract template is updated according to the update information, the update information including: and the template identifier can find the corresponding initial intelligent contract template. And when the similarity between the characteristic information of the updated intelligent contract template and the characteristic information of the initial intelligent contract template is within a preset range, determining that the updated intelligent contract template and the initial intelligent contract template belong to the same category, otherwise, determining the updated intelligent contract template as a new intelligent contract template, and executing the classification operation of the steps 901-904.
The specific implementation process of each step may be referred to the description in the above device embodiments, and will not be repeated here.
The present embodiment also provides an electronic device, which may be a desktop computer, a tablet computer, a mobile terminal, or the like, and the present embodiment is not limited thereto. In this embodiment, the electronic device may be implemented by referring to the method embodiment and the processing device embodiment of the blockchain intelligent contract template, and the contents thereof are incorporated herein, and the repetition is omitted.
Fig. 10 is a schematic block diagram of a system configuration of an electronic device 600 according to an embodiment of the present invention. As shown in fig. 10, the electronic device 600 may include a central processor 100 and a memory 140; memory 140 is coupled to central processor 100. Notably, the diagram is exemplary; other types of structures may also be used in addition to or in place of the structures to implement telecommunications functions or other functions.
In one embodiment, the processing functionality of the blockchain smart contract template may be integrated into the central processor 100. Wherein the central processor 100 may be configured to control as follows:
in response to receiving the new smart contract template, stored smart contract template information is obtained, the stored smart contract template information comprising: template category;
training a classification model based on a K nearest neighbor KNN algorithm according to the stored intelligent contract module information to obtain an optimal adjacent distance K value required by the KNN algorithm;
inputting the new intelligent contract template information into the trained classification model to predict the category of the new intelligent contract template;
determining a category of the new smart contract template based on a webpage ranking PageRank algorithm in response to the predicted category of the new smart contract template being non-unique;
scoring all intelligent contract templates of the belonging category to determine the optimal intelligent contract template of the belonging category.
As can be seen from the above description, the electronic device provided in the embodiment of the present invention trains a classification model based on a KNN algorithm according to the acquired stored intelligent contract template information when a new intelligent contract template is received, so as to obtain a K value required by the KNN algorithm, then inputs the new intelligent contract template information into the trained classification model, predicts the class of the new intelligent contract template, determines the class of the new intelligent contract template based on the PageRank algorithm when the predicted class of the new intelligent contract template is not unique, and then performs a scoring operation on all intelligent contract templates of the class to determine an optimal intelligent contract template of the class.
In another embodiment, the processing device of the blockchain smart contract template may be configured separately from the central processor 100, for example, the processing device of the blockchain smart contract template may be configured as a chip connected to the central processor 100, and the processing function of the blockchain smart contract template is implemented under the control of the central processor.
As shown in fig. 10, the electronic device 600 may further include: a communication module 110, an input unit 120, an audio processing unit 130, a display 160, a power supply 170. It is noted that the electronic device 600 need not include all of the components shown in fig. 10; in addition, the electronic device 600 may further include components not shown in fig. 10, to which reference is made to the related art.
As shown in fig. 10, the central processor 100, sometimes also referred to as a controller or operational control, may include a microprocessor or other processor device and/or logic device, which central processor 100 receives inputs and controls the operation of the various components of the electronic device 600.
The memory 140 may be, for example, one or more of a buffer, a flash memory, a hard drive, a removable media, a volatile memory, a non-volatile memory, or other suitable device. The information about failure may be stored, and a program for executing the information may be stored. And the central processor 100 can execute the program stored in the memory 140 to realize information storage or processing, etc.
The input unit 120 provides an input to the central processor 100. The input unit 120 is, for example, a key or a touch input device. The power supply 170 is used to provide power to the electronic device 600. The display 160 is used for displaying display objects such as images and characters. The display may be, for example, but not limited to, an LCD display.
The memory 140 may be a solid state memory such as Read Only Memory (ROM), random Access Memory (RAM), SIM card, or the like. But also a memory which holds information even when powered down, can be selectively erased and provided with further data, an example of which is sometimes referred to as EPROM or the like. Memory 140 may also be some other type of device. Memory 140 includes a buffer memory 141 (sometimes referred to as a buffer). The memory 140 may include an application/function storage 142, the application/function storage 142 for storing application programs and function programs or a flow for executing operations of the electronic device 600 by the central processor 100.
The memory 140 may also include a data store 143, the data store 143 for storing data, such as contacts, digital data, pictures, sounds, and/or any other data used by the electronic device. The driver storage 144 of the memory 140 may include various drivers of the electronic device for communication functions and/or for performing other functions of the electronic device (e.g., messaging applications, address book applications, etc.).
The communication module 110 is a transmitter/receiver 110 that transmits and receives signals via an antenna 111. A communication module (transmitter/receiver) 110 is coupled to the central processor 100 to provide an input signal and receive an output signal, which may be the same as in the case of a conventional mobile communication terminal.
Based on different communication technologies, a plurality of communication modules 110, such as a cellular network module, a bluetooth module, and/or a wireless local area network module, etc., may be provided in the same electronic device. The communication module (transmitter/receiver) 110 is also coupled to a speaker 131 and a microphone 132 via an audio processor 130 to provide audio output via the speaker 131 and to receive audio input from the microphone 132 to implement usual telecommunication functions. The audio processor 130 may include any suitable buffers, decoders, amplifiers and so forth. In addition, the audio processor 130 is also coupled to the central processor 100 so that sound can be recorded locally through the microphone 132 and so that sound stored locally can be played through the speaker 131.
The embodiment of the invention also provides a computer readable storage medium, on which a computer program is stored, which when being executed by a processor, is used for realizing the steps of the processing method of the blockchain intelligent contract template.
In summary, the embodiment of the invention provides a combination scheme of a KNN optimization algorithm and a blockchain technology based on machine learning, so as to realize contract template optimization of different scene categories. Namely, the KNN algorithm is optimized based on the algorithm idea of PageRank, the algorithm is used for accurately classifying scenes of all targets of a contract warehouse, and intelligent contract templates of different applicable scenes are optimized by combining alliance voting of block chains, so that the template quality is continuously improved, the development threshold and the manual auditing cost are reduced, and the intelligent contract code quality is improved.
Preferred embodiments of the present invention are described above with reference to the accompanying drawings. The many features and advantages of the embodiments are apparent from the detailed specification, and thus, it is intended by the appended claims to cover all such features and advantages of the embodiments which fall within the true spirit and scope thereof. Further, since numerous modifications and changes will readily occur to those skilled in the art, it is not desired to limit the embodiments of the invention to the exact construction and operation illustrated and described, and accordingly, all suitable modifications and equivalents may be resorted to, falling within the scope thereof.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The principles and embodiments of the present invention have been described in detail with reference to specific examples, which are provided to facilitate understanding of the method and core ideas of the present invention; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present invention, the present description should not be construed as limiting the present invention in view of the above.

Claims (11)

1. A method for processing a blockchain intelligent contract template, the method comprising:
in response to receiving the new smart contract template, stored smart contract template information is obtained, the stored smart contract template information comprising: template category;
training a classification model based on a K nearest neighbor KNN algorithm according to the stored intelligent contract module information to obtain an optimal adjacent distance K value required by the KNN algorithm;
inputting the new intelligent contract template information into the trained classification model to predict the category of the new intelligent contract template;
determining a category of the new smart contract template based on a webpage ranking PageRank algorithm in response to the predicted category of the new smart contract template being non-unique;
scoring all intelligent contract templates of the category to determine an optimal intelligent contract template of the category;
in response to receiving update information for a stored initial smart contract template, updating the initial smart contract template according to the update information, the update information comprising: a template identification;
and when the similarity of the characteristic information of the updated intelligent contract template and the characteristic information of the initial intelligent contract template is within a preset range, determining that the updated intelligent contract template and the initial intelligent contract template belong to the same category, otherwise, determining the updated intelligent contract template as a new intelligent contract template.
2. The method of claim 1, wherein training a KNN algorithm-based classification model based on the stored smart contract module information to obtain an optimal proximity K value required by the KNN algorithm comprises:
dividing the stored intelligent contract module information into training set data and test set data;
and training the classification model according to the training set data and the testing set data based on a cross-validation method to obtain the K value.
3. The method of claim 1, wherein the stored smart contract template information further comprises: feature information, inputting new intelligent contract template information into the trained classification model to predict the category of the new intelligent contract template includes:
and inputting the template category and the characteristic information of the new intelligent contract template information and the stored intelligent contract template information into a trained classification model to predict the category of the new intelligent contract template.
4. The method of claim 1, wherein responsive to the predicted category of the new smart contract template being non-unique, determining the category of the new smart contract template based on a PageRank algorithm comprises:
acquiring predicted user click information of all intelligent contract templates of each category based on a PageRank algorithm;
and determining the category of the new intelligent contract template according to the user click information of each category.
5. The method of claim 1, wherein scoring all intelligent contract templates of a category comprises:
storing the new intelligent contract template into an intelligent contract template set of the category to which the new intelligent contract template belongs;
and scoring each intelligent contract template of the category to which the intelligent contract template belongs based on a preset scoring rule.
6. A processing apparatus for a blockchain intelligent contract template, the apparatus comprising:
a template information acquisition unit configured to acquire stored smart contract template information in response to receiving a new smart contract template, the stored smart contract template information including: template category;
the training unit is used for training a classification model based on the KNN algorithm according to the stored intelligent contract module information so as to obtain an optimal adjacent distance K value required by the KNN algorithm;
the category prediction unit is used for inputting the information of the new intelligent contract template into the trained classification model so as to predict the category of the new intelligent contract template;
a category determining unit for determining a category of the new smart contract template based on a PageRank algorithm in response to the predicted category of the new smart contract template being not unique;
the scoring unit is used for scoring all intelligent contract templates of the category to determine the optimal intelligent contract template of the category;
an updating unit, configured to update an initial smart contract template stored in response to receiving update information of the initial smart contract template according to the update information, where the update information includes: a template identification;
and the updated template processing unit is used for determining that the updated intelligent contract template and the initial intelligent contract template belong to the same category when the similarity of the characteristic information of the updated intelligent contract template and the characteristic information of the initial intelligent contract template is within a preset range, otherwise, determining the updated intelligent contract template as a new intelligent contract template.
7. The apparatus of claim 6, wherein the training unit comprises:
the data dividing module is used for dividing the stored intelligent contract module information into training set data and test set data;
and the training module is used for training the classification model based on the cross-validation device according to the training set data and the testing set data so as to obtain the K value.
8. The apparatus of claim 6, wherein the stored smart contract template information further comprises: the category prediction unit is specifically configured to:
and inputting the template category and the characteristic information of the new intelligent contract template information and the stored intelligent contract template information into a trained classification model to predict the category of the new intelligent contract template.
9. The apparatus according to claim 6, wherein the category determining unit includes:
the click information acquisition module is used for acquiring the predicted user click information of all intelligent contract templates of each category based on the PageRank algorithm;
and the category determining module is used for determining the category of the new intelligent contract template according to the user click information of each category.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the method of any one of claims 1 to 5 when the program is executed by the processor.
11. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method according to any one of claims 1 to 5.
CN202011144874.6A 2020-10-23 2020-10-23 Processing method and device of intelligent contract template of block chain Active CN112230984B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011144874.6A CN112230984B (en) 2020-10-23 2020-10-23 Processing method and device of intelligent contract template of block chain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011144874.6A CN112230984B (en) 2020-10-23 2020-10-23 Processing method and device of intelligent contract template of block chain

Publications (2)

Publication Number Publication Date
CN112230984A CN112230984A (en) 2021-01-15
CN112230984B true CN112230984B (en) 2023-09-08

Family

ID=74110503

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011144874.6A Active CN112230984B (en) 2020-10-23 2020-10-23 Processing method and device of intelligent contract template of block chain

Country Status (1)

Country Link
CN (1) CN112230984B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109816021A (en) * 2019-01-28 2019-05-28 网易(杭州)网络有限公司 Intelligent contract processing method and processing device, system, storage medium and electronic equipment
CN110555299A (en) * 2019-08-01 2019-12-10 平安科技(深圳)有限公司 electronic contract signing and storing method and device, computer equipment and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109816021A (en) * 2019-01-28 2019-05-28 网易(杭州)网络有限公司 Intelligent contract processing method and processing device, system, storage medium and electronic equipment
CN110555299A (en) * 2019-08-01 2019-12-10 平安科技(深圳)有限公司 electronic contract signing and storing method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN112230984A (en) 2021-01-15

Similar Documents

Publication Publication Date Title
CN107071193B (en) Method and device for accessing interactive response system to user
CN111932269B (en) Equipment information processing method and device
CN109690581B (en) User guidance system and method
CN108932646B (en) User tag verification method and device based on operator and electronic equipment
KR102144126B1 (en) Apparatus and method for providing information for enterprise
CN104424284A (en) Information processing method and education platform
CN110717509A (en) Data sample analysis method and device based on tree splitting algorithm
CN116414815A (en) Data quality detection method, device, computer equipment and storage medium
CN110288468B (en) Data feature mining method and device, electronic equipment and storage medium
US11941502B2 (en) Manifold-anomaly detection with axis parallel
CN106294406A (en) A kind of method and apparatus accessing data for processing application
CN113656699A (en) User feature vector determination method, related device and medium
CN112230984B (en) Processing method and device of intelligent contract template of block chain
CN115562960A (en) Application optimization method and system of intelligent equipment
CN111768306B (en) Risk identification method and system based on intelligent data analysis
CN111160929B (en) Method and device for determining client type
CN114021716A (en) Model training method and system and electronic equipment
CN115114415A (en) Question-answer knowledge base updating method and device, computer equipment and storage medium
CN111401395A (en) Data processing method, terminal equipment and storage medium
CN115713354A (en) Mobile banking user loss early warning method and system
CN118013421A (en) Classification model training method, classification method, device and equipment
CN117196801A (en) Analysis method and device for banking activity data, computer equipment and storage medium
CN115578186A (en) Credit limit prediction method, device, computer equipment, storage medium and product
CN115689349A (en) Digital music value evaluation method adopting classification indexes and related device
CN114118059A (en) Sample statement processing method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant