AI & ML Developer Guide
Every capability on this page is part of the standard library — no pip, no npm, no third-party packages. Import the bundle, compile with the flag, and go. See the API reference for full class documentation.
Contents
Authentication
Cloud APIs use API keys stored in plain text files in your working directory.
OpenAI
Create openai_api_key.dat containing your key, then read it at startup:
use API.OpenAI, System.IO.Filesystem;
token := FileReader->ReadFile("openai_api_key.dat")->Trim();
Gemini
Create gemini_api_key.dat and use the built-in helper:
use API.Google.Gemini;
token := EndPoint->GetApiKey(); # reads gemini_api_key.dat
Ollama
No key required. Start the daemon and pull a model:
ollama serve ollama pull llama3.2
OpenAI
Chat & Text
use API.OpenAI.Responses, System.IO.Filesystem, Collection;
class ChatExample {
function : Main(args : String[]) ~ Nil {
token := FileReader->ReadFile("openai_api_key.dat")->Trim();
# single-turn
response := Response->Respond("gpt-4o-mini",
Pair->New("user", "Explain JIT compilation in one sentence.")<String, String>,
token);
response->GetText()->PrintLine();
# multi-turn conversation
messages := Vector->New()<Pair<String, String>>;
messages->AddBack(Pair->New("system", "You are a concise coding assistant.")<String, String>);
messages->AddBack(Pair->New("user", "What is a closure?")<String, String>);
messages->AddBack(Pair->New("assistant", "A closure captures its enclosing scope.")<String, String>);
messages->AddBack(Pair->New("user", "Show me one in Objeck.")<String, String>);
response := Response->Respond("gpt-4o-mini", messages, Nil, token); # Nil: no output schema
response->GetText()->PrintLine();
}
}
> obc -src chat.obs -lib net,net_server,json,cipher,misc,openai > obr chat
Vision
use API.OpenAI, API.OpenAI.Responses, System.IO.Filesystem, Collection;
bytes := FileReader->ReadBinaryFile("photo.jpg");
image := ImageQuery->New("What is in this image?", bytes, ImageQuery->MimeType->JPEG);
query := Pair->New("user", image)<String, ImageQuery>;
response := Response->Respond("gpt-4o", query, token);
response->GetText()->PrintLine();
Embeddings
use API.OpenAI;
values := Embedding->Create("Objeck is a JIT-compiled language",
"text-embedding-3-small", token);
if(values <> Nil) {
"Dimensions: {$values->Size()}"->PrintLine(); # 1536
};
Moderation
Per-category safety flags and confidence scores:
use API.OpenAI;
result := Moderation->Check("I want to hurt someone.", token);
if(result <> Nil) {
"Flagged: {$result->IsFlagged()}"->PrintLine();
if(result->IsFlagged()) {
score := result->GetScore("violence");
"violence score: {$score}"->PrintLine();
};
};
Categories: harassment, hate, self-harm, sexual, violence (and /threatening, /graphic, /instructions, /intent variants).
Batch Processing
Up to 50,000 requests at 50% cost. Results within 24 hours.
use API.OpenAI;
# 1. upload request file (or reuse the one already uploaded)
file := File->LoadOrCreate("requests.jsonl", "batch", token);
# 2. submit
job := Batch->Create(file->GetId(), "/v1/chat/completions", token);
"Batch ID: {$job->GetId()}"->PrintLine();
# 3. poll for completion
job := Batch->Get(job->GetId(), token);
if(job->IsComplete()) {
"Output file: {$job->GetOutputFileId()}"->PrintLine();
};
Request format — one JSON object per line in requests.jsonl:
{"custom_id":"r1","method":"POST","url":"/v1/chat/completions","body":{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Hello"}]}}
Realtime Audio
Text or audio over WebSocket; returns transcript and PCM audio. Requires -lib sdl2 for playback.
use API.OpenAI, Game.SDL2;
response := Realtime->Respond("What time is it in Tokyo?",
"gpt-4o-realtime-preview", token);
if(response <> Nil) {
response->GetFirst()->PrintLine(); # transcript
audio := response->GetSecond();
Mixer->PlayPcm(audio->Get(), 24000,
AudioFormat->SDL_AUDIO_S16LSB, 1); # 24 kHz mono PCM
};
Gemini
Chat & Vision
use API.Google.Gemini;
class GeminiChat {
function : Main(args : String[]) ~ Nil {
token := EndPoint->GetApiKey();
# single-turn text
content := Content->New("user")
->AddPart(TextPart->New("Why is the sky blue?"));
candidates := Model->GenerateContent("models/gemini-2.0-flash", content, token);
if(candidates <> Nil & <>candidates->IsEmpty()) {
candidates->First()->GetAllText()->PrintLine();
};
# image + text
bytes := System.IO.Filesystem.FileReader->ReadBinaryFile("chart.png");
content := Content->New("user")
->AddPart(TextPart->New("Summarize this chart."))
->AddPart(BinaryPart->New(bytes, "image/png"));
candidates := Model->GenerateContent("models/gemini-2.0-flash", content, token);
if(candidates <> Nil & <>candidates->IsEmpty()) {
candidates->First()->GetAllText()->PrintLine();
};
# multi-turn with system instruction
chat := Chat->New("models/gemini-2.0-flash", token);
chat->SetSystemInstruction(
Content->New("system")->AddPart(TextPart->New("You are a coding assistant.")));
chat->SendPart(TextPart->New("What is a closure?"), "user")->GetAllText()->PrintLine();
chat->SendPart(TextPart->New("Show me one in Objeck."), "user")->GetAllText()->PrintLine();
}
}
Search Grounding
Anchor responses in live Google Search results for up-to-date answers:
use API.Google.Gemini;
content := Content->New("user")
->AddPart(TextPart->New("What major AI models were released this month?"));
candidates := Model->GenerateContentWithGrounding(
"models/gemini-2.0-flash", content, token);
if(candidates <> Nil & <>candidates->IsEmpty()) {
candidates->First()->GetAllText()->PrintLine();
};
Files API
Upload once, reference across many requests without re-uploading:
use API.Google.Gemini, System.IO.Filesystem;
# upload
data := FileReader->ReadBinaryFile("report.pdf");
file := FileManager->Upload("Q1 Report", data, "application/pdf", token);
if(file <> Nil & file->IsActive()) {
"URI: {$file->GetUri()}"->PrintLine();
};
# list active files
files := FileManager->List(token);
each(f in files) {
"{$f->GetName()}: {$f->GetState()}"->PrintLine();
};
# delete
FileManager->Delete("files/abc123", token);
Context Caching
Cache large reused content server-side to avoid re-tokenization cost on every request:
use API.Google.Gemini, System.IO.Filesystem;
large_context := FileReader->ReadFile("legal_document.txt");
content := Content->New("user")->AddPart(TextPart->New(large_context));
# cache for 5 minutes (300 seconds)
item := CachedContent->Create(
"models/gemini-1.5-pro-001", content, 300, "legal-doc-cache", token);
if(item <> Nil) {
"Tokens cached: {$item->GetTokenCount()}"->PrintLine();
"Expires: {$item->GetExpireTime()}"->PrintLine();
};
CachedContent->Delete("cachedContents/abc123", token);
Embeddings
use API.Google.Gemini, Collection;
# single embedding (768 dimensions)
content := Content->New("user")->AddPart(TextPart->New("machine learning"));
values := Model->EmbedContent(content, token);
"Dimensions: {$values->Size()}"->PrintLine();
# batch — multiple texts in one round-trip
texts := Vector->New()<String>;
texts->AddBack("Objeck is JIT-compiled");
texts->AddBack("Python uses an interpreter");
texts->AddBack("Rust is memory-safe");
embeddings := Model->BatchEmbedContent("models/text-embedding-004", texts, token);
each(i : embeddings) {
dim := embeddings->Get(i)->Size();
" [{$i}] dim={$dim}"->PrintLine();
};
Ollama (Local LLMs)
Run open-source models locally. No API key, no data leaves your machine. Install Ollama, start the daemon, then pull a model:
ollama serve && ollama pull llama3.2
use API.Ollama;
class LocalChat {
function : Main(args : String[]) ~ Nil {
# one-shot generation
Completion->Generate("llama3.2", "What is 2 + 2?")->PrintLine();
# with temperature control
opts := Options->New()->SetTemperature(0.2);
Completion->Generate("llama3.2", "List 3 capitals of Europe.", opts)->PrintLine();
# multi-turn — context maintained automatically
chat := Chat->New("llama3.2");
chat->Send("My name is Alice.");
chat->Send("What is my name?")->PrintLine(); # "Your name is Alice."
# vision (multimodal models)
image := System.IO.Filesystem.File->New("photo.jpg");
Completion->Generate("llava", "Describe this image.", image)->PrintLine();
# local embeddings
values := Model->Embeddings("nomic-embed-text", "machine learning");
"Dimensions: {$values->Size()}"->PrintLine();
}
}
> obc -src local_chat.obs -lib net,json,cipher,misc,ollama > obr local_chat
Machine Learning
Pure Objeck ML routines backed by the Eigen C++ library — no Python, no external frameworks. Covers linear algebra, regression, neural networks, clustering, and model evaluation.
Matrix Operations
Matrix2D provides the foundational matrix math used by all other ML classes, plus activation functions used in neural architectures:
use System.ML;
class MatrixExample {
function : Main(args : String[]) ~ Nil {
a := [[1.0, 2.0], [3.0, 4.0]];
b := [[5.0, 6.0], [7.0, 8.0]];
# matrix dot product: [[19,22],[43,50]]
c := Matrix2D->DotProduct(a, b);
dims := c->Size(); # [rows, columns]
each(r : dims[0]) {
each(col : dims[1]) {
value := c[r,col];
"{$value} "->Print();
};
'\n'->Print();
};
# 19.000000 22.000000
# 43.000000 50.000000
# activation functions (element-wise)
x := [[0.5, -0.3], [1.2, -0.8]];
Matrix2D->ReLU(x); # max(0, x): [[0.5,0.0],[1.2,0.0]]
Matrix2D->Sigmoid(x); # 1/(1+e^-x)
Matrix2D->Tanh(x); # hyperbolic tangent
Matrix2D->Softmax(x); # probability distribution over all elements (sums to 1)
# statistical helpers
"Row 0 avg: {$Matrix2D->AverageRow(0, a)}"->PrintLine(); # 1.500000
"Col 1 sum: {$Matrix2D->SumColumn(1, a)}"->PrintLine(); # 6.000000
"Std dev: {$Matrix2D->StdDevColumn(0, a)}"->PrintLine(); # 1.414214 (sample)
# random matrices for weight initialization
weights := Matrix2D->Random(3, 4); # uniform [0,1]
weights := Matrix2D->RandomNormal(0.0, 0.1, 3, 4); # Gaussian
}
}
Regression
Linear Regression — least-squares fit for continuous target prediction:
use System.ML;
class RegressionExample {
function : Main(args : String[]) ~ Nil {
# features: [size_sqft, rooms] → price
X := [[800.0, 2.0], [1200.0, 3.0], [1600.0, 4.0], [2000.0, 5.0]];
y := [[150000.0], [220000.0], [300000.0], [380000.0]];
model := LinearRegression->New();
if(model->Fit(X, y)) {
preds := model->Predict([[1400.0, 3.0]]);
price := preds[0,0];
"Predicted price: {$price}"->PrintLine(); # ~263148
"R²: {$model->GetRSquared()}"->PrintLine(); # ~0.998
coefficients := model->GetCoefficients();
each(i : coefficients->Size()) {
weight := coefficients[i];
"w[{$i}] = {$weight}"->PrintLine();
};
};
}
}
Logistic Regression — gradient descent binary classifier with sigmoid activation:
use System.ML;
class ClassifierExample {
function : Main(args : String[]) ~ Nil {
# features: [hours_studied, prev_score] → pass/fail
X := [[2.0, 55.0], [3.0, 60.0], [7.0, 80.0], [9.0, 90.0]];
y := [[0.0], [0.0], [1.0], [1.0]];
model := LogisticRegression->New(0.01, 2000);
if(model->Fit(X, y)) {
probs := model->Predict([[5.0, 72.0]]);
classes := model->PredictClass([[5.0, 72.0]]);
probability := probs[0];
passed := classes[0];
"Probability: {$probability}"->PrintLine(); # ~0.43
"Predicted pass: {$passed}"->PrintLine(); # false
};
}
}
Neural Networks
Configurable multi-layer network trained with backpropagation. Models can be saved and reloaded:
use System.ML, Collection;
class XorNet {
function : Main(args : String[]) ~ Nil {
# XOR training data: each sample is a column vector, one row per input node
inputs := Vector->New()<FloatMatrixRef>;
targets := Vector->New()<FloatMatrixRef>;
inputs->AddBack(FloatMatrixRef->New([[0.0], [0.0]])); targets->AddBack(FloatMatrixRef->New([[0.0]]));
inputs->AddBack(FloatMatrixRef->New([[0.0], [1.0]])); targets->AddBack(FloatMatrixRef->New([[1.0]]));
inputs->AddBack(FloatMatrixRef->New([[1.0], [0.0]])); targets->AddBack(FloatMatrixRef->New([[1.0]]));
inputs->AddBack(FloatMatrixRef->New([[1.0], [1.0]])); targets->AddBack(FloatMatrixRef->New([[0.0]]));
# Train: 2 inputs → 6 hidden (2 × factor 3) → 1 output
net := NeuralNetwork->Train(2, inputs, 3, 1, targets, 0.3, 10000);
if(net <> Nil) {
query := FloatMatrixRef->New([[1.0], [0.0]]);
"1 XOR 0 — confidence: {$net->Confidence(query)}"->PrintLine(); # for example 0.987407 (weights start random)
"1 XOR 0 — activated: {$net->Query(query)}"->PrintLine(); # true
net->Store("xor.dat");
};
}
}
Load CSV training data with the built-in reader — it splits inputs and targets automatically:
use System.ML, Collection;
# iris.csv: no header row; 4 feature columns scaled to 0..1, then 3 one-hot class columns
# LoadSplitMatrices: filename, number of target columns (the last 3), train fraction, line ending
# each row becomes a 4x1 input and a 3x1 target, the column shapes Train expects
splits := MatrixReader->LoadSplitMatrices("iris.csv", 3, 0.8, "\n");
# splits[0]=train_inputs splits[1]=train_targets
# splits[2]=test_inputs splits[3]=test_targets
train_inputs := splits[0];
train_targets := splits[1];
net := NeuralNetwork->Train(4, train_inputs, 6, 3, train_targets, 0.05, 5000);
> obc -src xor_net.obs -lib ml,gen_collect,csv > obr xor_net
Clustering & Classification
K-Nearest Neighbors — instance-based classification over float feature vectors:
use System.ML;
class KNNExample {
function : Main(args : String[]) ~ Nil {
# training: [height_cm, weight_kg] with size labels
data := [[162.0, 55.0], [175.0, 75.0], [185.0, 90.0], [155.0, 48.0]];
labels := ["S", "M", "L", "XS"];
knn := KNearestNeighbors->New(data, labels);
neighbors := knn->Query(3, [170.0, 68.0]);
each(n in neighbors) {
"{$n->GetCategory()}: distance={$n->GetDistance()}"->PrintLine();
};
}
}
K-Means Clustering — unsupervised grouping with Dunn index quality score:
use System.ML, Collection;
class ClusterExample {
function : Main(args : String[]) ~ Nil {
records := Vector->New()<FloatArrayRef>;
records->AddBack(FloatArrayRef->New([1.0, 1.5]));
records->AddBack(FloatArrayRef->New([1.2, 1.3]));
records->AddBack(FloatArrayRef->New([8.0, 8.5]));
records->AddBack(FloatArrayRef->New([7.8, 8.2]));
records->AddBack(FloatArrayRef->New([4.5, 4.0]));
groups := ["high", "low"]; # one label per cluster: K = 2
grouping := KMeans->Group(groups, records, 2, 0.0, 10.0);
"Dunn Index: {$grouping->GetDunnIndex()}"->PrintLine(); # 1.241838
each(i : grouping->Size()) {
g := grouping->Get(i);
"Group '{$g->GetName()}': {$g->Size()} members"->PrintLine();
};
# Group 'high': 2 members
# Group 'low': 3 members
}
}
Naive Bayes — probabilistic text classification (spam detection, sentiment, etc.):
use System.ML;
class SpamFilter {
function : Main(args : String[]) ~ Nil {
# "ham" group (index 0)
ham := BayesGroup->New(0.6);
ham->AddEntry(BayesEntry->New("meeting", 15));
ham->AddEntry(BayesEntry->New("report", 12));
ham->AddEntry(BayesEntry->New("project", 18));
# "spam" group (index 1)
spam := BayesGroup->New(0.4);
spam->AddEntry(BayesEntry->New("buy", 30));
spam->AddEntry(BayesEntry->New("free", 25));
spam->AddEntry(BayesEntry->New("click", 20));
classifier := NaiveBayes->New(ham, spam);
result := classifier->Query(["buy", "free"]);
if(result = 1) {
"Spam"->PrintLine();
} else {
"Ham"->PrintLine();
};
}
}
Evaluation & Preprocessing
FeatureScaler normalizes inputs before training; Metrics evaluates classifier performance:
use System.ML;
class EvalExample {
function : Main(args : String[]) ~ Nil {
# ── Feature scaling ──────────────────────────────
raw := [[10.0, 200.0], [20.0, 400.0], [30.0, 600.0]];
scaled := FeatureScaler->MinMaxScaler(raw); # [0, 1]
z_score := FeatureScaler->StandardScaler(raw); # mean=0, std=1
l2_norm := FeatureScaler->Normalize(raw); # L2 row normalization
# ── Metrics ──────────────────────────────────────
predictions := [true, false, true, true, false];
actuals := [true, true, false, true, false];
"Accuracy: {$Metrics->Accuracy(predictions, actuals)}"->PrintLine(); # 0.600000
"Precision: {$Metrics->Precision(predictions, actuals)}"->PrintLine(); # 0.666667
"Recall: {$Metrics->Recall(predictions, actuals)}"->PrintLine(); # 0.666667
"F1 Score: {$Metrics->F1Score(predictions, actuals)}"->PrintLine(); # 0.666667
"MCC: {$Metrics->MCC(predictions, actuals)}"->PrintLine(); # 0.166667
cm := Metrics->ConfusionMatrix(predictions, actuals); # [[TN, FP], [FN, TP]] = [[1, 1], [1, 2]]
Metrics->PrintConfusionMatrix(cm);
# ── Train/test split ─────────────────────────────
data := [[1.0, 2.0], [3.0, 4.0], [5.0, 6.0], [7.0, 8.0], [9.0, 10.0]];
splits := CrossValidation->TrainTestSplit(data, 0.2); # 80/20, rows shuffled
train_dims := splits[0]->Get()->Size(); # [rows, columns]
test_dims := splits[1]->Get()->Size();
train_rows := train_dims[0];
test_rows := test_dims[0];
"Train rows: {$train_rows}, Test rows: {$test_rows}"->PrintLine(); # Train rows: 4, Test rows: 1
}
}
> obc -src eval.obs -lib ml,gen_collect,csv > obr eval
ONNX Local Inference
Run ONNX models locally with hardware acceleration: DirectML on Windows x64, QNN on Windows ARM64, CoreML on macOS. The Linux x64 library is CPU-only, and the Linux ARM64 packages include no ONNX library. CPU inference requires no GPU. Models load from local files — no internet at runtime.
Face Recognition
Uses InsightFace buffalo_l: SCRFD 10G-KPS detector + ArcFace R50 512-dim embeddings.
curl -L -o buffalo_l.zip https://github.com/deepinsight/insightface/releases/download/v0.7/buffalo_l.zip unzip buffalo_l.zip # det_10g.onnx and w600k_r50.onnx
use API.Onnx, System.IO.Filesystem;
session := FaceSession->New("det_10g.onnx", "w600k_r50.onnx");
img1 := FileReader->ReadBinaryFile("person_a.jpg");
img2 := FileReader->ReadBinaryFile("person_b.jpg");
r1 := session->Recognize(img1, 0.5);
r2 := session->Recognize(img2, 0.5);
if(r1->GetSize() > 0 & r2->GetSize() > 0) {
emb1 := r1->GetResults()[0]->GetEmbedding();
emb2 := r2->GetResults()[0]->GetEmbedding();
sim := FaceSession->Compare(emb1, emb2);
"Similarity: {$sim}"->PrintLine();
"Same person: {$(sim > 0.35)}"->PrintLine();
};
session->Close();
Object Detection (YOLO)
use API.Onnx, System.IO.Filesystem;
labels := String->New[80]; # COCO class labels
labels[0] := "person"; labels[1] := "bicycle"; # ... fill all 80
session := YoloSession->New("yolov11n.onnx");
img := FileReader->ReadBinaryFile("street.jpg");
result := session->Inference(img, 640, 640, 0.5, labels);
detections := result->GetClassifications();
each(d in detections) {
"{$d->GetName()}: {$d->GetConfidence()}"->PrintLine();
};
session->Close();
Phi-3 Mini (Local SLM)
Run Microsoft's Phi-3 Mini locally — no internet at inference time. (~2 GB model)
huggingface-cli download microsoft/Phi-3-mini-4k-instruct-onnx \ --include "directml/directml-int4-awq-block-128/*"
use API.Onnx, System.IO.Filesystem;
tokenizer := Phi3Tokenizer->New("tokenizer.json");
session := Phi3Session->New("phi3-mini-4k-instruct.onnx");
prompt := "<|user|>\nWhat is the capital of France?<|end|>\n<|assistant|>\n";
token_ids := tokenizer->Encode(prompt);
eos := Int->New[1]; eos[0] := 32007;
result := session->Generate(token_ids, 200, 0.7, eos);
tokenizer->Decode(result->GetTokens())->PrintLine();
session->Close();
Computer Vision (OpenCV)
use API.OpenCV, API.Onnx, System.IO.Filesystem;
class VisionExample {
function : Main(args : String[]) ~ Nil {
# load, process, save
image := Image->Load("photo.jpg");
gray := image->CvtColor(ColorConversionCodes->BGR2GRAY);
blurred := gray->GaussianBlur(5, 5, 0.0); # sigma 0: derived from the kernel size
edges := blurred->Canny(50, 150);
edges->Save("edges.jpg");
# face detection: no cascade classifier in the OpenCV bundle, so detect
# with ONNX (FaceSession, add onnx to -lib) and draw with OpenCV
bytes := FileReader->ReadBinaryFile("group.jpg");
session := FaceSession->New("det_10g.onnx");
faces := session->Detect(bytes, 0.5);
"Faces detected: {$faces->GetSize()}"->PrintLine();
group := Image->Load(bytes);
detections := faces->GetDetections();
each(face in detections) {
group := group->DrawRectangle(face->GetBounds(), Scalar->New(0.0, 255.0, 0.0), 2);
};
group->Save("faces.jpg");
session->Close();
# resize and color space conversion
resized := image->Resize(Size->New(320, 240));
resized->CvtColor(ColorConversionCodes->BGR2HSV)->Save("hsv_output.jpg");
}
}
Natural Language Processing
Built-in NLP primitives — no model download required. Pure Objeck bytecode.
use System.NLP;
class NLPExample {
function : Main(args : String[]) ~ Nil {
# sentiment
SentimentAnalyzer->Classify("This product is absolutely wonderful!")->PrintLine(); # "positive"
# TF-IDF vectorization
docs := String->New[3];
docs[0] := "cats are pets";
docs[1] := "dogs are pets";
docs[2] := "birds can fly";
tfidf := TF_IDF->New();
tfidf->Fit(docs);
vector := tfidf->Transform("cats and dogs");
each(v in vector) { v->PrintLine(); };
# cosine similarity of two TF-IDF vectors
sim := TextSimilarity->CosineSimilarity(tfidf->Transform("cats are pets"), tfidf->Transform("dogs are pets"));
"Similarity: {$sim}"->PrintLine();
# tokenization
tokens := Tokenizer->WordTokenize("The quick brown fox");
each(t in tokens) { t->PrintLine(); };
}
}
> obc -src nlp.obs -lib gen_collect,nlp > obr nlp
Quick Reference
| Capability | Class | Library flag | Key |
|---|---|---|---|
| Chat / text | Response | openai | OpenAI |
| Vision (image input) | Response + ImageQuery | openai | OpenAI |
| Realtime audio | Realtime | openai,sdl2 | OpenAI |
| Text embeddings | Embedding | openai | OpenAI |
| Content moderation | Moderation | openai | OpenAI |
| Batch processing | Batch | openai | OpenAI |
| Gemini chat / vision | Model::GenerateContent | gemini | Gemini |
| Search grounding | Model::GenerateContentWithGrounding | gemini | Gemini |
| File upload | FileManager | gemini | Gemini |
| Context caching | CachedContent | gemini | Gemini |
| Gemini embeddings | Model::EmbedContent / BatchEmbedContent | gemini | Gemini |
| Local chat / generation | Completion, Chat | ollama | None |
| Local embeddings | Model::Embeddings | ollama | None |
| Matrix algebra | Matrix2D | ml,gen_collect,csv | None |
| Linear regression | LinearRegression | ml,gen_collect,csv | None |
| Logistic regression | LogisticRegression | ml,gen_collect,csv | None |
| Neural network | NeuralNetwork | ml,gen_collect,csv | None |
| K-nearest neighbors | KNearestNeighbors | ml,gen_collect,csv | None |
| K-means clustering | KMeans | ml,gen_collect,csv | None |
| Naive Bayes | NaiveBayes | ml,gen_collect,csv | None |
| Feature scaling | FeatureScaler | ml,gen_collect,csv | None |
| Model evaluation | Metrics, CrossValidation | ml,gen_collect,csv | None |
| Face recognition | FaceSession | onnx | None |
| Object detection | YoloSession | onnx | None |
| Local SLM | Phi3Session | onnx | None |
| Computer vision | Image, VideoCapture | opencv | None |
| Sentiment / TF-IDF | SentimentAnalyzer, TF_IDF | nlp | None |
Model Recommendations
| Task | OpenAI | Gemini | Ollama (local) |
|---|---|---|---|
| General chat | gpt-4o-mini | gemini-2.0-flash | llama3.2 |
| Reasoning | o3-mini | gemini-2.5-pro | qwen2.5 |
| Vision | gpt-4o | gemini-2.0-flash | llava |
| Realtime audio | gpt-4o-realtime-preview | — | — |
| Text embeddings | text-embedding-3-small | text-embedding-004 | nomic-embed-text |
| Fast & cheap | gpt-4o-mini | gemini-2.5-flash | phi3 |
Example Programs
Full working examples in programs/frameworks/:
openai_batch.obs openai_tune.obs openai_responses.obs
gemini/ gemini_image.obs gemini_audio.obs gemini_files.obs
gemini_cache.obs gemini_grounding.obs gemini_embed.obs
ollama/ test_0.obs (generate) test_1.obs (vision) test_2.obs (chat) test_3.obs (models)
opencv_onnx/ demo_face.obs demo_yolo.obs demo_phi3_*.obs