Why does understanding the abstract representations of source code matter? What's the motivation behind? How shall we introduce the idea?
Uniqueness of source code:
Granularity concept
Automatic programming applicability
Any studies in the Computer Science community:
Automatic Programming (Program Synthesis)
Structured Generative Models of Natural Source Code (Maddison & Tarlow, 2014)
Deep Software Engineering operates with tensors for modeling high-level representations of software data, such operations are employed to automate SE tasks
Neural Network
SE
Artificial Code Generation is the automatic construction of source code by means of Generative Models; algorithms which are able to generate source code might be substantially better at understanding intrinsically SE tasks
Neural Network
Program
Source Code Generative Agent
Real Source Code
Synthetic Source Code
A (deep) NN model is able to learn the abstract features of source code to generate the same structure
Source Code Generative Agent
SE Discriminative Agent
A generative agent can be converted into a discriminative one to solve a supervised task
Transfer Learning
Source Code
SE Task
Supervised SE Task
A fine-tuned discriminative agent is able to solve and automate SE tasks in an enhance fashion
SE Discriminative Agent
OpenAI proves that Generative Agents can be trained for specific discriminative tasks
Source Code Generative Agent
SE Discriminative Agent
Purpose: to synthesize and understand the intrinsic properties of the source code
Purpose: to perform classification (e.g., bug fixing, security-related identification, traceability) or regression (prediction of metrics: bugs, source code size, error proneness)
Multi-taskers
Real Source Code
We know from the Hoeffding's inequality that "learning" is feasible. However, obtaining such generalization would require more than training one agent. Goodfellow demonstrates that generator and discriminator competition improves agents' knowledge
Gaussian Noise
Synthetic Source Code
SC Generator
SC Discriminator
Agents might be able to produce "unique" source code as an emergent behavior from the non-linear interactions with each other. Such emergent behavior is supported by observations from complexity science
Enhanced Software 2.0 Programs? or Probably Brand-New Programs?
Enhanced synthesized source code?
First view: The generative Agent
Second view: The discriminative Agent
Third view: Generative Agents by Competition
Fourth view: Emergent "uniqueness" by complex interactions
First view: The generative Agent
Second view: The discriminative Agent
Third view: Generative Agents by Competition
Fourth view: Emergent "uniqueness" by complex interactions
First view: The generative Agent
Second view: The discriminative Agent
Third view: Generative Agents by Competition
Fourth view: Emergent "uniqueness" by complex interactions
First view: The generative Agent
Second view: The discriminative Agent
Third view: Generative Agents by Competition
Fourth view: Emergent "uniqueness" by complex interactions
SE-Based Benchmarks for Understanding and Comparing Deep Generative Source Code Models
The goal of generative research is to answer the question: How can we learn p_model similar to p_data?
The goal of generative research is to answer the question: How can we learn p_model similar to p_data?
Observational Joint
Interventional Joint
Unconditioned Generator
Conditioned Generator
Discriminator
Observational Code Model
Unconditioned Generator
Conditioned Generator
Discriminator
Interventional Code Model
Unconditioned Generator
Conditioned Generator
Discriminator
Unconditioned Generator
Conditioned Generator
Discriminator
Unconditioned Generator
Conditioned Generator
Discriminator
Self-Supervised
Unsupervised
Supervised
Unconditional
Conditional
Classification
Deep Code Generator
Unconditioned Generator
Conditioned Generator
Discriminator
Unsupervised
Supervised:
Self-Supervised:
Fine-Tuning
?
Unconditioned Generator
Conditioned Generator
Unconditioned Sampling
Unconditioned Training
Conditioned Sampling
Unconditioned Interventional Sampling
Unconditioned Observational Sampling
Unconditioned Interventional Sampling
Unconditioned Observational Sampling
Unconditioned Interventional Sampling
Unconditioned Observational Sampling
Unconditioned Interventional Sampling
Unconditioned Observational Sampling
Y is a code assessment property and A is the "treatment" or model employed.
Syntax Correctness in all the individuals (or samples) under lstm treatment
Syntax Correctness in all the individuals (or samples) under human treatment
We say that the generative agent (or autoregressive model) has a causal effect on the Syntax Correcteness if ...
We are interested in null causality. We don't want to observe a causal effect on outcomes.
We are interested in null causality. We don't want to observe a causal effect on outcomes.
Distribution of the dataset
Training
Validation
Test
BPE
Training (0.8)
Validation (0.1)
Test (0.09)
BPE (0.01)
[feasible-java-methods]
Testbed Generation
[feasible-py-methods]
[transXL-java-samples]
Transformation
[noisy-py-methods]
Deep Generators
[TransformerXL]
[AWD-LSTM]
Sampling
[noisy-java-methods]
[lstm-java-samples]
[transXL-py-samples]
[lstm-py-samples]
Unconditional Interpretability
Artificial Code Data
Human Code Data
Manifold
Causal Inference
Conditional Interpretability
1
2
1
4
3
5
LOC
CYCLO
FORs
...
LOC
CYCLO
FORs
...
SE Structure Distance
1
;
-
-
...
;
-
-
...
;
-
-
...
Compilation Error Distance
2
3
4
Inf. Contentent & Semantic Distance
1
2
3
Training
Validation
Test
BPE
Alien Prototype
(confidence or entropy)
Original Training Set
Alien Criticism
Alien Prototype
Source Code Generative Agent
The generative model is autoregressive. That is, it is trained on sequential data by predicting the next token
Conditioned Sampling
Unconditioned Sampling
Output Space Analysis
Feature Space Analysis
Conditioned Sampling
Unconditioned Sampling
Feature Clustering Representation
Cell Activation
Output Space Analysis
Feature Space Analysis
Conditioned Sampling
Unconditioned Sampling
Clustering Represenation
Cell Activation
Unconditioned Sampling
Unconditioned Sampling
Unconditioned Sampling
Uniqueness: distance from centroids
Unconditioned Sampling
Unconditioned Sampling
Static: Syntax Checkers
Syntax Error Rate
Static and Dynamic Meaningfulness
Unconditioned Sampling
Unconditioned Sampling
Alien Cluster
(confidence or entropy)
Alien Sample
Unconditioned Sampling
Conditioned Sampling
Conditioned Sampling
Conditioned Sampling
Conditioned Sampling
for (int i = 0
;
=
for
int
....
0.3
0.4
0.01
0.01
Conditioned Sampling
for (int i = 0
;
=
for
int
....
0.3
0.4
0.01
0.01
Conditioned Sampling
Conditioned Sampling
Transformer (20 layers)
Transformer (50 layers)
Conditioned Sampling
Well-written testbed
Which generative model is a good predictor?
Correlation
Conditioned Sampling
Well-written testbed
Noisy testbed 1
mutations
Noisy testbed 2
Which generative model is a good predictor?
Correlation
Causation
Source Code Discriminative Agent
The generative model can be adapted by transfer learning strategies to become a discriminative one
Classification
Regression
Source Code Generative Agent + Discriminative
SE Multitask Agent
Unsupervised multi-task learners are employed in Language Models, the same way we can employ SE Multitask learners!
Real Source Code
Gaussian Noise
Synthetic Source Code
SC Generator
SC Discriminator
The generator learns how to create source code in such a way that the discriminator is not able to distinguish synthetic source code
Real Source Code
Gaussian Noise
Synthetic Source Code
SC Generator
SC Discriminator
The generator is an "Intelligent Agent" that is able to enhance its source code by competition (game theory)
Agent
Enviroment
Large scale agent interactions might produce "emergent" (human-level) source code
Close-ended Evolution
Open-Ended Evolution
Evolutionary Computation to communicate SC agents
Neural Network
Are Neural Networks Turing Complete?
Algorithm
Program
ON THE TURING COMPLETENESS OF MODERN NEURAL NETWORK ARCHITECTURES (ICLR'19 Perez, et al.)
https://royalsocietypublishing.org/doi/10.1098/rsif.2018.0395
Auto-regressive, adversarial, or autoenconder architectures
Trained Generative Agent
Trained Fine-Tuned Agent
Deep Neural Classifier
Better Performance
Generative Agents are sensitive to initial conditions (hyper-parameters) and inputs
Fine-Tune Strategy 1
Fine-Tune Strategy 2
Worst Performance
No leading agent or "deep neural net" controlling for interactions
Case study 1 [self-replication]: Are self-replicated "programs" (or NN or Software 2.0) somewhat better? What type of properties have? Can the multi-tasker agents perform a brand new task?
Case study 2 [self-organization]: are the generative agents reporting enhanced accuracy after transfer-learning interactions?
Assembled Agent (by transfer learning strategies)
Enhanced synthesized code?
Simple and Local Transfer Rules
Better accuracy? What type of tasks emerged?
Fine-Tuning
Complex Programs or Advanced Software Systems
[semantic|conditioned] Learned Representation Analysis for SE Metrics: to determine if the learned representation from the generators has learned about the concept of SE metrics such as cyclomatic complexity, lines of code, etc.
Probing classifier - MLP that is fed the representation (i.e. hidden state) of a method the model is given and is asked to predict some SE Metric, i.e. cyclomatic complexity
Performance Metric: We are attempting to measure how well the generator is able to capture SE related metrics and so we will be measuring mostly precision, recall, accuracy for each SE metric.
[design-pattern-01] Testbed of classes with different design patterns such as factory method, singleton, decorator, etc.
[anti-pattern-01] Testbed of classes with different anti patterns such as anemic domain model, call super, circular dependency, etc.
[ast-01] Testbed of methods with different types of AST nodes and relations.
[cfg-01] Testbed of methods with different types of CFGs.
[type-01] Testbed for classifying the type based on the variable name
First view: The generative Agent
Second view: The discriminative Agent
Third view: Generative Agents by Competition
Fourth view: Emergent "uniqueness" by complex interactions