Views
No views yet
ibm-granite/granite-3.1-1b-a400m-instruct. It writes runnable
scikit-learn / pandas / NumPy code, explains ML pipeline steps, and reasons about
everyday concepts like overfitting, cross-validation, and gradient descent.Built as the reference model for the TEKIMAX ML Model Workshop (fine-tune → host on HF/Ollama → build a production DL app).
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4tok = AutoTokenizer.from_pretrained("Tekimax/granite-ml-coder")
5model = AutoModelForCausalLM.from_pretrained(
6 "Tekimax/granite-ml-coder", dtype=torch.float32, attn_implementation="eager"
7)
8
9messages = [
10 {"role": "system", "content": "You are an expert Python machine-learning engineer."},
11 {"role": "user", "content": "Write a scikit-learn pipeline to classify the iris dataset and explain how you avoid overfitting."},
12]
13enc = tok.apply_chat_template(messages, add_generation_prompt=True,
14 return_tensors="pt", return_dict=True, enable_thinking=False)
15out = model.generate(**enc, max_new_tokens=400, do_sample=True, temperature=0.7, top_p=0.9)
16print(tok.decode(out[0][enc["input_ids"].shape[1]:], skip_special_tokens=True))ollama run tekimaxllc/granite-ml-coder "Write a Keras autoencoder for network-traffic anomaly detection"Q4_K_M build (~378 MB) is available at
Tekimax/granite-ml-coder-GGUF:llama-cli -m granite-ml-coder-Q4_K_M.gguf -p "Write a sklearn pipeline"| Base model | ibm-granite/granite-3.1-1b-a400m-instruct (Apache-2.0, IBM) — ~1.3B total / 400M active MoE |
| Data | iamtarun/python_code_instructions_18k_alpaca, filtered to ML/DS rows (≈2,341 examples) |
| Method | Full fine-tune, instruction format with the Granite chat template; loss computed on the assistant answer only (prompt tokens masked) |
| Schedule | 2 epochs · effective batch size 16 · LR 2e-5 cosine · max_len 512 |
| Hardware | Apple M2 Ultra, CPU (the MPS/Metal backend was unstable for fine-tuning on torch 2.12 — see the workshop appendix) |
| Result | training loss decreasing steadily, no NaN |
transformers Trainer; quantized with llama.cpp.