DATASPIRES

AfriLink
Notebooks
VS Code
FAQ

AfriLink

AfriLink Documentation

SDK guides for API-key authentication, finetuning, custom containers, and deploying each model kind.

Overview

AfriLink gives you one-line access to a dedicated NVIDIA Tesla V100 80 GB hosted by OpenToken for training (any framework — YOLOv8, custom PyTorch, etc.) and finetuning (LoRA/QLoRA for LLMs). The SDK handles authentication, dataset upload, GPU-aware docker run, status polling, and model download. Install with pip install dataspires.

Which API should I use?

Pick the entry point based on what you are training — not how advanced the job is.

Your goalCallYou provide
Fine-tune a transformer (LLM/VLM) from a foundation modelclient.finetune()model, mode, data
Pre-train a transformer with random-init weightsclient.pretrain()architecture, data, tokenizer
Adapt YOLO/CNN with pretrained weightsclient.adapt()recipe, weights or model, data
Initialize YOLO/CNN with random weightsclient.initialize()recipe, data
Deprecated: custom script pathclient.train()Use adapt() / initialize() instead
Custom framework/version not in curated containersclient.build_and_train()Image spec + script

Rule of thumb: transformer + foundation checkpoint → finetune(). Transformer + random weights → pretrain(). YOLO/CNN + pretrained weights → adapt(). YOLO/CNN + random weights → initialize(). The platform owns every training loop.

Train & Finetune

Train any model with client.train() or finetune LLMs with client.finetune() - one call handles upload, container run, and polling.

Stateless API-Key Auth

One notebook secret, instant auth, no email/password prompts and no 12-hour certificates to refresh. Reads DATASPIRES_API_KEY from Colab Secrets, Kaggle Secrets, or your env.

GPU jobs

Jobs run on AfriLink GPUs. Pass gpus= and time_limit=; the SDK submits and returns when the job finishes.

Bring your own training code

Pass a script and a dataset. The SDK runs the job and returns the outputs.

Quick Start

python
pip install dataspiresfrom dataspires import DataSpiresClientclient = DataSpiresClient()client.authenticate()  # reads DATASPIRES_API_KEY from notebook secrets / envjob = client.finetune(    model="qwen2.5-0.5b",    training_mode="low",    data=your_dataframe,    gpus=1,    time_limit="01:00:00",)result = job.run(wait=True)if result["status"] == "completed":    client.download_model(result["job_id"], "./my-model")    from transformers import AutoModelForCausalLM, AutoTokenizer    from peft import PeftModel    base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B")    model = PeftModel.from_pretrained(base, "./my-model")    tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B")    out = model.generate(**tokenizer("Hello!", return_tensors="pt"), max_new_tokens=64)    print(tokenizer.decode(out[0], skip_special_tokens=True))

Installation

bash
pip install dataspires

The [build] extras pull cryptography + requests, needed for the custom-container path. Without them only the curated client.train() and client.finetune() paths work.

The core package has zero required dependencies — heavy libraries are only loaded at the point you use them and are pre-installed in most notebook environments.

Authentication

Create an API key under Profile → AfriLink SDK keys and pass it to authenticate().

Get an API key

  1. Sign up at dataspires.com.
  2. Open API keys, click Create key, copy the dsp_live_… value (shown once).
  3. Add it to your notebook environment under the name DATASPIRES_API_KEY.

Where to set the key

EnvironmentHow to set
Google Colab🔑 sidebar → Add secret → name DATASPIRES_API_KEY, paste, enable for notebook
KaggleAdd-ons → Secrets → name DATASPIRES_API_KEY, paste, attach to notebook
Local Jupyter / VS Codeos.environ["DATASPIRES_API_KEY"] = "dsp_live_…" before client.authenticate()
AnywherePass directly: client.authenticate(api_key="dsp_live_…")

Rotate a key by revoking it on the dashboard and creating a new one.

GPU memory guide

Model sizeTraining modeFits on 1 GPU?
0.5B – 1Blow (QLoRA 4-bit)yes
3B – 7Blow / mediumyes
7B – 13Blow (QLoRA)yes
13Bhigh (bf16)tight — checkpoint-heavy
30B+low (QLoRA)marginal

Curated Models

Use client.list_available_models() to browse, or filter with size="tiny". For anything outside this registry, use client.build_image() with a custom model_source.

ModelTypeParamsMin VRAM
Qwen 2.5 0.5BText0.50B4 GB
Gemma 3 270MText0.27B2 GB
Llama 3.2 1BText1.00B4 GB
DeepSeek R1 1.5BText1.50B6 GB
Ministral 3BText3.30B8 GB
SmolVLM 256MVision0.26B2 GB
InternVL2 1BVision1.00B4 GB
Moondream 2Vision1.90B8 GB
Florence 2 BaseVision0.23B4 GB
LLaVA 1.5 7BVision7.00B16 GB

Training Modes

This backend has a single GPU; gpus>1 is clamped to 1. clamps to 1 with a console note.

ModeStrategyQuantizationBest For
lowQLoRA (rank 8)4-bitQuick experiments, small datasets
mediumLoRA (rank 16)8-bit / noneBalanced quality and cost
highFull LoRA (rank 64)NoneProduction-grade training runs

Dataset Formats

TypeHow it's handled
pandas.DataFrameSerialised to JSONL, uploaded over SCP to /mnt/data/sdk-jobs/<job_id>/input/
datasets.DatasetSaved to disk and uploaded as a directory
File path (local)JSONL or CSV file uploaded
Archive (.tar.gz / .zip)Uploaded and extracted inside the container

DataFrame should have a text column with the full prompt + response (Alpaca-style or chat template). Inside the container the dataset is at /workspace/job/input/.

Training (General-Purpose)

Use client.train() to run any training script in a curated container. For LoRA/QLoRA LLM fine-tuning, use client.finetune() instead.

python
job = client.train(    script="train_yolo.py",        # your training script    container="afrilink-yolo",      # curated container (Ultralytics + PyTorch)    data="./dataset/",              # uploaded with the job    data_config="dataset.yaml",     # YOLO config file    gpus=1,    time_limit="02:00:00",)result = job.run(wait=True)print(job.get_logs(tail=50))client.download_model(result["job_id"], "./yolo-out")

Available curated containers:

NameFrameworksUse case
afrilink-yoloUltralytics, PyTorch, torchvisionObject detection, segmentation, pose
afrilink-finetunePyTorch, Transformers, PEFT, bitsandbytesLLM fine-tuning (used by client.finetune())

Need a different stack? Use client.build_image() / client.build_and_train() below.

Custom Containers

If the built-in training paths do not cover your job, use client.build_and_train().

python
# Define exactly the environment your training needs.spec = dict(    base_image="pytorch",                                # preset    pip_packages=["transformers>=4.45", "accelerate>=0.34"],    apt_packages=["git"],    model_source={        "kind": "huggingface",        "id": "Qwen/Qwen2.5-0.5B-Instruct",    },)# Check the cache first - skip the build if a matching image already exists.hit = client.find_existing_image(**spec)if hit:    print("cache hit:", hit["image"])# Build (or skip if cached) + run + cleanup, in one call.result = client.build_and_train(    **spec,    script="my_train.py",    gpus=1,    time_limit_hours=1.0,    reuse_existing_image=True,   # default; False forces a fresh build)client.download_model(result["run"]["job_id"], "./output")

Presets for base_image:

PresetResolves to
pytorchpytorch/pytorch:2.5.0-cuda12.4-cudnn9-runtime
pytorch-2.4pytorch/pytorch:2.4.0-cuda12.4-cudnn9-runtime
pytorch-cpupytorch/pytorch:2.5.0-cpu-runtime (CPU-only)
cuda-12.4nvidia/cuda:12.4.0-runtime-ubuntu22.04
ultralyticsultralytics/ultralytics:latest

You can also pass any full image:tag string.

Model sources for model_source=:

KindRequired fieldsExample
huggingfaceid, optional revision/subfolder{"kind":"huggingface","id":"meta-llama/Llama-3.2-1B"}
urlurl{"kind":"url","url":"https://…/weights.tar.gz"}
giturl, optional revision{"kind":"git","url":"https://github.com/openai/whisper.git"}
gsuri{"kind":"gs","uri":"gs://bucket/checkpoints/"}
s3uri{"kind":"s3","uri":"s3://bucket/checkpoints/"}

Models are fetched at container runtime, not baked at build time — keeps your images thin (~2 GB instead of 7+ GB) and means you can iterate on deps without re-shipping weights. The downloaded model lands at /workspace/models/<sanitised_id>/ and the path is exposed via the MODELS_DIR env var to your script.

For gated HF models (Llama, Gemma, etc.): add HUGGINGFACE_TOKEN as a notebook secret and the SDK forwards it to the container automatically.

Cache: the SDK hashes your spec (base_image + pip/apt packages + model source) and bakes the hash into the image as a Docker label. Re-running the same spec hits the cache instantly — first build The first build can take several minutes. Later runs reuse it.

SDK Reference

DataSpiresClient

MethodDescription
authenticate(api_key=None)Resolves the API key (arg, env, Colab/Kaggle Secrets), exchanges at authenticate().
finetune(model, training_mode, data, gpus, ...)Create a FinetuneJob in the curated afrilink-finetune container. Call .run() to submit.
train(script, container, data, gpus, ...)Create a TrainJob in a curated container. Call .run() to submit.
find_existing_image(base_image, pip_packages, ...)Returns an existing custom image if one already matches the spec. None otherwise.
build_image(base_image, pip_packages, script, model_source, ...)Build a custom training image. Does not start a job.
build_and_train(..., reuse_existing_image=True)Build if needed, then run the job.
download_model(job_id, local_dir)Download job outputs. files land in <local_dir>/output/.
list_available_models(size=None)Browse the curated model registry.
list_containers()List available curated training containers.
cancel_job(job_id)Stop a running job.
run_command(cmd)Run a command in the job environment.

TrainJob / FinetuneJob (returned by client.train() / client.finetune())

Method / propertyDescription
run(wait=True)Submit the job. wait=True waits until it finishes.
cancel()Stop + remove the container with docker stop && docker rm.
get_logs(tail=100)Fetch recent log lines via docker logs --tail.
statusCurrent state — one of queued, running, completed, failed, cancelled.
job_idAfriLink job ID (8-char UUID prefix).
container_idJob id after run().

run() returns a dict with job_id, container_id, status, output_dir. Always check result["status"] before downloading.

Deploy

After a job finishes, client.deploy() gives you a URL to call from a notebook or an app. Use the same API key you trained with. The first call can take a few minutes while the model loads. Call client.undeploy() when you are done.

python
dep = client.deploy(job.job_id, artifact="final", name="my-model")print(dep.url)# Text modeldep.predict(prompt="Say hi in three words.", max_tokens=32)dep.chat(messages=[{"role": "user", "content": "Say hi in three words."}])# Vision-language model — pass a file pathdep.predict(prompt="Describe this image in one short sentence.", image="./sample.png")# Image classifier — pass the architecture you traineddep = client.deploy(cnn_job.job_id, name="resnet", architecture="resnet18")dep.predict(image="./sample.png", top_k=5)# Object detectordep = client.deploy(detect_job.job_id, artifact="best", name="detector")dep.predict(image="./photo.jpg", conf=0.25)client.undeploy(dep.deployment_id)

chat() is for text and vision-language models. Classifiers and detectors use predict().

Built-in User Guide

Query the inline reference manual from any notebook cell — no internet required:

python
import dataspiresdataspires.docs("help")          # index of all topicsdataspires.docs("quickstart")    # getting starteddataspires.docs("auth")          # authenticationdataspires.docs("finetune")      # finetune parameters & modesdataspires.docs("training")      # general training jobsdataspires.docs("specs")         # V100 hardware spec sheetdataspires.docs("datasets")      # dataset formatsdataspires.docs("deploy")        # serve a finished job

Working With Your Model

Once downloaded, adapter weights work directly with standard HuggingFace tooling.

Export to GGUF & run with Ollama

python
from transformers import AutoModelForCausalLM, AutoTokenizerfrom peft import PeftModel# Merge adapter into base modelbase = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B")merged = PeftModel.from_pretrained(base, "./my-model").merge_and_unload()merged.save_pretrained("./my-model-merged")AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B").save_pretrained("./my-model-merged")# python convert_hf_to_gguf.py ./my-model-merged --outfile my-model.gguf# ./llama-quantize my-model.gguf my-model-q4.gguf Q4_K_M# ollama create my-model -f Modelfile  &&  ollama run my-model

Publish to HuggingFace Hub

python
from huggingface_hub import HfApiapi = HfApi(token="hf_...")repo_id = "your-username/my-finetuned-model"api.create_repo(repo_id, exist_ok=True)api.upload_folder(folder_path="./my-model", repo_id=repo_id)          # adapter onlyapi.upload_folder(folder_path="./my-model-merged", repo_id=repo_id)   # full merged modelapi.upload_file(path_or_fileobj="./my-model-q4.gguf",                path_in_repo="my-model-q4.gguf", repo_id=repo_id)       # GGUF