NeuralProgramSynthesizer<T>
Models & Types · AiDotNet.ProgramSynthesis.Engines
Neural network-based program synthesizer that generates programs from specifications.
Inheritance: NeuralNetworkBase<T> → DeclaredModelLayoutBase<T> → TokenLanguageModelLayoutBase<T> → NeuralProgramSynthesizer<T>
Implements: IProgramSynthesizer<T>
For Beginners
This AI can write programs for you automatically!
Imagine describing what you want a program to do, or showing examples of inputs and outputs, and an AI writes the actual code. That’s what this does!
You can provide:
- A description: “Write a function that sorts a list of numbers”
- Examples: Input [3,1,2] → Output [1,2,3]
- Or both!
The AI learns from training and generates working code that solves your problem. It’s like having an AI programmer that can code based on your requirements!
How It Works
NeuralProgramSynthesizer uses deep learning to generate programs from natural language descriptions, input-output examples, or formal specifications. It employs an encoder-decoder architecture similar to CodeT5 but optimized for program synthesis tasks.
Example
var architecture = new CodeSynthesisArchitecture<float>(
SynthesisType.Neural, ProgramLanguage.CSharp, CodeTask.Generation);
var codeModel = new CodeBERT<float>(architecture);
var synthesizer = new NeuralProgramSynthesizer<float>(architecture, codeModel);
Constructors
| Constructor | Summary |
|---|---|
NeuralProgramSynthesizer(CodeSynthesisArchitecture<T> architecture, ICodeModel<T> codeModel, ILossFunction<T> lossFunction, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, IProgramExecutionEngine executionEngine, NeuralProgramSynthesizerOptions options, ISqlSyntaxValidator sqlSyntaxValidator, ICodeSyntaxProvider codeSyntaxProvider) |
Initializes a new instance of the NeuralProgramSynthesizer class. |
Properties
| Property | Summary |
|---|---|
ProgramLanguage TargetLanguage { get; } |
|
SynthesisType SynthesisType { get; } |
|
int MaxProgramLength { get; } |
Methods
| Method | Summary |
|---|---|
ModelMetadata<T> GetModelMetadata() |
|
Program<T> RefineProgram(Program<T> program, ProgramInput<T> feedback) |
Refines an existing program to better meet the specification. |
Program<T> SynthesizeProgram(ProgramInput<T> input) |
Synthesizes a program from the given input specification. |
bool ValidateProgram(Program<T> program) |
Validates whether a synthesized program is correct and well-formed. |
double EvaluateProgram(Program<T> program, ProgramInput<T> testCases) |
Evaluates how well a program satisfies the input specification. |