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
File size: 2,908 Bytes
f80e81a | 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 | """Colab GPU cell driver: full-model evaluation of LittleBoy and its base with the k3ref reference.
from google.colab import userdata; import huggingface_hub as h, os; os.environ['HF_TOKEN'] = userdata.get('STARHUGGIN')
exec(open(h.hf_hub_download('STAR-future/Trinity', 'tools/colab_k3_eval.py', token=os.environ['HF_TOKEN'],
force_download=True)).read())
K3_LAYERS (env, default 93) runs only the first layers (smoke test). Results go to /content/k3eval and are uploaded
to the LittleBoy repo under eval/ (private until release).
"""
import json
import os
import subprocess
import sys
from pathlib import Path
from huggingface_hub import HfApi, hf_hub_download
TOK = os.environ["HF_TOKEN"]
REPO = "STAR-future/Trinity"
W = Path("/content/k3eval")
W.mkdir(parents=True, exist_ok=True)
subprocess.run([sys.executable, "-m", "pip", "install", "-q", "tiktoken", "datasets"], check=True)
for f in ("k3ref.py", "k3stream.py"):
p = hf_hub_download(REPO, f"tools/{f}", token=TOK, force_download=True)
(W / f).write_bytes(Path(p).read_bytes())
texts = W / "eval.jsonl"
if not texts.exists():
from datasets import load_dataset
ds = load_dataset("wikimedia/wikipedia", "20231101.en", split="train", streaming=True)
rows = []
for r in ds:
if len(r["text"]) > 16000:
rows.append({"id": r["title"], "text": r["text"], "set": "wikipedia"})
if len(rows) >= 16:
break
texts.write_text("".join(json.dumps(r) + "\n" for r in rows), encoding="utf-8")
layers = os.environ.get("K3_LAYERS", "93")
out = W / f"out_L{layers}"
cmd = [sys.executable, "-u", str(W / "k3stream.py"), "--texts", str(texts), "--seq", os.environ.get("K3_SEQ", "2048"),
"--batch", os.environ.get("K3_BATCH", "8"), "--max-seqs", os.environ.get("K3_MAXSEQS", "16"),
"--out", str(out), "--layers", layers]
print(" ".join(cmd), flush=True)
log = W / f"k3stream_L{layers}.log"
with subprocess.Popen(cmd, cwd=W, env=dict(os.environ, PYTHONPATH=str(W)), stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, text=True, bufsize=1) as p, open(log, "w") as fo:
for line in p.stdout: # Colab does not show a child's output unless it is relayed
print(line, end="", flush=True)
fo.write(line)
print("exit", p.returncode, flush=True)
HfApi(token=TOK).upload_file(path_or_fileobj=str(log), path_in_repo=f"eval/k3stream_L{layers}.log", repo_id=REPO,
commit_message=f"k3ref run log, {layers} layers")
if p.returncode == 0 and (out / "summary.json").exists():
HfApi(token=TOK).upload_file(path_or_fileobj=str(out / "summary.json"), path_in_repo=f"eval/k3ref_summary_L{layers}.json",
repo_id=REPO, commit_message=f"k3ref evaluation, {layers} layers")
print(json.loads((out / "summary.json").read_text())["modes"], flush=True)
|