Downloads · 30 days
0
OpenGraph-AI/opengraph-image-gemma4-e4b-v1
opengraph-image-gemma4-e4b-v1 is a image-text-to-image model from OpenGraph-AI. Use it for the image-text-to-image task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as apache-2.0.
A fine-tuned Gemma 4 E4B that turns images into a valid, schema-faithful knowledge graph (graph.json) — objects, attributes, scene context, text spans, and the relationships between them — ready for AI agents to query…
Downloads · 30 days
0
Access
Public
Updated Aug 12, 2026
Repo size
—
Likes
1
Public
Click a slice to open those files.
.ipynb20 KB · 62%
From the Hugging Face model README
A fine-tuned Gemma 4 E4B that turns images into a valid, schema-faithful knowledge graph (graph.json) — objects, attributes, scene context, text spans, and the relationships between them — ready for AI agents to query and reason over. Built by OpenGraph AI as the small, cheap, on-device alternative to calling a frontier vision API for every extraction.
The model does one thing extremely well: image → knowledge graph, on-schema, every time. It was trained on verified image→graph gold pairs so that its output always conforms to OpenGraph's graph.json contract — stable snake_case node IDs with type prefixes (entity_, concept_, event_, attr_), typed edges, and cross-image-mergeable entities. Compared to prompting a general frontier model, it is dramatically cheaper per extraction, runs on a single consumer GPU (or laptop, quantized), and produces structurally consistent output that downstream graph tooling can rely on.
google/gemma-4-E4BFeed the model images plus the OpenGraph extraction system prompt; it returns a complete graph.json — nodes for detected objects (fine-grained labels, normalized bounding boxes), one scene node, attribute nodes, transcribed text spans, and the edges wiring them together. Useful anywhere images need to become structured, queryable knowledge: visual search indexes, dataset annotation, scene understanding, and document/diagram parsing.
The model's intended home is inside the opengraph-image MCP server: register it with Claude Desktop, Cursor, or any MCP-compatible agent, and the agent gains persistent, queryable visual memory — including multi-hop questions across many images ("which components appear in both photos, and what changed between them?"). It also serves as a local extraction backend for robotics scene memory, where per-frame frontier API calls are too slow and expensive.
graph.json schema; it is not a general-purpose captioner and will not follow arbitrary output formats reliably.Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. Validate every output with the schema validators shipped in the OpenGraph repo, keep a human in the loop for consequential decisions, and spot-check extractions when applying the model to a new image domain.
Use the code below to get started with the model.
# pip install -U "transformers>=5.10.1" torch torchvision accelerate
from transformers import AutoProcessor, AutoModelForImageTextToText
from PIL import Image
MODEL_ID = "OpenGraphAI/opengraph-image-gemma4-e4b-v1"
processor = AutoProcessor.from_pretrained(MODEL_ID)
model = AutoModelForImageTextToText.from_pretrained(
MODEL_ID, dtype="auto", device_map="auto"
)
SYSTEM_PROMPT = """[More Information Needed — paste the OpenGraph extraction system prompt]"""
image = Image.open("your_image.jpg").convert("RGB")
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": [
{"type": "image", "image": image},
{"type": "text", "text": "Extract the knowledge graph from this image."},
]},
]
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=2048)
graph_json = processor.decode(
outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True
)
print(graph_json) # -> valid graph.json
Or skip the code entirely and use it through the MCP server:
[More Information Needed — one-line MCP install command]
Trained on [placeholder] verified image→graph.json gold pairs (OpenGraphAI/opengraph-image-gold-v1), assembled from two sources: (1) public scene-graph datasets (e.g., Visual Genome) converted programmatically into the graph.json schema, and (2) unannotated images labeled by two independent frontier vision models, auto-accepted where both models agreed and human-reviewed otherwise. Every pair passed the OpenGraph Pydantic schema validators before inclusion.
Supervised fine-tuning (SFT) with QLoRA: the base model frozen in 4-bit NF4 quantization, with LoRA adapters (rank 16, all linear layers, plus lm_head/embed_tokens) trained via Hugging Face TRL's SFTTrainer, following Google's official Gemma 4 vision QLoRA guide.
Each example is formatted as a three-turn conversation (system = schema instruction, user = image + extraction request, assistant = gold graph.json) and templated with the official Gemma 4 chat template. Images are processed at their native aspect ratio; image tokens are masked out of the training loss.
[More Information Needed — fill after training: total training time, adapter size, merged checkpoint size]
A held-out test split (5%) of OpenGraphAI/opengraph-image-gold-v1, never seen during training.
Results are disaggregated by image source/domain (converted scene-graph data vs. frontier-labeled robot/inspection frames). [More Information Needed — add further factors after evaluation]
All numbers produced by the open eval harness and reproducible from the linked script.
| Metric | This model | Base Gemma 4 E4B-it | Frontier API baseline |
|---|---|---|---|
| Schema-valid rate | [More Information Needed] | [More Information Needed] | [More Information Needed] |
| Node/Edge F1 | [More Information Needed] | [More Information Needed] | [More Information Needed] |
| $ / 1k images | [More Information Needed] | [More Information Needed] | [More Information Needed] |
| p50 latency | [More Information Needed] | [More Information Needed] | [More Information Needed] |
[More Information Needed — 2–3 honest sentences: where the fine-tune wins, where it still trails the frontier baseline]
Gemma 4 E4B: a decoder-only transformer (~4.5B effective parameters, ~8B with embeddings) with a dedicated vision encoder, hybrid local/global attention, and a 128K-token context window. Fine-tuning objective: supervised next-token prediction on gold graph.json completions, with prompt and image tokens masked from the loss.
[More Information Needed — e.g., 1× NVIDIA L4 24GB (Google Colab Pro)]
Python, PyTorch, Hugging Face transformers>=5.10.1, trl, peft, bitsandbytes, datasets.
OpenGraph AI is open-source, MCP-first infrastructure for turning heterogeneous data (images, tables, text, audio, video) into semantic knowledge graphs that AI agents can query and reason over. ⭐ Star the repo — and contribute schemas, test images, or extraction edge cases.
OpenGraph AI team