Abstract syntax tree-based guided programming exercise system for multiple programming languages
By constructing an ASTPB tree with location information and using a programming practice system with layer convolution and Tide models, the problem of existing platforms being unable to provide personalized recommendations and knowledge tracking is solved, achieving more accurate programming problem recommendations and knowledge tracking while reducing computational overhead.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG UNIV
- Filing Date
- 2023-11-16
- Publication Date
- 2026-07-14
AI Technical Summary
Existing programming practice platforms fail to fully leverage individual learner differences, lack AI-based personalized question recommendations, and current models cannot effectively utilize the tree structure information of programming code for knowledge tracking.
This system employs a multi-language guided programming practice system based on abstract syntax trees. By constructing an ASTPB tree with positional information, it captures the local and global relative positional relationships within the tree. It uses a pre-trained ASTPB model to extract programming code features and combines layer convolution and Tide models for feature encoding, thereby achieving more accurate knowledge tracking and personalized recommendations.
It improves the personalized recommendation effect for learners, reduces the server computing load, is highly adaptable, and can dynamically update the model to adapt to the knowledge network characteristics of more disciplines and languages, thereby improving the accuracy and efficiency of knowledge tracking.
Smart Images

Figure CN117762384B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer education, specifically relating to a guided programming practice system for multiple programming languages based on abstract syntax trees. Background Technology
[0002] Learning is fundamentally a reflection of human cognition, which is a highly complex process. Two particularly relevant themes in cognitive science are that human thinking and its learning processes are recursive and analogically driven. The knowledge tracing problem was first proposed and extensively studied in the field of intelligent tutoring. Faced with these challenges, the primary goal of knowledge tracing is to build a model that, while perhaps not capturing all cognitive processes, is extremely useful.
[0003] Knowledge tracking, or modeling a student's knowledge as they interact with coursework, is a well-established problem in computer-assisted education. It models a student's knowledge over a period of time, allowing the model to predict their performance in future interactions. Improvements in this task mean that new learning resources can be recommended based on individual student needs, skipping or postponing content predicted to be too easy or too difficult. Students receiving one-on-one human tutoring show an average improvement of two standard deviations in learning outcomes compared to those without, and human-adjusted intelligent tutoring systems attempting customized content have yielded effective results. Machine learning solutions can provide high-quality, personalized instruction to anyone in the world free of charge. The knowledge tracking problem is inherently challenging because human learning is based on the complexity of the human brain and human knowledge. Effectively modeling students' knowledge has a significant educational impact, but the task faces many inherent challenges, one of which is knowledge tracking for programming problems. The additional information inherent in programming problems cannot be utilized in traditional knowledge tracking models.
[0004] Deep learning was initially applied to knowledge tracing by Chris Piech in his book *Deep KnowledgeTracing*, using recurrent neural networks. Over the past few decades, deep learning has made significant strides in computer vision, natural language processing, and speech processing, with several methods proposed for extracting tree structures. A tree is a specific type of graph that can be processed using graph-based methods. However, these methods typically incur higher computational costs compared to techniques specifically designed for trees. Tree structures have applications across various fields, with source code representation being one of the most common.
[0005] Traditional knowledge tracing tasks only used students' questions or question text as training input. However, for currently popular programming practice platforms, a submitted and approved code can also represent the question. Furthermore, due to the individual differences in code submitted by multiple learners, these submissions can more comprehensively cover the knowledge points (explicit and implicit) involved in the question. Current knowledge tracing algorithms still need further development in processing this type of code.
[0006] Previous models based on LSTM, tree-based convolutional neural networks (TCNN), etc., could not fully utilize the hierarchical structure of trees to analyze source code, nor could they use the hierarchical structure of AST to capture rich semantic information, thus failing to achieve more effective code analysis and downstream tasks.
[0007] Current programming practice platforms generally use a flat, modular display of problem selections, lacking AI-based problem recommendation algorithms. While such platforms can provide teachers with standardized problem assignments, they are limited in their ability to offer personalized recommendations based on individual learners' differences. Summary of the Invention
[0008] In view of the above, the purpose of this invention is to provide a guided programming practice system for multiple programming languages based on Abstract Syntax Trees (ASTPB). By constructing an ASTPB tree with positional information, it focuses on capturing local and global relative positional relationships within the tree. ASTPB trees achieve excellent learning accuracy in code clone detection and code classification tasks. In knowledge tracing tasks, by using ASTPB, learners' programming practice submissions are submitted for more complete and accurate knowledge tracing, solving the problem that programming problems are difficult to effectively utilize in knowledge tracing systems. At the same time, the computational load required in inference tasks is relatively small, and the requirements for server computing performance are low.
[0009] To achieve the above-mentioned objectives, the embodiment provides a guided programming practice system for multiple programming languages based on abstract syntax trees, comprising:
[0010] The programming code feature extraction module is used to extract feature representations of programming code using a pre-trained ASTPB model. Specifically, the programming code of the programming problem is constructed into an abstract syntax tree with positional information. The nodes of the abstract syntax tree include attribute information and positional information. Multi-layer convolution is performed on the abstract syntax tree to enhance the positional relationship features of neighboring nodes. Feature encoding is performed on the nodes after convolution to obtain the feature representation of the programming problem.
[0011] The knowledge tracking module records learners' learning progress on historical programming problems. This learning progress includes feature representations of the programming problems. The knowledge tracking model is used to predict the accuracy rate of completing unfinished programming problems based on the learning progress.
[0012] The recommendation module categorizes all programming problems into several levels based on course chapters and knowledge relevance. The programming problems in each level are highly relevant to the corresponding subject and have adjacent learning sequences. Furthermore, the knowledge points of the next level include those of the previous level. During the recommendation process, the module identifies the programming problem with the lowest completion accuracy and automatically recommends other programming problems in the same level. If the average completion accuracy of the programming problems in the current level exceeds a threshold, the module then recommends programming problems for the next level.
[0013] Preferably, constructing the programming code of the programming problem into an abstract syntax tree with positional information includes:
[0014] An abstract syntax tree is generated for the programming code of each programming problem. Each node in the abstract syntax tree contains specific information marked in the source code and attribute words of node features. The word vectors of all attribute words of each node are accumulated and averaged to obtain the attribute vector of the node.
[0015] Each node is bound with position information based on its position in the abstract syntax tree. This position information includes four parameters: the depth of the node in the abstract syntax tree, the index of the node in the current level of the abstract syntax tree, the depth of the node's parent node in the abstract syntax tree, and the index of the node's parent node in the current level of the abstract syntax tree.
[0016] The position information of each node is encoded to obtain a position vector, making the dimension of the position vector the same as that of the attribute vector. The dimensions of the position vector and the attribute vector are superimposed to obtain the initial vector of the node.
[0017] Preferably, the position information of each node is encoded using the following formula to obtain a position vector, such that the dimension of the position vector is the same as that of the attribute vector:
[0018]
[0019]
[0020] Where value represents the value of each parameter in the location information, Pos (value,2i) This represents the encoded value at an even position in the encoded vector for each parameter value, x. dim This represents the dimension of the attribute vector, where i represents the position count, with values of 0, 1, 2, ..., x. dim / 8;
[0021] The location vector is obtained by concatenating the encoded vectors of the four parameter values.
[0022] Preferably, the initial vector of the node is obtained by superimposing the position vector and the attribute vector in terms of dimensions, as expressed by the formula:
[0023] W n " ode =PB+W n ′ ode
[0024] Among them, W n " ode Let PB represent the initial vector of a node, and W represent the position vector of the node. n ′ ode A vector representing the attributes of a node.
[0025] Preferably, the step of performing multi-level convolution on the abstract syntax tree to enhance the positional relationship features of neighboring nodes includes:
[0026]
[0027]
[0028] Where lfn represents the depth of the convolutional layer, and l represents the layer index. Conv represents the vector representation of each node after convolution. (l,j) W represents the j-th convolutional kernel in the l-th layer of the convolutional operation, cn represents the number of nodes in the l-th layer, and W represents the number of nodes in the l-th layer. n " odeat(l,j) W represents the initial vector of the j-th node in the l-th layer during the convolution operation. l levelfuse This represents the vector representation after the l-th convolution layer.
[0029] Preferably, the step of performing feature encoding on the nodes after convolution to obtain the feature representation of the programming problem includes:
[0030] The abstract syntax tree after convolution is routed to obtain the vector representation of the traversed nodes, and a node sequence composed of vector representations is formed.
[0031] The Tide model is used to extract feature representations of node sequences. Specifically, the node sequences are compressed to obtain fused position vectors. Then, the fused position vectors are encoded and decoded to obtain decoded features. The decoded features and the compressed fused position vectors are superimposed and then activated and linearly mapped to obtain the final feature representation of the encoded question.
[0032] Preferably, the compression process is implemented using ResidualBlock, and the specific process of ResidualBlock includes:
[0033] V fp3 =Relu(W3V) route +b3)
[0034] V fp2 =Dropout(W2V fp3 +b2)
[0035] V fp1 =W1V route +b1
[0036] V fp =LayerNorm(V fp1 +V fp2 )
[0037] Among them, V route V represents a sequence of nodes. fp3 V fp2 and V fp1 All represent intermediate results, ReLU represents ReLU activation, Dropout represents Dropout operation, LayerNorm represents layer normalization, W3, W2, W1 represent weight parameters, b3, b2, b1 represent bias parameters, and V represents intermediate results. fp This represents the fused position vector.
[0038] Preferably, the learning situation also includes the question number and the question completion rate.
[0039] Compared with the prior art, the beneficial effects of the present invention include at least the following:
[0040] (1) This invention uniquely makes full use of learners’ code information and uses a recommendation algorithm to dynamically recommend new questions to learners. In contrast, most previous learning systems required teachers to manually assign fixed questions. This invention has a better effect on solving the problem of inefficient learning caused by individual differences among learners.
[0041] (2) This invention uses a pre-trained ASTPB model for feature extraction, which has a strong adaptability to the cold start problem. Furthermore, during system operation, the current model can be dynamically updated to adapt to the knowledge network characteristics of more disciplines and languages.
[0042] (3) The present invention is simple and feasible. The ASTPB model itself can be used as a tree structure feature extraction and can be used as an enhancement module to complete a variety of tasks that require tree structure feature extraction, such as code clone detection tasks and code classification tasks.
[0043] (4) The present invention uses the Tide model and UTKT model with smaller computational load for feature extraction and knowledge tracking. Compared with the previous feature extraction and knowledge tracking based on graph neural network, RNN and LSTM models, it has smaller computational overhead and helps to reduce server load. Attached Figure Description
[0044] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0045] Figure 1 This is a schematic diagram of the structure of the guided programming practice system provided in the embodiment;
[0046] Figure 2 This is a schematic diagram of the ASTPB model structure provided in the embodiment;
[0047] Figure 3 This is a schematic diagram of the ResidualBlock structure provided in the embodiment;
[0048] Figure 4 This is a schematic diagram of the matrix masking provided in the embodiment. Detailed Implementation
[0049] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not limit the scope of protection of this invention.
[0050] To address the technical problem that existing knowledge tracing methods cannot leverage the unique properties of programming problems, such as... Figure 1 As shown in the figure, the present invention provides a guided programming practice system for multiple programming languages based on abstract syntax trees, including a programming code feature extraction module, a knowledge tracking module, and a recommendation module.
[0051] In this embodiment, the programming code feature extraction module is used to extract the feature representation of the programming code using a pre-trained ASTPB model. Specifically, the programming code of the programming problem is constructed into an abstract syntax tree (AST) with positional information. The nodes of the abstract syntax tree include attribute information and positional information. Multi-layer convolution is performed on the abstract syntax tree to enhance the positional relationship features of neighboring nodes. Feature encoding is performed on the nodes after convolution to obtain the feature representation of the programming problem.
[0052] In one implementation, such as Figure 2 As shown, the programming code for the programming problem is constructed into an abstract syntax tree with positional information, including:
[0053] (1) An abstract syntax tree (AST) is generated for the programming code of each programming problem. Specifically, the AST is generated by performing syntactic analysis on the programming code, including using the javalang tool to process Java-style programming code and the pycparser tool to process C and C++-style programming code. Each node in the AST contains specific information marked in the source code and attribute words of node features. The attribute words of each node are encoded using the vec2word technique to obtain the word vector W of each node. node (k) is the average of the word vectors of all attribute words for each node, which is used as the attribute vector of the node. This can be expressed by the formula:
[0054]
[0055] Among them, W′ node Represents the attribute vector of a node, with a fixed size of x. dim W node (a) represents the word vector of the a-th attribute word included in the node, where the value of a is 1 - node. attrs node attrs This represents the total number of attribute words in a node. attrs The actual value of x is usually controlled within the integer range of [1, 4]. dim The value should be controlled within the range of 40, 80, and 120.
[0056] (2) Bind location information to each node according to its position in the AST.
[0057] Positional information within the Abstract Syntax Tree (AST) is indeed crucial for capturing the structural features of code. Previous methods primarily focused on the routing phase for capturing AST structure, which often requires additional parameters and increases model complexity. This additional routing task also puts pressure on the overall accuracy of the model. To address this issue, the ASTPB model of this invention focuses on utilizing positional information binding as a more efficient and effective method for capturing positional information within the AST. This positional information includes four parameters: the depth of the node in the AST, the node's index within the current level of the AST, the depth of the node's parent node in the AST, and the index of the node's parent node within the current level of the AST, denoted by (Pos). selfdepth Pos selfindex Pos parentdepth Pos parentindex ),
[0058] (3) Encode the position information of each node to obtain a position vector so that the dimension of the position vector is the same as that of the attribute vector. Specifically, the following formula is used:
[0059]
[0060]
[0061] Where value represents the value of each parameter in the location information, Pos (value,2i) This represents the encoded value at an even position in the encoded vector for each parameter value, x. dim This represents the dimension of the attribute vector, where i represents the position count, with values of 0, 1, 2, ..., x. dim / 8; Concatenate the encoded vectors of the four parameter values to obtain the location vector PB of the location information.
[0062] (4) The initial vector of the node is obtained by superimposing the dimensions of the position vector and the attribute vector. Specifically, the following formula is used:
[0063] W n " ode =PB+W n ′ ode
[0064] Among them, W n " ode The initial vector represents the node. The above operations construct a tree-structured representation. This tree structure captures the relationships between nodes, considering both the attributes of individual nodes and their relative positions (local and global) within the tree.
[0065] To obtain the local relationships between nodes, such as Figure 2 As shown, this embodiment of the invention uses convolution to transform a tree structure into a new tree structure, that is, performing multi-level convolution on the abstract syntax tree to enhance the positional relationship features of neighboring nodes. For each node of the newly generated tree structure... Obtained through the following methods:
[0066]
[0067]
[0068] Where lfn represents the depth of the convolutional layer, and l represents the layer index. Conv represents the vector representation of each node after convolution. (l,j) W represents the j-th convolutional kernel in the l-th layer of the convolutional operation, cn represents the number of nodes in the l-th layer, and W represents the number of nodes in the l-th layer. n " odeat(l,j) W represents the initial vector of the j-th node in the l-th layer during the convolution operation. l levelfuseThis represents the vector representation after the l-th convolutional layer. In the ASTPB model, embodiments of this invention generally choose lfn = 1 or lfn = 2, thus maintaining 2-3 convolutional layers, which can capture local information while keeping the overhead low.
[0069] like Figure 2 As shown, after performing convolutional layers, feature encoding is performed on the nodes after convolution to obtain the feature representation of the programming problem, specifically including:
[0070] First, a route traversal is performed on the abstract syntax tree after convolution to obtain the vector representation of the traversed nodes, and a node sequence V composed of vector representations is formed. route The specific routing uses a preorder traversal of a tree structure, similar to human reading habits, to perform the routing operation. After routing, a matrix sequence is obtained, encoded by the code through all the above steps. This matrix sequence can be equivalent to a time series of indefinite length, namely the point sequence V. route The node sequence V route The shape is (fused) num ,x dim Among them, fused num x represents the total number of nodes traversed in the route. dim The vector representing a node represents its dimension.
[0071] Then, the Tide model is used to extract feature representations of the node sequence, specifically including compressing the node sequence to obtain fused position vectors, using methods such as... Figure 3 The ResidualBlock shown implements compression processing, and the specific process includes:
[0072] V fp3 =Relu(W3V) route +b3)
[0073] V fp2 =Dropout(W2V fp3 +b2)
[0074] V fp1 =W1V route +b1
[0075] V fp =LayerNorm(V fp1 +V fp2 )
[0076] Among them, V route V represents a sequence of nodes. fp3 V fp2 and V fp1All represent intermediate results, ReLU represents ReLU activation, Dropout represents Dropout operation, LayerNorm represents layer normalization, W3, W2, W1 represent weight parameters, b3, b2, b1 represent bias parameters, and V represents intermediate results. fp This represents the fused position vector.
[0077] Then, the fused position vector is encoded and decoded to obtain the decoded features. Specifically, after encoding, the shape is (fused). num ,info dim The encoding feature V encoder Encoding vector V encoder The decoder further refines the result to obtain a shape of (fused). num ,ebd dim Decoding features V decoder Among them, info dim and ebd dim These represent the dimensions of the encoding and decoding features, respectively.
[0078] Finally, decode feature V decoder and fused position vector V fp The compressed results are superimposed and then subjected to activation and linear mapping to obtain the final feature representation V of the encoded question. sc In company terms:
[0079] V sc =V decoder +ResidualBlock connector (V fp )
[0080] Among them, ResidualBlock connector This indicates the compression process implemented by the connector, which is also implemented using esidualBlock.
[0081] It should also be noted that for other classification tasks, the ASTPB model can continue to use a Softmax layer to output a single predicted value y, which is related to the specific task and can be expressed by the formula:
[0082] y = Softmax(V ec )
[0083] In this embodiment, the knowledge tracking module records the learner's learning progress on historical programming problems. This learning progress includes feature representations of the programming problems, which are the average of the feature representations corresponding to the coding codes of all learners for the same programming problem. Each coding code's feature representation is obtained through a programming code feature extraction module. The learning progress also includes problem feature representations and problem completion rates, thus generating a unique learning progress sequence for each learner.
[0084] The knowledge tracking module uses a knowledge tracking model to predict the completion accuracy of each unlocked but incomplete programming question based on the learning progress sequence. This completion accuracy provides data support for subsequent question recommendations and learning plan customization.
[0085] In knowledge tracing tasks, embodiments of the present invention use the encoded representation V from the ASTPB model. ec Replace the programming question IDs in the exercises. This encoding representation is a more informative and context-sensitive representation of the exercises, enhancing the model's ability to capture relationships and dependencies between exercises. Therefore, compared to traditional models such as DKT, SAKT, and DSAKT, this invention can capture more complex relationships and dependencies between questions.
[0086] Knowledge tracing is applied in learning systems. As students learn within the system, they accumulate various learning-related data. The task of knowledge tracing is to analyze this data and use it to support future learning. Specifically, the knowledge tracing model reads the data from the following formula and predicts the correctness of the (n+1)th question:
[0087] x={q1,q 2, …,q k}
[0088] E = {e1,e2,…,e} k}
[0089] Where x represents the input queue, q k This represents the question number, which is then replaced with the feature representation corresponding to the question, i.e., q. k =V ec E represents the sequence of whether a question is correct or incorrect, e k This indicates whether the corresponding question is correct or not. In addition, other information C can be used, such as the specific time taken to complete the task, the interval between tasks, and the specific score for each question. Combining the question number and the correctness of a programming question into one interaction (I) is called one interaction. k =(q k ,e k ).
[0090] In one implementation, the knowledge tracing model is executed using the UTKT model, and the specific process is as follows:
[0091] (1) Input sequence:
[0092] I = [I1, I2, ..., I k ]
[0093] E = [e2, e3…e k ]
[0094] In this sequence, the dimension of sequence E is one less than the dimension of sequence I, the purpose of which is to predict e. k+1 The value of .
[0095] (2) Mapping encoding:
[0096] I ′ =Embedding I (I),I ′ ∈R Q*d
[0097] E ′ =Embedding R (E),E ′ ∈R Q*d
[0098] Among them, I ′ and E ′ The mapped and encoded interaction sequence and the sequence of correct / incorrect questions, where Q represents the maximum question number and d is the dimension of the hidden layer.
[0099] (3) Encoding and Decoding:
[0100] The mapping and encoding results are input into a multi-layer encoding / decoding module. Each layer includes an encoder and a decoder. Both the encoder and decoder employ attention mechanisms and feedforward neural networks, and positional encoding is applied, specifically including:
[0101] The encoding process in the encoder is as follows:
[0102] t1 = PE + TE + Encoder in
[0103] t2=LayerNorm(t1+Multihead(t1,t1,t1))
[0104] Encoder out =LayerNorm(t2+FFN(t2))
[0105] Where t1 and t2 represent intermediate variables, Encoder in In the first layer encoding / decoding module, it is I ′In the encoding / decoding modules of all layers except the first layer, the encoder represents the encoded result of the previous layer's encoding / decoding module. out The encoding result is represented by Multihead(·), which means performing a multi-head attention mechanism on the input data to calculate the attention variable. LayerNorm means layer normalization. FFN(·) means the output result of the input data in the feedforward neural network. PE means the position encoding of the input interaction sequence I. TE means the position encoding of the interaction sequence I in the encoder layer. The specific calculation process is as follows:
[0106] PE(pos,2i)=sin(pos / 10000 2i / d )
[0107] PE(pos,2i+1)=cos(pos / 10000 2i / d )
[0108] TE(layer,2i)=sin(layer / 10000 2i / d )
[0109] TE(layer,2i+1)=cos(layer / 10000 2i / d )
[0110] Where i represents the index of the position in the interaction sequence I, and its value is... d represents the dimension, pos represents the parameter value at each position in the interaction sequence I, PE(pos,2i) represents the encoding result of the parameter value at even positions in the interaction sequence I, PE(pos,2i+1) represents the encoding result of the parameter value at odd positions in the interaction sequence I, PE(pos,2i) and PE(pos,2i+1) together form PE, layer represents the index of the layer in the encoder, its value is 1≤layer≤layers, layers represents the total number of layers in the encoder, TE(layer,2i) represents the encoding result of the feature value at even positions in the layer, TE(layer,2i+1) represents the encoding result of the feature value at odd positions in the layer, TE(layer,2i) and TE(layer,2i+1) together form TE.
[0111] The decoding process in the decoder is as follows:
[0112] t1' = PE' + TE' + Decoder in
[0113] t2'=LayerNorm(t1'+Multihead(t1',t1',t1'))
[0114] t3′=LayerNorm(t2′+FFN(t2′))
[0115] t4′=LayerNorm(t3′+MultiHead(t3′,Encoder out Encoder out ))
[0116] Decoder out =LayerNorm(t4′+FFN(t4′))
[0117] Where t1', t2', t3', and t4' represent intermediate variables, and Decoder in E in the first layer encoding / decoding module ′ In the encoding / decoding modules other than the first layer, the decoder represents the decoding result of the previous layer's encoding / decoding module. out This represents the decoding result, specifically the Encoder used when calculating t4′. out For the encoder results in the same layer of the encoder-decoder module, PE' represents the positional encoding of the input question's correctness sequence E, and TE' represents the positional encoding of sequence E in the decoder layer. The specific calculation process is as follows:
[0118] PE(pos′,2i′)=sin(pos′ / 10000 2i′ / d )
[0119] PE(pos′,2i′+1)=cos(pos′ / 10000 2i′ / d )
[0120] TE(layer′,2i′)=sin(layer′ / 10000 2i′ / d )
[0121] TE(layer′,2i′+1)=cos(layer′ / 10000 2i′ / d )
[0122] Where i′ represents the index of a position in sequence E, and its value is... d represents the dimension, pos′ represents the parameter value at each position in sequence E, PE(pos′,2i′) represents the decoding result of the parameter value at even positions in sequence E, PE(pos′,2i′+1) represents the decoding result of the parameter value at odd positions in sequence E, PE(pos′,2i′) and PE(pos′,2i′+1) together form PE', layer′ represents the index of the layer in the decoder, its value is 1≤layer′≤layers′, layers′ represents the total number of layers in the decoder, TE(layer′,2i′) represents the decoding result of the feature value at even positions in layer′, TE(layer′,2i′+1) represents the decoding result of the feature value at odd positions in layer′, TE(layer′,2i′+1) together form TE'.
[0123] The multi-head attention mechanism is as follows:
[0124] Multihead(Q,K,V)=Concat(head1,…,head h W O
[0125]
[0126] Among them, Q n K n and V n This means dividing Q, K, V into n parts, and calculating the attention head for each part. n By concat, multiple attention points are spliced together, W O Representing weights, UpperTriangularMask represents a mask for the matrix, such as... Figure 4 As shown, UpperTriangularMask sets the calculated matrix to 0 in the shaded area. This signifies that, under the constraint of knowledge tracing, previous interactions cannot be considered in relation to subsequent interactions. In other words, when a student is solving a problem, the model cannot use the results of future students' solutions to make current predictions.
[0127] During the encoding and decoding process, positional information is incorporated into each element. This replaces the RNN loop training mode and allows for parallel training of the relationships between positions.
[0128] (4) Complete the accuracy prediction;
[0129] The decoded result output from the last encoding / decoding module is passed through a linear layer, and the predicted value is obtained using the Sigmoid function, represented as follows:
[0130] r ′=Sigmoid(Decoder) out "W+b)
[0131] Where, r ′ This represents the predicted accuracy value for the Decoder. out "" represents the decoding result output by the last layer encoding / decoding module, and W and b represent the weight and bias parameters of the linear layer.
[0132] In this embodiment, the recommendation module is used to divide all programming questions into several levels according to course chapters and knowledge relevance. The knowledge points of programming questions in each level are highly relevant in the corresponding subject and are adjacent in learning order. The knowledge points of the next level include the knowledge points of the previous level. When making recommendations, the module determines the programming question with the lowest completion accuracy and automatically recommends other programming questions in the same level. When the average completion accuracy of programming questions in the current level is higher than a threshold, the module recommends programming questions for the next level.
[0133] It should also be noted that in the above-mentioned guided programming practice system, the ASTPB model and UTKT model need to be optimized before they are applied. Specifically, the OJ dataset is used as the training dataset, and the parameters of the ASTPB model and UTKT model are optimized based on the knowledge tracing task.
[0134] The specific embodiments described above illustrate the technical solution and beneficial effects of the present invention in detail. It should be understood that the above description is only the most preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, additions, and equivalent substitutions made within the scope of the principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A guided programming practice system for multiple programming languages based on abstract syntax trees, characterized in that, include: The programming code feature extraction module is used to extract feature representations of programming code using a pre-trained ASTPB model. Specifically, the programming code of the programming problem is constructed into an abstract syntax tree with positional information. The nodes of the abstract syntax tree include attribute information and positional information. Multi-layer convolution is performed on the abstract syntax tree to enhance the positional relationship features of neighboring nodes. Feature encoding is performed on the nodes after convolution to obtain the feature representation of the programming problem. The knowledge tracking module records learners' learning progress on historical programming problems. This learning progress includes feature representations of the programming problems. The knowledge tracking model is used to predict the accuracy rate of completing unfinished programming problems based on the learning progress. The recommendation module is used to divide all programming questions into several levels according to course chapters and knowledge relevance. The programming questions in each level are highly relevant to the corresponding subject and have adjacent learning order. The knowledge points of the next level include the knowledge points of the previous level. When making recommendations, the programming question with the lowest completion accuracy is identified, and other programming questions in the same level are automatically recommended. When the average completion accuracy of the programming questions in the current level is higher than the threshold, programming questions in the next level are recommended. The step of constructing the programming code of the programming problem into an abstract syntax tree with positional information includes: An abstract syntax tree is generated for the programming code of each programming problem. Each node in the abstract syntax tree contains specific information marked in the source code and attribute words of node features. The word vectors of all attribute words of each node are accumulated and averaged to obtain the attribute vector of the node. Each node is bound with position information based on its position in the abstract syntax tree. This position information includes four parameters: the depth of the node in the abstract syntax tree, the index of the node in the current level of the abstract syntax tree, the depth of the node's parent node in the abstract syntax tree, and the index of the node's parent node in the current level of the abstract syntax tree. The position information of each node is encoded to obtain a position vector, making the dimension of the position vector the same as that of the attribute vector. The dimensions of the position vector and the attribute vector are superimposed to obtain the initial vector of the node. The position information of each node is encoded using the following formula to obtain a position vector, such that the dimension of the position vector is the same as that of the attribute vector: in, This represents each parameter value in the location information. This represents the encoded value at an even-numbered position in the encoded vector for each parameter value. Represents the dimension of the attribute vector. i This represents the position count, with values of 0, 1, 2, ... ; The location vector is obtained by concatenating the encoded vectors of the four parameter values.
2. The guided programming practice system for multiple programming languages based on abstract syntax trees according to claim 1, characterized in that, The initial vector of a node is obtained by superimposing the dimensions of the position vector and the attribute vector, as expressed by the formula: in, Represents the initial vector of a node. Represents the position vector of a node. A vector representing the attributes of a node.
3. The guided programming practice system for multiple programming languages based on abstract syntax trees according to claim 1, characterized in that, The method of performing multi-level convolutions on the abstract syntax tree to enhance the positional relationship features of neighboring nodes includes: in, Indicates the depth of the convolutional layer. Indicates the level index. This represents the vector representation of each node after performing a convolutional layer. In the convolution operation, the first... l Layer j One convolutional kernel, Indicates the first l The number of nodes in the layer. In the convolution operation, the first... l The first in the layer j The initial vector of each node. Indicates the first l Vector representation after convolution.
4. The guided programming practice system for multiple programming languages based on abstract syntax trees according to claim 1, characterized in that, The feature encoding of the nodes after convolution to obtain the feature representation of the programming problem includes: The abstract syntax tree after convolution is routed to obtain the vector representation of the traversed nodes, and a node sequence composed of vector representations is formed. The Tide model is used to extract feature representations of node sequences. Specifically, the node sequences are compressed to obtain fused position vectors. Then, the fused position vectors are encoded and decoded to obtain decoded features. The decoded features and the compressed fused position vectors are superimposed and then activated and linearly mapped to obtain the final feature representation of the encoded question.
5. The guided programming practice system for multiple programming languages based on abstract syntax trees according to claim 4, characterized in that, The compression process employs... accomplish, The specific process includes: in, Represents a sequence of nodes. , as well as All of these represent intermediate results. express activation, express operate, Representation layer normalization, , , Represents the weight parameters. , , Indicates the bias parameter. This represents the fused position vector.
6. The guided programming practice system for multiple programming languages based on abstract syntax trees according to claim 1, characterized in that, The learning progress also includes the question number and the question completion rate.
7. The guided programming practice system for multiple programming languages based on abstract syntax trees according to claim 1, characterized in that, The method of using a knowledge tracing model to predict the accuracy rate of incomplete programming problems based on learning progress includes: The knowledge tracing model is executed using the UTKT model, and the specific process is as follows: (1) Input sequence: In this sequence, the dimension of sequence E is one less than the dimension of sequence I, the purpose of which is to predict... The value; (2) Mapping encoding: in, and The mapped and encoded interaction sequence and the sequence of correct or incorrect questions, where Q represents the maximum question number and d is the dimension of the hidden layer; (3) Encoding and decoding: The mapping and encoding results are input into a multi-layer encoding / decoding module. Each layer includes an encoder and a decoder. Both the encoder and decoder employ attention mechanisms and feedforward neural networks, and positional encoding is applied, specifically including: The encoding process in the encoder is as follows: in, and Indicates intermediate variables. In the first layer encoding / decoding module In the encoding / decoding modules of all layers except the first layer, the encoding result is the result of the previous layer's encoding / decoding module. This indicates the encoding result. Indicates to Calculate attention variables using a multi-head attention mechanism. Representation layer normalization, This represents the output of the input data in the feedforward neural network. Represents the input interaction sequence Location encoding, Represents an interaction sequence Encode the position of the layer number in the encoder; The decoding process in the decoder is as follows: in, , , as well as Indicates intermediate variables. In the first layer encoding / decoding module In the encoding / decoding modules of all layers except the first layer, the result is the decoding result of the previous layer's encoding / decoding module. Represents the decoding result, calculation Used at the time The encoding results of the encoder in the same layer of the encoding / decoding module. Represents a sequence of whether the input question is correct or not. Location encoding, Represents a sequence Encode the position of the layer in the decoder.
8. The guided programming practice system for multiple programming languages based on abstract syntax trees according to claim 7, characterized in that, The and Calculated in the following way: in, i Represents an interaction sequence The index of the middle position, with a value , d Representing dimension, Represents an interaction sequence The parameter value at each position in the text. Represents an interaction sequence The encoding result of the even position parameter value in the middle. Represents an interaction sequence The encoding result of the odd position parameter value. and composition , This represents the index of a layer in the encoder, and its value is... , Indicates the total number of layers in the encoder. Indicates the first The encoding result of the feature value at the even position. Indicates the first The encoding results of feature values at odd positions in the middle and composition ; and Calculated in the following way: in, Represents a sequence The index of the middle position, with a value , d Representing dimension, Represents a sequence The parameter value at each position in the text. Represents a sequence Decoding results of even-numbered positional parameter values. Represents a sequence Decoding results of odd-numbered position parameter values, and composition , This represents the index of the layer in the decoder, and its value is... , express Total number of layers in the decoder Indicates the first Decoding results of even-numbered positional features. Indicates the first Decoding results of feature values at odd positions in the middle and composition .