A Personalized Programming Problem Recommendation Method Integrating Dynamic Interactive Information
By integrating dynamic interactive information into a personalized programming problem recommendation method, and utilizing pre-trained models and long short-term memory networks, this approach addresses the problem of neglecting dynamic interactive data in existing technologies, achieving more accurate programming problem recommendations and improving learning efficiency and experience.
Patent Information
- Application Number
- CN202511415943.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-30
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2045-09-30
AI Technical Summary
Existing personalized programming problem recommendation methods ignore the rich information in student-submitted code and fail to effectively utilize dynamic interactive data, resulting in poor recommendation performance. Furthermore, the general programming model has not been optimized for the student-problem-feedback three-dimensional interaction.
We employ a pre-trained programming large-scale model UniXcoder and a language model GPT2-encoder, combined with a long short-term memory network and attention mechanism, to construct a personalized programming problem recommendation model. This model integrates a code representation module and a problem recommendation module, and uses students' historical programming interaction sequences and evaluation feedback information to generate the recommendation probability distribution for the next time step.
It enables a comprehensive modeling of students' real-time programming abilities, improves the accuracy and effectiveness of personalized problem recommendations, and enhances the learning efficiency and experience of programming instruction.
Smart Images

Figure CN120892633B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a recommendation method that integrates dynamic interactive information, specifically a personalized programming problem recommendation method that integrates dynamic interactive information. Background Technology
[0002] Personalized recommendation is a technology that automatically matches and pushes resources or services that best suit a user's needs based on their historical behavior and characteristics. Personalized programming problem recommendation, as a specific application of personalized recommendation in programming education, aims to estimate a student's knowledge level by analyzing their programming behavior and then recommending programming problems that match their ability level, achieving "teaching according to aptitude" to efficiently improve programming skills. In recent years, with the rapid development of online education platforms and the rise of artificial intelligence technology, personalized programming problem recommendation has become a highly anticipated cutting-edge research direction.
[0003] Current programming learning activities primarily rely on online judge (OJ) platforms, such as LeetCode and Luogu. In the process of learning programming skills, students write code based on their understanding of specific programming problems and submit it to the OJ system. The system evaluates the code using pre-set test cases and provides feedback. Students then continuously optimize and resubmit their code based on the feedback until it passes all test cases or they move on to other problems. This dynamic interactive process generates rich data, including code submission records and evaluation feedback scores. Analyzing this dynamic interactive data helps to more accurately estimate students' true programming abilities, thereby improving the quality of personalized recommendation systems.
[0004] However, existing personalized programming problem recommendation schemes have shortcomings in the following aspects:
[0005] 1. Early programming problem recommendation methods mainly used content or collaborative filtering methods, which usually relied on students' external characteristics, answer sequences, or problem similarity for recommendations, ignoring the rich information contained in the code submitted by students, thus limiting the recommendation effect.
[0006] 2. Static code feature methods typically only encode the abstract syntax tree (AST) or token sequence once, without considering the dynamic relationship between the semantics of the question text and the evaluation feedback score information;
[0007] 3. While general programming models (such as UniXcoder and CodeBERT) can extract code syntax and semantic information, they are not specifically optimized for the "student-question-feedback" triadic interaction, and their direct application to recommendation accuracy is limited.
[0008] To overcome the aforementioned deficiencies of the prior art, embodiments of the present invention propose a personalized programming problem recommendation framework that integrates dynamic interactive information, so that the recommendation results are highly matched with the student's real-time ability. Summary of the Invention
[0009] To address the aforementioned issues, this invention proposes a personalized programming question recommendation method that integrates dynamic interactive information. This method constructs code representations based on a pre-trained large programming model and a supervised learning network, models historical answer sequences using a long short-term memory network, and recommends programming questions using an attention mechanism.
[0010] The technical solution for implementing this invention is: a personalized programming problem recommendation method that integrates dynamic interactive information, comprising the following steps:
[0011] Step S1: Obtain the dataset from the online evaluation platform, and preprocess and partition the dataset.
[0012] Step S2: Based on the data from Step S1, formalize and define the students' historical programming interaction sequences;
[0013] Step S3: Based on the task requirements of step S2, build an overall framework including a code representation module and a question recommendation module, and establish a personalized programming question recommendation model;
[0014] Step S4: Implement and train the code representation module in step S3. Use the online evaluation platform dataset obtained in step S1 as the input of the code representation module. Use the programming big model UniXcoder and the language model GPT2-encoder to generate code and question text vectors, and fuse them into a comprehensive code representation through supervised learning.
[0015] Step S5: Implement and train the question recommendation module in Step S3. Based on the comprehensive code representation in Step S4, combine the student's historical programming interaction sequence, use a long short-term memory network and attention mechanism to model the student's ability evolution, and generate the probability distribution of the recommendation for the next time step.
[0016] Further, step S1: Obtain the online evaluation platform dataset, and preprocess and partition the online evaluation platform dataset, specifically as follows:
[0017] Step S11: Collect the dataset from the online assessment platform. The dataset contains students' code submission records, which include question identifiers, question text, student submitted code text, and assessment feedback scores.
[0018] Step S12: Preprocess the dataset from the online assessment platform. The preprocessing includes score discretization, question label remapping, and sorting of students' historical programming interaction sequences.
[0019] The scoring discretization process transforms the evaluation feedback scores into three categories: incorrect, partially correct, and completely correct scores for each student. The question identifier remapping process maps the non-continuous question numbers in the online evaluation platform dataset to consecutive numbers. The sorting of students' historical programming interaction sequences involves arranging each student's code submission records in ascending order according to the submission time to form the students' historical programming interaction sequences.
[0020] Step S13: The preprocessed online evaluation platform dataset is randomly divided into groups based on students. Specifically, 80% of the students' submission records are randomly selected as the training set, and the remaining 20% of the students' submission records are selected as the test set.
[0021] Further, step S2: formally express and define the student's historical programming interaction sequence; specifically:
[0022] Step S21, formally describe and define the personalized programming problem recommendation task: Let... Given a set of all different programming problems, where Indicates the first A programming problem, Let be the total number of programming problems, and let there be 4 student records in the training set.
[0023] Step S22, let the historical programming interaction sequence of each student be... ,in Indicates the student's time step The question identifier for answering, Indicates the student's time step Question identifier for answering The corresponding question text, Indicates the student's time step Question identifier for answering The corresponding commit code, This indicates the student's assessment feedback score category, which is represented by three student assessment feedback score categories: incorrect, partially correct, and completely correct.
[0024] Step S23, given the historical programming interaction sequence for each student in step S22. Based on this, study the random variables of candidate problems. The conditional distribution P( | ), and select As It continuously recommends programming problems to students, enabling personalized problem recommendations. This indicates that the conditional distribution P( | The largest candidate random variable for learning problems The value of .
[0025] Further, in step S3, the overall framework including the code representation module and the question recommendation module is built, and a personalized programming question recommendation model is established. The specific process is as follows:
[0026] Step S31: The code representation module uses a pre-trained programming language model to extract the semantic and structural features of the code and the semantic features of the question text, generates the corresponding embedding vectors of the code and the question text, and uses supervised learning to fuse the code and the question text to obtain a comprehensive code representation vector.
[0027] In step S32, the question recommendation module uses a comprehensive code representation vector and the student's historical programming interaction sequence to predict the probability distribution of the next recommendation moment through a long short-term memory network and attention mechanism.
[0028] Further, in step S4, the code representation module from step S3 is implemented and trained. The online evaluation platform dataset obtained in step S1 is used as input to the code representation module. The UniXcoder programming model and the GPT2-encoder language model are used to generate code and question text vectors, which are then fused into a comprehensive code representation through supervised learning. The specific process is as follows:
[0029] Step S41: Using the student code submission records in the online assessment platform dataset obtained in step S11, input them into the code representation module;
[0030] Step S42: Input the student's submitted code text and question text from the student's code submission record into the programming big model UniXcoder and the language model GPT2-encoder, respectively;
[0031] Step S43: In the preprocessing layer of the UniXcoder programming model, the student-submitted code text is first segmented into words to obtain a length of... sequence ,in, This represents the first word segmented from the student's submitted code text. This indicates the first segment of the code text submitted by the student. 1 word element, then, in a length of sequence Insert a special marker CLS at the very beginning, denoted as The length is obtained as Code text segmentation sequence ;
[0032] Step S44: Based on the programming language category of the student's submitted code text, call the multi-language parsing framework Tree-sitter to load the corresponding syntax library, parse the student's submitted code text, and generate a length of [length missing]. Code Abstract Syntax Tree (AST) Node Sequence , This represents the label of the first node in the sequence of nodes in the Abstract Syntax Tree (AST). This represents the label of the second node in the sequence of nodes in the Abstract Syntax Tree (AST). The first node of the sequence of nodes in the Abstract Syntax Tree (AST) Each node label;
[0033] Step S45, segment the code text into word sequences and the sequence of nodes in the Abstract Syntax Tree (AST). The input sequence is obtained by concatenation. As shown in the formula:
[0034] ;
[0035] In the formula, It's a splicing operation. It is the code text segmentation sequence obtained in step S43. It is the sequence of AST nodes obtained in step S44;
[0036] Step S46: In the embedding layer of the UniXcoder programming model, the unified input sequence is... Each marker in the matrix is mapped to a high-dimensional vector, generating a high-dimensional vector matrix. ,in, Represents the real number field; It is the output dimension of the embedding layer of the UniXcoder large-scale programming model; vectors in a high-dimensional vector matrix. The corresponding special marker CLS is used to represent the overall semantic information of the code; vector These correspond to the word segmentation sequences in the code text. ;vector These correspond to the sequence of nodes in the Abstract Syntax Tree (AST). That is, a high-dimensional vector matrix. For code text word segmentation matrix With the Abstract Syntax Tree (AST) node matrix Line-by-line concatenation;
[0037] Step S47, the high-dimensional vector matrix generated in step S46 Input the Transformer encoder of the UniXcoder programming model to generate a feature matrix that integrates code semantics and the AST node structure of the code abstract syntax tree.
[0038] ;
[0039] in, To integrate the feature matrix of code semantics and the AST node structure, Indicates the first The joint representation of the code semantics and code abstract syntax tree (AST) structure obtained by fusing the global context; The sequence length obtained by segmenting the student-submitted code text for the large programming model UniXcoder. The length of the sequence of nodes in the Abstract Syntax Tree (AST).
[0040] After fusing the global context, the feature matrix integrates code semantics and the AST node structure. Vector corresponding to the special marker CLS This is used to represent the comprehensive semantic information of the entire piece of code submitted by the student; the vector is used to represent the comprehensive semantic information of the entire piece of code submitted by the student. As the embedding vector of the code text submitted by the student, let it be denoted as ;
[0041] Step S48, for students in the time step Question identifier for answering Corresponding question text The GPT2-encoder language model is used to segment students at each time step. Question identifier for answering Corresponding question text The sequence is segmented into word-tagged sequences, and the word embedding layer of the GPT2-encoder language model is used to map each word-tagged sequence to a high-dimensional embedding vector.
[0042] ;
[0043] in, It is the output dimension of the word embedding layer. For students in time steps Question identifier for answering Corresponding question text Segmentation token sequence length, Indicates the student's time step Question identifier for answering Corresponding question text The high-dimensional embedding vector mapped to the j-th word tag;
[0044] Step S49, will Indicates the student's time step Question identifier for answering Corresponding question text The series of high-dimensional embedding vectors mapped to the j-th word tag The text of the question is fed into a multi-layer Transformer encoder of the GPT2-encoder language model to obtain the student's answer at time step i. Corresponding question text The final embedded representation;
[0045] ;
[0046] in, Indicates the student's time step Question identifier for answering Corresponding question text The final embedding representation, This represents the hidden state after context enhancement;
[0047] Step S410, using a weight matrix as The bias vector is The activation function is A fully connected layer that integrates student-submitted code text embedding vectors. The text of the questions that students answer at time step i Corresponding question text The final embedding representation Construct a comprehensive code representation vector; the specific formula is:
[0048] ;
[0049] In the formula, It is a comprehensive code representation vector; It is a modified linear unit activation function;
[0050] Step S411: Based on the score discretization process in step S1, classify the student's evaluation feedback score into categories. Converted into a code-based true class vector through one-hot encoding. Simultaneously, the comprehensive code representation vector obtained in step S410 is... Input a weight matrix as The bias vector is The activation function is The fully connected layer yields the predicted code category vector. ;
[0051] Step S412: For the code text submitted by students in the training set, after step S411, the true class vector of the code is obtained. With the predicted code category vector Suppose there are a total of n students in the training group, and the nth student has a total of [number missing]. This code commit;
[0052] Let the actual label and predicted probability of the code submitted by student number 'i' at time step 'i' in category 'k' of the code feedback score be used to calculate the cross-entropy loss function. :
[0053] ;
[0054] In the formula, It is the code feedback score category, 𝑠∈{0,1,2}, For student number n, step n belongs to the nth time step. The actual category label of the class, To predict whether the model will belong to the _th student at time step _i. The probability of a class;
[0055] Step S413: Use the cross-entropy loss function calculated in step S412. The parameters of the UniXcoder programming model, the fully connected layer parameters used for fusion in training step S410, and the fully connected layer parameters used for classification in training step S411 are fine-tuned using the backpropagation algorithm; the parameters of the language model GPT2-encoder are frozen and do not participate in parameter updates.
[0056] Step S414: After completing the training in step S413, use the trained parameters to analyze all students at each time step. Question identifier for answering Corresponding commit code Each of these is converted into a comprehensive code representation vector. .
[0057] Further, in step S5, the question recommendation module from step S3 is implemented and trained. Based on the comprehensive code representation from step S4, and combined with the student's historical programming interaction sequence, a long short-term memory network and attention mechanism are used to model the student's ability evolution and generate the probability distribution for the next time step recommendation. The specific process is as follows:
[0058] Step S51, construct the student response interaction vector; at time step Students using one-hot encoding at time step Question identifier for answering In the case of the above response, the interaction vector is obtained. ;
[0059] If the student is in time step Answer correctly (i.e., submit code) If all test cases are passed, the evaluation feedback is correct. Interaction vectors The middle ( +M) positions have 1s, and the remaining positions have 0s; if the student answers incorrectly (i.e., submits incorrect code) If not all test cases pass, the evaluation feedback will be correct. Interaction vectors The Middle One position is 1, and the rest are 0;
[0060] Step S52, the interaction vector Mapped to a low-dimensional embedding representation; utilizing a learnable weight matrix. , interaction vector Transform into a low-dimensional, dense question interaction embedding vector , It represents the dimension of the question's interactive embedding vector, where T denotes the matrix transpose;
[0061] Step S53: Construct a comprehensive interactive embedding representation; combine this with the comprehensive code representation vector obtained in step S410. Interact with the question embedding vector in step S52 By concatenating the elements in sequence, a comprehensive interactive embedding is obtained; the formula is as follows:
[0062] ;
[0063] In the formula, This represents the student's integrated interaction embedding vector at time step i;
[0064] Step S54, use a Long Short-Term Memory network to model the student's comprehensive interaction embedding sequence; the student's comprehensive interaction embedding sequence at each time step is { },in, This represents the student's integrated interaction embedding vector at the first time step. This represents the student's integrated interaction embedding vector at the second time step. This represents the student's integrated interaction embedding vector at time step t;
[0065] Embed the student's comprehensive interactions at each time step into the sequence { Input a Long Short-Term Memory (LSTM) network, and let the initial hidden state of the LSTM network be... ,for arrive At each time step, the hidden state of the Long Short-Term Memory (LSTM) network is updated incrementally. , It is the hidden state dimension of the Long Short-Term Memory (LSTM) network;
[0066] ;
[0067] In the formula, Is Hidden states of a Long Short-Term Memory (LSTM) network at time steps;
[0068] Step S55: Calculate the hidden state similarity; when recommending the next question, calculate the hidden state at time step t. Similarity score with the previous hidden state The similarity function is calculated as follows:
[0069] ;
[0070] in, It is the hidden state of a Long Short-Term Memory (LSTM) network from time step i=1 to t-1. The transpose of the concatenated matrix, Indicates a fully connected layer;
[0071] Step S56: Obtain the context vector representing the student's historical ability state; obtain the similarity function of the previously hidden state obtained in step S55. ,application The function obtains normalized attention weights :
[0072] ;
[0073] Then, by weighted summation, historical response information related to the current state is captured, resulting in a context vector representing the student's historical ability state. :
[0074] ;
[0075] Step S57: Predict the recommended question for the next moment; use the context vector representing the student's historical ability state. Hidden state at time step t After being spliced together, they are input to the fully connected layer (FC). Activation function, obtain Probability distribution of recommended questions at all times :
[0076] ;
[0077] Step S58: Construct the supervised loss and update the model parameters; for each sample in the training set, extract the sample time step. Title identifier And generate one-hot true class vectors. ;
[0078] ;
[0079] in, Represents the true class vector The kth component, Represents the true class vector The first component, Represents the true class vector The second component, Represents the true class vector The (M-1)th component;
[0080] Step S59, calculate the cross-entropy loss, and record the total number of students in the training set for the i-th student. Each time step, from t=1 to t= At time t, step S58 generates the true class vector of the nth student at time t+1, denoted as [vector]. And the probability distribution of the predicted question for the nth student at time t+1 in step S57 is denoted as follows: ;
[0081] Cross-entropy loss function here Defined as:
[0082] ;
[0083] in, Let n be the true class vector of student t+1 at time t. Belongs to the code feedback score category Category tags, Probability distribution of recommending a question for student number t+1 at time t Prediction code feedback score category The probability value; calculated by the cross-entropy loss function. And minimize the cross-entropy loss function To achieve this, we update all parameters in the Long Short-Term Memory (LSTM) network, the fully connected layers, and the embedding mapping matrix, up to the cross-entropy loss function. Until it stops falling;
[0084] Step S510: After calculating the cross-entropy loss in step S59, for the students' historical programming interaction sequences... Obtained using step S57 Probability distribution of recommended questions at all times Take the question identifier corresponding to the maximum value in the distribution and recommend it to students as the next time step t+1.
[0085] The advantages of this invention are: It integrates the semantic and structural features of code text, the semantic features of question text, and real-time feedback scores from online programming assessment platforms to construct a comprehensive code representation containing dynamic interactive information, thereby providing a more comprehensive model of students' instant programming abilities. This invention employs a long short-term memory network and attention mechanism to effectively capture the implicit ability changes in students' answer sequences, thus more accurately predicting the programming questions students currently need, further improving the personalized question recommendation effect. The method of this invention has a wide range of applications and can be easily applied to various online programming education platforms, providing personalized question recommendation services for programming teaching, realizing individualized instruction, and improving students' learning efficiency and experience. Attached Figure Description
[0086] Figure 1 This is a flowchart illustrating the overall model structure of the present invention. Detailed Implementation
[0087] Figure 1 It demonstrates the complete process of building a model from input to output.
[0088] The specific process is as follows: Using a self-built online assessment platform dataset, preprocess the dataset by remapping discrete question numbers to consecutive numbers; divide student code feedback scores into three categories, and sort each student's submission records in ascending order of submission time. Finally, divide all students in the dataset into training and test sets, and report all metrics on the test set.
[0089] Students' historical programming learning behaviors are represented as a sequence of historical programming interactions on an online programming assessment platform.
[0090] We construct a personalized programming problem recommendation model, which includes a code representation module and a problem recommendation module.
[0091] Using the score category information from step S1 as the target, and taking the code text embedding generated by the fine-tuned UniXcoder model and the question text embedding generated by the GPT2-encoder model as inputs, a supervised pre-trained classification task is constructed. During training, a fully connected layer is used to fuse the two inputs to construct a comprehensive code representation vector.
[0092] In the stage of modeling student response interaction sequence in the long short-term memory network, the question interaction embedding vector is formed by fusing programming questions and student response feedback information. This vector is then concatenated with the comprehensive code representation obtained in step S4 and input into the long short-term memory network to obtain the hidden state representation of the student's learning state. An attention mechanism is used to fuse the current learning state with relevant historical response information, and a fully connected network is used to predict questions that match the student's current programming ability.
[0093] An embodiment of the present invention: A personalized programming problem recommendation method integrating dynamic interactive information, comprising the following steps:
[0094] Step S1: Obtain the dataset from the online evaluation platform, and preprocess and partition the dataset.
[0095] Step S2: Based on the data from Step S1, formalize and define the students' historical programming interaction sequences;
[0096] Step S3: Based on the task requirements of step S2, build an overall framework including a code representation module and a question recommendation module, and establish a personalized programming question recommendation model;
[0097] Step S4: Implement and train the code representation module in step S3. Use the online evaluation platform dataset obtained in step S1 as the input of the code representation module. Use the programming big model UniXcoder and the language model GPT2-encoder to generate code and question text vectors, and fuse them into a comprehensive code representation through supervised learning.
[0098] Step S5: Implement and train the question recommendation module in Step S3. Based on the comprehensive code representation in Step S4, combine the student's historical programming interaction sequence, use a long short-term memory network and attention mechanism to model the student's ability evolution, and generate the probability distribution of the recommendation for the next time step.
[0099] Further, step S1: Obtain the online evaluation platform dataset, and preprocess and partition the online evaluation platform dataset, specifically as follows:
[0100] Step S11: Collect the dataset from the online assessment platform. The dataset contains students' code submission records, which include question identifiers, question text, student submitted code text, and assessment feedback scores.
[0101] Step S12: Preprocess the dataset from the online assessment platform. The preprocessing includes score discretization, question label remapping, and sorting of students' historical programming interaction sequences.
[0102] The scoring discretization process transforms the evaluation feedback scores into three categories: incorrect, partially correct, and completely correct scores for each student. The question identifier remapping process maps the non-continuous question numbers in the online evaluation platform dataset to consecutive numbers. The sorting of students' historical programming interaction sequences involves arranging each student's code submission records in ascending order according to the submission time, forming the students' historical programming interaction sequences.
[0103] Step S13: The preprocessed online evaluation platform dataset is randomly divided into groups based on students. Specifically, 80% of the students' submission records are randomly selected as the training set, and the remaining 20% of the students' submission records are selected as the test set.
[0104] Further, step S2: formally express and define the student's historical programming interaction sequence; specifically:
[0105] Step S21, formally describe and define the personalized programming problem recommendation task: Let... Given a set of all different programming problems, where Indicates the first A programming problem, Let be the total number of programming problems, and let there be 4 student records in the training set.
[0106] Step S22, let the historical programming interaction sequence of each student be... ,in Indicates the student's time step The question identifier for answering, Indicates the student's time step Question identifier for answering The corresponding question text, Indicates the student's time step Question identifier for answering The corresponding commit code, This indicates the student's assessment feedback score category, which is represented by three student assessment feedback score categories: incorrect, partially correct, and completely correct.
[0107] Step S23, given the historical programming interaction sequence for each student in step S22. Based on this, study the random variables of candidate problems. The conditional distribution P( | ), and select As The system continuously recommends programming problems to students, enabling personalized problem recommendations. This indicates that the conditional distribution P( | The largest candidate random variable for learning problems The value of .
[0108] Further, in step S3, the overall framework including the code representation module and the question recommendation module is built, and a personalized programming question recommendation model is established. The specific process is as follows:
[0109] Step S31: The code representation module uses a pre-trained programming language model to extract the semantic and structural features of the code and the semantic features of the question text, generates the corresponding embedding vectors of the code and the question text, and uses supervised learning to fuse the code and the question text to obtain a comprehensive code representation vector.
[0110] In step S32, the question recommendation module uses a comprehensive code representation vector and the student's historical programming interaction sequence to predict the probability distribution of the next recommendation moment through a long short-term memory network and attention mechanism.
[0111] Further, in step S4, the code representation module from step S3 is implemented and trained. The online evaluation platform dataset obtained in step S1 is used as input to the code representation module. The UniXcoder programming model and the GPT2-encoder language model are used to generate code and question text vectors, which are then fused into a comprehensive code representation through supervised learning. The specific process is as follows:
[0112] Step S41: Using the student code submission records in the online assessment platform dataset obtained in step S11, input them into the code representation module;
[0113] Step S42: Input the student's submitted code text and question text from the student's code submission record into the programming big model UniXcoder and the language model GPT2-encoder, respectively;
[0114] Step S43: In the preprocessing layer of the UniXcoder programming model, the student-submitted code text is first segmented into words to obtain a length of... sequence ,in, This represents the first word segmented from the student's submitted code text. This indicates the first segment of the code text submitted by the student. 1 word element, then, in a length of sequence Insert a special marker CLS at the very beginning, denoted as The length is obtained as Code text segmentation sequence ;
[0115] Step S44: Based on the programming language category of the student's submitted code text, call the multi-language parsing framework Tree-sitter to load the corresponding syntax library, parse the student's submitted code text, and generate a length of [length missing]. Code Abstract Syntax Tree (AST) Node Sequence , This represents the label of the first node in the sequence of nodes in the Abstract Syntax Tree (AST). This represents the label of the second node in the sequence of nodes in the Abstract Syntax Tree (AST). The first node of the sequence of nodes in the Abstract Syntax Tree (AST) Each node label;
[0116] Step S45, segment the code text into word sequences and the sequence of nodes in the Abstract Syntax Tree (AST). The input sequence is obtained by concatenation. As shown in the formula:
[0117] ;
[0118] In the formula, It's a splicing operation. It is the code text segmentation sequence obtained in step S43. It is the sequence of AST nodes obtained in step S44;
[0119] Step S46: In the embedding layer of the UniXcoder programming model, the unified input sequence is... Each marker in the matrix is mapped to a high-dimensional vector, generating a high-dimensional vector matrix. ,in, Represents the real number field; It is the output dimension of the embedding layer of the UniXcoder large-scale programming model; vectors in a high-dimensional vector matrix. The corresponding special marker CLS is used to represent the overall semantic information of the code; vector These correspond to the word segmentation sequences in the code text. ;vector These correspond to the sequence of nodes in the Abstract Syntax Tree (AST). That is, a high-dimensional vector matrix. For code text word segmentation matrix With the Abstract Syntax Tree (AST) node matrix Line-by-line concatenation;
[0120] Step S47, the high-dimensional vector matrix generated in step S46 Input the Transformer encoder of the UniXcoder programming model to generate a feature matrix that integrates code semantics and the AST node structure of the code abstract syntax tree.
[0121] ;
[0122] in, To integrate the feature matrix of code semantics and the AST node structure, Indicates the first The joint representation of the code semantics and code abstract syntax tree (AST) structure obtained by fusing the global context; The sequence length obtained by segmenting the student-submitted code text for the large programming model UniXcoder. The length of the sequence of nodes in the Abstract Syntax Tree (AST).
[0123] After fusing the global context, the feature matrix integrates code semantics and the AST node structure. Vector corresponding to the special marker CLS This is used to represent the comprehensive semantic information of the entire piece of code submitted by the student; the vector is used to represent the comprehensive semantic information of the entire piece of code submitted by the student. As the embedding vector of the code text submitted by the student, let it be denoted as ;
[0124] Step S48, for students in the time step Question identifier for answering Corresponding question text The GPT2-encoder language model is used to segment students at each time step. Question identifier for answering Corresponding question text The sequence is segmented into word-tagged sequences, and the word embedding layer of the GPT2-encoder language model is used to map each word-tagged sequence to a high-dimensional embedding vector.
[0125] ;
[0126] in, It is the output dimension of the word embedding layer. For students in time steps Question identifier for answering Corresponding question text Segmentation token sequence length, Indicates the student's time step Question identifier for answering Corresponding question text The high-dimensional embedding vector mapped to the j-th word tag;
[0127] Step S49, will Indicates the student's time step Question identifier for answering Corresponding question text The series of high-dimensional embedding vectors mapped to the j-th word tag The text of the question is fed into a multi-layer Transformer encoder of the GPT2-encoder language model to obtain the student's answer at time step i. Corresponding question text The final embedded representation;
[0128] ;
[0129] in, Indicates the student's time step Question identifier for answering Corresponding question text The final embedding representation, This represents the hidden state after context enhancement;
[0130] Step S410, using a weight matrix as The bias vector is The activation function is A fully connected layer that integrates student-submitted code text embedding vectors. The text of the questions that students answer at time step i Corresponding question text The final embedding representation Construct a comprehensive code representation vector; the specific formula is:
[0131] ;
[0132] In the formula, It is a comprehensive code representation vector; It is a modified linear unit activation function;
[0133] Step S411: Based on the score discretization process in step S1, classify the student's evaluation feedback score into categories. Converted into a code-based true class vector through one-hot encoding. Simultaneously, the comprehensive code representation vector obtained in step S410 is... Input a weight matrix as The bias vector is The activation function is The fully connected layer yields the predicted code category vector. ;
[0134] Step S412: For the code text submitted by students in the training set, after step S411, the true class vector of the code is obtained. With the predicted code category vector Suppose there are a total of n students in the training group, and the nth student has a total of [number missing]. This code commit;
[0135] Let the actual label and predicted probability of the code submitted by student number 'i' at time step 'i' in category 'k' of the code feedback score be used to calculate the cross-entropy loss function. :
[0136] ;
[0137] In the formula, It is the code feedback score category, 𝑠∈{0,1,2}, For student number n, step n belongs to the nth time step. The actual category label of the class, To predict whether the model will belong to the _th student at time step _i. The probability of a class;
[0138] Step S413: Use the cross-entropy loss function calculated in step S412. The parameters of the UniXcoder programming model, the fully connected layer parameters used for fusion in training step S410, and the fully connected layer parameters used for classification in training step S411 are fine-tuned using the backpropagation algorithm; the parameters of the language model GPT2-encoder are frozen and do not participate in parameter updates.
[0139] Step S414: After completing the training in step S413, use the trained parameters to analyze all students at each time step. Question identifier for answering Corresponding commit code Each of these is converted into a comprehensive code representation vector. .
[0140] Further, in step S5, the question recommendation module from step S3 is implemented and trained. Based on the comprehensive code representation from step S4, and combined with the student's historical programming interaction sequence, a long short-term memory network and attention mechanism are used to model the student's ability evolution and generate the probability distribution for the next time step recommendation. The specific process is as follows:
[0141] Step S51, construct the student response interaction vector; at time step Students using one-hot encoding at time step Question identifier for answering In the case of the above response, the interaction vector is obtained. ;
[0142] If the student is in time step Answer correctly (i.e., submit code) If all test cases are passed, the evaluation feedback is correct. Interaction vectors The middle ( +M) positions have 1s, and the remaining positions have 0s; if the student answers incorrectly (i.e., submits incorrect code) If not all test cases pass, the evaluation feedback will be correct. Interaction vectors The Middle One position is 1, and the rest are 0;
[0143] Step S52, the interaction vector Mapped to a low-dimensional embedding representation; utilizing a learnable weight matrix. , interaction vector Transform into a low-dimensional, dense question interaction embedding vector , It represents the dimension of the question's interactive embedding vector, where T denotes the matrix transpose;
[0144] Step S53: Construct a comprehensive interactive embedding representation; combine this with the comprehensive code representation vector obtained in step S410. Interact with the question embedding vector in step S52 By concatenating the elements in sequence, a comprehensive interactive embedding is obtained; the formula is as follows:
[0145] ;
[0146] In the formula, This represents the student's integrated interaction embedding vector at time step i;
[0147] Step S54, use a Long Short-Term Memory network to model the student's comprehensive interaction embedding sequence; the student's comprehensive interaction embedding sequence at each time step is { },in, This represents the student's integrated interaction embedding vector at the first time step. This represents the student's integrated interaction embedding vector at the second time step. This represents the student's integrated interaction embedding vector at time step t;
[0148] Embed the student's comprehensive interactions at each time step into the sequence { Input a Long Short-Term Memory (LSTM) network, and let the initial hidden state of the LSTM network be... ,for arrive At each time step, the hidden state of the Long Short-Term Memory (LSTM) network is updated incrementally. , It is the hidden state dimension of the Long Short-Term Memory (LSTM) network;
[0149] ;
[0150] In the formula, Is Hidden states of a Long Short-Term Memory (LSTM) network at time steps;
[0151] Step S55: Calculate the hidden state similarity; when recommending the next question, calculate the hidden state at time step t. Similarity score with the previous hidden state The similarity function is calculated as follows:
[0152] ;
[0153] in, It is the hidden state of a Long Short-Term Memory (LSTM) network from time step i=1 to t-1. The transpose of the concatenated matrix, Indicates a fully connected layer;
[0154] Step S56: Obtain the context vector representing the student's historical ability state; obtain the similarity function of the previously hidden state obtained in step S55. ,application The function obtains normalized attention weights :
[0155] ;
[0156] Then, by weighted summation, historical response information related to the current state is captured, resulting in a context vector representing the student's historical ability state. :
[0157] ;
[0158] Step S57: Predict the recommended question for the next moment; use the context vector representing the student's historical ability state. Hidden state at time step t After being spliced together, they are input to the fully connected layer (FC). Activation function, obtain Probability distribution of recommended questions at all times :
[0159] ;
[0160] Step S58: Construct the supervised loss and update the model parameters; for each sample in the training set, extract the sample time step. Title identifier And generate one-hot true class vectors. ;
[0161] ;
[0162] in, Represents the true class vector The kth component, Represents the true class vector The first component, Represents the true class vector The second component, Represents the true class vector The (M-1)th component;
[0163] Step S59, calculate the cross-entropy loss, and record the total number of students in the training set for the i-th student. Each time step, from t=1 to t= At time t, step S58 generates the true class vector of the nth student at time t+1, denoted as [vector]. And the probability distribution of the predicted question for the nth student at time t+1 in step S57 is denoted as follows: ;
[0164] Cross-entropy loss function here Defined as:
[0165] ;
[0166] in, Let n be the true class vector of student t+1 at time t. Belongs to the code feedback score category Category tags, Probability distribution of recommending a question for student number t+1 at time t Prediction code feedback score category The probability value; calculated by the cross-entropy loss function. And minimize the cross-entropy loss function To achieve this, we update all parameters in the Long Short-Term Memory (LSTM) network, the fully connected layers, and the embedding mapping matrix, up to the cross-entropy loss function. Until it stops falling;
[0167] Step S510: After calculating the cross-entropy loss in step S59, for the students' historical programming interaction sequences... Obtained using step S57 Probability distribution of recommended questions at all times Take the question identifier corresponding to the maximum value in the distribution and recommend it to students as the next time step t+1.
Claims
1. A personalized programming question recommendation method that fuses dynamic interaction information, characterized by: Comprising the following steps: Step S1: Obtain an online evaluation platform dataset, and pre-process and divide the online evaluation platform dataset; Step S2: Based on the data of step S1, formalize the student's historical programming interaction sequence and task definition; Step S3: According to the task requirement of step S2, build a general framework including a code representation module and a question recommendation module, and establish a personalized programming question recommendation model; Step S4: Implement and train the code representation module in step S3, use the online evaluation platform dataset obtained in step S1 as the input of the code representation module, use the programming large model UniXcoder and the language model GPT2-encoder to generate code and question text vectors, and integrate them into a comprehensive code representation through supervised learning; Step S5: Implement and train the question recommendation module in step S3, based on the comprehensive code representation of step S4, combine the student's historical programming interaction sequence, use long short-term memory network and attention mechanism to model the student's ability evolution, and generate the probability distribution of the next moment recommendation; Wherein step S4, the specific process is: Step S41, input the student's code submission record in the online evaluation platform dataset obtained in step S11 into the code representation module; Step S42, input the student's code submission record into the programming large model UniXcoder and the language model GPT2-encoder respectively; Step S43, in the preprocessing layer of the programmed large model UniXcoder, the student submitted code text is first segmented to obtain a sequence of length wherein, represents the first word unit segmented from the student submitted code text, represents the word unit segmented from the student submitted code text, and then a special mark CLS is inserted at the most leading end of a sequence of length , denoted as , to obtain a code text segmentation sequence of length ; Step S44, according to the programming language category to which the student submits the code text belongs, a multi-language analysis framework Tree-sitter is called to load the corresponding syntax library to parse the student-submitted code text to generate a code abstract syntax tree AST node sequence with a length of , represents the first node label of the code abstract syntax tree AST node sequence, represents the second node label of the code abstract syntax tree AST node sequence, represents the th node label of the code abstract syntax tree AST node sequence; Step S45, segmenting the code text into a sequence of words and a sequence of code abstract syntax tree AST nodes to obtain a unified input sequence ; Step S46, in the embedding layer of the programmed large model UniXcoder, each token in the unified input sequence is mapped into a high-dimensional vector respectively; Step S47, generating a high-dimensional vector matrix from the high-dimensional vector matrix generated in step S46 The Transformer encoder of the input programming large model UniXcoder generates a feature matrix that fuses code semantics and code abstract syntax tree AST node structure; After fusing the global context, a feature matrix is fused with the code semantics and the code abstract syntax tree AST node structure The vector corresponding to the special mark CLS , used to represent the comprehensive semantic information of the entire student submitted code; the vector is taken as the embedding vector of the student submitted code text, denoted as .
2. The method of claim 1, wherein the method further comprises: Step S1: Obtain an online evaluation platform dataset, and pre-process and divide the online evaluation platform dataset, specifically: Step S11, collect the online evaluation platform dataset, which includes the student's code submission record, the student's code submission record has the question identification, the question text, the student's submitted code text and the evaluation feedback score information; Step S12, pre-process the online evaluation platform dataset, which includes score discretization processing, question identification remapping and student's historical programming interaction sequence sorting; The score discretization processing converts the evaluation feedback score information into three categories of student evaluation feedback scores: error, partial correctness and full correctness; Question identification remapping uniformly maps the non-continuous question numbers in the online evaluation platform dataset to continuous numbers; The sorting of the student's historical programming interaction sequence is to arrange the code submission records of each student in ascending order according to the submission time to form the student's historical programming interaction sequence; Step S13, divide the pre-processed online evaluation platform dataset into students as a whole, that is, randomly select 80% of the students' all submission records as the training set, and the remaining 20% of the students' all submission records as the test set. 3.The method of claim 2, wherein the method further comprises: Step S2: Formalize the student's historical programming interaction sequence and task definition; Specifically: Step S21, formalize the personalized programming question recommendation task expression and definition: let be the set of all different programming questions, where represents the th programming question, is the total number of programming questions, and let there be a total of 𝑈 records of students in the training set; Step S22, set the historical programming interaction sequence of each student as wherein denotes the question identifier answered by the student at time step , denotes the question identifier answered by the student at time step , corresponding question text, denotes the question identifier answered by the student at time step , corresponding submitted code, denotes the classification of the student's evaluation feedback, respectively, as error, partial correctness, and full correctness. Step S23, on the basis of the historical programming interaction sequence of each student given in step S22 , learn the conditional distribution P( | ) of the learning candidate question random variable , and select as the programming question to be recommended to the student at the moment , to realize personalized question recommendation, wherein represents the value of the learning candidate question random variable that maximizes the conditional distribution P( | ).
4. The method of claim 3, wherein the method further comprises: Step S3, build a general framework including a code representation module and a question recommendation module, and establish a personalized programming question recommendation model, the specific process is: Step S31, the code representation module extracts the semantic and structural features of the code and the semantic features of the question text using the pre-trained programming language model, generates the corresponding embedding vectors of the code and the question text, and fuses the code and the question text using supervised learning to obtain a comprehensive code representation vector; Step S32, the question recommendation module uses the comprehensive code representation vector and the student's historical programming interaction sequence to predict the probability distribution of the next moment recommendation through the long short-term memory network and the attention mechanism.
5. The method of claim 4, wherein the method further comprises: Step S4, the code representation module in step S3 is implemented and trained, and the online evaluation platform dataset obtained in step S1 is input into the code representation module, the code and question text vector is generated by using the programming large model UniXcoder and the language model GPT2-encoder, and the comprehensive code representation is fused through supervised learning; further comprising the following steps: In the step S45, the input sequence is unified As shown in the formula: ; In the formula, is a splicing operation, is the code text segmentation sequence obtained in step S43, is the code abstract syntax tree AST node sequence obtained in step S44; wherein, in step S46, a high-dimensional vector matrix is generated wherein, denotes a real number field; is the embedding layer output dimension of the programmed large model UniXcoder; a vector in the high-dimensional vector matrix corresponds to a special mark CLS, used to represent the overall semantic information of the code; a vector respectively correspond to the token sequence in the code text ; a vector respectively correspond to the abstract syntax tree AST node sequence ; that is, the high-dimensional vector matrix is the token matrix of the code text and the abstract syntax tree AST node matrix is spliced by row Among them, step S47, a feature matrix is generated by fusing the code semantics and the code abstract syntax tree AST node structure; the formula is: ; wherein, is a feature matrix fusing code semantics and code abstract syntax tree AST node structure, represents the code semantics-code abstract syntax tree AST structure joint representation of the th token after fusing the global context; is the sequence length of the student-submitted code text segmented by the programming large model UniXcoder, is the length of the code abstract syntax tree AST node sequence; Step S48, for students in the time step Question identifier for answering Corresponding question text The GPT2-encoder language model is used to segment students at each time step. Question identifier for answering Corresponding question text The sequence is segmented into word-tagged sequences, and the word embedding layer of the GPT2-encoder language model is used to map each word-tagged sequence to a high-dimensional embedding vector. ; wherein, is the output dimension of the word embedding layer, is the question identity answered by the student at time step is the corresponding question text is the split token sequence length, is the high-dimensional embedding vector mapped from the jth token of the question identity answered by the student at time step is the corresponding question text is the split token sequence length, is the high-dimensional embedding vector mapped from the jth token of the question identity answered by the student at time step Step S49, the representations of the student's answer at time step the question identifier the corresponding question text the series of high-dimensional embedding vectors mapped from the jth word token of the question text are fed into the multi-layer Transformer encoder of the language model GPT2-encoder to obtain the final embedding representation of the question text corresponding to the student's answer at time step i ; ; wherein, represents the student's embedding representation at time step the question identifier that the student answered, the corresponding question text, the final embedding representation of the question, represents the context augmented hidden state; Step S410, using a weight matrix as The bias vector is The activation function is A fully connected layer that integrates student-submitted code text embedding vectors. The text of the questions that students answer at time step i Corresponding question text The final embedding representation Construct a comprehensive code representation vector; the specific formula is: ; In the formula, is a synthetic code representation vector; is a rectified linear unit activation function; Step S411, according to the score discretization processing in step S1, the student's evaluation feedback is classified , and converted into a code real category vector through one-hot encoding At the same time, the comprehensive code representation vector obtained in step S410 is input into a full connection layer with a weight matrix , a bias vector , and an activation function to obtain a predicted code category vector ; Step S412, for the student in the training set, the code text is submitted, and the code true category vector is obtained after step S411 With the predicted code category vector Suppose there are U students in the training set, and the Uth student has Code submission times The cross-entropy loss function is calculated for the true label and the predicted probability of the code feedback classification submitted by the u-th student at the i-th time step : ; where, is the classification of the code feedback, s e {0, 1, 2}, is the true class label of the u-th student at the i-th time step belonging to the class, is the probability of the model predicting that the u-th student at the i-th time step belongs to the class. Step S413, using the cross-entropy loss function calculated in step S412 , fine-tune the parameters of the programming large model UniXcoder, the parameters of the fully connected layer used for fusion in step S410, and the parameters of the fully connected layer used for classification in step S411 through the back propagation algorithm; the parameters of the language model GPT2-encoder are frozen and do not participate in parameter updating; Step S414, after completing the training of step S413, using the trained parameters, the full student answers at each time step to the question are identified corresponding submission code , respectively converted into a comprehensive code representation vector .
6. The method of claim 5, wherein the method further comprises: Step S5, the question recommendation module in step S3 is implemented and trained, based on the comprehensive code representation of step S4, combined with the student's historical programming interaction sequence, the long short-term memory network and the attention mechanism are used to model the evolution of the student's ability, and the probability distribution of the next moment recommendation is generated; the specific process is: Step S51, construct student answer interaction vector; at time step Using one-hot encoding student at time step Answer the question identity Under the condition of answering, get interaction vector ; If the student is in time step If the answer is correct, the assessment feedback is correct. Interaction vectors The middle ( +M) positions are set to 1, and the remaining positions are set to 0; if a student answers incorrectly, the assessment will provide feedback on the correctness of the answer. Interaction vectors The Middle One position is 1, and the rest are 0; Step S52, mapping the interaction vector into a low-dimensional embedding representation; using a learnable weight matrix , Step S53, converting the interaction vector into a low-dimensional dense question interaction embedding vector is the dimension of the question interaction embedding vector, and T represents matrix transposition; Step S53, constructing the comprehensive interaction embedding representation; combining the comprehensive code representation vector obtained in step S410 , the topic interaction embedding vector of step S52 Concatenating in order to obtain the comprehensive interaction embedding; the formula is as follows: ; In the formula, denotes the comprehensive interaction embedding vector of the student at time step i; Step S54, modeling the integrated interaction embedding sequence of the student using a long short-term memory network; the integrated interaction embedding sequence of the student at each time step is }, wherein, represents the integrated interaction embedding vector of the student at the 1st time step, represents the integrated interaction embedding vector of the student at the 2nd time step, represents the integrated interaction embedding vector of the student at the tth time step; embed the integrated interaction of the student at each time step into a sequence } into a long short-term memory network LSTM, and set an initial hidden state of the long short-term memory network LSTM as , for each time step from 1 to T update the hidden state of the long short-term memory network LSTM step by step , , is a hidden state dimension of the long short-term memory network LSTM; ; In the formula, is the hidden state of the long short-term memory network LSTM at the time step is the hidden state of the long short-term memory network LSTM at the time step Step S55, calculate the hidden state similarity; calculate the hidden state of time step t when the next question is recommended Similarity score with previous hidden state The similarity function is calculated as follows: ; wherein, is the hidden state of a long short-term memory network, LSTM, for time steps i = 1 to t - 1 is a concatenation matrix transpose, denotes a fully connected layer; Step S56, obtaining a context vector representing the student's historical ability state; applying a similarity function to the previously hidden state obtained in step S55 , applying a function to obtain normalized attention weights : ; Then by weighted summation, the history answer information related to the current state is captured to obtain a context vector representing the history ability state of the student : ; Step S57, predicting the next time recommendation topic; the context vector representing the student's historical ability state hidden state of time step t After splicing, it is jointly input to the full connection layer FC, and after activation function, the probability distribution of the next time recommendation topic : ; Step S58, construct supervision loss and update model parameters; for each sample in the training set, extract the time step of the sample the subject identification , and generate a true category vector in one-hot form ; ; wherein, represents the kth component of the true class vector represents the 1st component of the true class vector represents the 2nd component of the true class vector represents the 1st component of the true class vector represents the M-1st component of the true class vector represents the 1st component of the true class vector represents the M-1st component of the true class vector represents the 1st component of the true class vector Step S59, calculate the cross-entropy loss, and record the total number of students in the training set for the i-th student. Each time step, from t=1 to t= At time t, step S58 generates the true class vector of the nth student at time t+1, denoted as [vector]. And the probability distribution of the predicted question for the nth student at time t+1 in step S57 is denoted as follows: ; The cross-entropy loss function here is defined as: is defined as: ; wherein, is the true class vector of the u-th student at the t+1 time is the class of the code feedback is the class label, is the probability distribution of the u-th student's recommended question at the t+1 time is the predicted class of the code feedback is the probability value; by calculating the cross-entropy loss function and minimizing the cross-entropy loss function as the goal, and then updating all parameters in the long short-term memory network (LSTM), the fully connected layer and the embedding mapping matrix until the cross-entropy loss function no longer decreases. Step S510: After calculating the cross-entropy loss in step S59, for the student's historical programming interaction sequence... Obtained using step S57 Probability distribution of recommended questions at all times Take the question identifier corresponding to the maximum value in the distribution and recommend it to students as the next time step t+1.
Citation Information
Patent Citations
Dynamic perception test question recommendation method and system fused with deep knowledge tracking
CN114372137A
Programming knowledge tracking method and device fusing multi-dimensional attributes of questions and code representation
CN119026681A