Developed as a solution to the complexity of modern deep learning frameworks, rriftt_ai.h is a single-header C library that allows users to build, train, and run Transformer models without external dependencies or verbose build systems. Experience pure machine learning efficiency with total memory control.
rriftt_ai.h is a minimal, dependency-free AI library implemented in pure C, designed for developers who require a straightforward and efficient solution for creating neural networks. This single-header C23 library serves as a bare-metal neural network engine, alleviating the complexities associated with modern deep learning frameworks that often rely on extensive dependencies and complex build systems.
Key Features
- Zero Dependencies: No need for external libraries or complex installations. Simply include
rriftt_ai.hin your project to get started. - Control Over Memory: Utilizes a custom memory arena through
RaiArena, ensuring efficient memory management without any dynamic allocation during execution. This guarantees predictable performance in your applications. - Modern C Architecture: Built with strict C23 compliance, this library integrates advanced modern programming practices.
- Comprehensive Transformer Support: Features robust implementations of RoPE, RMSNorm, SwiGLU, and Scaled Dot-Product Attention, allowing for sophisticated model designs.
- Integrated Training Engine: Offers built-in routines for backpropagation along with Cross-Entropy loss and AdamW optimizer, all encapsulated within C structures, facilitating seamless training workflows.
- Native Tokenization: Supports Byte-Pair Encoding (BPE) directly in C for efficient data preprocessing.
Quick Start
Developers can easily start utilizing the library with limited code, as demonstrated in the following example:
#define RRIFTT_AI_IMPLEMENTATION
#include "rriftt_ai.h"
int main(void) {
RaiArena arena = rai_arena_create(1024 * 1024);
RaiTensor A = RAI_TENSOR_ALLOC_FILL(&arena, 2.0f, 2, 2);
RaiTensor B = RAI_TENSOR_ALLOC_FILL(&arena, 3.0f, 2, 2);
RaiTensor C = rai_tensor_add(&arena, A, B);
rai_arena_destroy(&arena);
return 0;
}
Compile your code using a standard C compiler with a simple command:
gcc main.c -o engine -lm
./engine
Active Development
rriftt_ai.h is actively developed, welcoming contributions for enhancements, optimizations, and new features. The project aims for scalability, allowing community involvement in its evolution.
This library is ideal for those who need a lightweight, efficient solution for AI model implementation without the overhead of traditional machine learning frameworks.
No comments yet.
Sign in to be the first to comment.