Instructions to use hmellor/tiny-random-DeepseekV2ForCausalLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hmellor/tiny-random-DeepseekV2ForCausalLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="hmellor/tiny-random-DeepseekV2ForCausalLM") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("hmellor/tiny-random-DeepseekV2ForCausalLM") model = AutoModelForCausalLM.from_pretrained("hmellor/tiny-random-DeepseekV2ForCausalLM", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use hmellor/tiny-random-DeepseekV2ForCausalLM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hmellor/tiny-random-DeepseekV2ForCausalLM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hmellor/tiny-random-DeepseekV2ForCausalLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/hmellor/tiny-random-DeepseekV2ForCausalLM
- SGLang
How to use hmellor/tiny-random-DeepseekV2ForCausalLM 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 "hmellor/tiny-random-DeepseekV2ForCausalLM" \ --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": "hmellor/tiny-random-DeepseekV2ForCausalLM", "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 "hmellor/tiny-random-DeepseekV2ForCausalLM" \ --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": "hmellor/tiny-random-DeepseekV2ForCausalLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use hmellor/tiny-random-DeepseekV2ForCausalLM with Docker Model Runner:
docker model run hf.co/hmellor/tiny-random-DeepseekV2ForCausalLM
Add tiny random DeepseekV2 for vLLM MLA tests
Browse files- README.md +34 -0
- chat_template.jinja +5 -0
- config.json +57 -0
- generation_config.json +9 -0
- model.safetensors +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +14 -0
README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
tags: []
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# tiny-random-DeepseekV2ForCausalLM
|
| 7 |
+
|
| 8 |
+
Randomly initialised `DeepseekV2ForCausalLM` for testing MLA (multi-head latent
|
| 9 |
+
attention) and MoE code paths without loading a 29 GiB checkpoint. Used by
|
| 10 |
+
vLLM's `tests/models/transformers/test_backend.py::test_mla`.
|
| 11 |
+
|
| 12 |
+
The attention head dimensions are copied verbatim from
|
| 13 |
+
[deepseek-ai/DeepSeek-V2-Lite-Chat](https://huggingface.co/deepseek-ai/DeepSeek-V2-Lite-Chat)
|
| 14 |
+
so that `kv_lora_rank + qk_rope_head_dim == 576`, the latent head size every MLA
|
| 15 |
+
kernel is built around. Only the width, depth and expert counts are shrunk.
|
| 16 |
+
|
| 17 |
+
| | DeepSeek-V2-Lite-Chat | this model |
|
| 18 |
+
| ------------------- | --------------------- | ---------- |
|
| 19 |
+
| `kv_lora_rank` | 512 | 512 |
|
| 20 |
+
| `qk_nope_head_dim` | 128 | 128 |
|
| 21 |
+
| `qk_rope_head_dim` | 64 | 64 |
|
| 22 |
+
| `v_head_dim` | 128 | 128 |
|
| 23 |
+
| `hidden_size` | 2048 | 256 |
|
| 24 |
+
| `num_hidden_layers` | 27 | 4 |
|
| 25 |
+
| `num_attention_heads` | 16 | 4 |
|
| 26 |
+
| `n_routed_experts` | 64 | 8 |
|
| 27 |
+
| `n_shared_experts` | 2 | 2 |
|
| 28 |
+
| parameters | 15.7B | 59.8M |
|
| 29 |
+
|
| 30 |
+
Layer 0 is dense and the rest are MoE (`first_k_dense_replace=1`), matching the
|
| 31 |
+
real model. The tokenizer is DeepSeek-V2-Lite-Chat's, unmodified.
|
| 32 |
+
|
| 33 |
+
The weights are random, so the outputs are meaningless. This is only useful for
|
| 34 |
+
checking that two implementations agree with each other.
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{{ bos_token }}{% for message in messages %}{% if message['role'] == 'user' %}{{ 'User: ' + message['content'] + '
|
| 2 |
+
|
| 3 |
+
' }}{% elif message['role'] == 'assistant' %}{{ 'Assistant: ' + message['content'] + eos_token }}{% elif message['role'] == 'system' %}{{ message['content'] + '
|
| 4 |
+
|
| 5 |
+
' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}
|
config.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"DeepseekV2ForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 100000,
|
| 8 |
+
"dtype": "bfloat16",
|
| 9 |
+
"eos_token_id": 100001,
|
| 10 |
+
"first_k_dense_replace": 1,
|
| 11 |
+
"head_dim": 64,
|
| 12 |
+
"hidden_act": "silu",
|
| 13 |
+
"hidden_size": 256,
|
| 14 |
+
"initializer_range": 0.02,
|
| 15 |
+
"intermediate_size": 512,
|
| 16 |
+
"kv_lora_rank": 512,
|
| 17 |
+
"max_position_embeddings": 163840,
|
| 18 |
+
"mlp_bias": false,
|
| 19 |
+
"model_type": "deepseek_v2",
|
| 20 |
+
"moe_intermediate_size": 128,
|
| 21 |
+
"moe_layer_freq": 1,
|
| 22 |
+
"n_group": 1,
|
| 23 |
+
"n_routed_experts": 8,
|
| 24 |
+
"n_shared_experts": 2,
|
| 25 |
+
"norm_topk_prob": false,
|
| 26 |
+
"num_attention_heads": 4,
|
| 27 |
+
"num_experts_per_tok": 2,
|
| 28 |
+
"num_hidden_layers": 4,
|
| 29 |
+
"num_key_value_heads": 4,
|
| 30 |
+
"pad_token_id": null,
|
| 31 |
+
"pretraining_tp": 1,
|
| 32 |
+
"q_lora_rank": null,
|
| 33 |
+
"qk_head_dim": 192,
|
| 34 |
+
"qk_nope_head_dim": 128,
|
| 35 |
+
"qk_rope_head_dim": 64,
|
| 36 |
+
"rms_norm_eps": 1e-06,
|
| 37 |
+
"rope_parameters": {
|
| 38 |
+
"beta_fast": 32,
|
| 39 |
+
"beta_slow": 1,
|
| 40 |
+
"factor": 40,
|
| 41 |
+
"mscale": 0.707,
|
| 42 |
+
"mscale_all_dim": 0.707,
|
| 43 |
+
"original_max_position_embeddings": 4096,
|
| 44 |
+
"rope_theta": 10000,
|
| 45 |
+
"rope_type": "yarn",
|
| 46 |
+
"type": "yarn"
|
| 47 |
+
},
|
| 48 |
+
"routed_scaling_factor": 1.0,
|
| 49 |
+
"scoring_func": "softmax",
|
| 50 |
+
"tie_word_embeddings": false,
|
| 51 |
+
"topk_group": 1,
|
| 52 |
+
"topk_method": "greedy",
|
| 53 |
+
"transformers_version": "5.15.0.dev0",
|
| 54 |
+
"use_cache": true,
|
| 55 |
+
"v_head_dim": 128,
|
| 56 |
+
"vocab_size": 102400
|
| 57 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 100000,
|
| 4 |
+
"eos_token_id": 100001,
|
| 5 |
+
"output_attentions": false,
|
| 6 |
+
"output_hidden_states": false,
|
| 7 |
+
"transformers_version": "5.15.0.dev0",
|
| 8 |
+
"use_cache": true
|
| 9 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:652d9531e43e7cf8338120cbe4ca21948b0bc8585eaa80e5b990a21c95fbddd3
|
| 3 |
+
size 119572560
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"bos_token": "<|begin▁of▁sentence|>",
|
| 4 |
+
"clean_up_tokenization_spaces": false,
|
| 5 |
+
"eos_token": "<|end▁of▁sentence|>",
|
| 6 |
+
"is_local": false,
|
| 7 |
+
"legacy": true,
|
| 8 |
+
"local_files_only": false,
|
| 9 |
+
"model_max_length": 16384,
|
| 10 |
+
"pad_token": "<|end▁of▁sentence|>",
|
| 11 |
+
"sp_model_kwargs": {},
|
| 12 |
+
"tokenizer_class": "TokenizersBackend",
|
| 13 |
+
"unk_token": null
|
| 14 |
+
}
|