Image-Text-to-Text
Transformers
Safetensors
kimi_k31
text-generation
mixture-of-experts
expert-upcycling
scientific-ai
chip-design
space
physics
s-t-a-r
custom_code
8-bit precision
Instructions to use STAR-future/Trinity with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use STAR-future/Trinity with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="STAR-future/Trinity", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForSeq2SeqLM model = AutoModelForSeq2SeqLM.from_pretrained("STAR-future/Trinity", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use STAR-future/Trinity with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "STAR-future/Trinity" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "STAR-future/Trinity", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/STAR-future/Trinity
- SGLang
How to use STAR-future/Trinity with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "STAR-future/Trinity" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "STAR-future/Trinity", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "STAR-future/Trinity" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "STAR-future/Trinity", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use STAR-future/Trinity with Docker Model Runner:
docker model run hf.co/STAR-future/Trinity
Download tools/colab_k3scale.py from STAR-future/Trinity: direct link, hf CLI and curl.
- Browser
- Download file 3.66 kB
-
https://huggingface.co/STAR-future/Trinity/resolve/f8aef0743bc8ed88e849346528d7dfe34ec00228/tools/colab_k3scale.py
- Command line
-
hf download hf://STAR-future/Trinity@f8aef0743bc8ed88e849346528d7dfe34ec00228/tools/colab_k3scale.py
-
curl -L -o colab_k3scale.py https://huggingface.co/STAR-future/Trinity/resolve/f8aef0743bc8ed88e849346528d7dfe34ec00228/tools/colab_k3scale.py
3.66 kB
| """Colab GPU cell: how does the k3 pass cost scale with the number of tokens? (timing only, no cache, no training) | |
| Same texts (train_corpus_v1 packed as in colab_k3pass 'train') at x1 and x10 copies, first 4 layers only. | |
| Reads the per-layer 'attn'/'mlp' seconds from k3pass and uploads eval/k3scale.json. Decides whether expanding the | |
| domain cache 10-10000x costs ~linear GPU time or mostly a fixed per-layer weight cost. | |
| import os; from google.colab import userdata; import huggingface_hub as h | |
| os.environ['HF_TOKEN'] = userdata.get('STARHUGGIN') | |
| exec(open(h.hf_hub_download('STAR-future/Trinity', 'tools/colab_k3scale.py', token=os.environ['HF_TOKEN'], | |
| force_download=True)).read()) | |
| """ | |
| import json | |
| import os | |
| import re | |
| import subprocess | |
| import sys | |
| import time | |
| from pathlib import Path | |
| from huggingface_hub import HfApi, hf_hub_download | |
| TOK = os.environ["HF_TOKEN"] | |
| REPO = "STAR-future/Trinity" | |
| W = Path("/content/k3s") | |
| W.mkdir(parents=True, exist_ok=True) | |
| api = HfApi(token=TOK) | |
| subprocess.run([sys.executable, "-m", "pip", "install", "-q", "tiktoken"], check=True) | |
| for f in ("k3ref.py", "k3pass.py"): | |
| (W / f).write_bytes(Path(hf_hub_download(REPO, f"tools/{f}", token=TOK, force_download=True)).read_bytes()) | |
| docs = [json.loads(x) for x in Path(hf_hub_download(REPO, "eval/data/train_corpus_v1.jsonl", token=TOK, | |
| force_download=True)).read_text(encoding="utf-8").splitlines() if x.strip()] | |
| rows = [] | |
| for dom in sorted({d["domain"] for d in docs}): | |
| buf, k = [], 0 | |
| for d in sorted((d for d in docs if d["domain"] == dom), key=lambda d: d["id"]): | |
| buf.append(d["text"].strip()) | |
| if sum(len(b) for b in buf) >= 12500: | |
| rows.append({"id": f"s_{dom}_{k:03d}", "text": "\n\n".join(buf), "set": f"train_{dom}", "role": "train", | |
| "base": False}) | |
| buf, k = [], k + 1 | |
| import torch # noqa: E402 | |
| gpu = torch.cuda.get_device_name(0) | |
| gb = torch.cuda.get_device_properties(0).total_memory / 2 ** 30 | |
| batch = os.environ.get("K3_BATCH", "12" if gb > 60 else ("8" if gb > 20 else "4")) | |
| res = {"gpu": gpu, "batch": batch, "layers": 4, "runs": []} | |
| for mult in (1, 10): | |
| texts = W / f"t{mult}.jsonl" | |
| texts.write_text("".join(json.dumps(dict(r, id=f"{r['id']}_c{c}")) + "\n" for c in range(mult) for r in rows), | |
| encoding="utf-8") | |
| t0 = time.time() | |
| p = subprocess.run([sys.executable, "-u", str(W / "k3pass.py"), "--texts", str(texts), "--work", str(W / f"w{mult}"), | |
| "--out", str(W / f"o{mult}"), "--batch", batch, "--layers", "4", "--no-cache"], cwd=W, | |
| env=dict(os.environ, PYTHONPATH=str(W), PYTORCH_CUDA_ALLOC_CONF="expandable_segments:True", | |
| HF_HUB_DISABLE_PROGRESS_BARS="1"), capture_output=True, text=True) | |
| log = p.stdout + p.stderr | |
| print(log[-3000:], flush=True) | |
| toks = re.findall(r"tokens (\d+)", log) | |
| lay = [{"layer": int(a), "wait": int(b), "attn": int(c), "mlp": int(d)} | |
| for a, b, c, d in re.findall(r"layer (\d+) wait (\d+)s attn (\d+)s mlp (\d+)s", log)] | |
| res["runs"].append({"mult": mult, "rc": p.returncode, "tokens": int(toks[0]) if toks else None, "layers": lay, | |
| "wall_s": round(time.time() - t0)}) | |
| print(json.dumps(res["runs"][-1]), flush=True) | |
| (W / "k3scale.json").write_text(json.dumps(res, indent=1)) | |
| api.upload_file(path_or_fileobj=str(W / "k3scale.json"), path_in_repo="eval/k3scale.json", repo_id=REPO, | |
| commit_message="k3 pass scaling measurement") | |
| print("SCALE", json.dumps(res), flush=True) | |