A text classifier based on ModernBERT (307M params, 32K context, 1800+ languages) that determines the appropriate response modality for user prompts:
Label
Description
Routed To
Example
AR
Text-only response
Autoregressive LLM (e.g., Llama, Qwen)
"What is the capital of France?"
DIFFUSION
Image generation
Diffusion model (e.g., Flux, SDXL)
"A cyberpunk city at night, neon lights"
BOTH
Text + image response
Both AR + Diffusion pipeline
"Explain photosynthesis and show a diagram"
Quick Start
Pipeline API (simplest)
from transformers import pipeline
classifier = pipeline(
"text-classification",
model="llm-semantic-router/mmbert32k-modality-router-merged",
)
results = classifier([
"What are the benefits of exercise?",
"A serene Japanese garden with cherry blossoms, watercolor style",
"Explain how neural networks work and generate a diagram",
])
for r in results:
print(f"{r['label']}: {r['score']:.3f}")
# AR: 0.995# DIFFUSION: 0.717# BOTH: 0.978
Direct Model Usage
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"llm-semantic-router/mmbert32k-modality-router-merged"
)
tokenizer = AutoTokenizer.from_pretrained(
"llm-semantic-router/mmbert32k-modality-router-merged"
)
prompts = [
"Summarize the key points of quantum computing",
"portrait of a woman in renaissance style, oil painting, dramatic lighting",
"Write a blog post about climate change and include relevant charts",
]
model.eval()
inputs = tokenizer(prompts, return_tensors="pt", truncation=True, padding=True, max_length=512)
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.argmax(outputs.logits, dim=-1)
labels = model.config.id2label
for prompt, pred_id inzip(prompts, predictions):
print(f"{labels[pred_id.item()]}: {prompt[:60]}...")
# AR: Summarize the key points of quantum computing...# DIFFUSION: portrait of a woman in renaissance style, oil painting, d...# BOTH: Write a blog post about climate change and include releva...
Integration with vLLM Semantic Router
# Example: Route requests to different model backendsdefroute_request(prompt: str, classifier) -> str:
"""Route a user prompt to the appropriate model backend."""
result = classifier(prompt)[0]
modality = result["label"]
confidence = result["score"]
if modality == "AR":
return call_llm_backend(prompt) # e.g., Llama, Qwenelif modality == "DIFFUSION":
return call_diffusion_backend(prompt) # e.g., Flux, SDXLelse: # BOTH
text = call_llm_backend(prompt)
image = call_diffusion_backend(prompt)
return combine_response(text, image)
ONNX Runtime (for production latency)
The base model (
mmbert-32k-yarn
) supports ONNX export for sub-5ms inference on AMD MI300X GPUs.
mmbert32k-modality-router-merged huggingface.co is an AI model on huggingface.co that provides mmbert32k-modality-router-merged's model effect (), which can be used instantly with this llm-semantic-router mmbert32k-modality-router-merged model. huggingface.co supports a free trial of the mmbert32k-modality-router-merged model, and also provides paid use of the mmbert32k-modality-router-merged. Support call mmbert32k-modality-router-merged model through api, including Node.js, Python, http.
mmbert32k-modality-router-merged huggingface.co is an online trial and call api platform, which integrates mmbert32k-modality-router-merged's modeling effects, including api services, and provides a free online trial of mmbert32k-modality-router-merged, you can try mmbert32k-modality-router-merged online for free by clicking the link below.
llm-semantic-router mmbert32k-modality-router-merged online free url in huggingface.co:
mmbert32k-modality-router-merged is an open source model from GitHub that offers a free installation service, and any user can find mmbert32k-modality-router-merged on GitHub to install. At the same time, huggingface.co provides the effect of mmbert32k-modality-router-merged install, users can directly use mmbert32k-modality-router-merged installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
mmbert32k-modality-router-merged install url in huggingface.co: