Documentation
¶
Overview ¶
Package golifai is a production-grade, pure-Go AI/ML library.
GoLifAI provides a complete machine-learning ecosystem — from raw tensor operations and automatic differentiation all the way up to neural networks, classical ML algorithms, data pipelines, NLP, vision, audio, generative models, reinforcement learning, and model serving — with zero CGO, zero C bindings, and (for the core module) zero external dependencies.
Sub-packages ¶
Import the sub-package you need directly:
import "github.com/chesslaw-tech/golifai/tensor" // N-D tensors import "github.com/chesslaw-tech/golifai/autograd" // reverse-mode AD import "github.com/chesslaw-tech/golifai/nn" // neural-network layers import "github.com/chesslaw-tech/golifai/ml/tree" // decision trees import "github.com/chesslaw-tech/golifai/serving" // HTTP inference server // … and so on for audio, data, gen, nlp, pipelines, rl, vision
The root golifai package re-exports the most commonly used types and constructors as a convenience façade so that simple programs only need one import.
Quick start ¶
package main
import (
"fmt"
"github.com/chesslaw-tech/golifai"
)
func main() {
// Create a 2×3 float64 tensor
t := golifai.Zeros[float64](2, 3)
fmt.Println(t.Shape()) // [2 3]
// Build an autograd variable and differentiate
x := golifai.NewVariable(golifai.Ones[float64](2, 2), true)
loss, _ := golifai.SumAll(x)
loss.Backward()
fmt.Println(x.Grad.Data()) // [1 1 1 1]
}
gRPC serving (optional, separate module) ¶
Real HTTP/2 gRPC inference is available as a separate sub-module so the core library has zero external dependencies:
go get github.com/chesslaw-tech/golifai/serving/grpcpb
Design principles ¶
- Pure Go: no CGO, no C libraries.
- No external deps in the core: gpu stubs live behind build tags.
- Idiomatic generics: [T constraints.Float] throughout the tensor API.
- Race-detector clean: every package ships with parallel-safe tests.
Index ¶
- func Add(a, b *autograd.Variable) (*autograd.Variable, error)
- func MatMul(a, b *autograd.Variable) (*autograd.Variable, error)
- func NewTensor[T tensor.Numeric](data []T, shape ...int) (*tensor.Tensor[T], error)
- func NewVariable(t *tensor.Tensor[float64], requiresGrad bool) *autograd.Variable
- func Ones[T tensor.Numeric](shape ...int) *tensor.Tensor[T]
- func SumAll(v *autograd.Variable) (*autograd.Variable, error)
- func Zeros[T tensor.Numeric](shape ...int) *tensor.Tensor[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
Add performs element-wise addition with broadcasting support. Equivalent to autograd.Add(a, b).
func NewTensor ¶
NewTensor creates a tensor from an existing flat data slice. The product of shape dimensions must equal len(data). Equivalent to tensor.New[T](data, shape...).
func NewVariable ¶
NewVariable wraps a tensor in an autograd Variable. Set requiresGrad=true for any leaf that should accumulate gradients. Equivalent to autograd.NewVariable(t, requiresGrad).
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
_examples
|
|
|
cmd
Package cmd provides command-line tools for training and serving goml models.
|
Package cmd provides command-line tools for training and serving goml models. |
|
cmd/serve
command
Command serve starts a production-grade HTTP inference server backed by the serving/http package.
|
Command serve starts a production-grade HTTP inference server backed by the serving/http package. |
|
cmd/train
command
Command train provides a config-driven training CLI for goml neural networks.
|
Command train provides a config-driven training CLI for goml neural networks. |
|
examples/distributed
command
Distributed training example — gradient all-reduce using distributed.Default.
|
Distributed training example — gradient all-reduce using distributed.Default. |
|
examples/nlp
command
Command nlp demonstrates sentiment analysis on a synthetic 1000-document corpus using TF-IDF vectorisation + Logistic Regression from the goml NLP and ML packages.
|
Command nlp demonstrates sentiment analysis on a synthetic 1000-document corpus using TF-IDF vectorisation + Logistic Regression from the goml NLP and ML packages. |
|
examples/rl
command
Command rl demonstrates tabular Q-Learning and Deep Q-Network (DQN) on a 5×5 GridWorld with obstacles.
|
Command rl demonstrates tabular Q-Learning and Deep Q-Network (DQN) on a 5×5 GridWorld with obstacles. |
|
examples/tabular
command
Command tabular demonstrates multi-class classification on a 100-row Iris-like dataset using logistic regression and a decision tree from the ml package.
|
Command tabular demonstrates multi-class classification on a 100-row Iris-like dataset using logistic regression and a decision tree from the ml package. |
|
examples/vision
command
Command vision demonstrates digit classification on a synthetic MNIST-subset (100 grayscale 8×8 images, 10 classes 0-9) using a two-layer MLP from the nn package, trained with cross-entropy loss and Adam.
|
Command vision demonstrates digit classification on a synthetic MNIST-subset (100 grayscale 8×8 images, 10 classes 0-9) using a two-layer MLP from the nn package, trained with cross-entropy loss and Adam. |
|
audio
|
|
|
features
Package features provides audio feature extraction.
|
Package features provides audio feature extraction. |
|
io
Package io provides WAV audio file reading and writing.
|
Package io provides WAV audio file reading and writing. |
|
models
Package models provides audio deep learning models.
|
Package models provides audio deep learning models. |
|
Package autograd — differentiable Concat and axis-wise reductions.
|
Package autograd — differentiable Concat and axis-wise reductions. |
|
Package data provides dataset abstractions, dataloaders, and DataFrame utilities.
|
Package data provides dataset abstractions, dataloaders, and DataFrame utilities. |
|
dataframe
Package dataframe provides a typed, column-oriented DataFrame.
|
Package dataframe provides a typed, column-oriented DataFrame. |
|
transforms
Package transforms implements data transformation pipelines for tensor data.
|
Package transforms implements data transformation pipelines for tensor data. |
|
gen
|
|
|
image
Package image — Convolutional Variational Autoencoder.
|
Package image — Convolutional Variational Autoencoder. |
|
text
Package text implements text generation models.
|
Package text implements text generation models. |
|
Package ml provides a comprehensive classical machine learning toolkit for Go, designed with a clean, type-safe API.
|
Package ml provides a comprehensive classical machine learning toolkit for Go, designed with a clean, type-safe API. |
|
cluster
Package cluster provides clustering algorithms.
|
Package cluster provides clustering algorithms. |
|
decompose
Package decompose provides dimensionality reduction algorithms.
|
Package decompose provides dimensionality reduction algorithms. |
|
ensemble
Package ensemble provides ensemble learning methods: random forests and gradient boosted trees.
|
Package ensemble provides ensemble learning methods: random forests and gradient boosted trees. |
|
knn
Package knn implements K-Nearest Neighbours classification and regression.
|
Package knn implements K-Nearest Neighbours classification and regression. |
|
linear
Package linear provides linear and logistic regression estimators.
|
Package linear provides linear and logistic regression estimators. |
|
model_selection
Package model_selection provides cross-validation and hyperparameter search.
|
Package model_selection provides cross-validation and hyperparameter search. |
|
naive_bayes
Package naive_bayes implements Gaussian, Multinomial, and Bernoulli Naive Bayes.
|
Package naive_bayes implements Gaussian, Multinomial, and Bernoulli Naive Bayes. |
|
pipeline
Package pipeline provides a composable ML pipeline.
|
Package pipeline provides a composable ML pipeline. |
|
preprocessing
Package preprocessing provides data preprocessing transformers.
|
Package preprocessing provides data preprocessing transformers. |
|
svm
Package svm implements Support Vector Machines via the Pegasos algorithm.
|
Package svm implements Support Vector Machines via the Pegasos algorithm. |
|
tree
Package tree implements CART decision trees for classification and regression.
|
Package tree implements CART decision trees for classification and regression. |
|
nlp
|
|
|
embedding
Package embedding implements dense word embeddings.
|
Package embedding implements dense word embeddings. |
|
pipeline
Package pipeline provides a composable NLP processing pipeline.
|
Package pipeline provides a composable NLP processing pipeline. |
|
tfidf
Package tfidf provides TF-IDF vectorisation for text.
|
Package tfidf provides TF-IDF vectorisation for text. |
|
tokenizer
Package tokenizer provides text tokenisation utilities.
|
Package tokenizer provides text tokenisation utilities. |
|
vocab
Package vocab provides vocabulary management for NLP tasks.
|
Package vocab provides vocabulary management for NLP tasks. |
|
Package nn — ALiBi (Attention with Linear Biases).
|
Package nn — ALiBi (Attention with Linear Biases). |
|
pipelines
|
|
|
checkpoint
Package checkpoint provides model checkpointing: saving and restoring model weights and training state to/from disk.
|
Package checkpoint provides model checkpointing: saving and restoring model weights and training state to/from disk. |
|
distributed
Package distributed provides hooks for multi-GPU and multi-worker training.
|
Package distributed provides hooks for multi-GPU and multi-worker training. |
|
eval
Package eval provides evaluation metrics for machine learning models.
|
Package eval provides evaluation metrics for machine learning models. |
|
tracking
Package tracking provides experiment tracking: logging metrics, hyperparameters, and artifacts to local files for later analysis.
|
Package tracking provides experiment tracking: logging metrics, hyperparameters, and artifacts to local files for later analysis. |
|
train
Package train — EarlyStopping and LRWarmupScheduler for the training loop.
|
Package train — EarlyStopping and LRWarmupScheduler for the training loop. |
|
rl
|
|
|
agent
Package agent implements reinforcement learning agents.
|
Package agent implements reinforcement learning agents. |
|
algo
Package algo implements deep reinforcement learning algorithms.
|
Package algo implements deep reinforcement learning algorithms. |
|
env
Package env defines the reinforcement learning environment interface.
|
Package env defines the reinforcement learning environment interface. |
|
replay
Package replay provides an experience replay buffer for reinforcement learning.
|
Package replay provides an experience replay buffer for reinforcement learning. |
|
serving
|
|
|
batch
Package batch provides asynchronous batch prediction with a queue.
|
Package batch provides asynchronous batch prediction with a queue. |
|
config
Package config provides configuration management for the serving layer.
|
Package config provides configuration management for the serving layer. |
|
grpc
Package grpc provides a pure-Go JSON-RPC inference server using net/rpc/jsonrpc.
|
Package grpc provides a pure-Go JSON-RPC inference server using net/rpc/jsonrpc. |
|
http
Package http provides an HTTP inference server for ML models.
|
Package http provides an HTTP inference server for ML models. |
|
Package tensor provides a high-performance, type-safe n-dimensional array implementation for Go.
|
Package tensor provides a high-performance, type-safe n-dimensional array implementation for Go. |
|
vision
|
|
|
image
Package image provides pure-Go image data structures and I/O.
|
Package image provides pure-Go image data structures and I/O. |
|
models
Package models provides neural network architectures for computer vision.
|
Package models provides neural network architectures for computer vision. |
|
transforms
Package transforms implements image preprocessing transforms for computer vision.
|
Package transforms implements image preprocessing transforms for computer vision. |