ooples/AiDotNet

A new library for all of the newest ai algorithms

C#

60

4,662 commits

updated Oct 4, 2026

See the code

README

AiDotNet

The Most Comprehensive AI/ML Framework for .NET

8,100+ public classes (grep -c verified) across 139 modules - the most complete AI/ML platform for .NET

Build Status CodeQL Codacy Badge NuGet License

Neural Networks Classical ML Computer Vision Audio Video RL Agents Diffusion RAG LoRA HuggingFace Multi-GPU

Getting Started • Samples • Documentation • API Reference • Contributing


Why AiDotNet?

FeatureAiDotNetTorchSharpTensorFlow.NETML.NETAccord.NET
Neural Network Architectures160+50+30+~10~20
Classical ML Algorithms155+NoneNone~30~50
Computer Vision Models115+Via PyTorchVia TFLimitedLimited
Audio Processing250+LimitedLimitedNoneBasic
Reinforcement Learning50+ agentsManualLimitedNoneNone
Diffusion Models75+ManualNoneNoneNone
LoRA Fine-tuning50+ adaptersManualNoneNoneNone
RAG Components50+NoneNoneNoneNone
Distributed TrainingDDP, FSDP, ZeRODDP onlyMirroredStrategyNoneNone
HuggingFace IntegrationNativePartialPartialNoneNone
GPU AccelerationCUDA, OpenCL, VulkanVia LibTorchVia TF RuntimeLimitedNone
Pure .NET (No Runtime)YesNo (LibTorch)No (TF Runtime)YesYes
Startup TimeFastSlowSlowFastFast
Memory/Span SupportFullLimitedLimitedLimitedNone

Quick Start by Task

What do you want to build?

TaskQuick LinkDescription
Classify dataClassificationBinary, multi-class, image classification
Predict valuesRegressionPrice prediction, forecasting
Group similar itemsClusteringCustomer segmentation, anomaly detection
Detect objects in imagesComputer VisionYOLO, DETR, Mask R-CNN
Process audio/speechAudioWhisper, TTS, music generation
Build a chatbot with RAGRAGVector stores, retrievers, rerankers
Fine-tune LLMsLoRA Fine-tuningQLoRA, DoRA, AdaLoRA
Generate imagesDiffusion ModelsStable Diffusion, DALL-E 3
Train RL agentsReinforcement LearningDQN, PPO, SAC, multi-agent
Forecast time seriesTime SeriesARIMA, Prophet, N-BEATS
Scale trainingDistributed TrainingMulti-GPU, multi-node

Installation

dotnet add package AiDotNet

Requirements: .NET 10.0 / .NET 8.0+ (or .NET Framework 4.7.1+)


Hello World Example

using AiDotNet;
using AiDotNet.Enums;
using AiDotNet.LinearAlgebra;
using AiDotNet.NeuralNetworks;

// features: [N, 4] tensor of Iris measurements
// labels:   [N, 3] one-hot tensor of species
var architecture = new NeuralNetworkArchitecture<double>(
    inputFeatures: 4, numClasses: 3, complexity: NetworkComplexity.Simple);

var result = await new AiModelBuilder<double, Tensor<double>, Tensor<double>>()
    .ConfigureModel(new NeuralNetwork<double>(architecture))
    .BuildAsync(features, labels);

var predictions = result.Predict(testFeatures);

Full runnable version (inline Iris dataset, train/test split, accuracy report): samples/getting-started/HelloWorld/Program.cs


Complete Feature Reference

Neural Networks (160+ Architectures)

Click to expand all neural network types

Core Architectures

  • NeuralNetwork - Feedforward networks
  • ConvolutionalNeuralNetwork - CNNs for images
  • RecurrentNeuralNetwork - RNNs for sequences
  • LSTMNeuralNetwork - Long Short-Term Memory
  • GRUNeuralNetwork - Gated Recurrent Units
  • TransformerArchitecture - Attention-based models
  • ResNetNetwork - Residual networks
  • DenseNetNetwork - Densely connected networks
  • EfficientNetNetwork - Efficient scaling
  • MobileNetV2Network, MobileNetV3Network - Mobile-optimized

Generative Models

  • GenerativeAdversarialNetwork (GAN)
  • DCGAN, ConditionalGAN, CycleGAN
  • ProgressiveGAN, BigGAN, StyleGAN
  • ACGAN, InfoGAN, Pix2Pix
  • Autoencoder, VariationalAutoencoder

Graph Neural Networks

  • GraphNeuralNetwork (GNN)
  • GraphAttentionNetwork (GAT)
  • GraphSAGENetwork
  • GraphIsomorphismNetwork (GIN)
  • GraphGenerationModel

Specialized Architectures

  • CapsuleNetwork - Capsule networks
  • SpikingNeuralNetwork - Neuromorphic computing
  • QuantumNeuralNetwork - Quantum ML
  • HyperbolicNeuralNetwork - Hyperbolic geometry
  • MixtureOfExpertsNeuralNetwork - MoE
  • NeuralTuringMachine - NTM
  • DifferentiableNeuralComputer - DNC
  • MemoryNetwork - Memory-augmented
  • EchoStateNetwork - Reservoir computing
  • LiquidStateMachine - Liquid state machines
  • HopfieldNetwork - Associative memory
  • RestrictedBoltzmannMachine - RBM
  • DeepBeliefNetwork - DBN
  • DeepBoltzmannMachine - DBM
  • RadialBasisFunctionNetwork - RBF
  • SelfOrganizingMap - SOM
  • ExtremeLearningMachine - ELM
  • NEAT - Neuroevolution

Vision-Language Models

  • ClipNeuralNetwork - CLIP
  • BlipNeuralNetwork, Blip2NeuralNetwork - BLIP
  • LLaVANeuralNetwork - LLaVA
  • FlamingoNeuralNetwork - Flamingo
  • Gpt4VisionNeuralNetwork - GPT-4V

Attention Mechanisms

  • AttentionNetwork
  • FlashAttention - Memory-efficient attention
  • MultiHeadAttention

Example:

var model = new AiModelBuilder<double, Tensor<double>, Tensor<double>>()
    .ConfigureModel(new ConvolutionalNeuralNetwork<double>(
        inputChannels: 3,
        numClasses: 1000,
        architecture: CNNArchitecture.ResNet50))
    .ConfigureOptimizer(new AdamWOptimizer<double>(learningRate: 0.001))
    .ConfigureMixedPrecision()  // FP16 training
    .ConfigureGpuAcceleration()
    .BuildAsync(trainImages, trainLabels);

Classification (50 Algorithms)

Click to expand all classification algorithms

Ensemble Methods

  • RandomForestClassifier
  • GradientBoostingClassifier
  • AdaBoostClassifier
  • ExtraTreesClassifier
  • BaggingClassifier
  • StackingClassifier
  • VotingClassifier

Naive Bayes

  • GaussianNaiveBayes
  • MultinomialNaiveBayes
  • BernoulliNaiveBayes
  • ComplementNaiveBayes
  • CategoricalNaiveBayes

Linear Models

  • LogisticRegression
  • RidgeClassifier
  • SGDClassifier
  • PassiveAggressiveClassifier
  • PerceptronClassifier

Support Vector Machines

  • LinearSupportVectorClassifier
  • SupportVectorClassifier

Discriminant Analysis

  • LinearDiscriminantAnalysis
  • QuadraticDiscriminantAnalysis

Multi-label/Multi-output

  • OneVsRestClassifier
  • OneVsOneClassifier
  • ClassifierChain
  • MultiOutputClassifier

Neighbors

  • KNeighborsClassifier

Example:

var result = await new AiModelBuilder<double, double[], double>()
    .ConfigureModel(new RandomForestClassifier<double>(nEstimators: 100))
    .ConfigurePreprocessing(pipeline => pipeline
        .Add(new StandardScaler<double>())
        .Add(new SimpleImputer<double>()))
    .ConfigureCrossValidation(new KFoldCrossValidator<double>(k: 5))
    .BuildAsync(features, labels);

Console.WriteLine($"Accuracy: {result.CrossValidationResult?.MeanAccuracy:P2}");

Regression (57 Algorithms)

Click to expand all regression algorithms

Linear Models

  • MultipleRegression
  • PolynomialRegression
  • RidgeRegression
  • LassoRegression
  • ElasticNetRegression
  • BayesianRegression
  • OrthogonalRegression

Tree-Based

  • DecisionTreeRegression
  • GradientBoostingRegression
  • AdaBoostR2Regression
  • ExtremelyRandomizedTreesRegression
  • M5ModelTreeRegression
  • ConditionalInferenceTreeRegression

Kernel Methods

  • GaussianProcessRegression
  • KernelRidgeRegression
  • SupportVectorRegression

Specialized

  • IsotonicRegression
  • LocallyWeightedRegression
  • PartialLeastSquaresRegression
  • MultivariateRegression
  • GeneralizedAdditiveModelRegression

Probabilistic

  • PoissonRegression
  • NegativeBinomialRegression
  • QuantileRegression
  • RobustRegression

Neural Network Based

  • MultilayerPerceptronRegression
  • NeuralNetworkRegression

Optimization-Based

  • GeneticAlgorithmRegression

Example:

var result = await new AiModelBuilder<double, double[], double>()
    .ConfigureModel(new GradientBoostingRegression<double>(
        nEstimators: 200,
        maxDepth: 5,
        learningRate: 0.1))
    .ConfigureHyperparameterOptimizer(
        new BayesianOptimizer<double>(),
        searchSpace: new HyperparameterSearchSpace()
            .AddContinuous("learning_rate", 0.01, 0.3)
            .AddInteger("max_depth", 3, 10),
        trials: 50)
    .BuildAsync(features, targets);

Clustering (48 Algorithms)

Click to expand all clustering algorithms

Centroid-Based

  • KMeansClustering
  • KMedoidsClustering
  • MiniBatchKMeans

Density-Based

  • DBSCAN
  • HDBSCAN
  • OPTICS
  • MeanShift
  • Denclue

Hierarchical

  • AgglomerativeClustering
  • BIRCH
  • CURE

Model-Based

  • GaussianMixtureClustering
  • BayesianGaussianMixture

Spectral

  • SpectralClustering

Self-Organizing

  • GMeans
  • XMeans

Distance Metrics

  • EuclideanDistance
  • ManhattanDistance
  • CosineDistance
  • MahalanobisDistance
  • ChebyshevDistance
  • MinkowskiDistance

Validation Metrics

  • SilhouetteScore
  • DaviesBouldinIndex
  • CalinskiHarabaszIndex
  • DunnIndex
  • AdjustedRandIndex

Example:

var result = await new AiModelBuilder<double, double[], int>()
    .ConfigureModel(new HDBSCAN<double>(minClusterSize: 15, minSamples: 5))
    .ConfigureAutoML(new ClusteringAutoML<double>())  // Auto-tune parameters
    .BuildAsync(features);

Console.WriteLine($"Clusters found: {result.Model.Labels.Distinct().Count()}");
Console.WriteLine($"Silhouette Score: {result.ClusteringMetrics?.SilhouetteScore:F3}");

Computer Vision (115+ Models)

Click to expand all computer vision capabilities

Object Detection

  • YOLO Family: YOLOv5, YOLOv8, YOLOv9, YOLOv10, YOLOv11
  • Transformer-Based: DETR, Deformable DETR, DINO
  • Two-Stage: Faster R-CNN, Cascade R-CNN
  • Anchor-Free: FCOS, CenterNet

Instance Segmentation

  • Mask R-CNN
  • YOLACT
  • SOLOv2
  • Segment Anything (SAM)

Semantic Segmentation

  • DeepLabV3+
  • UNet, UNet++
  • PSPNet
  • HRNet

Object Tracking

  • SORT
  • DeepSORT
  • ByteTrack
  • OC-SORT

OCR & Scene Text

  • SceneTextReader
  • Text detection + recognition
  • Multi-language support

Pose Estimation

  • OpenPose
  • HRNet-Pose
  • ViTPose

3D Vision

  • PointNet, PointNet++
  • MeshCNN
  • NeRF (Neural Radiance Fields)

Example:

var builder = new AiModelBuilder<float, Tensor<float>, DetectionResult[]>()
    .ConfigureObjectDetector(new YOLOv8Detector<float>(
        modelSize: YOLOModelSize.Medium,
        confidenceThreshold: 0.5f))
    .ConfigureVisualization(new VisualizationOptions { DrawLabels = true });

var result = await builder.BuildAsync();
var detections = result.Model.Detect(image);

foreach (var det in detections)
    Console.WriteLine($"{det.Label}: {det.Confidence:P1} at {det.BoundingBox}");

Audio Processing (250+ Models)

Click to expand all audio capabilities

Speech Recognition

  • Whisper: whisper-tiny, whisper-base, whisper-small, whisper-medium, whisper-large
  • Wav2Vec2: Multiple languages
  • HuBERT
  • Conformer

Text-to-Speech

  • VITS
  • FastSpeech2
  • Tacotron2
  • XTTS (multi-speaker, cross-lingual)

Music Generation

  • MusicGen
  • AudioGen
  • Riffusion

Audio Classification

  • Audio event detection
  • Music genre classification
  • Environmental sound classification

Speaker Analysis

  • Speaker identification
  • Speaker verification
  • Speaker diarization

Audio Enhancement

  • Noise reduction
  • Echo cancellation
  • Speech enhancement

Source Separation

  • Vocals/instruments separation
  • Multi-track separation

Voice Activity Detection

  • WebRTC VAD
  • Silero VAD

Emotion Recognition

  • Speech emotion classification

Music Analysis

  • Beat detection
  • Chord recognition
  • Key detection
  • Tempo estimation

Example:

// Speech-to-Text with Whisper
var whisper = new WhisperModel<float>(WhisperModelSize.Medium, language: "en");
var transcription = await whisper.TranscribeAsync(audioFile);
Console.WriteLine(transcription.Text);

// Text-to-Speech
var tts = new VITSModel<float>(voice: "en-US-female");
var audio = await tts.SynthesizeAsync("Hello, world!");
await audio.SaveAsync("output.wav");

Video Processing (80+ Models)

Click to expand all video capabilities

Video Generation

  • Stable Video Diffusion
  • AnimateDiff
  • VideoCrafter
  • Text2Video

Action Recognition

  • SlowFast
  • TimeSformer
  • Video Swin Transformer

Video Understanding

  • CLIP4Clip
  • Video captioning

Optical Flow

  • RAFT
  • FlowNet

Video Object Detection

  • Video object tracking
  • Multi-object tracking

Example:

var videoGen = new StableVideoDiffusion<float>();
var video = await videoGen.GenerateAsync(
    prompt: "A cat playing piano",
    numFrames: 24,
    fps: 8);
await video.SaveAsync("output.mp4");

Reinforcement Learning (50+ Agents)

Click to expand all RL agents

Value-Based

  • DQNAgent - Deep Q-Network
  • DoubleDQNAgent - Double DQN
  • DuelingDQNAgent - Dueling architecture
  • RainbowDQNAgent - Rainbow (all improvements)
  • QLearningAgent, DoubleQLearningAgent
  • SARSAAgent, ExpectedSARSAAgent
  • NStepQLearningAgent, NStepSARSAAgent

Policy Gradient

  • REINFORCEAgent
  • A2CAgent - Advantage Actor-Critic
  • A3CAgent - Asynchronous A3C
  • PPOAgent - Proximal Policy Optimization

Actor-Critic

  • DDPGAgent - Deep Deterministic PG
  • TD3Agent - Twin Delayed DDPG
  • SACAgent - Soft Actor-Critic

Model-Based

  • DreamerAgent - World models
  • MuZeroAgent - MuZero
  • DynaQAgent, DynaQPlusAgent
  • PrioritizedSweepingAgent

Multi-Agent

  • MADDPGAgent - Multi-Agent DDPG
  • QMIXAgent - QMIX

Offline RL

  • CQLAgent - Conservative Q-Learning
  • IQLAgent - Implicit Q-Learning

Monte Carlo

  • MonteCarloExploringStartsAgent
  • FirstVisitMonteCarloAgent
  • EveryVisitMonteCarloAgent
  • OffPolicyMonteCarloAgent

Planning

  • MCTSNode - Monte Carlo Tree Search
  • PolicyIterationAgent
  • ModifiedPolicyIterationAgent

Bandits

  • EpsilonGreedyBanditAgent
  • UCBBanditAgent
  • ThompsonSamplingAgent
  • GradientBanditAgent

Sequence Models

  • DecisionTransformerAgent

Example:

var env = new CartPoleEnvironment();
var agent = new PPOAgent<double>(
    stateSize: env.ObservationSpace,
    actionSize: env.ActionSpace,
    hiddenSize: 64,
    learningRate: 3e-4);

// Training loop
for (int episode = 0; episode < 1000; episode++)
{
    var state = env.Reset();
    double totalReward = 0;

    while (!env.IsDone)
    {
        var action = agent.SelectAction(state);
        var (nextState, reward, done) = env.Step(action);
        agent.Store(state, action, reward, nextState, done);
        state = nextState;
        totalReward += reward;
    }

    agent.Train();
    Console.WriteLine($"Episode {episode}: Reward = {totalReward}");
}

Time Series (30+ Models)

Click to expand all time series models

Classical Statistical

  • ARModel - Autoregressive
  • MAModel - Moving Average
  • ARMAModel - ARMA
  • ARIMAModel - ARIMA
  • SARIMAModel - Seasonal ARIMA
  • ARIMAXModel - ARIMAX with exogenous variables
  • GARCHModel - Volatility modeling
  • VARModel, VARMAModel - Vector models

Exponential Smoothing

  • ExponentialSmoothingModel
  • HoltWintersModel
  • TBATSModel

Deep Learning

  • NBEATSModel - N-BEATS
  • NHiTSModel - N-HiTS
  • DeepARModel - DeepAR
  • TemporalFusionTransformer
  • InformerModel - Informer
  • AutoformerModel - Autoformer
  • ChronosFoundationModel - Chronos

Anomaly Detection

  • DeepANT
  • LSTMVAE
  • TimeSeriesIsolationForest

Specialized

  • ProphetModel - Facebook Prophet
  • StateSpaceModel
  • BayesianStructuralTimeSeriesModel
  • SpectralAnalysisModel

Example:

var result = await new AiModelBuilder<double, double[], double>()
    .ConfigureModel(new NBEATSModel<double>(
        stackTypes: new[] { StackType.Trend, StackType.Seasonality, StackType.Generic },
        horizonSize: 24))
    .ConfigureTrainingPipeline(new TrainingPipelineConfiguration<double>
    {
        EarlyStopping = new EarlyStoppingConfig { Patience = 10 }
    })
    .BuildAsync(historicalData);

var forecast = result.Model.Forecast(steps: 24);

Retrieval-Augmented Generation (50+ Components)

Click to expand all RAG components

Vector Stores

  • In-memory vector store
  • FAISS integration
  • Pinecone, Weaviate, Qdrant adapters
  • Chroma, Milvus support

Embedding Models

  • OpenAI embeddings
  • HuggingFace embeddings
  • Sentence Transformers
  • BGE, ColBERT

Retrievers

  • Dense retriever
  • Sparse retriever (BM25)
  • Hybrid retriever
  • Multi-query retriever
  • Self-query retriever

Rerankers

  • Cross-encoder reranker
  • ColBERT reranker
  • Cohere reranker

Document Processing

  • Text splitters (recursive, semantic)
  • Document loaders
  • Chunking strategies

Graph RAG

  • Knowledge graph construction
  • Entity extraction
  • Relation extraction
  • Graph traversal retrieval

Query Processing

  • Query expansion
  • Query rewriting
  • HyDE (Hypothetical Document Embeddings)

Example:

var result = await new AiModelBuilder<float, string, string>()
    .ConfigureRetrievalAugmentedGeneration(
        retriever: new HybridRetriever<float>(
            denseRetriever: new DenseRetriever<float>(embeddingModel),
            sparseRetriever: new BM25Retriever(),
            alpha: 0.7f),
        reranker: new CrossEncoderReranker<float>(),
        generator: new LLMGenerator<float>(llmClient),
        queryProcessors: new[] { new QueryExpander() })
    .BuildAsync();

var answer = await result.Model.QueryAsync("What is the capital of France?", documents);

LoRA Fine-tuning (50+ Adapters)

Click to expand all LoRA variants

Standard LoRA

  • LoRAAdapter - Original LoRA
  • LoRAPlusAdapter - LoRA+

Quantized

  • QLoRAAdapter - 4-bit quantization
  • QALoRAAdapter - Quantization-aware

Memory Efficient

  • DoRAAdapter - Weight-Decomposed
  • VeRAAdapter - Very efficient
  • NOLAAdapter - Noise-optimized

Rank Adaptation

  • AdaLoRAAdapter - Adaptive rank
  • DyLoRAAdapter - Dynamic rank
  • ReLoRAAdapter - Recursive

Specialized

  • LoHaAdapter - Hadamard product
  • LoKrAdapter - Kronecker product
  • MoRAAdapter - Mixture of ranks
  • LongLoRAAdapter - Long context
  • GraphConvolutionalLoRAAdapter - For GNNs

Advanced

  • PiSSAAdapter - Principal singular values
  • FloraAdapter - Floating-point
  • DeltaLoRAAdapter - Delta updates
  • LoftQAdapter - Quantization-aware init
  • ChainLoRAAdapter - Chained adapters

Example:

var result = await new AiModelBuilder<float, string, string>()
    .ConfigureLoRA(new QLoRAConfiguration<float>
    {
        Rank = 16,
        Alpha = 32,
        TargetModules = new[] { "q_proj", "v_proj", "k_proj", "o_proj" },
        QuantizationBits = 4,
        UseDoubleQuantization = true
    })
    .ConfigureFineTuning(new FineTuningConfiguration<float>
    {
        BaseModel = "meta-llama/Llama-2-7b-hf",
        TrainingArguments = new TrainingArguments
        {
            NumEpochs = 3,
            BatchSize = 4,
            GradientAccumulationSteps = 8
        }
    })
    .BuildAsync(trainingData);

Diffusion Models (75+ Models)

Click to expand all diffusion models

Image Generation

  • StableDiffusionModel
  • SDXLModel - Stable Diffusion XL
  • DallE3Model - DALL-E 3
  • PixArtModel - PixArt

Image Editing

  • ControlNetModel
  • IPAdapterModel
  • Inpainting, Outpainting

Audio Generation

  • AudioLDMModel, AudioLDM2Model
  • MusicGenModel
  • RiffusionModel
  • DiffWaveModel

Video Generation

  • StableVideoDiffusion
  • AnimateDiffModel
  • VideoCrafterModel

3D Generation

  • DreamFusionModel
  • MVDreamModel
  • ShapEModel
  • PointEModel
  • Zero123Model

Architectures

  • DDPMModel - Denoising Diffusion
  • ConsistencyModel - Fast inference
  • Various schedulers (DDIM, PNDM, etc.)

Example:

var diffusion = new SDXLModel<float>();
var image = await diffusion.GenerateAsync(
    prompt: "A photorealistic cat astronaut on Mars",
    negativePrompt: "blurry, low quality",
    width: 1024,
    height: 1024,
    numInferenceSteps: 30,
    guidanceScale: 7.5f);

await image.SaveAsync("output.png");

Distributed Training

Click to expand distributed training options

Data Parallelism

  • DDPModel - Distributed Data Parallel
  • DDPOptimizer

Model Parallelism

  • PipelineParallelModel
  • TensorParallelModel

Fully Sharded

  • FSDPModel - Fully Sharded Data Parallel
  • ZeROOptimizer (Stage 1, 2, 3)
  • HybridShardedModel

Communication

  • NCCL backend (NVIDIA)
  • Gloo backend
  • MPI backend

Optimization

  • GradientCompressionOptimizer
  • AsyncSGDOptimizer
  • LocalSGDOptimizer
  • ElasticOptimizer - Fault-tolerant

Example:

var result = await new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
    .ConfigureModel(largeModel)
    .ConfigureDistributedTraining(
        strategy: DistributedStrategy.FSDP,
        backend: new NCCLCommunicationBackend(),
        configuration: new FSDPConfiguration
        {
            ShardingStrategy = ShardingStrategy.FullShard,
            MixedPrecision = true,
            ActivationCheckpointing = true
        })
    .ConfigureGpuAcceleration(new GpuAccelerationConfig { DeviceIds = new[] { 0, 1, 2, 3 } })
    .BuildAsync(trainData);

Meta-Learning (18+ Algorithms)

Click to expand meta-learning methods

Optimization-Based

  • MAMLAlgorithm - Model-Agnostic Meta-Learning
  • iMAMLAlgorithm - Implicit MAML
  • ReptileAlgorithm
  • MetaSGDAlgorithm
  • ANILAlgorithm - Almost No Inner Loop
  • BOILAlgorithm - Body Only Inner Loop

Metric-Based

  • ProtoNetsAlgorithm - Prototypical Networks
  • MatchingNetworksAlgorithm
  • RelationNetworkAlgorithm

Memory-Based

  • MANNAlgorithm - Memory-Augmented NN
  • NTMAlgorithm - Neural Turing Machine

Hybrid

  • LEOAlgorithm - Latent Embedding Optimization
  • CNAPAlgorithm - Conditional Neural Adaptive Processes
  • TADAMAlgorithm - Task-Dependent Adaptive Metric
  • MetaOptNetAlgorithm
  • GNNMetaAlgorithm - Graph-based

Example:

var result = await new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
    .ConfigureMetaLearning(new MAMLAlgorithm<float>(
        innerLearningRate: 0.01f,
        outerLearningRate: 0.001f,
        innerSteps: 5))
    .BuildAsync(metaTrainTasks);

// Few-shot learning on new task
var adapted = result.MetaLearner.Adapt(supportSet, numSteps: 10);
var predictions = adapted.Predict(querySet);

Self-Supervised Learning (10+ Methods)

Click to expand SSL methods

Contrastive

  • SimCLR
  • MoCo - Momentum Contrast
  • BYOL - Bootstrap Your Own Latent
  • BarlowTwins
  • SwAV - Swapping Assignments

Masked

  • MAE - Masked Autoencoder
  • BEiT

Distillation

  • DINO - Self-Distillation
  • iBOT

Evaluation

  • Linear probing
  • KNN evaluation
  • Transfer benchmarks

Optimizers (40+)

Click to expand all optimizers

Adaptive Learning Rate

  • AdamOptimizer, AdamWOptimizer
  • AdagradOptimizer
  • AdaDeltaOptimizer
  • AdaMaxOptimizer
  • AMSGradOptimizer
  • NadamOptimizer

Momentum-Based

  • MomentumOptimizer
  • NesterovAcceleratedGradientOptimizer

Second-Order

  • BFGSOptimizer, LBFGSOptimizer
  • NewtonMethodOptimizer
  • LevenbergMarquardtOptimizer
  • ConjugateGradientOptimizer

Large-Scale

  • LAMBOptimizer - Layer-wise Adaptive
  • LARSOptimizer - Layer-wise Rate Scaling
  • LionOptimizer - Evolved Sign Momentum

Regularized

  • FTRLOptimizer - Follow-The-Regularized-Leader

Evolutionary

  • GeneticAlgorithmOptimizer
  • ParticleSwarmOptimizer
  • DifferentialEvolutionOptimizer
  • CMAESOptimizer - Covariance Matrix Adaptation
  • AntColonyOptimizer

Specialized

  • BayesianOptimizer - Hyperparameter tuning
  • NelderMeadOptimizer - Simplex method
  • CoordinateDescentOptimizer
  • ADMMOptimizer - Alternating Direction

Loss Functions (37+)

  • Classification: CrossEntropy, BinaryCrossEntropy, FocalLoss, LabelSmoothing
  • Regression: MSE, MAE, Huber, LogCosh, Quantile
  • Segmentation: Dice, IoU, Tversky, Lovász
  • Metric Learning: Triplet, Contrastive, ArcFace, CosFace, Circle
  • Generative: Wasserstein, Hinge, LSGAN
  • Multi-task: Uncertainty-weighted, GradNorm

Additional Features

AutoML

  • Hyperparameter optimization (Bayesian, Random, Grid)
  • Neural Architecture Search (NAS)
  • Feature selection
  • Model selection

Federated Learning

  • FedAvg, FedProx, FedNova
  • Secure aggregation
  • Differential privacy
  • Client selection strategies

Tokenization (HuggingFace Compatible)

  • BPE, WordPiece, Unigram, SentencePiece
  • Pre-trained tokenizer loading
  • Custom tokenizer training

Model Compression

  • Pruning (magnitude, structured)
  • Quantization (INT8, FP16, INT4)
  • Knowledge distillation
  • Low-rank factorization

Uncertainty Quantification

  • Monte Carlo Dropout
  • Deep Ensembles
  • Bayesian Neural Networks
  • Conformal Prediction

Data Augmentation

  • Image: Flip, rotate, crop, color jitter, MixUp, CutMix, AutoAugment
  • Text: Synonym replacement, back-translation, EDA
  • Audio: Time stretch, pitch shift, noise injection
  • Tabular: SMOTE, ADASYN

Experiment Tracking

  • Experiment management
  • Metric logging
  • Checkpoint management
  • Model registry

Prompt Engineering

  • Prompt templates
  • Chain-of-thought
  • Few-shot learning
  • Prompt optimization

Samples

See the samples/ directory for complete, runnable examples:

CategorySampleDescription
Getting StartedHelloWorldYour first AiDotNet model
ClassificationSentimentAnalysisText sentiment with NaiveBayes
Computer VisionObjectDetectionYOLOv8 object detection
AudioSpeechRecognitionWhisper transcription
RAGBasicRAGBuild a Q&A system
RLCartPoleTrain a PPO agent

API Reference

Full API documentation: docfx-generated reference at ooples.github.io/AiDotNet/api/; narrative docs and guides at aidotnet.dev/docs.

Key namespaces:

  • AiDotNet - Core builder and result types
  • AiDotNet.NeuralNetworks - All neural network architectures
  • AiDotNet.Classification - Classification algorithms
  • AiDotNet.Regression - Regression algorithms
  • AiDotNet.Clustering - Clustering algorithms
  • AiDotNet.ComputerVision - Vision models
  • AiDotNet.Audio - Audio processing
  • AiDotNet.ReinforcementLearning - RL agents
  • AiDotNet.RetrievalAugmentedGeneration - RAG components
  • AiDotNet.LoRA - Fine-tuning adapters
  • AiDotNet.Diffusion - Diffusion models
  • AiDotNet.DistributedTraining - Distributed strategies
  • AiDotNet.MetaLearning - Meta-learning algorithms
  • AiDotNet.TimeSeries - Time series models
  • AiDotNet.Optimizers - Optimization algorithms

Feature Maturity

The repository ships a wide surface; not every subsystem is at the same maturity level. The labels below set expectations for enterprise consumers — stable features are appropriate for production use today; beta features are functional but may have visible rough edges or API churn; experimental features are exploratory and should not be relied on in production; preview indicates work-in-progress that may not yet be feature-complete; stub indicates an interface present for forward compatibility but without a substantial implementation.

SubsystemMaturityNotes
Classical ML (regression, classification, clustering, time series)stableLong-standing surface, extensive tests.
Neural networks core (training, inference, autodiff tape)stableActive hardening; recent fixes for #1380 / #1382 mode-collapse + facade gradient bridge.
Optimizers (Adam, AdamW, SGD, etc.)stablePer-tensor + flat-vector paths; gradient clipping and mixed precision supported.
Layers + activations + lossesbetaEleven bottom-up invariants (finite output, deterministic replay, shape agreement, parameter roundtrip, serialization, taped-vs-numerical gradient) run green over the core layers — 88 assertions in ModelFamilyTests/Layers. That is a small fraction of the ~225 layer types; the harness accepts a new layer in about four lines, and widening it is ongoing.
Diffusion / image generationbetaImplementation present; sample-quality benchmarks pending.
Reinforcement learning agentsbetaAPI stable; broader benchmark suite in progress.
Federated learning (DP-SGD, secure aggregation)betaPrivacy primitives present; production deployments should validate threat model.
RAG / retrievalbetaRetriever + generator + chunking are functional; LangChain-style orchestration is lighter.
LoRA fine-tuningbetaAdapter wiring works; quantized LoRA path is newer.
AiDotNet.Serving (REST API for inference)betaDefault-allow-list auth and CORS; observability + audit logging still developing.
Program synthesis (sandboxed code generation)experimentalHigh-risk surface — disable unless explicitly required and isolated.
ONNX / external-model interopbetaImport covered; export coverage is partial.
Native acceleration (OpenBLAS, BLAS, fused kernels)betaCPU SIMD paths shipped; GPU determinism is being pinned (see GpuTransformerDeterminismTests).
Telemetry (opt-in via AIDOTNET_TELEMETRY=true)stableNo PII or model data collected; collects usage metrics only.
Licensing (BSL 1.1 + commercial tiers)stableAPI-key hashing (PBKDF2-SHA256), AES-GCM-encrypted model artifacts on supported frameworks.
OpenTelemetry integration (serving)previewOpt-in scaffold; full meters/traces in progress.
Vision-language modelspreviewLarge surface (~360 source files) against ~22 test files that reference it.
Text-to-speechpreview~245 source files against ~8 test files that reference it.
Speech recognitionpreview~192 source files against ~11 test files that reference it.
Video models (generation, restoration, interpolation)preview~221 source files against ~16 test files that reference it.
Audio models (generation, codecs, music)preview~251 source files against ~21 test files that reference it.
Document understandingpreview~69 source files against ~10 test files that reference it.
LoRA fine-tuning REST endpointstubReturns 501 by design — IServableModel covers prediction, not training; use the in-process API. Contract asserted by FineTuneWithLoRA_WhenModelExists_Returns501.

Duplicate type names. Thirty-three public type names are declared in two namespaces each — for example Donut, LayoutLMv3, StableVideoDiffusion, BarkModel, WaveNet. In all but two cases the two declarations are independent implementations rather than copies, and they often differ several-fold in size. Code that imports both namespaces cannot use the bare name until one side is qualified.

The labels reflect a static review of the public repository. They are informational only — production adopters should validate against their own threat model and SLA requirements.


Platform Support

PlatformStatus
Windows✅ Full support
Linux✅ Full support
macOS✅ Full support
.NET 10.0✅ Primary target
.NET 8.0+✅ Supported
.NET Framework 4.7.1+✅ Supported

GPU Acceleration

BackendStatus
CUDA (NVIDIA)✅ Full support
OpenCL✅ Full support
Metal (Apple)🚧 Coming soon

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Areas where we especially welcome help:

  • Additional model implementations
  • Performance optimizations
  • Documentation and examples
  • Bug fixes and testing

Community


License

Business Source License 1.1 — see LICENSE for full terms.

What's free (always, no license needed)

  • Model training (all algorithms, all configurations)
  • Model inference and prediction
  • Data preprocessing, feature engineering, AutoML
  • GPU acceleration on any hardware
  • All utility functions and helpers

What requires a license

  • Model save/load operations (SaveModel, LoadModel, Serialize, Deserialize)
  • Free trial: 30 days or 10 operations, whichever comes first

License tiers

TierPriceWho qualifies
CommunityFreeOpen-source, education, personal projects, companies <$1M revenue with <5 devs
Professional$29/mo per seatCommercial use, individual developers and small teams
Enterprise$99/mo per seatLarge organizations, dedicated support, custom SLAs

See the pricing page for details and to register for a free community license.

Each version automatically converts to Apache License 2.0 four years after release (per the BSL Change Date / fourth-anniversary clause in the LICENSE file).


Made with care for the .NET AI/ML community

⭐ Star us on GitHub • 📦 NuGet Package

ai
aidotnet
algorithm
algorithms
algos
csharp
csharp-code
csharp-library
dotnet
machine-learning
machinelearning
machine-learning-algorithms
neural-network
neural-networks
regression
regression-algorithms
regression-analysis
regression-models

ooples/AiDotNet

A new library for all of the newest ai algorithms

C#

60

4,662 commits

updated Oct 4, 2026

See the code

README

AiDotNet

The Most Comprehensive AI/ML Framework for .NET

8,100+ public classes (grep -c verified) across 139 modules - the most complete AI/ML platform for .NET

Build Status CodeQL Codacy Badge NuGet License

Neural Networks Classical ML Computer Vision Audio Video RL Agents Diffusion RAG LoRA HuggingFace Multi-GPU

Getting Started • Samples • Documentation • API Reference • Contributing


Why AiDotNet?

FeatureAiDotNetTorchSharpTensorFlow.NETML.NETAccord.NET
Neural Network Architectures160+50+30+~10~20
Classical ML Algorithms155+NoneNone~30~50
Computer Vision Models115+Via PyTorchVia TFLimitedLimited
Audio Processing250+LimitedLimitedNoneBasic
Reinforcement Learning50+ agentsManualLimitedNoneNone
Diffusion Models75+ManualNoneNoneNone
LoRA Fine-tuning50+ adaptersManualNoneNoneNone
RAG Components50+NoneNoneNoneNone
Distributed TrainingDDP, FSDP, ZeRODDP onlyMirroredStrategyNoneNone
HuggingFace IntegrationNativePartialPartialNoneNone
GPU AccelerationCUDA, OpenCL, VulkanVia LibTorchVia TF RuntimeLimitedNone
Pure .NET (No Runtime)YesNo (LibTorch)No (TF Runtime)YesYes
Startup TimeFastSlowSlowFastFast
Memory/Span SupportFullLimitedLimitedLimitedNone

Quick Start by Task

What do you want to build?

TaskQuick LinkDescription
Classify dataClassificationBinary, multi-class, image classification
Predict valuesRegressionPrice prediction, forecasting
Group similar itemsClusteringCustomer segmentation, anomaly detection
Detect objects in imagesComputer VisionYOLO, DETR, Mask R-CNN
Process audio/speechAudioWhisper, TTS, music generation
Build a chatbot with RAGRAGVector stores, retrievers, rerankers
Fine-tune LLMsLoRA Fine-tuningQLoRA, DoRA, AdaLoRA
Generate imagesDiffusion ModelsStable Diffusion, DALL-E 3
Train RL agentsReinforcement LearningDQN, PPO, SAC, multi-agent
Forecast time seriesTime SeriesARIMA, Prophet, N-BEATS
Scale trainingDistributed TrainingMulti-GPU, multi-node

Installation

dotnet add package AiDotNet

Requirements: .NET 10.0 / .NET 8.0+ (or .NET Framework 4.7.1+)


Hello World Example

using AiDotNet;
using AiDotNet.Enums;
using AiDotNet.LinearAlgebra;
using AiDotNet.NeuralNetworks;

// features: [N, 4] tensor of Iris measurements
// labels:   [N, 3] one-hot tensor of species
var architecture = new NeuralNetworkArchitecture<double>(
    inputFeatures: 4, numClasses: 3, complexity: NetworkComplexity.Simple);

var result = await new AiModelBuilder<double, Tensor<double>, Tensor<double>>()
    .ConfigureModel(new NeuralNetwork<double>(architecture))
    .BuildAsync(features, labels);

var predictions = result.Predict(testFeatures);

Full runnable version (inline Iris dataset, train/test split, accuracy report): samples/getting-started/HelloWorld/Program.cs


Complete Feature Reference

Neural Networks (160+ Architectures)

Click to expand all neural network types

Core Architectures

  • NeuralNetwork - Feedforward networks
  • ConvolutionalNeuralNetwork - CNNs for images
  • RecurrentNeuralNetwork - RNNs for sequences
  • LSTMNeuralNetwork - Long Short-Term Memory
  • GRUNeuralNetwork - Gated Recurrent Units
  • TransformerArchitecture - Attention-based models
  • ResNetNetwork - Residual networks
  • DenseNetNetwork - Densely connected networks
  • EfficientNetNetwork - Efficient scaling
  • MobileNetV2Network, MobileNetV3Network - Mobile-optimized

Generative Models

  • GenerativeAdversarialNetwork (GAN)
  • DCGAN, ConditionalGAN, CycleGAN
  • ProgressiveGAN, BigGAN, StyleGAN
  • ACGAN, InfoGAN, Pix2Pix
  • Autoencoder, VariationalAutoencoder

Graph Neural Networks

  • GraphNeuralNetwork (GNN)
  • GraphAttentionNetwork (GAT)
  • GraphSAGENetwork
  • GraphIsomorphismNetwork (GIN)
  • GraphGenerationModel

Specialized Architectures

  • CapsuleNetwork - Capsule networks
  • SpikingNeuralNetwork - Neuromorphic computing
  • QuantumNeuralNetwork - Quantum ML
  • HyperbolicNeuralNetwork - Hyperbolic geometry
  • MixtureOfExpertsNeuralNetwork - MoE
  • NeuralTuringMachine - NTM
  • DifferentiableNeuralComputer - DNC
  • MemoryNetwork - Memory-augmented
  • EchoStateNetwork - Reservoir computing
  • LiquidStateMachine - Liquid state machines
  • HopfieldNetwork - Associative memory
  • RestrictedBoltzmannMachine - RBM
  • DeepBeliefNetwork - DBN
  • DeepBoltzmannMachine - DBM
  • RadialBasisFunctionNetwork - RBF
  • SelfOrganizingMap - SOM
  • ExtremeLearningMachine - ELM
  • NEAT - Neuroevolution

Vision-Language Models

  • ClipNeuralNetwork - CLIP
  • BlipNeuralNetwork, Blip2NeuralNetwork - BLIP
  • LLaVANeuralNetwork - LLaVA
  • FlamingoNeuralNetwork - Flamingo
  • Gpt4VisionNeuralNetwork - GPT-4V

Attention Mechanisms

  • AttentionNetwork
  • FlashAttention - Memory-efficient attention
  • MultiHeadAttention

Example:

var model = new AiModelBuilder<double, Tensor<double>, Tensor<double>>()
    .ConfigureModel(new ConvolutionalNeuralNetwork<double>(
        inputChannels: 3,
        numClasses: 1000,
        architecture: CNNArchitecture.ResNet50))
    .ConfigureOptimizer(new AdamWOptimizer<double>(learningRate: 0.001))
    .ConfigureMixedPrecision()  // FP16 training
    .ConfigureGpuAcceleration()
    .BuildAsync(trainImages, trainLabels);

Classification (50 Algorithms)

Click to expand all classification algorithms

Ensemble Methods

  • RandomForestClassifier
  • GradientBoostingClassifier
  • AdaBoostClassifier
  • ExtraTreesClassifier
  • BaggingClassifier
  • StackingClassifier
  • VotingClassifier

Naive Bayes

  • GaussianNaiveBayes
  • MultinomialNaiveBayes
  • BernoulliNaiveBayes
  • ComplementNaiveBayes
  • CategoricalNaiveBayes

Linear Models

  • LogisticRegression
  • RidgeClassifier
  • SGDClassifier
  • PassiveAggressiveClassifier
  • PerceptronClassifier

Support Vector Machines

  • LinearSupportVectorClassifier
  • SupportVectorClassifier

Discriminant Analysis

  • LinearDiscriminantAnalysis
  • QuadraticDiscriminantAnalysis

Multi-label/Multi-output

  • OneVsRestClassifier
  • OneVsOneClassifier
  • ClassifierChain
  • MultiOutputClassifier

Neighbors

  • KNeighborsClassifier

Example:

var result = await new AiModelBuilder<double, double[], double>()
    .ConfigureModel(new RandomForestClassifier<double>(nEstimators: 100))
    .ConfigurePreprocessing(pipeline => pipeline
        .Add(new StandardScaler<double>())
        .Add(new SimpleImputer<double>()))
    .ConfigureCrossValidation(new KFoldCrossValidator<double>(k: 5))
    .BuildAsync(features, labels);

Console.WriteLine($"Accuracy: {result.CrossValidationResult?.MeanAccuracy:P2}");

Regression (57 Algorithms)

Click to expand all regression algorithms

Linear Models

  • MultipleRegression
  • PolynomialRegression
  • RidgeRegression
  • LassoRegression
  • ElasticNetRegression
  • BayesianRegression
  • OrthogonalRegression

Tree-Based

  • DecisionTreeRegression
  • GradientBoostingRegression
  • AdaBoostR2Regression
  • ExtremelyRandomizedTreesRegression
  • M5ModelTreeRegression
  • ConditionalInferenceTreeRegression

Kernel Methods

  • GaussianProcessRegression
  • KernelRidgeRegression
  • SupportVectorRegression

Specialized

  • IsotonicRegression
  • LocallyWeightedRegression
  • PartialLeastSquaresRegression
  • MultivariateRegression
  • GeneralizedAdditiveModelRegression

Probabilistic

  • PoissonRegression
  • NegativeBinomialRegression
  • QuantileRegression
  • RobustRegression

Neural Network Based

  • MultilayerPerceptronRegression
  • NeuralNetworkRegression

Optimization-Based

  • GeneticAlgorithmRegression

Example:

var result = await new AiModelBuilder<double, double[], double>()
    .ConfigureModel(new GradientBoostingRegression<double>(
        nEstimators: 200,
        maxDepth: 5,
        learningRate: 0.1))
    .ConfigureHyperparameterOptimizer(
        new BayesianOptimizer<double>(),
        searchSpace: new HyperparameterSearchSpace()
            .AddContinuous("learning_rate", 0.01, 0.3)
            .AddInteger("max_depth", 3, 10),
        trials: 50)
    .BuildAsync(features, targets);

Clustering (48 Algorithms)

Click to expand all clustering algorithms

Centroid-Based

  • KMeansClustering
  • KMedoidsClustering
  • MiniBatchKMeans

Density-Based

  • DBSCAN
  • HDBSCAN
  • OPTICS
  • MeanShift
  • Denclue

Hierarchical

  • AgglomerativeClustering
  • BIRCH
  • CURE

Model-Based

  • GaussianMixtureClustering
  • BayesianGaussianMixture

Spectral

  • SpectralClustering

Self-Organizing

  • GMeans
  • XMeans

Distance Metrics

  • EuclideanDistance
  • ManhattanDistance
  • CosineDistance
  • MahalanobisDistance
  • ChebyshevDistance
  • MinkowskiDistance

Validation Metrics

  • SilhouetteScore
  • DaviesBouldinIndex
  • CalinskiHarabaszIndex
  • DunnIndex
  • AdjustedRandIndex

Example:

var result = await new AiModelBuilder<double, double[], int>()
    .ConfigureModel(new HDBSCAN<double>(minClusterSize: 15, minSamples: 5))
    .ConfigureAutoML(new ClusteringAutoML<double>())  // Auto-tune parameters
    .BuildAsync(features);

Console.WriteLine($"Clusters found: {result.Model.Labels.Distinct().Count()}");
Console.WriteLine($"Silhouette Score: {result.ClusteringMetrics?.SilhouetteScore:F3}");

Computer Vision (115+ Models)

Click to expand all computer vision capabilities

Object Detection

  • YOLO Family: YOLOv5, YOLOv8, YOLOv9, YOLOv10, YOLOv11
  • Transformer-Based: DETR, Deformable DETR, DINO
  • Two-Stage: Faster R-CNN, Cascade R-CNN
  • Anchor-Free: FCOS, CenterNet

Instance Segmentation

  • Mask R-CNN
  • YOLACT
  • SOLOv2
  • Segment Anything (SAM)

Semantic Segmentation

  • DeepLabV3+
  • UNet, UNet++
  • PSPNet
  • HRNet

Object Tracking

  • SORT
  • DeepSORT
  • ByteTrack
  • OC-SORT

OCR & Scene Text

  • SceneTextReader
  • Text detection + recognition
  • Multi-language support

Pose Estimation

  • OpenPose
  • HRNet-Pose
  • ViTPose

3D Vision

  • PointNet, PointNet++
  • MeshCNN
  • NeRF (Neural Radiance Fields)

Example:

var builder = new AiModelBuilder<float, Tensor<float>, DetectionResult[]>()
    .ConfigureObjectDetector(new YOLOv8Detector<float>(
        modelSize: YOLOModelSize.Medium,
        confidenceThreshold: 0.5f))
    .ConfigureVisualization(new VisualizationOptions { DrawLabels = true });

var result = await builder.BuildAsync();
var detections = result.Model.Detect(image);

foreach (var det in detections)
    Console.WriteLine($"{det.Label}: {det.Confidence:P1} at {det.BoundingBox}");

Audio Processing (250+ Models)

Click to expand all audio capabilities

Speech Recognition

  • Whisper: whisper-tiny, whisper-base, whisper-small, whisper-medium, whisper-large
  • Wav2Vec2: Multiple languages
  • HuBERT
  • Conformer

Text-to-Speech

  • VITS
  • FastSpeech2
  • Tacotron2
  • XTTS (multi-speaker, cross-lingual)

Music Generation

  • MusicGen
  • AudioGen
  • Riffusion

Audio Classification

  • Audio event detection
  • Music genre classification
  • Environmental sound classification

Speaker Analysis

  • Speaker identification
  • Speaker verification
  • Speaker diarization

Audio Enhancement

  • Noise reduction
  • Echo cancellation
  • Speech enhancement

Source Separation

  • Vocals/instruments separation
  • Multi-track separation

Voice Activity Detection

  • WebRTC VAD
  • Silero VAD

Emotion Recognition

  • Speech emotion classification

Music Analysis

  • Beat detection
  • Chord recognition
  • Key detection
  • Tempo estimation

Example:

// Speech-to-Text with Whisper
var whisper = new WhisperModel<float>(WhisperModelSize.Medium, language: "en");
var transcription = await whisper.TranscribeAsync(audioFile);
Console.WriteLine(transcription.Text);

// Text-to-Speech
var tts = new VITSModel<float>(voice: "en-US-female");
var audio = await tts.SynthesizeAsync("Hello, world!");
await audio.SaveAsync("output.wav");

Video Processing (80+ Models)

Click to expand all video capabilities

Video Generation

  • Stable Video Diffusion
  • AnimateDiff
  • VideoCrafter
  • Text2Video

Action Recognition

  • SlowFast
  • TimeSformer
  • Video Swin Transformer

Video Understanding

  • CLIP4Clip
  • Video captioning

Optical Flow

  • RAFT
  • FlowNet

Video Object Detection

  • Video object tracking
  • Multi-object tracking

Example:

var videoGen = new StableVideoDiffusion<float>();
var video = await videoGen.GenerateAsync(
    prompt: "A cat playing piano",
    numFrames: 24,
    fps: 8);
await video.SaveAsync("output.mp4");

Reinforcement Learning (50+ Agents)

Click to expand all RL agents

Value-Based

  • DQNAgent - Deep Q-Network
  • DoubleDQNAgent - Double DQN
  • DuelingDQNAgent - Dueling architecture
  • RainbowDQNAgent - Rainbow (all improvements)
  • QLearningAgent, DoubleQLearningAgent
  • SARSAAgent, ExpectedSARSAAgent
  • NStepQLearningAgent, NStepSARSAAgent

Policy Gradient

  • REINFORCEAgent
  • A2CAgent - Advantage Actor-Critic
  • A3CAgent - Asynchronous A3C
  • PPOAgent - Proximal Policy Optimization

Actor-Critic

  • DDPGAgent - Deep Deterministic PG
  • TD3Agent - Twin Delayed DDPG
  • SACAgent - Soft Actor-Critic

Model-Based

  • DreamerAgent - World models
  • MuZeroAgent - MuZero
  • DynaQAgent, DynaQPlusAgent
  • PrioritizedSweepingAgent

Multi-Agent

  • MADDPGAgent - Multi-Agent DDPG
  • QMIXAgent - QMIX

Offline RL

  • CQLAgent - Conservative Q-Learning
  • IQLAgent - Implicit Q-Learning

Monte Carlo

  • MonteCarloExploringStartsAgent
  • FirstVisitMonteCarloAgent
  • EveryVisitMonteCarloAgent
  • OffPolicyMonteCarloAgent

Planning

  • MCTSNode - Monte Carlo Tree Search
  • PolicyIterationAgent
  • ModifiedPolicyIterationAgent

Bandits

  • EpsilonGreedyBanditAgent
  • UCBBanditAgent
  • ThompsonSamplingAgent
  • GradientBanditAgent

Sequence Models

  • DecisionTransformerAgent

Example:

var env = new CartPoleEnvironment();
var agent = new PPOAgent<double>(
    stateSize: env.ObservationSpace,
    actionSize: env.ActionSpace,
    hiddenSize: 64,
    learningRate: 3e-4);

// Training loop
for (int episode = 0; episode < 1000; episode++)
{
    var state = env.Reset();
    double totalReward = 0;

    while (!env.IsDone)
    {
        var action = agent.SelectAction(state);
        var (nextState, reward, done) = env.Step(action);
        agent.Store(state, action, reward, nextState, done);
        state = nextState;
        totalReward += reward;
    }

    agent.Train();
    Console.WriteLine($"Episode {episode}: Reward = {totalReward}");
}

Time Series (30+ Models)

Click to expand all time series models

Classical Statistical

  • ARModel - Autoregressive
  • MAModel - Moving Average
  • ARMAModel - ARMA
  • ARIMAModel - ARIMA
  • SARIMAModel - Seasonal ARIMA
  • ARIMAXModel - ARIMAX with exogenous variables
  • GARCHModel - Volatility modeling
  • VARModel, VARMAModel - Vector models

Exponential Smoothing

  • ExponentialSmoothingModel
  • HoltWintersModel
  • TBATSModel

Deep Learning

  • NBEATSModel - N-BEATS
  • NHiTSModel - N-HiTS
  • DeepARModel - DeepAR
  • TemporalFusionTransformer
  • InformerModel - Informer
  • AutoformerModel - Autoformer
  • ChronosFoundationModel - Chronos

Anomaly Detection

  • DeepANT
  • LSTMVAE
  • TimeSeriesIsolationForest

Specialized

  • ProphetModel - Facebook Prophet
  • StateSpaceModel
  • BayesianStructuralTimeSeriesModel
  • SpectralAnalysisModel

Example:

var result = await new AiModelBuilder<double, double[], double>()
    .ConfigureModel(new NBEATSModel<double>(
        stackTypes: new[] { StackType.Trend, StackType.Seasonality, StackType.Generic },
        horizonSize: 24))
    .ConfigureTrainingPipeline(new TrainingPipelineConfiguration<double>
    {
        EarlyStopping = new EarlyStoppingConfig { Patience = 10 }
    })
    .BuildAsync(historicalData);

var forecast = result.Model.Forecast(steps: 24);

Retrieval-Augmented Generation (50+ Components)

Click to expand all RAG components

Vector Stores

  • In-memory vector store
  • FAISS integration
  • Pinecone, Weaviate, Qdrant adapters
  • Chroma, Milvus support

Embedding Models

  • OpenAI embeddings
  • HuggingFace embeddings
  • Sentence Transformers
  • BGE, ColBERT

Retrievers

  • Dense retriever
  • Sparse retriever (BM25)
  • Hybrid retriever
  • Multi-query retriever
  • Self-query retriever

Rerankers

  • Cross-encoder reranker
  • ColBERT reranker
  • Cohere reranker

Document Processing

  • Text splitters (recursive, semantic)
  • Document loaders
  • Chunking strategies

Graph RAG

  • Knowledge graph construction
  • Entity extraction
  • Relation extraction
  • Graph traversal retrieval

Query Processing

  • Query expansion
  • Query rewriting
  • HyDE (Hypothetical Document Embeddings)

Example:

var result = await new AiModelBuilder<float, string, string>()
    .ConfigureRetrievalAugmentedGeneration(
        retriever: new HybridRetriever<float>(
            denseRetriever: new DenseRetriever<float>(embeddingModel),
            sparseRetriever: new BM25Retriever(),
            alpha: 0.7f),
        reranker: new CrossEncoderReranker<float>(),
        generator: new LLMGenerator<float>(llmClient),
        queryProcessors: new[] { new QueryExpander() })
    .BuildAsync();

var answer = await result.Model.QueryAsync("What is the capital of France?", documents);

LoRA Fine-tuning (50+ Adapters)

Click to expand all LoRA variants

Standard LoRA

  • LoRAAdapter - Original LoRA
  • LoRAPlusAdapter - LoRA+

Quantized

  • QLoRAAdapter - 4-bit quantization
  • QALoRAAdapter - Quantization-aware

Memory Efficient

  • DoRAAdapter - Weight-Decomposed
  • VeRAAdapter - Very efficient
  • NOLAAdapter - Noise-optimized

Rank Adaptation

  • AdaLoRAAdapter - Adaptive rank
  • DyLoRAAdapter - Dynamic rank
  • ReLoRAAdapter - Recursive

Specialized

  • LoHaAdapter - Hadamard product
  • LoKrAdapter - Kronecker product
  • MoRAAdapter - Mixture of ranks
  • LongLoRAAdapter - Long context
  • GraphConvolutionalLoRAAdapter - For GNNs

Advanced

  • PiSSAAdapter - Principal singular values
  • FloraAdapter - Floating-point
  • DeltaLoRAAdapter - Delta updates
  • LoftQAdapter - Quantization-aware init
  • ChainLoRAAdapter - Chained adapters

Example:

var result = await new AiModelBuilder<float, string, string>()
    .ConfigureLoRA(new QLoRAConfiguration<float>
    {
        Rank = 16,
        Alpha = 32,
        TargetModules = new[] { "q_proj", "v_proj", "k_proj", "o_proj" },
        QuantizationBits = 4,
        UseDoubleQuantization = true
    })
    .ConfigureFineTuning(new FineTuningConfiguration<float>
    {
        BaseModel = "meta-llama/Llama-2-7b-hf",
        TrainingArguments = new TrainingArguments
        {
            NumEpochs = 3,
            BatchSize = 4,
            GradientAccumulationSteps = 8
        }
    })
    .BuildAsync(trainingData);

Diffusion Models (75+ Models)

Click to expand all diffusion models

Image Generation

  • StableDiffusionModel
  • SDXLModel - Stable Diffusion XL
  • DallE3Model - DALL-E 3
  • PixArtModel - PixArt

Image Editing

  • ControlNetModel
  • IPAdapterModel
  • Inpainting, Outpainting

Audio Generation

  • AudioLDMModel, AudioLDM2Model
  • MusicGenModel
  • RiffusionModel
  • DiffWaveModel

Video Generation

  • StableVideoDiffusion
  • AnimateDiffModel
  • VideoCrafterModel

3D Generation

  • DreamFusionModel
  • MVDreamModel
  • ShapEModel
  • PointEModel
  • Zero123Model

Architectures

  • DDPMModel - Denoising Diffusion
  • ConsistencyModel - Fast inference
  • Various schedulers (DDIM, PNDM, etc.)

Example:

var diffusion = new SDXLModel<float>();
var image = await diffusion.GenerateAsync(
    prompt: "A photorealistic cat astronaut on Mars",
    negativePrompt: "blurry, low quality",
    width: 1024,
    height: 1024,
    numInferenceSteps: 30,
    guidanceScale: 7.5f);

await image.SaveAsync("output.png");

Distributed Training

Click to expand distributed training options

Data Parallelism

  • DDPModel - Distributed Data Parallel
  • DDPOptimizer

Model Parallelism

  • PipelineParallelModel
  • TensorParallelModel

Fully Sharded

  • FSDPModel - Fully Sharded Data Parallel
  • ZeROOptimizer (Stage 1, 2, 3)
  • HybridShardedModel

Communication

  • NCCL backend (NVIDIA)
  • Gloo backend
  • MPI backend

Optimization

  • GradientCompressionOptimizer
  • AsyncSGDOptimizer
  • LocalSGDOptimizer
  • ElasticOptimizer - Fault-tolerant

Example:

var result = await new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
    .ConfigureModel(largeModel)
    .ConfigureDistributedTraining(
        strategy: DistributedStrategy.FSDP,
        backend: new NCCLCommunicationBackend(),
        configuration: new FSDPConfiguration
        {
            ShardingStrategy = ShardingStrategy.FullShard,
            MixedPrecision = true,
            ActivationCheckpointing = true
        })
    .ConfigureGpuAcceleration(new GpuAccelerationConfig { DeviceIds = new[] { 0, 1, 2, 3 } })
    .BuildAsync(trainData);

Meta-Learning (18+ Algorithms)

Click to expand meta-learning methods

Optimization-Based

  • MAMLAlgorithm - Model-Agnostic Meta-Learning
  • iMAMLAlgorithm - Implicit MAML
  • ReptileAlgorithm
  • MetaSGDAlgorithm
  • ANILAlgorithm - Almost No Inner Loop
  • BOILAlgorithm - Body Only Inner Loop

Metric-Based

  • ProtoNetsAlgorithm - Prototypical Networks
  • MatchingNetworksAlgorithm
  • RelationNetworkAlgorithm

Memory-Based

  • MANNAlgorithm - Memory-Augmented NN
  • NTMAlgorithm - Neural Turing Machine

Hybrid

  • LEOAlgorithm - Latent Embedding Optimization
  • CNAPAlgorithm - Conditional Neural Adaptive Processes
  • TADAMAlgorithm - Task-Dependent Adaptive Metric
  • MetaOptNetAlgorithm
  • GNNMetaAlgorithm - Graph-based

Example:

var result = await new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
    .ConfigureMetaLearning(new MAMLAlgorithm<float>(
        innerLearningRate: 0.01f,
        outerLearningRate: 0.001f,
        innerSteps: 5))
    .BuildAsync(metaTrainTasks);

// Few-shot learning on new task
var adapted = result.MetaLearner.Adapt(supportSet, numSteps: 10);
var predictions = adapted.Predict(querySet);

Self-Supervised Learning (10+ Methods)

Click to expand SSL methods

Contrastive

  • SimCLR
  • MoCo - Momentum Contrast
  • BYOL - Bootstrap Your Own Latent
  • BarlowTwins
  • SwAV - Swapping Assignments

Masked

  • MAE - Masked Autoencoder
  • BEiT

Distillation

  • DINO - Self-Distillation
  • iBOT

Evaluation

  • Linear probing
  • KNN evaluation
  • Transfer benchmarks

Optimizers (40+)

Click to expand all optimizers

Adaptive Learning Rate

  • AdamOptimizer, AdamWOptimizer
  • AdagradOptimizer
  • AdaDeltaOptimizer
  • AdaMaxOptimizer
  • AMSGradOptimizer
  • NadamOptimizer

Momentum-Based

  • MomentumOptimizer
  • NesterovAcceleratedGradientOptimizer

Second-Order

  • BFGSOptimizer, LBFGSOptimizer
  • NewtonMethodOptimizer
  • LevenbergMarquardtOptimizer
  • ConjugateGradientOptimizer

Large-Scale

  • LAMBOptimizer - Layer-wise Adaptive
  • LARSOptimizer - Layer-wise Rate Scaling
  • LionOptimizer - Evolved Sign Momentum

Regularized

  • FTRLOptimizer - Follow-The-Regularized-Leader

Evolutionary

  • GeneticAlgorithmOptimizer
  • ParticleSwarmOptimizer
  • DifferentialEvolutionOptimizer
  • CMAESOptimizer - Covariance Matrix Adaptation
  • AntColonyOptimizer

Specialized

  • BayesianOptimizer - Hyperparameter tuning
  • NelderMeadOptimizer - Simplex method
  • CoordinateDescentOptimizer
  • ADMMOptimizer - Alternating Direction

Loss Functions (37+)

  • Classification: CrossEntropy, BinaryCrossEntropy, FocalLoss, LabelSmoothing
  • Regression: MSE, MAE, Huber, LogCosh, Quantile
  • Segmentation: Dice, IoU, Tversky, Lovász
  • Metric Learning: Triplet, Contrastive, ArcFace, CosFace, Circle
  • Generative: Wasserstein, Hinge, LSGAN
  • Multi-task: Uncertainty-weighted, GradNorm

Additional Features

AutoML

  • Hyperparameter optimization (Bayesian, Random, Grid)
  • Neural Architecture Search (NAS)
  • Feature selection
  • Model selection

Federated Learning

  • FedAvg, FedProx, FedNova
  • Secure aggregation
  • Differential privacy
  • Client selection strategies

Tokenization (HuggingFace Compatible)

  • BPE, WordPiece, Unigram, SentencePiece
  • Pre-trained tokenizer loading
  • Custom tokenizer training

Model Compression

  • Pruning (magnitude, structured)
  • Quantization (INT8, FP16, INT4)
  • Knowledge distillation
  • Low-rank factorization

Uncertainty Quantification

  • Monte Carlo Dropout
  • Deep Ensembles
  • Bayesian Neural Networks
  • Conformal Prediction

Data Augmentation

  • Image: Flip, rotate, crop, color jitter, MixUp, CutMix, AutoAugment
  • Text: Synonym replacement, back-translation, EDA
  • Audio: Time stretch, pitch shift, noise injection
  • Tabular: SMOTE, ADASYN

Experiment Tracking

  • Experiment management
  • Metric logging
  • Checkpoint management
  • Model registry

Prompt Engineering

  • Prompt templates
  • Chain-of-thought
  • Few-shot learning
  • Prompt optimization

Samples

See the samples/ directory for complete, runnable examples:

CategorySampleDescription
Getting StartedHelloWorldYour first AiDotNet model
ClassificationSentimentAnalysisText sentiment with NaiveBayes
Computer VisionObjectDetectionYOLOv8 object detection
AudioSpeechRecognitionWhisper transcription
RAGBasicRAGBuild a Q&A system
RLCartPoleTrain a PPO agent

API Reference

Full API documentation: docfx-generated reference at ooples.github.io/AiDotNet/api/; narrative docs and guides at aidotnet.dev/docs.

Key namespaces:

  • AiDotNet - Core builder and result types
  • AiDotNet.NeuralNetworks - All neural network architectures
  • AiDotNet.Classification - Classification algorithms
  • AiDotNet.Regression - Regression algorithms
  • AiDotNet.Clustering - Clustering algorithms
  • AiDotNet.ComputerVision - Vision models
  • AiDotNet.Audio - Audio processing
  • AiDotNet.ReinforcementLearning - RL agents
  • AiDotNet.RetrievalAugmentedGeneration - RAG components
  • AiDotNet.LoRA - Fine-tuning adapters
  • AiDotNet.Diffusion - Diffusion models
  • AiDotNet.DistributedTraining - Distributed strategies
  • AiDotNet.MetaLearning - Meta-learning algorithms
  • AiDotNet.TimeSeries - Time series models
  • AiDotNet.Optimizers - Optimization algorithms

Feature Maturity

The repository ships a wide surface; not every subsystem is at the same maturity level. The labels below set expectations for enterprise consumers — stable features are appropriate for production use today; beta features are functional but may have visible rough edges or API churn; experimental features are exploratory and should not be relied on in production; preview indicates work-in-progress that may not yet be feature-complete; stub indicates an interface present for forward compatibility but without a substantial implementation.

SubsystemMaturityNotes
Classical ML (regression, classification, clustering, time series)stableLong-standing surface, extensive tests.
Neural networks core (training, inference, autodiff tape)stableActive hardening; recent fixes for #1380 / #1382 mode-collapse + facade gradient bridge.
Optimizers (Adam, AdamW, SGD, etc.)stablePer-tensor + flat-vector paths; gradient clipping and mixed precision supported.
Layers + activations + lossesbetaEleven bottom-up invariants (finite output, deterministic replay, shape agreement, parameter roundtrip, serialization, taped-vs-numerical gradient) run green over the core layers — 88 assertions in ModelFamilyTests/Layers. That is a small fraction of the ~225 layer types; the harness accepts a new layer in about four lines, and widening it is ongoing.
Diffusion / image generationbetaImplementation present; sample-quality benchmarks pending.
Reinforcement learning agentsbetaAPI stable; broader benchmark suite in progress.
Federated learning (DP-SGD, secure aggregation)betaPrivacy primitives present; production deployments should validate threat model.
RAG / retrievalbetaRetriever + generator + chunking are functional; LangChain-style orchestration is lighter.
LoRA fine-tuningbetaAdapter wiring works; quantized LoRA path is newer.
AiDotNet.Serving (REST API for inference)betaDefault-allow-list auth and CORS; observability + audit logging still developing.
Program synthesis (sandboxed code generation)experimentalHigh-risk surface — disable unless explicitly required and isolated.
ONNX / external-model interopbetaImport covered; export coverage is partial.
Native acceleration (OpenBLAS, BLAS, fused kernels)betaCPU SIMD paths shipped; GPU determinism is being pinned (see GpuTransformerDeterminismTests).
Telemetry (opt-in via AIDOTNET_TELEMETRY=true)stableNo PII or model data collected; collects usage metrics only.
Licensing (BSL 1.1 + commercial tiers)stableAPI-key hashing (PBKDF2-SHA256), AES-GCM-encrypted model artifacts on supported frameworks.
OpenTelemetry integration (serving)previewOpt-in scaffold; full meters/traces in progress.
Vision-language modelspreviewLarge surface (~360 source files) against ~22 test files that reference it.
Text-to-speechpreview~245 source files against ~8 test files that reference it.
Speech recognitionpreview~192 source files against ~11 test files that reference it.
Video models (generation, restoration, interpolation)preview~221 source files against ~16 test files that reference it.
Audio models (generation, codecs, music)preview~251 source files against ~21 test files that reference it.
Document understandingpreview~69 source files against ~10 test files that reference it.
LoRA fine-tuning REST endpointstubReturns 501 by design — IServableModel covers prediction, not training; use the in-process API. Contract asserted by FineTuneWithLoRA_WhenModelExists_Returns501.

Duplicate type names. Thirty-three public type names are declared in two namespaces each — for example Donut, LayoutLMv3, StableVideoDiffusion, BarkModel, WaveNet. In all but two cases the two declarations are independent implementations rather than copies, and they often differ several-fold in size. Code that imports both namespaces cannot use the bare name until one side is qualified.

The labels reflect a static review of the public repository. They are informational only — production adopters should validate against their own threat model and SLA requirements.


Platform Support

PlatformStatus
Windows✅ Full support
Linux✅ Full support
macOS✅ Full support
.NET 10.0✅ Primary target
.NET 8.0+✅ Supported
.NET Framework 4.7.1+✅ Supported

GPU Acceleration

BackendStatus
CUDA (NVIDIA)✅ Full support
OpenCL✅ Full support
Metal (Apple)🚧 Coming soon

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Areas where we especially welcome help:

  • Additional model implementations
  • Performance optimizations
  • Documentation and examples
  • Bug fixes and testing

Community


License

Business Source License 1.1 — see LICENSE for full terms.

What's free (always, no license needed)

  • Model training (all algorithms, all configurations)
  • Model inference and prediction
  • Data preprocessing, feature engineering, AutoML
  • GPU acceleration on any hardware
  • All utility functions and helpers

What requires a license

  • Model save/load operations (SaveModel, LoadModel, Serialize, Deserialize)
  • Free trial: 30 days or 10 operations, whichever comes first

License tiers

TierPriceWho qualifies
CommunityFreeOpen-source, education, personal projects, companies <$1M revenue with <5 devs
Professional$29/mo per seatCommercial use, individual developers and small teams
Enterprise$99/mo per seatLarge organizations, dedicated support, custom SLAs

See the pricing page for details and to register for a free community license.

Each version automatically converts to Apache License 2.0 four years after release (per the BSL Change Date / fourth-anniversary clause in the LICENSE file).


Made with care for the .NET AI/ML community

⭐ Star us on GitHub • 📦 NuGet Package

ai
aidotnet
algorithm
algorithms
algos
csharp
csharp-code
csharp-library
dotnet
machine-learning
machinelearning
machine-learning-algorithms
neural-network
neural-networks
regression
regression-algorithms
regression-analysis
regression-models

Languages

C#

98.6%