Instructions to use Seedyai/Orchidia with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Seedyai/Orchidia with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Seedyai/Orchidia", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download src/utils.py from Seedyai/Orchidia: direct link, hf CLI and curl.
- Browser
- Download file 1.72 kB
-
https://huggingface.co/Seedyai/Orchidia/resolve/main/src/utils.py
- Command line
-
hf download hf://Seedyai/Orchidia/src/utils.py
-
curl -L -o utils.py https://huggingface.co/Seedyai/Orchidia/resolve/main/src/utils.py
1.72 kB
| """Determinism, logging, device/dtype helpers.""" | |
| from __future__ import annotations | |
| import logging | |
| import os | |
| import random | |
| import numpy as np | |
| import torch | |
| def setup_logging(log_dir: str = "logs", name: str = "miniclef"): | |
| os.makedirs(log_dir, exist_ok=True) | |
| logger = logging.getLogger(name) | |
| logger.setLevel(logging.INFO) | |
| if not logger.handlers: | |
| fh = logging.FileHandler(os.path.join(log_dir, f"{name}.log")) | |
| ch = logging.StreamHandler() | |
| fmt = logging.Formatter("%(asctime)s | %(levelname)s | %(message)s") | |
| fh.setFormatter(fmt) | |
| ch.setFormatter(fmt) | |
| logger.addHandler(fh) | |
| logger.addHandler(ch) | |
| return logger | |
| def set_seed(seed: int = 0): | |
| random.seed(seed) | |
| np.random.seed(seed) | |
| torch.manual_seed(seed) | |
| torch.cuda.manual_seed_all(seed) | |
| # deterministic (may cost speed; required by spec) | |
| torch.backends.cudnn.deterministic = True | |
| torch.backends.cudnn.benchmark = False | |
| try: | |
| torch.use_deterministic_algorithms(True, warn_only=True) | |
| except Exception: | |
| pass | |
| def pick_dtype(name: str) -> torch.dtype: | |
| name = name.lower() | |
| if name == "bf16": | |
| return torch.bfloat16 | |
| if name == "fp16": | |
| return torch.float16 | |
| if name == "fp32": | |
| return torch.float32 | |
| raise ValueError(f"unknown dtype '{name}'") | |
| def pick_attn(requested: str | None) -> str | None: | |
| """Return attn implementation string or None (auto). Validates availability.""" | |
| if requested in (None, "", "auto"): | |
| return None | |
| if requested not in ("eager", "sdpa", "flash_attention_2", "flash_attention_3"): | |
| raise ValueError(f"unknown attention '{requested}'") | |
| return requested | |