Introduction of SmolDocling-256M-preview-mlx-bf16-docling-snap
Model Details of SmolDocling-256M-preview-mlx-bf16-docling-snap
SmolDocling-256M-preview-mlx-bf16
This model was converted to MLX format from
ds4sd/SmolDocling-256M-preview
using mlx-vlm version
0.1.18
.
Has configuration files adapted for usage with Docling-Snap.
Refer to the
original model card
for more details on the model.
Use with mlx
pip install -U mlx-vlm pillow docling-core
# /// script# requires-python = ">=3.12"# dependencies = [# "docling-core",# "mlx-vlm",# "pillow",# ]# ///from io import BytesIO
from pathlib import Path
from urllib.parse import urlparse
import requests
from PIL import Image
from docling_core.types.doc import ImageRefMode
from docling_core.types.doc.document import DocTagsDocument, DoclingDocument
from mlx_vlm import load, generate
from mlx_vlm.prompt_utils import apply_chat_template
from mlx_vlm.utils import load_config, stream_generate
## Settings
SHOW_IN_BROWSER = True# Export output as HTML and open in webbrowser.## Load the model
model_path = "ds4sd/SmolDocling-256M-preview-mlx-bf16"
model, processor = load(model_path)
config = load_config(model_path)
## Prepare input
prompt = "Convert this page to docling."# image = "https://ibm.biz/docling-page-with-list"
image = "https://ibm.biz/docling-page-with-table"# Load image resourceif urlparse(image).scheme != "": # it is a URL
response = requests.get(image, stream=True, timeout=10)
response.raise_for_status()
pil_image = Image.open(BytesIO(response.content))
else:
pil_image = Image.open(image)
# Apply chat template
formatted_prompt = apply_chat_template(processor, config, prompt, num_images=1)
## Generate outputprint("DocTags: \n\n")
output = ""for token in stream_generate(
model, processor, formatted_prompt, [image], max_tokens=4096, verbose=False
):
output += token.text
print(token.text, end="")
if"</doctag>"in token.text:
breakprint("\n\n")
# Populate document
doctags_doc = DocTagsDocument.from_doctags_and_image_pairs([output], [pil_image])
# create a docling document
doc = DoclingDocument(name="SampleDocument")
doc.load_from_doctags(doctags_doc)
## Export as any format# Markdownprint("Markdown: \n\n")
print(doc.export_to_markdown())
# HTMLif SHOW_IN_BROWSER:
import webbrowser
out_path = Path("./output.html")
doc.save_as_html(out_path, image_mode=ImageRefMode.EMBEDDED)
webbrowser.open(f"file:///{str(out_path.resolve())}")
Runs of docling-project SmolDocling-256M-preview-mlx-bf16-docling-snap on huggingface.co
16
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
-4
30-day runs
More Information About SmolDocling-256M-preview-mlx-bf16-docling-snap huggingface.co Model
More SmolDocling-256M-preview-mlx-bf16-docling-snap license Visit here:
SmolDocling-256M-preview-mlx-bf16-docling-snap huggingface.co is an AI model on huggingface.co that provides SmolDocling-256M-preview-mlx-bf16-docling-snap's model effect (), which can be used instantly with this docling-project SmolDocling-256M-preview-mlx-bf16-docling-snap model. huggingface.co supports a free trial of the SmolDocling-256M-preview-mlx-bf16-docling-snap model, and also provides paid use of the SmolDocling-256M-preview-mlx-bf16-docling-snap. Support call SmolDocling-256M-preview-mlx-bf16-docling-snap model through api, including Node.js, Python, http.
SmolDocling-256M-preview-mlx-bf16-docling-snap huggingface.co is an online trial and call api platform, which integrates SmolDocling-256M-preview-mlx-bf16-docling-snap's modeling effects, including api services, and provides a free online trial of SmolDocling-256M-preview-mlx-bf16-docling-snap, you can try SmolDocling-256M-preview-mlx-bf16-docling-snap online for free by clicking the link below.
docling-project SmolDocling-256M-preview-mlx-bf16-docling-snap online free url in huggingface.co:
SmolDocling-256M-preview-mlx-bf16-docling-snap is an open source model from GitHub that offers a free installation service, and any user can find SmolDocling-256M-preview-mlx-bf16-docling-snap on GitHub to install. At the same time, huggingface.co provides the effect of SmolDocling-256M-preview-mlx-bf16-docling-snap install, users can directly use SmolDocling-256M-preview-mlx-bf16-docling-snap installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
SmolDocling-256M-preview-mlx-bf16-docling-snap install url in huggingface.co: