Instructions to use bofenghuang/doctomodernbert-fr-base-diffusion-v0.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bofenghuang/doctomodernbert-fr-base-diffusion-v0.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="bofenghuang/doctomodernbert-fr-base-diffusion-v0.1") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("bofenghuang/doctomodernbert-fr-base-diffusion-v0.1") model = AutoModelForMaskedLM.from_pretrained("bofenghuang/doctomodernbert-fr-base-diffusion-v0.1") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use bofenghuang/doctomodernbert-fr-base-diffusion-v0.1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bofenghuang/doctomodernbert-fr-base-diffusion-v0.1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bofenghuang/doctomodernbert-fr-base-diffusion-v0.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/bofenghuang/doctomodernbert-fr-base-diffusion-v0.1
- SGLang
How to use bofenghuang/doctomodernbert-fr-base-diffusion-v0.1 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 "bofenghuang/doctomodernbert-fr-base-diffusion-v0.1" \ --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": "bofenghuang/doctomodernbert-fr-base-diffusion-v0.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "bofenghuang/doctomodernbert-fr-base-diffusion-v0.1" \ --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": "bofenghuang/doctomodernbert-fr-base-diffusion-v0.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use bofenghuang/doctomodernbert-fr-base-diffusion-v0.1 with Docker Model Runner:
docker model run hf.co/bofenghuang/doctomodernbert-fr-base-diffusion-v0.1
DoctoModernBERT-fr-base-diffusion-v0.1
A text diffusion model based on DoctoModernBERT-fr-base, finetuned on a medical instruction-following dataset.
Unlike an autoregressive LLM, which decodes strictly left to right one token at a time, this model works by iterative denoising. It starts from a fully masked canvas and, at each step, predicts all masked positions at once and keeps only the most confident ones. It still moves through the sequence one block at a time, so generation is parallel inside each block but left to right across blocks.
This is an exploratory checkpoint. It's small and lightly trained, so expect mistakes and weaker answers.
π How to Use
Training and generation are done through the dLLM library.
Setup
git clone https://github.com/ZHZisZZ/dllm
cd dllm
pip install -e .
Sampling
import dllm
model_id = "bofenghuang/doctomodernbert-fr-base-diffusion-v0.1" # or a local path
model = dllm.utils.get_model(model_name_or_path=model_id).eval()
tokenizer = dllm.utils.get_tokenizer(model_name_or_path=model_id)
sampler = dllm.core.samplers.MDLMSampler(model=model, tokenizer=tokenizer)
config = dllm.core.samplers.MDLMSamplerConfig(
steps=128, # total diffusion steps
max_new_tokens=128, # length of the generated answer span
block_size=32, # semi-autoregressive block size
temperature=0.0, # 0.0 = greedy / low-confidence remasking
remasking="low_confidence",
)
messages = [
[{"role": "user", "content": "Quels sont les symptΓ΄mes typiques d'une infection urinaire ?"}],
]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=True)
outputs = sampler.sample(inputs, config, return_dict=True)
print(dllm.utils.sample_trim(tokenizer, outputs.sequences.tolist(), inputs)[0])
Interactive chat
python -u examples/bert/chat.py --model_name_or_path "bofenghuang/doctomodernbert-fr-base-diffusion-v0.1"
The chat template wraps turns as [SYS] β¦ [/SYS], [Question] β¦ [/Question], [Answer] β¦ [/Answer].
- Downloads last month
- 24