DEV Community

Mehmet Γ‡elik
Mehmet Γ‡elik

Posted on

πŸš€ Introducing ml_transformer: A Pure Dart ML/NN Library πŸŽ‰



Most machine learning (ML) and deep learning (DL) libraries are dominated by the Python ecosystem. But with the rapid growth of Flutter and Dart, there’s a clear need for native Dart ML tools.

That’s why I built ml_transformer β€” a lightweight, modular, and extensible machine learning & neural network library written entirely in Dart.

πŸ”‘ Key Features

Transformer Architecture β†’ Pre-LN block, Multi-Head Attention, FeedForward, LayerNorm, Rotary Positional Encoding (RoPE).

Core Layers β†’ Embedding, Linear, LayerNorm, Attention, TransformerBlock.

Mini Training Engine β†’ Autograd + AdamW optimizer for tiny training loops.

Quantization Helpers β†’ int8, int4, int2, fp16, bf16.

ONNX Bridge β†’ JSON-based import/export (protobuf support planned).

RNN Family β†’ RNN, LSTM, GRU with batched forward.

Dataset & Batch API β†’ Easy dataset loading & batching.

Callbacks & Monitoring β†’ EarlyStopping, History.

FFI Acceleration β†’ Native performance examples with NumPy references.

Unit Testing β†’ Verified with NumPy integration and strong test coverage.

MIT Licensed β†’ Fully open-source and free to use.

🎯 Why Dart for ML?

Flutter-first integration β†’ Run ML pipelines directly in your apps.

Lightweight β†’ Smaller footprint compared to heavy Python-based stacks.

Educational β†’ Great for learning Transformer and RNN internals.

Prototyping β†’ Build and test small-scale models quickly.

🌍 Who Can Use It?

πŸ§‘β€πŸŽ“ Students β†’ Explore neural networks in a new language.

πŸ‘¨β€πŸ’» Developers β†’ Add ML pipelines directly into Flutter projects.

πŸ”¬ Researchers β†’ Use as a minimalist sandbox for experiments.

πŸš€ Entrepreneurs β†’ Quickly validate ideas with ML-enabled prototypes.

πŸ“¦ Installation

Add it to your pubspec.yaml:

dependencies:
  ml_transformer: ^1.0.0

Enter fullscreen mode Exit fullscreen mode

πŸ“Š Resources

πŸ“¦ Pub.dev package
πŸ“Š Score & Metrics
πŸ’» GitHub Repository
πŸ’¬ Closing Thoughts

This is just the beginning. ml_transformer is not intended to replace big ML frameworks β€” but to open the door for Dart/Flutter developers to experiment with ML natively.

I’d love to hear your feedback, contributions, and ideas to make it even better πŸ™Œ

πŸ‘‰ Try it out, fork it, and let’s push ML in Dart forward together!

Dart #Flutter #MachineLearning #DeepLearning #OpenSource #Transformer

Top comments (0)