Text Generation
Transformers
Safetensors
English
qwen2
verifier
answer-verification
llm-cascade
model-cascade
escalation
llm-router
orchestration
multi-agent
conversational
Eval Results (legacy)
text-generation-inference
Instructions to use podstack/Jedi with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use podstack/Jedi with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="podstack/Jedi") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("podstack/Jedi") model = AutoModelForCausalLM.from_pretrained("podstack/Jedi", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use podstack/Jedi with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "podstack/Jedi" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "podstack/Jedi", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/podstack/Jedi
- SGLang
How to use podstack/Jedi 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 "podstack/Jedi" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "podstack/Jedi", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "podstack/Jedi" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "podstack/Jedi", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use podstack/Jedi with Docker Model Runner:
docker model run hf.co/podstack/Jedi
File size: 4,260 Bytes
f3680b0 | 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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | """Ladder (glm -> qwen -> nemotron-ultra) on the 491 held-out tasks, gated by Jedi vs by the surface-feature baseline."""
import json, math, random, re, sys
import numpy as np, torch
import common
from datasets import load_from_disk
from transformers import AutoModelForCausalLM, AutoTokenizer
def roc_auc_score(y, p):
y, p = np.asarray(y, bool), np.asarray(p, float)
r = np.argsort(np.argsort(p, kind="mergesort")) + 1
return float((r[y].sum() - y.sum() * (y.sum() + 1) / 2) / (y.sum() * (~y).sum()))
class LogisticRegression:
def fit(self, X, y):
X = torch.tensor(X, dtype=torch.float32); y = torch.tensor(np.asarray(y, float), dtype=torch.float32)
self.mu, self.sd = X.mean(0), X.std(0) + 1e-6
X = (X - self.mu) / self.sd
self.w = torch.zeros(X.shape[1], requires_grad=True); self.b = torch.zeros(1, requires_grad=True)
opt = torch.optim.LBFGS([self.w, self.b], max_iter=500)
def closure():
opt.zero_grad(); l = torch.nn.functional.binary_cross_entropy_with_logits(X @ self.w + self.b, y); l.backward(); return l
opt.step(closure); return self
def predict_proba(self, X):
X = (torch.tensor(X, dtype=torch.float32) - self.mu) / self.sd
p = torch.sigmoid(X @ self.w + self.b).detach().numpy(); return np.stack([1 - p, p], 1)
random.seed(0)
P = sys.argv[1] if len(sys.argv) > 1 else "jedi-0.5b"
cal = json.load(open(P + "/calibration.json")); tok = AutoTokenizer.from_pretrained(P); tok.padding_side = "left"
model = AutoModelForCausalLM.from_pretrained(P, dtype=torch.bfloat16).cuda().eval()
ds = load_from_disk("data/jedi_judge")
def score(views, bs=16):
out = np.zeros(len(views)); order = np.argsort([len(v) for v in views])
for i in range(0, len(views), bs):
idx = order[i:i + bs]
msgs = [[{"role": "system", "content": common.JEDI_SYSTEM}, {"role": "user", "content": views[j]}] for j in idx]
enc = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt", padding=True, return_dict=True).to("cuda")
with torch.no_grad(): l = model(**enc).logits[:, -1].float()
g = (l[:, cal["accept_token"]] - l[:, cal["escalate_token"]]).cpu().numpy()
out[idx] = 1 / (1 + np.exp(-(cal["a"] * g + cal["b"])))
return out
def feats(d):
ag = sorted(set(ds["train"]["agent"])); src = sorted(set(ds["train"]["source"]) | set(ds["ood"]["source"]))
X = []
for r in d:
X.append([math.log1p(r["completion_tokens"]), r["finish"] == "length", not r["pred"].strip()]
+ [r["agent"] == a for a in ag] + [r["source"] == s for s in src])
return np.array(X, float)
base = ds["train"].filter(lambda r: r["sample"] == 0) # one sample per (task, agent): no oversampling dupes in fit
lr = LogisticRegression().fit(feats(base), base["correct"])
from datasets import load_dataset
from common import LADDER, POOL, STRONGEST
CHEAP, MID = LADDER[0], LADDER[1]
d = ds["test"]
pj = score(d["judge_input"]); ps = lr.predict_proba(feats(d))[:, 1]
R = {}
for r, a, b in zip(d.select_columns(["task_id", "agent", "sample", "correct", "completion_tokens"]), pj, ps):
R[r["task_id"], r["agent"], r["sample"]] = dict(r, pj=float(a), ps=float(b))
shak = {r["id"]: r for sp in ("train", "test") for r in load_dataset("podstack/Shaktimaan-routing", split=sp)}
srcs = {"gsm8k", "math", "mmlupro", "arc", "mbpp", "humaneval"}
tasks = sorted({t for (t, _, _) in R if t.split("-")[0] in srcs and (t, CHEAP, 0) in R and (t, MID, 0) in R and t in shak})
def ultra(t):
x = json.loads(shak[t]["agent_results"])[STRONGEST]; return x["correct"], x["completion_tokens"]
ucost = sum(POOL[STRONGEST]["cost"] * ultra(t)[1] for t in tasks)
def ladder(key, tau):
c = cost = 0
for t in tasks:
for i, ag in enumerate(LADDER):
if i == 2:
ok, tk = ultra(t); cost += POOL[ag]["cost"] * tk; c += ok; break
a = R[t, ag, 0]; cost += POOL[ag]["cost"] * a["completion_tokens"]
if a[key] >= tau: c += a["correct"]; break
return round(c / len(tasks), 4), round(cost / ucost, 4)
print("n", len(tasks))
for tau in (0.05, 0.1, 0.2, 0.3, 0.4, 0.45, 0.5):
print(tau, "jedi", ladder("pj", tau), "shallow", ladder("ps", tau))
|