Instructions to use KdaiP/ModernBERT-CJE-tiny with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use KdaiP/ModernBERT-CJE-tiny with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="KdaiP/ModernBERT-CJE-tiny")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("KdaiP/ModernBERT-CJE-tiny") model = AutoModelForMaskedLM.from_pretrained("KdaiP/ModernBERT-CJE-tiny", device_map="auto") - Notebooks
- Google Colab
- Kaggle
ModernBERT-CJE-tiny
ModernBERT-CJE-tiny is a lightweight text encoder for Chinese, Japanese, and English, distilled from ModernBERT-CJE-large using activation-based initialization and relation distillation. It provides contextual token representations for downstream NLP tasks, text-to-speech (TTS) systems, and other applications that use text features.
This repository contains the tiny checkpoint, including its masked language modeling head and tokenizer. The model uses the ModernBERT architecture with 6 transformer layers, a hidden size of 256, and 4.525M backbone parameters.
Source code, pretraining, distillation, evaluation details, and more examples: KdaiP/ModernBERT-CJE on GitHub.
Quick start
import torch
from transformers import AutoModel, AutoTokenizer
model_id = "KdaiP/ModernBERT-CJE-tiny"
device = "cuda" if torch.cuda.is_available() else "cpu"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModel.from_pretrained(model_id).to(device).eval()
texts = [
"δ½ ε₯½οΌδΈηοΌ",
"γγγ«γ‘γ―γδΈηοΌ",
"Hello, world!",
]
inputs = tokenizer(
texts,
padding=True,
truncation=True,
max_length=512,
return_tensors="pt",
).to(device)
with torch.inference_mode():
outputs = model(**inputs, return_dict=True)
features = outputs.last_hidden_state
print(features.shape) # [batch_size, padded_sequence_length, 256]
License
This model is released under the MIT License.
- Downloads last month
- 42