joaopauloschuler/neural-api

CAI NEURAL API - Pascal based deep learning neural network API optimized for AVX, AVX2 and AVX512 instruction sets plus OpenCL capable devices including AMD, Intel and NVIDIA.

What it is

CAI Neural API is a deep‑learning library written in Free Pascal / Lazarus. It implements a wide range of neural‑network layers (transformers, Mixture‑of‑Experts, RWKV, xLSTM, spiking neurons, normalising flows, CNNs, etc.) and can run them on CPU with AVX/AVX2/AVX‑512 or OpenCL‑accelerated GPUs from AMD, Intel or NVIDIA. The whole framework compiles to a single native executable – no Python interpreter, no CUDA runtime, no large dependency chain.

What you can do with it

Feature How it works (as described in the README)
Run large language models Load a HuggingFace instruct checkpoint (e.g., Qwen 2.5, Qwen 3, Llama, Mistral, Phi‑3, OLMoE) and interact via the ChatTerminal CLI or expose an OpenAI‑compatible HTTP server with ChatServer.
Text‑to‑music MusicGenText uses a T5 encoder + MusicGen decoder to turn a prompt like “lo‑fi hip‑hop with a mellow piano” into an audio file.
Audio processing MusicSourceSeparation separates a song into stems; Qwen2AudioChat lets you converse with an audio‑aware model.
Image super‑resolution SuperResolution up‑scales images using a pre‑trained network shipped with the repo.
Standard vision demos CIFAR‑10/‑100, MNIST, Fashion‑MNIST classification, ResNet‑20, DenseNet, MobileNet‑style separable convolutions, auto‑encoders, GAN art, gradient‑ascent visualisation, etc.
Training utilities TNNetFit‑style classes (TNeuralImageFit) provide simple APIs for fitting networks, learning‑rate control, inertia, and model checkpointing.
Data handling TNNetVolume is a flexible 1‑D/2‑D/3‑D array type that supports SIMD operations and can be transferred to/from OpenCL buffers.

Who might use it

  • Systems programmers who want deep‑learning inside a native Pascal application without pulling in Python, PyTorch, or CUDA.
  • Embedded or low‑dependency deployments where a single binary is preferable (e.g., edge devices, Windows/Linux servers without a Python runtime).
  • Pascal enthusiasts / Lazarus developers looking for a ready‑made neural‑network stack that integrates with their existing code base.
  • Researchers interested in experimenting with less‑common architectures (RWKV, spiking neurons, Mixture‑of‑Experts) in a language that compiles to highly‑optimised machine code.

How to get started

  1. Install Lazarus (the IDE) and, if you want GPU acceleration, the appropriate OpenCL drivers.
  2. Clone the repo and add the neural/ folder to Lazarus’ unit search path.
  3. Build one of the example programs (e.g., examples/ChatTerminal/ChatTerminal.lpr).
  4. Point the example at a HuggingFace checkpoint (the README lists supported models) and run.

Limitations / notes

  • The library is Pascal‑only; it does not work with Delphi on the master branch (Delphi support is limited to the older v2.0.0 release).
  • GPU support relies on OpenCL, not CUDA, so NVIDIA GPUs need the OpenCL driver layer.
  • Performance‑critical code is hand‑optimised for AVX/AVX2/AVX‑512; older CPUs may see slower runtimes.
  • The project provides many educational examples and pre‑trained models, but production‑grade model zoo integration is left to the user.

All information above is taken directly from the repository’s README; no additional features have been inferred.

Related

  • Project
  • Project
  • Dispatch
  • Project
  • Project