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
Add model card, Bartsch LICENSE, Apache-2.0 NOTICE, tokenizer, standalone read-only Triton runtime & verified benchmarks
53ce2f5 verified Download benchmarks/spreadsheet_engine_looptop8.py from batteryphil/Inkling-2-Mini-PRIME-Quant: direct link, hf CLI and curl.
- Browser
- Download file 7.79 kB
-
https://huggingface.co/batteryphil/Inkling-2-Mini-PRIME-Quant/resolve/main/benchmarks/spreadsheet_engine_looptop8.py
- Command line
-
hf download hf://batteryphil/Inkling-2-Mini-PRIME-Quant/benchmarks/spreadsheet_engine_looptop8.py
-
curl -L -o spreadsheet_engine_looptop8.py https://huggingface.co/batteryphil/Inkling-2-Mini-PRIME-Quant/resolve/main/benchmarks/spreadsheet_engine_looptop8.py
7.79 kB
| """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") | |