Image-Text-to-Text
Transformers
Safetensors
lfm2_vl
ad-detection
ad-blocking
axera
npu
edge
lfm2.5
vision-language-model
streaming-tv
conversational
Instructions to use TheGarageDev/Minus-v0.2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TheGarageDev/Minus-v0.2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="TheGarageDev/Minus-v0.2") 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("TheGarageDev/Minus-v0.2") model = AutoModelForMultimodalLM.from_pretrained("TheGarageDev/Minus-v0.2", 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 TheGarageDev/Minus-v0.2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TheGarageDev/Minus-v0.2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TheGarageDev/Minus-v0.2", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/TheGarageDev/Minus-v0.2
- SGLang
How to use TheGarageDev/Minus-v0.2 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 "TheGarageDev/Minus-v0.2" \ --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": "TheGarageDev/Minus-v0.2", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "TheGarageDev/Minus-v0.2" \ --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": "TheGarageDev/Minus-v0.2", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use TheGarageDev/Minus-v0.2 with Docker Model Runner:
docker model run hf.co/TheGarageDev/Minus-v0.2
Minus-v0.2: squash-trained LFM2.5-VL-450M + screen-state head, AX650 build with FP32 residual stream
97d19f2 verified Download conversion/make_configs.py from TheGarageDev/Minus-v0.2: direct link, hf CLI and curl.
- Browser
- Download file 2.86 kB
-
https://huggingface.co/TheGarageDev/Minus-v0.2/resolve/main/conversion/make_configs.py
- Command line
-
hf download hf://TheGarageDev/Minus-v0.2/conversion/make_configs.py
-
curl -L -o make_configs.py https://huggingface.co/TheGarageDev/Minus-v0.2/resolve/main/conversion/make_configs.py
2.86 kB
| #!/usr/bin/env python3 | |
| """Simplify exported graphs (static shapes) and write one Pulsar2 5.1 build config per | |
| graph, reproducing the minus-v0.1 recipe (docs/LFM2_VL_AX650_OPTIMIZATION.md, D.5): | |
| - NPU3 (all 3 cores), U16 everywhere, | |
| - FP32 on every RMSNorm chain op (Mul/ReduceMean/Add/Sqrt/Div/Mul): 2 chains per conv | |
| layer, 4 per attention layer (operator, q_layernorm, k_layernorm, ffn) + post's norm, | |
| - FP32 runtime I/O (indices S32), Numpy calibration from gen_calib.py, | |
| - vision: onnxsim off, smooth-quant + FP32 conv bias (AXERA vision-encoder practice). | |
| python make_configs.py <build_dir> | |
| """ | |
| import json, os, sys | |
| import onnx | |
| from onnxsim import simplify | |
| B = sys.argv[1] | |
| meta = json.load(open(f"{B}/export_meta.json")) | |
| graphs = ["vision_encoder_512"] + [f"l{i}_{t}_fused" for i, t in enumerate(meta["layer_types"])] + ["post_d"] | |
| os.makedirs(f"{B}/sim", exist_ok=True) | |
| os.makedirs(f"{B}/configs", exist_ok=True) | |
| summary = {} | |
| for g in graphs: | |
| m = onnx.load(f"{B}/onnx/{g}.onnx") | |
| if g != "vision_encoder_512": | |
| m, ok = simplify(m) | |
| assert ok, g | |
| onnx.save(m, f"{B}/sim/{g}.onnx", save_as_external_data=m.ByteSize() > 1.9e9) | |
| norm_ops = [n.name for n in m.graph.node | |
| if "norm" in n.name.lower() and n.op_type in ("Mul", "ReduceMean", "Add", "Sqrt", "Div", "Pow")] | |
| inputs = [i.name for i in m.graph.input] | |
| is_vision = g == "vision_encoder_512" | |
| cfg = { | |
| "model_type": "ONNX", | |
| "npu_mode": "NPU3", | |
| "target_hardware": "AX650", | |
| "onnx_opt": {"enable_onnxsim": False}, | |
| "quant": { | |
| "input_configs": [{"tensor_name": n, "calibration_dataset": f"/data/calib/{g}/{n}.tar", | |
| "calibration_format": "Numpy", "calibration_size": -1} for n in inputs], | |
| "layer_configs": [{"start_tensor_names": ["DEFAULT"], "end_tensor_names": ["DEFAULT"], | |
| "data_type": "U16"}], | |
| "calibration_method": "MinMax", | |
| "precision_analysis": True, | |
| "precision_analysis_method": "EndToEnd", | |
| "conv_bias_data_type": "FP32", | |
| "enable_smooth_quant": is_vision, | |
| }, | |
| "input_processors": [{"tensor_name": n, "src_dtype": "S32" if n == "indices" else "FP32"} | |
| for n in inputs], | |
| "compiler": {"check": 0}, | |
| } | |
| if norm_ops and not is_vision: | |
| cfg["quant"]["layer_configs"].append({"layer_names": norm_ops, "data_type": "FP32"}) | |
| json.dump(cfg, open(f"{B}/configs/{g}.json", "w"), indent=1) | |
| summary[g] = {"nodes": len(m.graph.node), "fp32_norm_ops": len(norm_ops), | |
| "op_types": sorted({n.op_type for n in m.graph.node})} | |
| print(g, summary[g]["nodes"], "nodes,", len(norm_ops), "FP32 norm ops", flush=True) | |
| json.dump(summary, open(f"{B}/configs/summary.json", "w"), indent=1) | |