Small supervised learning
The current example uses logistic regression on a tiny subset of the Iris measurements, then evaluates predictions on held-out examples.
A practical guide to using gs_brain from greenServeFE, building a small reproducible baseline, preparing trustworthy datasets, and planning larger CPU, GPU and supercomputer workloads without confusing today's implemented features with future engineering work.
gs_brain is a native C shared-library module imported by a .gsve program. The documented development examples cover small CPU-oriented machine-learning operations and training utilities. Treat the source repository and passing tests as the authority for the exact API in the version you build.
The current example uses logistic regression on a tiny subset of the Iris measurements, then evaluates predictions on held-out examples.
Examples exercise matrix multiplication, means, one-hot encoding, a small reverse-mode autograd path, SGD updates and vector checkpoint save/load.
Do not assume transformer pretraining, GPU kernels, multi-GPU collectives, distributed optimizers, mixed precision or cluster scheduling are implemented. Those require separate verified backends and tests.
Use a Linux environment with GCC, Make, pkg-config and libcurl development headers. Follow the current repository README if build instructions have changed.
git clone https://github.com/dominexmacedon-docs/greenServeFE-.git cd /path/to/your/greenServeFE-build make clean all mkdir -p dist cc -D_POSIX_C_SOURCE=200809L -std=c11 -O2 -Wall -Wextra -Wpedantic \ -Wno-unused-parameter -fPIC -shared -I. $(pkg-config --cflags libcurl) \ -o dist/gs_brain.so ai-modules/gs_brain.c \ $(pkg-config --libs libcurl) -lm export GREENSERVE_MODULE_PATH="$PWD/dist"
Run the GSVE script with the greenServeFE executable built by your checkout, for example ./greenServeFE test.gsve if that executable is present at the repository root. Some distributions install the runtime separately; use that runtime's actual path.
This small, reproducible binary-classification example uses petal length and width from the public Iris dataset. Labels are simplified to setosa = 0 and versicolor = 1. The values below are embedded so this example does not depend on an unimplemented CSV reader.
import gs_brain;
// Four training examples per class from the Iris measurements.
define X_train = [
[1.4, 0.2], [1.3, 0.2], [1.5, 0.2], [1.7, 0.4],
[4.7, 1.4], [4.5, 1.5], [4.9, 1.5], [4.0, 1.3]
];
define y_train = [0, 0, 0, 0, 1, 1, 1, 1];
// Keep separate records for a simple held-out check.
define X_test = [[1.9, 0.4], [1.4, 0.3], [4.6, 1.3], [4.2, 1.5]];
define y_test = [0, 0, 1, 1];
define model = gs_brain.learn.train_logistic(
X_train, y_train, 3000, 0.05, 0.001
);
define probabilities = gs_brain.learn.predict_proba(X_test, model);
define predictions = gs_brain.learn.predict_logistic(X_test, model);
define accuracy = gs_brain.learn.accuracy_score(y_test, predictions);
define report = gs_brain.learn.classification_report(y_test, predictions, 1);
print("Training loss:");
print(model.loss);
print("Held-out accuracy:");
print(accuracy);
print("Probabilities:");
print(probabilities);
print("Predictions:");
print(predictions);
print("Classification report:");
print(report);
if (accuracy == 1 && model.loss < 0.1) {
print("PASS: Iris training and held-out smoke test");
} else {
print("CHECK: inspect model output and training settings");
}
The component test in the private development checkout is intended to exercise independent primitives before scaling an experiment: matrix multiplication and mean, gradient propagation, one-hot encoding, SGD updates and checkpoint save/load.
// Run the repository's component test with the same module path.
greenServeFE tests/gs_brain-components.gsve
The component test source and manual GitHub Actions workflow are available inside the private build-source checkout to authorized collaborators. Run the workflow and inspect its logs before treating the current checkout as validated. Public visitors can use the GSVE examples and public release information linked below.
Every model—from a small CPU classifier to a cluster-scale language model—needs traceable data, reproducible preprocessing, honest evaluation and a reliable artifact lifecycle.
Specify intended users, target behavior, input/output format, success metrics, failure modes and a baseline before collecting data.
Use public datasets with compatible licenses, permissioned documents, opt-in contributions or content you created. Record source, date, license and restrictions.
Decode consistently; remove corrupt records, spam and exact/near duplicates; normalize text carefully; filter secrets and personal data you do not need.
Create train, validation and test partitions before fitting transformations. Group related documents and near-duplicates together so test data cannot leak into training.
For numeric models, make matrices and labels. For language models, define tokenizer, vocabulary, sequence packing, masks and next-token targets in a separately tested data pipeline.
Run a small CPU experiment first. Check loss movement, gradient correctness, a trivial baseline, held-out metrics and reproducibility.
Profile memory and throughput, then choose CPU parallelism, one GPU, multi-GPU or a scheduled HPC cluster. Scale only after the numerical path is correct.
Use untouched test data, task-appropriate metrics, subgroup/error analysis, memorization checks and human review for high-impact use cases.
Save model state, optimizer state when supported, step/epoch, random seeds, configuration, data manifest and source revision. Test recovery after interruption.
Publish versioned artifacts with a model card, intended-use limits, dataset citations and a rollback plan. Monitor drift and failures after deployment.
More data is not automatically better. Relevant, diverse, accurately labeled, legally usable and well-documented records usually beat a much larger noisy dump.
Start with UCI and other research datasets, government open-data portals, public-domain material, repositories whose licenses permit your use, opt-in community submissions, and your own authored examples. Check each dataset's actual license and terms.
Prefer documented APIs and bulk downloads. Respect terms of service, robots instructions where applicable, rate limits, copyright and database rights. Identify your crawler, cache responses, avoid login walls and do not bypass access controls.
Keep a manifest with URL or dataset ID, retrieval timestamp, license, language, document ID, preprocessing version and checksums. Track filtering counts so data loss is explainable.
Exclude credentials, private messages and sensitive personal information unless there is a valid, reviewed basis to process them. Redact secrets, limit retention and document deletion requests.
data/
raw/ # immutable source snapshots; access controlled
manifests/ # source, license, timestamp, checksum, provenance
interim/ # decoded records and validation reports
processed/ # deduplicated, normalized, filtered records
splits/
train/
validation/
test/
tokenizer/ # tokenizer config and versioned vocabulary
reports/ # quality, duplication, language and leakage reports
artifacts/
checkpoints/
evaluation/
model-card.md
Keep large raw corpora and credentials out of Git history. Use dataset hosting or object storage with access controls and versioned manifests; publish only data you are authorized to redistribute.
Important: the current gs_brain module does not automatically perform all of these steps. Tokenization, scalable corpus loading, batching and sequence packing must be implemented and validated in the data pipeline before claiming end-to-end language-model training.
Choose hardware from model size, sequence length, batch size, precision and throughput goals—not from the word “AI” alone. Benchmark the actual workload and include data loading and checkpoint time.
| Hardware | Good starting point | What to plan for |
|---|---|---|
| CPU laptop / desktop | Data cleaning, tokenization experiments, unit tests, small tabular models and CPU baselines. | RAM, vectorization, thread count, disk speed and elapsed time. Start with small batches and measure memory. |
| Multi-core CPU server | Parallel preprocessing, feature extraction, classical ML and data preparation for accelerators. | NUMA effects, memory bandwidth, worker oversubscription and throughput across cores. |
| One GPU | Neural-network experiments after a supported GPU backend exists. | VRAM for parameters, gradients, optimizer state, activations and batch; driver/runtime compatibility and transfer overhead. |
| Multiple GPUs | Data/model parallel training when a distributed implementation exists and the model or workload benefits. | Collective communication, interconnect bandwidth, synchronization, checkpoint coordination and fault recovery. |
| HPC / supercomputer | Large distributed workloads with a tested multi-node implementation, scheduler integration and a measured scaling plan. | Site policies, scheduler allocation, high-speed fabric, scratch storage, quotas, containers/modules and coordinated restarts. |
This is an infrastructure template only. It will not make gs_brain GPU-capable by itself; replace the executable and arguments with the real, tested GPU-enabled training program for your cluster.
#!/bin/bash #SBATCH --job-name=gs-brain-train #SBATCH --output=logs/%x-%j.out #SBATCH --error=logs/%x-%j.err #SBATCH --time=02:00:00 #SBATCH --nodes=1 #SBATCH --ntasks=1 #SBATCH --cpus-per-task=8 #SBATCH --gres=gpu:1 #SBATCH --mem=32G set -euo pipefail mkdir -p logs artifacts/checkpoints module list nvidia-smi # Replace with your real, validated GPU training command: ./trainer-gpu --config configs/experiment.yaml \ --data data/processed --output artifacts/checkpoints
Cluster directives differ by site; some use --gpus, partitions, account/project IDs, containers or different accelerator resource syntax. Follow local documentation. Do not submit this template unchanged and assume it will train a model.
For a credible general-purpose AI framework, build and test these layers incrementally rather than claiming a feature from a hardware diagram alone.
CSV/JSONL or binary dataset readers, streaming iterators, shuffling, batching, deterministic splits, schema checks and resumable data cursors.
Explicit tensor shapes, dtype/device semantics, broadcasting rules, stable loss functions, gradient checks and broad operator coverage.
Mini-batches, optimizer state, learning-rate schedules, gradient clipping, metrics, early stopping and reliable checkpoint/resume.
A device abstraction and tested GPU kernels for core operations, memory allocation, transfers, synchronization and numerical parity against CPU.
Multi-process launch, gradient synchronization, data sharding, failure handling, distributed checkpoints and measured scaling efficiency.
Tokenizer, embedding, attention, normalization, transformer blocks, next-token loss, efficient sequence batching, generation and evaluation suites.
Understand the GSVE syntax, bytecode VM and native module loader.
Runtime guide →Browse the existing examples for language constructs and module usage.
Examples →Find public-facing greenServeFE runtime releases. The implementation source and internal tests are in a private development repository.
Public releases →