Text Generation
PEFT
Safetensors
lora
qwen2.5
alfworld
privileged-information
knowledge-distillation
conversational
Instructions to use TDSMike/ALF-qwen3B-privilege with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use TDSMike/ALF-qwen3B-privilege with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("/share/shenmingxiang/closing-square/models/Qwen2.5-3B-Instruct") model = PeftModel.from_pretrained(base_model, "TDSMike/ALF-qwen3B-privilege") - Notebooks
- Google Colab
- Kaggle
Download code/checkpointing.py from TDSMike/ALF-qwen3B-privilege: direct link, hf CLI and curl.
- Browser
- Download file 2.04 kB
-
https://huggingface.co/TDSMike/ALF-qwen3B-privilege/resolve/main/code/checkpointing.py
- Command line
-
hf download hf://TDSMike/ALF-qwen3B-privilege/code/checkpointing.py
-
curl -L -o checkpointing.py https://huggingface.co/TDSMike/ALF-qwen3B-privilege/resolve/main/code/checkpointing.py
2.04 kB
| """Race-safe immutable checkpoint management. | |
| Checkpoint directories are written under a temporary name and atomically | |
| renamed once complete. ``best`` and ``latest`` are atomically replaced symlinks. | |
| No checkpoint is deleted while a run is active; pruning, if ever requested, | |
| must happen only after all consumers have stopped. | |
| """ | |
| from __future__ import annotations | |
| import json | |
| import os | |
| import uuid | |
| from pathlib import Path | |
| from typing import Any, Callable | |
| class AtomicCheckpointManager: | |
| def __init__(self, root: Path): | |
| self.root = root.resolve() | |
| self.checkpoints = self.root / "checkpoints" | |
| self.checkpoints.mkdir(parents=True, exist_ok=True) | |
| def _atomic_link(self, link_name: str, target: Path) -> None: | |
| link = self.root / link_name | |
| temp = self.root / f".{link_name}.tmp.{os.getpid()}.{uuid.uuid4().hex}" | |
| relative_target = os.path.relpath(target, self.root) | |
| os.symlink(relative_target, temp) | |
| os.replace(temp, link) | |
| def save( | |
| self, | |
| tag: str, | |
| writer: Callable[[Path], None], | |
| metadata: dict[str, Any], | |
| *, | |
| is_best: bool, | |
| ) -> Path: | |
| final = self.checkpoints / tag | |
| if final.exists(): | |
| raise FileExistsError(f"immutable checkpoint already exists: {final}") | |
| temp = self.checkpoints / f".{tag}.tmp.{os.getpid()}.{uuid.uuid4().hex}" | |
| temp.mkdir(parents=False) | |
| try: | |
| writer(temp) | |
| with (temp / "checkpoint_metadata.json").open("w", encoding="utf-8") as f: | |
| json.dump(metadata, f, ensure_ascii=False, indent=2) | |
| f.flush() | |
| os.fsync(f.fileno()) | |
| os.replace(temp, final) | |
| except Exception: | |
| # Leave a failed temporary directory for diagnosis; never remove a | |
| # possibly-active directory from another process. | |
| raise | |
| self._atomic_link("latest", final) | |
| if is_best: | |
| self._atomic_link("best", final) | |
| return final | |