Quickstart — your first audit-ready training run
This guide walks you through installing cognify-sdk, instrumenting a training script, and exporting your first compliance package. Estimated time: 5 minutes.
Installation
Install cognify-sdk from PyPI. Python 3.8+ required.
$ pip install cognify-sdk==2.1.4
# Or with extras for your framework:
$ pip install "cognify-sdk[hf,pytorch]"==2.1.4
Initialization
Create a Cognify API key from your workspace settings. Then initialize at the top of your training script:
import os
import cognify
cognify.init(
workspace="your-workspace-slug",
api_key=os.environ["COGNIFY_API_KEY"],
run_name="my-first-ft-run",
tags=["experiment", "clinical-nlp"]
)
Instrumenting your training loop
Wrap your dataset registration and training call. For Hugging Face Trainer, the SDK auto-hooks into checkpoint events.
from transformers import Trainer, TrainingArguments
from datasets import load_dataset
# Register your dataset — Cognify hashes and versions it
train_ds = load_dataset("my_org/clinical-ner-v2")
cognify.dataset(
name="clinical-ner-train",
source=train_ds,
split="train"
)
training_args = TrainingArguments(
output_dir="./checkpoints",
num_train_epochs=3,
per_device_train_batch_size=16,
learning_rate=2e-5,
save_steps=500,
)
trainer = Trainer(model=model, args=training_args, train_dataset=train_ds["train"])
trainer.train() # Checkpoints auto-logged
Viewing the lineage graph
After training completes, view your run in the Cognify dashboard at app.fyntuneq.com/runs/my-first-ft-run. The lineage graph shows:
- Dataset snapshot with SHA-256 hash and record count
- Training configuration (hyperparameters, hardware)
- Checkpoint sequence with step numbers and loss values
- Eval results (if eval dataset registered)
Exporting your first audit package
Once your run completes, export a compliance package:
import cognify
pkg = cognify.export_audit(
run_name="my-first-ft-run",
formats=["pdf", "json"],
output_dir="./audit_packages"
)
print(f"Exported to: {pkg.output_path}")
The package includes a model card, data provenance report, training configuration attestation, and eval benchmark summary (if eval was configured). Share the PDF with your compliance team — it contains everything needed for model sign-off.
Next steps
- Full SDK API reference — all methods, parameters, return types
- Dataset versioning guide — manual snapshots, retention policies
- Audit trail deep-dive — immutability guarantees, export formats