Text Generation
Transformers
Safetensors
English
qwen2
sdlm
diffusion language model
custom_code
conversational
text-generation-inference
Instructions to use OpenGVLab/SDLM-3B-D4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenGVLab/SDLM-3B-D4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OpenGVLab/SDLM-3B-D4", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("OpenGVLab/SDLM-3B-D4", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("OpenGVLab/SDLM-3B-D4", trust_remote_code=True, device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use OpenGVLab/SDLM-3B-D4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenGVLab/SDLM-3B-D4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenGVLab/SDLM-3B-D4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/OpenGVLab/SDLM-3B-D4
- SGLang
How to use OpenGVLab/SDLM-3B-D4 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 "OpenGVLab/SDLM-3B-D4" \ --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": "OpenGVLab/SDLM-3B-D4", "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 "OpenGVLab/SDLM-3B-D4" \ --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": "OpenGVLab/SDLM-3B-D4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use OpenGVLab/SDLM-3B-D4 with Docker Model Runner:
docker model run hf.co/OpenGVLab/SDLM-3B-D4
Commit History
-
Update generation_config.json
Verified signature925abb3 -
Update modeling_sdlm.py
Verified signaturefbf5553 -
Update attn_mask_utils.py
Verified signature2339df1 -
Update config.json
Verified signature75380a8
-
Add project page link and introductory sentence to model card (#1)
Verified signature- Add project page link and introductory sentence to model card (8552cf2954c43b3ee7a2e3d656b4699cc778e736) Co-authored-by: Niels Rogge <nielsr@users.noreply.huggingface.co>0227e96
-
Update README.md
Verified signature0ac33b2 -
Update README.md
Verified signatureae08b90 -
Update README.md
Verified signatureee42c7f -
Update README.md
Verified signature374b1a8
-
Upload model-00002-of-00002.safetensors with huggingface_hub
Verified signature0d0b639 -
Upload generation_config.json with huggingface_hub
Verified signature3fe9ef1 -
Upload attn_mask_utils.py with huggingface_hub
Verified signature0bd3613 -
Upload tokenizer_config.json with huggingface_hub
Verified signature009f006 -
Upload model.safetensors.index.json with huggingface_hub
Verified signaturef2ee89a -
Upload model-00001-of-00002.safetensors with huggingface_hub
Verified signatureb08671d -
Update README.md
Verified signature79fbdab -
Upload configuration_sdlm.py with huggingface_hub
Verified signaturea4ef5eb -
Upload vocab.json with huggingface_hub
Verified signature9d8fd66 -
Upload special_tokens_map.json with huggingface_hub
Verified signature5797866 -
Upload modeling_sdlm.py with huggingface_hub
Verified signature08a9a69 -
Upload merges.txt with huggingface_hub
Verified signature15ac7bf -
Upload config.json with huggingface_hub
Verified signaturea1656f9 -
Upload added_tokens.json with huggingface_hub
Verified signatureb9b5ece -
Upload folder using huggingface_hub
Verified signature0e848a4 -
initial commit
Verified signature90cb305