Text Generation
Transformers
English
multilingual
inkling2_loop
image-text-to-text
prime-quant
2-bit
4-bit precision
Mixture of Experts
inkling-2
inkling-2-mini
looped-transformer
triton
rocm
cuda
quantization
coding
conversational
Instructions to use batteryphil/Inkling-2-Mini-PRIME-Quant with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use batteryphil/Inkling-2-Mini-PRIME-Quant with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="batteryphil/Inkling-2-Mini-PRIME-Quant") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("batteryphil/Inkling-2-Mini-PRIME-Quant") model = AutoModelForMultimodalLM.from_pretrained("batteryphil/Inkling-2-Mini-PRIME-Quant", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use batteryphil/Inkling-2-Mini-PRIME-Quant with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "batteryphil/Inkling-2-Mini-PRIME-Quant" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "batteryphil/Inkling-2-Mini-PRIME-Quant", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/batteryphil/Inkling-2-Mini-PRIME-Quant
- SGLang
How to use batteryphil/Inkling-2-Mini-PRIME-Quant 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 "batteryphil/Inkling-2-Mini-PRIME-Quant" \ --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": "batteryphil/Inkling-2-Mini-PRIME-Quant", "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 "batteryphil/Inkling-2-Mini-PRIME-Quant" \ --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": "batteryphil/Inkling-2-Mini-PRIME-Quant", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use batteryphil/Inkling-2-Mini-PRIME-Quant with Docker Model Runner:
docker model run hf.co/batteryphil/Inkling-2-Mini-PRIME-Quant
File size: 7,789 Bytes
53ce2f5 | 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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | """spreadsheet_engine.py"""
from collections import deque
from formula_parser import (
FormulaError,
FormulaSyntaxError,
parse_formula,
collect_refs,
normalize_coord,
_eval,
)
class CircularReferenceError(Exception):
pass
class _Cell:
__slots__ = ("coord", "kind", "literal", "ast", "deps", "error", "value")
def __init__(self, coord, kind, literal=None, ast=None, deps=None):
self.coord = coord
self.kind = kind
self.literal = literal
self.ast = ast
self.deps = set(deps or ())
self.error = None
self.value = literal if kind == "constant" else None
class Spreadsheet:
def __init__(self):
self.cells = {}
self.dependents = {}
def set_cell(self, coord, value):
self.batch_update({coord: value})
def get(self, coord):
info = normalize_coord(coord)
cell = self.cells.get(info)
if cell is None:
return 0
if cell.error is not None:
raise cell.error
if cell.kind == "constant":
return cell.literal
return cell.value
def _spec(self, coord, value):
info = normalize_coord(coord)
if value is None:
return (info, "clear", None, None, set())
if isinstance(value, bool):
raise FormulaSyntaxError("bool is not a valid spreadsheet value")
if isinstance(value, (int, float)):
return (info, "constant", value, None, set())
if isinstance(value, str):
if value.startswith("="):
ast = parse_formula(value[1:])
return (info, "formula", None, ast, set(collect_refs(ast)))
try:
return (info, "constant", int(value), None, set())
except ValueError:
pass
try:
return (info, "constant", float(value), None, set())
except ValueError:
raise FormulaSyntaxError("invalid numeric literal")
raise FormulaSyntaxError("invalid value type")
def batch_update(self, updates):
if updates is None:
return
spec_map = {}
specs = []
for coord, value in updates.items():
info, kind, literal, ast, deps = self._spec(coord, value)
spec_map[info] = (kind, literal, ast, deps)
specs.append((info, kind, literal, ast, deps))
tentative = {}
for info, cell in self.cells.items():
if info in spec_map:
continue
if cell.kind == "formula":
tentative[info] = set(cell.deps)
for info, kind, literal, ast, deps in specs:
if kind == "formula":
tentative[info] = set(deps)
elif kind == "constant":
pass
else:
tentative.pop(info, None)
visiting = {}
def dfs(start):
visiting[start] = 1
stack = [(start, 0)]
while stack:
node, idx = stack[-1]
deps = list(tentative.get(node, set()))
if idx < len(deps):
dep = deps[idx]
stack[-1] = (node, idx + 1)
if dep in tentative:
if visiting.get(dep) == 1:
raise CircularReferenceError("cycle detected")
if visiting.get(dep) is None:
visiting[dep] = 1
stack.append((dep, 0))
else:
visiting[node] = 2
stack.pop()
for info in list(tentative):
if visiting.get(info) != 2:
dfs(info)
new_cells = {}
for info, cell in self.cells.items():
if info in spec_map:
continue
new_cells[info] = cell
for info, kind, literal, ast, deps in specs:
if kind == "clear":
new_cells.pop(info, None)
elif kind == "constant":
new_cells[info] = _Cell(info, "constant", literal=literal)
else:
new_cells[info] = _Cell(info, "formula", ast=ast, deps=deps)
self.cells = new_cells
self.dependents = {}
for info, cell in self.cells.items():
if cell.kind != "formula":
continue
for dep in cell.deps:
self.dependents.setdefault(dep, set()).add(info)
affected = set()
q = deque()
for info, kind, literal, ast, deps in specs:
q.append(info)
while q:
u = q.popleft()
for v in self.dependents.get(u, set()):
if v not in affected:
affected.add(v)
q.append(v)
affected_formulas = {info for info, cell in self.cells.items()
if cell.kind == "formula" and info in affected}
for info, kind, literal, ast, deps in specs:
if kind == "formula":
affected_formulas.add(info)
in_deg = {}
for node in affected_formulas:
cell = self.cells[node]
in_deg[node] = sum(1 for dep in cell.deps if dep in affected_formulas)
q = deque([n for n, d in in_deg.items() if d == 0])
order = []
while q:
node = q.popleft()
order.append(node)
for dependent in self.dependents.get(node, set()):
if dependent in in_deg:
in_deg[dependent] -= 1
if in_deg[dependent] == 0:
q.append(dependent)
def get_val(coord):
info = normalize_coord(coord)
cell = self.cells.get(info)
if cell is None:
return 0
if cell.error is not None:
return 0
if cell.kind == "constant":
return cell.literal
if cell.value is None:
return 0
return cell.value
def is_populated(coord):
info = normalize_coord(coord)
cell = self.cells.get(info)
if cell is None:
return False
if cell.kind == "formula":
return cell.error is None and cell.value is not None
return True
for info, kind, literal, ast, deps in specs:
if kind == "constant":
cell = self.cells.get(info)
if cell is not None:
cell.value = literal
cell.error = None
# Propagate upstream error state before evaluating downstream formulas.
for node in order:
cell = self.cells.get(node)
if cell is None or cell.kind != "formula":
continue
upstream_error = None
for dep in cell.deps:
dep_cell = self.cells.get(dep)
if dep_cell is not None and dep_cell.error is not None:
upstream_error = dep_cell.error
break
if upstream_error is not None:
cell.value = None
cell.error = upstream_error
continue
try:
cell.value = _eval(cell.ast, get_val, is_populated)
cell.error = None
except FormulaError as exc:
cell.error = exc
cell.value = None
def clear_error_if_fixed(node):
cell = self.cells.get(node)
if cell is not None and cell.kind == "constant":
cell.error = None
cell.value = cell.literal
clear_error_if_fixed("nonexistent")
|