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
colab_k3pass: train4-7 on corpus v3
Browse files- tools/colab_k3pass.py +13 -6
tools/colab_k3pass.py
CHANGED
|
@@ -27,13 +27,15 @@ TOK = os.environ["HF_TOKEN"]
|
|
| 27 |
REPO = "STAR-future/Trinity"
|
| 28 |
CACHE = "STAR-future/Trinity-k3cache"
|
| 29 |
MODE = os.environ.get("K3P", "holdout")
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
CACHE = f"STAR-future/Trinity-k3cache-{MODE}"
|
| 32 |
W = Path("/content/k3p")
|
| 33 |
W.mkdir(parents=True, exist_ok=True)
|
| 34 |
# FAIL-0089: the boot disk (236 GB) cannot hold the work files (214 GB + shards) and the final cache (~94 GB per 1.3 M
|
| 35 |
# tokens). Colab A100 runtimes mount a 368 GB /mnt/local-scratch: put work and output there when it exists.
|
| 36 |
-
if Path("/mnt/local-scratch").exists() and MODE in ("train",
|
| 37 |
for _n in (f"work_{MODE}", f"out_{MODE}"):
|
| 38 |
_t, _l = Path("/mnt/local-scratch") / _n, W / _n
|
| 39 |
_t.mkdir(parents=True, exist_ok=True)
|
|
@@ -48,6 +50,9 @@ for f in ("k3ref.py", "k3pass.py", "lb_tail_train.py", "lb_tail_eval.py"):
|
|
| 48 |
if MODE in ("train2", "train3"): # domain corpus v2 (~10x v1, arXiv CC0 abstracts submitted before 2026-10-01)
|
| 49 |
(W / "train_corpus_v2.jsonl").write_bytes(Path(hf_hub_download(REPO, "eval/data/train_corpus_v2b.jsonl" if MODE == "train3" else "eval/data/train_corpus_v2.jsonl", token=TOK,
|
| 50 |
force_download=True)).read_bytes())
|
|
|
|
|
|
|
|
|
|
| 51 |
# the holdout lives only in the PRIVATE cache dataset: holdouts are never published (moved there 2026-11-19)
|
| 52 |
(W / "k3stream_holdout_pack.jsonl").write_bytes(Path(hf_hub_download("STAR-future/Trinity-k3cache", "eval-data/k3stream_holdout_pack.jsonl",
|
| 53 |
repo_type="dataset", token=TOK,
|
|
@@ -99,7 +104,7 @@ def up(path, name):
|
|
| 99 |
api.upload_file(path_or_fileobj=str(path), path_in_repo=f"eval/{name}", repo_id=REPO, commit_message=name)
|
| 100 |
|
| 101 |
|
| 102 |
-
if MODE in ("holdout", "train"
|
| 103 |
rows = []
|
| 104 |
if MODE == "holdout":
|
| 105 |
for r in map(json.loads, (W / "k3stream_holdout_pack.jsonl").read_text(encoding="utf-8").splitlines()):
|
|
@@ -107,7 +112,7 @@ if MODE in ("holdout", "train", "train2", "train3"):
|
|
| 107 |
for r in wiki(0, 16):
|
| 108 |
rows.append({"id": r["title"], "text": r["text"], "set": "wikipedia", "role": "holdout", "base": True})
|
| 109 |
else:
|
| 110 |
-
cfile = "train_corpus_v2.jsonl" if MODE in ("train2", "train3") else "train_corpus_v1.jsonl"
|
| 111 |
docs = [json.loads(x) for x in (W / cfile).read_text(encoding="utf-8").splitlines() if x.strip()]
|
| 112 |
for dom in sorted({d["domain"] for d in docs}):
|
| 113 |
buf, k = [], 0
|
|
@@ -117,7 +122,9 @@ if MODE in ("holdout", "train", "train2", "train3"):
|
|
| 117 |
rows.append({"id": f"{MODE}_{dom}_{k:03d}", "text": "\n\n".join(buf), "set": f"train_{dom}",
|
| 118 |
"role": "train", "base": False})
|
| 119 |
buf, k = [], k + 1
|
| 120 |
-
|
|
|
|
|
|
|
| 121 |
rows.append({"id": r["title"], "text": r["text"], "set": "general_wiki", "role": "train", "base": False})
|
| 122 |
texts = W / f"streams_{MODE}.jsonl"
|
| 123 |
texts.write_text("".join(json.dumps(r) + "\n" for r in rows), encoding="utf-8")
|
|
@@ -136,7 +143,7 @@ if MODE in ("holdout", "train", "train2", "train3"):
|
|
| 136 |
up(out / "nll.npy", f"k3pass_{MODE}_nll.npy")
|
| 137 |
up(out / "streams.json", f"k3pass_{MODE}_streams.json")
|
| 138 |
if rc == 0 and (out / "summary.json").exists(): # keep the per-token cache durable: private dataset
|
| 139 |
-
api.create_repo(CACHE, repo_type="dataset", private=MODE not in
|
| 140 |
# FAIL-0092: one 98 GB upload_folder commit never finished before the Colab VM was recycled (24 h). One commit
|
| 141 |
# per file, retried, skipping what is already there, so every finished file survives a lost runtime.
|
| 142 |
have = set(api.list_repo_files(CACHE, repo_type="dataset"))
|
|
|
|
| 27 |
REPO = "STAR-future/Trinity"
|
| 28 |
CACHE = "STAR-future/Trinity-k3cache"
|
| 29 |
MODE = os.environ.get("K3P", "holdout")
|
| 30 |
+
PUBLIC_TRAIN = ("train2", "train3", "train4", "train5", "train6", "train7")
|
| 31 |
+
V3_PARTS = ("train4", "train5", "train6", "train7") # 2026-11-24: corpus v3 (arXiv CC0 + NASA PD), 4 slices
|
| 32 |
+
if MODE in PUBLIC_TRAIN: # 2026-11-21: private quota is full; these caches are of public CC0 text, so they go public
|
| 33 |
CACHE = f"STAR-future/Trinity-k3cache-{MODE}"
|
| 34 |
W = Path("/content/k3p")
|
| 35 |
W.mkdir(parents=True, exist_ok=True)
|
| 36 |
# FAIL-0089: the boot disk (236 GB) cannot hold the work files (214 GB + shards) and the final cache (~94 GB per 1.3 M
|
| 37 |
# tokens). Colab A100 runtimes mount a 368 GB /mnt/local-scratch: put work and output there when it exists.
|
| 38 |
+
if Path("/mnt/local-scratch").exists() and MODE in ("train",) + PUBLIC_TRAIN:
|
| 39 |
for _n in (f"work_{MODE}", f"out_{MODE}"):
|
| 40 |
_t, _l = Path("/mnt/local-scratch") / _n, W / _n
|
| 41 |
_t.mkdir(parents=True, exist_ok=True)
|
|
|
|
| 50 |
if MODE in ("train2", "train3"): # domain corpus v2 (~10x v1, arXiv CC0 abstracts submitted before 2026-10-01)
|
| 51 |
(W / "train_corpus_v2.jsonl").write_bytes(Path(hf_hub_download(REPO, "eval/data/train_corpus_v2b.jsonl" if MODE == "train3" else "eval/data/train_corpus_v2.jsonl", token=TOK,
|
| 52 |
force_download=True)).read_bytes())
|
| 53 |
+
if MODE in V3_PARTS:
|
| 54 |
+
(W / "train_corpus_v3.jsonl").write_bytes(Path(hf_hub_download(REPO, "eval/data/train_corpus_v3.jsonl", token=TOK,
|
| 55 |
+
force_download=True)).read_bytes())
|
| 56 |
# the holdout lives only in the PRIVATE cache dataset: holdouts are never published (moved there 2026-11-19)
|
| 57 |
(W / "k3stream_holdout_pack.jsonl").write_bytes(Path(hf_hub_download("STAR-future/Trinity-k3cache", "eval-data/k3stream_holdout_pack.jsonl",
|
| 58 |
repo_type="dataset", token=TOK,
|
|
|
|
| 104 |
api.upload_file(path_or_fileobj=str(path), path_in_repo=f"eval/{name}", repo_id=REPO, commit_message=name)
|
| 105 |
|
| 106 |
|
| 107 |
+
if MODE in ("holdout", "train") + PUBLIC_TRAIN:
|
| 108 |
rows = []
|
| 109 |
if MODE == "holdout":
|
| 110 |
for r in map(json.loads, (W / "k3stream_holdout_pack.jsonl").read_text(encoding="utf-8").splitlines()):
|
|
|
|
| 112 |
for r in wiki(0, 16):
|
| 113 |
rows.append({"id": r["title"], "text": r["text"], "set": "wikipedia", "role": "holdout", "base": True})
|
| 114 |
else:
|
| 115 |
+
cfile = "train_corpus_v3.jsonl" if MODE in V3_PARTS else "train_corpus_v2.jsonl" if MODE in ("train2", "train3") else "train_corpus_v1.jsonl"
|
| 116 |
docs = [json.loads(x) for x in (W / cfile).read_text(encoding="utf-8").splitlines() if x.strip()]
|
| 117 |
for dom in sorted({d["domain"] for d in docs}):
|
| 118 |
buf, k = [], 0
|
|
|
|
| 122 |
rows.append({"id": f"{MODE}_{dom}_{k:03d}", "text": "\n\n".join(buf), "set": f"train_{dom}",
|
| 123 |
"role": "train", "base": False})
|
| 124 |
buf, k = [], k + 1
|
| 125 |
+
if MODE in V3_PARTS: # slice i of 4 (by row order), so each pass fits the 368 GB scratch disk (~640 rows)
|
| 126 |
+
rows = rows[V3_PARTS.index(MODE)::4]
|
| 127 |
+
for r in (wiki(176 + 32 * V3_PARTS.index(MODE), 32) if MODE in V3_PARTS else wiki(112, 64) if MODE == "train3" else wiki(48, 64) if MODE == "train2" else wiki(16, 32)):
|
| 128 |
rows.append({"id": r["title"], "text": r["text"], "set": "general_wiki", "role": "train", "base": False})
|
| 129 |
texts = W / f"streams_{MODE}.jsonl"
|
| 130 |
texts.write_text("".join(json.dumps(r) + "\n" for r in rows), encoding="utf-8")
|
|
|
|
| 143 |
up(out / "nll.npy", f"k3pass_{MODE}_nll.npy")
|
| 144 |
up(out / "streams.json", f"k3pass_{MODE}_streams.json")
|
| 145 |
if rc == 0 and (out / "summary.json").exists(): # keep the per-token cache durable: private dataset
|
| 146 |
+
api.create_repo(CACHE, repo_type="dataset", private=MODE not in PUBLIC_TRAIN, exist_ok=True)
|
| 147 |
# FAIL-0092: one 98 GB upload_folder commit never finished before the Colab VM was recycled (24 h). One commit
|
| 148 |
# per file, retried, skipping what is already there, so every finished file survives a lost runtime.
|
| 149 |
have = set(api.list_repo_files(CACHE, repo_type="dataset"))
|