Text Generation
PEFT
Safetensors
GGUF
granite
uno
speculative-decoding
block-diffusion
lora
oflm
openflowlm
npu2
q4nx
conversational
Run this model with HF Jobs
Run Cyronius/granite-4.2-3b-uno on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/Cyronius/granite-4.2-3b-uno. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Cyronius/granite-4.2-3b-uno on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/Cyronius/granite-4.2-3b-uno. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/Cyronius/granite-4.2-3b-uno. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use Cyronius/granite-4.2-3b-uno with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Cyronius/granite-4.2-3b-uno with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("ibm-granite/granite-4.2-3b") model = PeftModel.from_pretrained(base_model, "Cyronius/granite-4.2-3b-uno") - Notebooks
- Google Colab
- Kaggle
File size: 4,557 Bytes
4ab04b3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | from __future__ import annotations
import hashlib
import json
import math
import netrc
import os
from dataclasses import asdict, dataclass
from pathlib import Path
from typing import Any, Literal
from .constants import (
DEFAULT_CE_ALPHA,
DEFAULT_KL_BETA,
DEFAULT_LORA_ALPHA_RATIO,
DEFAULT_TV_GAMMA,
)
CeTarget = Literal["teacher", "ground_truth"]
@dataclass(frozen=True)
class UnoObjectiveConfig:
"""The intentionally narrow public Uno objective."""
ce_target: CeTarget = "teacher"
noise: str = "uniform"
reverse_kl: bool = True
teacher_base_only: bool = True
ce_weight: float = DEFAULT_CE_ALPHA
kl_weight: float = DEFAULT_KL_BETA
tv_weight: float = DEFAULT_TV_GAMMA
def validate(self) -> None:
if self.ce_target not in ("teacher", "ground_truth"):
raise ValueError(
"ce_target must be either 'teacher' or 'ground_truth'."
)
if self.noise != "uniform":
raise ValueError("Public Uno training supports uniform noise only.")
if not self.reverse_kl:
raise ValueError("Public Uno training supports reverse KL only.")
if not self.teacher_base_only:
raise ValueError("The Uno teacher must use frozen base weights only.")
weights = (self.ce_weight, self.kl_weight, self.tv_weight)
if any(not isinstance(weight, (int, float)) for weight in weights):
raise ValueError("Uno loss weights must be numeric.")
if any(not math.isfinite(weight) or weight < 0 for weight in weights):
raise ValueError("Uno loss weights must be finite and non-negative.")
if not any(weight > 0 for weight in weights):
raise ValueError("At least one Uno loss weight must be positive.")
@property
def internal_ce_target(self) -> str:
self.validate()
return "clean_argmax" if self.ce_target == "teacher" else "data"
@dataclass(frozen=True)
class LoraSettings:
target: str
rank: int
alpha: int | None
dropout: float
@property
def resolved_alpha(self) -> int:
return self.alpha if self.alpha is not None else DEFAULT_LORA_ALPHA_RATIO * self.rank
def validate(self) -> None:
if self.rank <= 0:
raise ValueError("LoRA rank must be positive.")
if self.alpha is not None and self.alpha <= 0:
raise ValueError("LoRA alpha must be positive.")
if not 0.0 <= self.dropout < 1.0:
raise ValueError("LoRA dropout must be in [0, 1).")
def canonical_json(payload: dict[str, Any]) -> str:
return json.dumps(payload, sort_keys=True, separators=(",", ":"))
def manifest_digest(payload: dict[str, Any]) -> str:
return hashlib.sha256(canonical_json(payload).encode("utf-8")).hexdigest()
def write_json_atomic(path: Path, payload: dict[str, Any]) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
temporary = path.with_suffix(path.suffix + ".tmp")
temporary.write_text(json.dumps(payload, indent=2, sort_keys=True) + "\n")
temporary.replace(path)
def validate_resume_manifest(output_dir: Path, expected: dict[str, Any]) -> None:
manifest_path = output_dir / "uno_training_manifest.json"
if not manifest_path.is_file():
raise FileNotFoundError(
f"Cannot resume without the original run manifest: {manifest_path}"
)
actual = json.loads(manifest_path.read_text())
if actual.get("compatibility_sha256") != manifest_digest(expected):
raise ValueError(
"Resume configuration does not match the original training run. "
f"Expected compatibility hash {manifest_digest(expected)}, got "
f"{actual.get('compatibility_sha256')}."
)
def has_wandb_credentials() -> bool:
if os.environ.get("WANDB_API_KEY"):
return True
base_url = os.environ.get("WANDB_BASE_URL", "https://api.wandb.ai")
host = base_url.split("://", 1)[-1].split("/", 1)[0]
try:
auth = netrc.netrc().authenticators(host)
except (FileNotFoundError, netrc.NetrcParseError, OSError):
return False
return bool(auth and auth[2])
def validate_wandb_auth(mode: str) -> None:
if mode != "online":
return
if not has_wandb_credentials():
raise RuntimeError(
"W&B online logging is enabled, but no credentials were found. "
"Run `wandb login`, set WANDB_API_KEY, or set WANDB_MODE=disabled."
)
def dataclass_dict(value: Any) -> dict[str, Any]:
return asdict(value)
|