commit cc5839c4b3b2c17f4d35e7b1c330d5253141790c Author: ModelHub XC Date: Fri Oct 2 17:13:13 2026 +0800 初始化项目,由ModelHub XC社区提供模型 Model: RedHatAI/DeepSeek-R1-Distill-Qwen-1.5B-quantized.w4a16 Source: Original Platform diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..52373fe --- /dev/null +++ b/.gitattributes @@ -0,0 +1,36 @@ +*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.ckpt filter=lfs diff=lfs merge=lfs -text +*.ftz filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.h5 filter=lfs diff=lfs merge=lfs -text +*.joblib filter=lfs diff=lfs merge=lfs -text +*.lfs.* filter=lfs diff=lfs merge=lfs -text +*.mlmodel filter=lfs diff=lfs merge=lfs -text +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.npz filter=lfs diff=lfs merge=lfs -text +*.onnx filter=lfs diff=lfs merge=lfs -text +*.ot filter=lfs diff=lfs merge=lfs -text +*.parquet filter=lfs diff=lfs merge=lfs -text +*.pb filter=lfs diff=lfs merge=lfs -text +*.pickle filter=lfs diff=lfs merge=lfs -text +*.pkl filter=lfs diff=lfs merge=lfs -text +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.safetensors filter=lfs diff=lfs merge=lfs -text +saved_model/**/* filter=lfs diff=lfs merge=lfs -text +*.tar.* filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tflite filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.wasm filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text +tokenizer.json filter=lfs diff=lfs merge=lfs -text diff --git a/README.md b/README.md new file mode 100644 index 0000000..32a8b59 --- /dev/null +++ b/README.md @@ -0,0 +1,547 @@ +--- +license: mit +tags: +- deepseek +- int4 +- vllm +- llmcompressor +base_model: deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B +library_name: transformers +--- + +# DeepSeek-R1-Distill-Qwen-1.5B-quantized.w4a16 + +## Model Overview +- **Model Architecture:** Qwen2ForCausalLM + - **Input:** Text + - **Output:** Text +- **Model Optimizations:** + - **Weight quantization:** INT4 +- **Release Date:** 2/7/2025 +- **Version:** 1.0 +- **Model Developers:** Neural Magic + +Quantized version of [DeepSeek-R1-Distill-Qwen-1.5B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B). + + +### Model Optimizations + +This model was obtained by quantizing the weights of [DeepSeek-R1-Distill-Qwen-1.5B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B) to INT4 data type. +This optimization reduces the number of bits per parameter from 16 to 4, reducing the disk size and GPU memory requirements by approximately 75%. + + +Only the weights of the linear operators within transformers blocks are quantized. +Weights are quantized using a symmetric per-group scheme, with group size 128. +The [GPTQ](https://arxiv.org/abs/2210.17323) algorithm is applied for quantization, as implemented in the [llm-compressor](https://github.com/vllm-project/llm-compressor) library. + + +## Use with vLLM + +This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below. + +```python +from transformers import AutoTokenizer +from vllm import LLM, SamplingParams + +number_gpus = 1 +model_name = "neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-quantized.w4a16" + +tokenizer = AutoTokenizer.from_pretrained(model_name) +sampling_params = SamplingParams(temperature=0.6, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id]) +llm = LLM(model=model_name, tensor_parallel_size=number_gpus, trust_remote_code=True) + +messages_list = [ + [{"role": "user", "content": "Who are you? Please respond in pirate speak!"}], +] + +prompt_token_ids = [tokenizer.apply_chat_template(messages, add_generation_prompt=True) for messages in messages_list] + +outputs = llm.generate(prompt_token_ids=prompt_token_ids, sampling_params=sampling_params) + +generated_text = [output.outputs[0].text for output in outputs] +print(generated_text) +``` + +vLLM also supports OpenAI-compatible serving. See the [documentation](https://docs.vllm.ai/en/latest/) for more details. + +## Creation + +This model was created with [llm-compressor](https://github.com/vllm-project/llm-compressor) by running the code snippet below. + + +```python +from transformers import AutoModelForCausalLM, AutoTokenizer +from llmcompressor.modifiers.quantization import QuantizationModifier +from llmcompressor.modifiers.smoothquant import SmoothQuantModifier +from llmcompressor.transformers import oneshot + +# Load model +model_stub = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B" +model_name = model_stub.split("/")[-1] + +num_samples = 2048 +max_seq_len = 8192 + +tokenizer = AutoTokenizer.from_pretrained(model_stub) + +model = AutoModelForCausalLM.from_pretrained( + model_stub, + device_map="auto", + torch_dtype="auto", +) + +def preprocess_fn(example): + return {"text": tokenizer.apply_chat_template(example["messages"], add_generation_prompt=False, tokenize=False)} + +ds = load_dataset("neuralmagic/LLM_compression_calibration", split="train") +ds = ds.map(preprocess_fn) + +# Configure the quantization algorithm and scheme +recipe = QuantizationModifier( + targets="Linear", + scheme="W4A16", + ignore=["lm_head"], + dampening_frac=0.1, +) + +# Apply quantization +oneshot( + model=model, + dataset=ds, + recipe=recipe, + max_seq_length=max_seq_len, + num_calibration_samples=num_samples, +) + +# Save to disk in compressed-tensors format +save_path = model_name + "-quantized.w4a16 +model.save_pretrained(save_path) +tokenizer.save_pretrained(save_path) +print(f"Model and tokenizer saved to: {save_path}") +``` + +## Evaluation + +The model was evaluated on OpenLLM Leaderboard [V1](https://huggingface.co/spaces/open-llm-leaderboard-old/open_llm_leaderboard) and [V2](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard#/), using the following commands: + +OpenLLM Leaderboard V1: +``` +lm_eval \ + --model vllm \ + --model_args pretrained="neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-quantized.w4a16",dtype=auto,max_model_len=4096,tensor_parallel_size=1,enable_chunked_prefill=True \ + --tasks openllm \ + --write_out \ + --batch_size auto \ + --output_path output_dir \ + --show_config +``` + +OpenLLM Leaderboard V2: +``` +lm_eval \ + --model vllm \ + --model_args pretrained="neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-quantized.w4a16",dtype=auto,max_model_len=4096,tensor_parallel_size=1,enable_chunked_prefill=True \ + --apply_chat_template \ + --fewshot_as_multiturn \ + --tasks leaderboard \ + --write_out \ + --batch_size auto \ + --output_path output_dir \ + --show_config +``` + +### Accuracy + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CategoryMetricdeepseek-ai/DeepSeek-R1-Distill-Qwen-1.5Bneuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-quantized.w4a16Recovery
ReasoningAIME 2024 (pass@1)30.0524.6381.96%
MATH-500 (pass@1)84.6685.5297.47%
GPQA Diamond (pass@1)35.3733.1693.75%
Average Score50.0346.7793.48%
OpenLLM V1ARC-Challenge (Acc-Norm, 25-shot)37.2035.8496.3%
GSM8K (Strict-Match, 5-shot)69.9868.0197.2%
HellaSwag (Acc-Norm, 10-shot)43.8642.3896.6%
MMLU (Acc, 5-shot)37.3836.9898.9%
TruthfulQA (MC2, 0-shot)45.2146.68103.3%
Winogrande (Acc, 5-shot)54.3055.49102.2%
Average Score47.9947.5699.1%
OpenLLM V2IFEval (Inst Level Strict Acc, 0-shot)34.6334.2198.8%
BBH (Acc-Norm, 3-shot)2.402.82---
Math-Hard (Exact-Match, 4-shot)0.000.00---
GPQA (Acc-Norm, 0-shot)0.931.19---
MUSR (Acc-Norm, 0-shot)1.261.37---
MMLU-Pro (Acc, 5-shot)1.321.31---
Average Score6.806.82---
CodingHumanEval (pass@1)37.9035.7094.2%
HumanEval (pass@10)61.3061.40100.2%
HumanEval+ (pass@10)33.0031.9096.7%
HumanEval+ (pass@10)55.9055.5099.3%
+ + +## Inference Performance + + +This model achieves up to 1.5x speedup in single-stream deployment, depending on hardware and use-case scenario. +The following performance benchmarks were conducted with [vLLM](https://docs.vllm.ai/en/latest/) version 0.7.2, and [GuideLLM](https://github.com/neuralmagic/guidellm). + +
+Benchmarking Command + +``` +guidellm --model neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-quantized.w4a16 --target "http://localhost:8000/v1" --data-type emulated --data "prompt_tokens=,generated_tokens=" --max seconds 360 --backend aiohttp_server +``` +
+ +### Single-stream performance (measured with vLLM version 0.7.2) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Instruction Following
256 / 128
Multi-turn Chat
512 / 256
Docstring Generation
768 / 128
RAG
1024 / 128
Code Completion
256 / 1024
Code Fixing
1024 / 1024
Large Summarization
4096 / 512
Large RAG
10240 / 1536
HardwareModelAverage cost reductionLatency (s)QPDLatency (s)QPDLatency (s)QPDLatency (s)QPDLatency (s)QPDLatency (s)QPDLatency (s)QPDLatency (s)QPD
A6000x1deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B---0.856671.627760.855150.854666.47056.56973.5129518.3246
neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-quantized.w8a81.140.766351.333400.763960.763435.38455.48322.9154721.3211
neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-quantized.w4a161.380.582931.141840.679760.675044.310514.410332.5181921.1213
A100x1deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B---0.633591.216540.632860.632414.74244.94112.677821.195
neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-quantized.w8a81.050.635311.118070.634270.634804.54484.54472.484223.586
neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-quantized.w4a161.030.634691.117510.634030.634074.54474.64352.581523.386
H100x1deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B---0.426040.812990.425430.425513.33303.43261.861214.078
neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-FP8-dynamic1.040.426940.813640.426700.426393.23473.23411.667314.178
neuralmagic/DeepSeek-R1-Distill-Qwen-1.5B-quantized.w4a160.840.521111.010650.520680.521194.12704.12652.153015.173
+ +**Use case profiles: prompt tokens / generation tokens + +**QPD: Queries per dollar, based on on-demand cost at [Lambda Labs](https://lambdalabs.com/service/gpu-cloud) (observed on 2/18/2025). diff --git a/config.json b/config.json new file mode 100644 index 0000000..fc0a418 --- /dev/null +++ b/config.json @@ -0,0 +1,62 @@ +{ + "_name_or_path": "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B", + "architectures": [ + "Qwen2ForCausalLM" + ], + "attention_dropout": 0.0, + "bos_token_id": 151643, + "eos_token_id": 151643, + "hidden_act": "silu", + "hidden_size": 1536, + "initializer_range": 0.02, + "intermediate_size": 8960, + "max_position_embeddings": 131072, + "max_window_layers": 21, + "model_type": "qwen2", + "num_attention_heads": 12, + "num_hidden_layers": 28, + "num_key_value_heads": 2, + "quantization_config": { + "config_groups": { + "group_0": { + "input_activations": null, + "output_activations": null, + "targets": [ + "Linear" + ], + "weights": { + "actorder": "group", + "block_structure": null, + "dynamic": false, + "group_size": 128, + "num_bits": 4, + "observer": "mse", + "observer_kwargs": {}, + "strategy": "group", + "symmetric": true, + "type": "int" + } + } + }, + "format": "pack-quantized", + "global_compression_ratio": 2.0710890309058, + "ignore": [ + "lm_head" + ], + "kv_cache_scheme": null, + "quant_method": "compressed-tensors", + "quantization_status": "compressed", + "sparsity_config": {} + }, + "rms_norm_eps": 1e-06, + "rope_scaling": null, + "rope_theta": 10000, + "sliding_window": null, + "tie_word_embeddings": false, + "torch_dtype": "bfloat16", + "transformers_version": "4.48.0", + "use_cache": true, + "use_mrope": false, + "use_sliding_window": false, + "vocab_size": 151936 +} diff --git a/configuration.json b/configuration.json new file mode 100644 index 0000000..bbeeda1 --- /dev/null +++ b/configuration.json @@ -0,0 +1 @@ +{"framework": "pytorch", "task": "text-generation", "allow_remote": true} \ No newline at end of file diff --git a/generation_config.json b/generation_config.json new file mode 100644 index 0000000..f40ad03 --- /dev/null +++ b/generation_config.json @@ -0,0 +1,9 @@ +{ + "_from_model_config": true, + "bos_token_id": 151646, + "do_sample": true, + "eos_token_id": 151643, + "temperature": 0.6, + "top_p": 0.95, + "transformers_version": "4.48.0" +} diff --git a/model.safetensors b/model.safetensors new file mode 100644 index 0000000..b6feae2 --- /dev/null +++ b/model.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:89ea42cf4f9f651398ed53167f162f1b4cbe1cfacd1ef04baed49b2223731341 +size 1611497856 diff --git a/recipe.yaml b/recipe.yaml new file mode 100644 index 0000000..3f7d09d --- /dev/null +++ b/recipe.yaml @@ -0,0 +1,10 @@ +quant_stage: + quant_modifiers: + GPTQModifier: + dampening_frac: 0.1 + ignore: [lm_head] + config_groups: + group_0: + weights: {num_bits: 4, type: int, symmetric: true, strategy: group, group_size: 128, + actorder: group, observer: mse} + targets: [Linear] diff --git a/special_tokens_map.json b/special_tokens_map.json new file mode 100644 index 0000000..1d385d6 --- /dev/null +++ b/special_tokens_map.json @@ -0,0 +1,23 @@ +{ + "bos_token": { + "content": "<|begin▁of▁sentence|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "eos_token": { + "content": "<|end▁of▁sentence|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "pad_token": { + "content": "<|end▁of▁sentence|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + } +} diff --git a/tokenizer.json b/tokenizer.json new file mode 100644 index 0000000..8e71bf3 --- /dev/null +++ b/tokenizer.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:88145e3c3249adc2546ede277e9819d6e405e19072456e4b521cbc724bd60773 +size 7031660 diff --git a/tokenizer_config.json b/tokenizer_config.json new file mode 100644 index 0000000..1046e6c --- /dev/null +++ b/tokenizer_config.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8ac8c85fb242563c2260baec0909debd69d718af6a0b3d90e6cab62b4d341cd5 +size 3071