初始化项目,由ModelHub XC社区提供模型

Model: AvoCahDoe/llama-2-7b-rlmpq-balanced
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-07-14 03:15:12 +08:00
commit 6ca0774686
9 changed files with 277414 additions and 0 deletions

35
.gitattributes vendored Normal file
View File

@@ -0,0 +1,35 @@
*.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

89
README.md Normal file
View File

@@ -0,0 +1,89 @@
---
license: llama2
base_model: meta-llama/Llama-2-7b-hf
pipeline_tag: text-generation
language:
- en
tags:
- llama
- text-generation
- rl-mpq
- mixed-precision
- quantization
- fake-quantization
- balanced
- llama-2
library_name: transformers
datasets:
- wikitext
widget:
- text: "The capital of France is"
---
# Llama 2 7B — RL-MPQ Balanced
Standalone **RL-MPQ** (Reinforcement Learning Mixed-Precision Quantization) checkpoint for the
**Balanced** scenario — a quantized variant of
[meta-llama/Llama-2-7b-hf](https://huggingface.co/meta-llama/Llama-2-7b-hf).
| Field | Value |
|-------|-------|
| **Base model** | [meta-llama/Llama-2-7b-hf](https://huggingface.co/meta-llama/Llama-2-7b-hf) |
| **Scenario** | Balanced |
| **Avg bits / weight** | 4.375 |
| **Compression vs FP16** | 3.6571× |
| **WikiText-2 PPL** | 5.0437 |
| **Layers** | 32 |
| **Bit distribution** | `{'4': 29, '8': 3}` |
| **Format** | Fake-quant FP16 + `rlmpq_policy.json` |
**Collection:** [RL-MPQ — Llama 2 7B](https://huggingface.co/collections/AvoCahDoe/rl-mpq-llama-2-7b-6a2ae4f8c590727304e3f634) — all five scenarios for Llama 2 7B.
## Usage
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "AvoCahDoe/llama-2-7b-rlmpq-balanced"
model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype="float16")
tokenizer = AutoTokenizer.from_pretrained(repo)
```
## Other Llama 2 7B scenarios
| Scenario | Avg bits | Compression | WikiText-2 PPL |
|----------|----------|-------------|----------------|
| [High Fidelity](https://huggingface.co/AvoCahDoe/llama-2-7b-rlmpq-high-fidelity) | 6.5 | 2.4615x | 4.9808 |
| [Conservative](https://huggingface.co/AvoCahDoe/llama-2-7b-rlmpq-conservative) | 5.125 | 3.122x | 5.0276 |
| [Aggressive](https://huggingface.co/AvoCahDoe/llama-2-7b-rlmpq-aggressive) | 3.5938 | 4.4522x | 5.2614 |
| [Extreme Survival](https://huggingface.co/AvoCahDoe/llama-2-7b-rlmpq-extreme-survival) | 2.9688 | 5.3895x | 10.9577 |
Grouped archive (all scenarios in one repo):
[AvoCahDoe/llama-2-7b-rlmpq](https://huggingface.co/AvoCahDoe/llama-2-7b-rlmpq)
## Method
1. **Phase 3** — PPO agent assigns per-layer bit widths under the Balanced reward target.
2. **Phase 4** — Policy replayed on real weights; WikiText-2 perplexity validates quality.
3. **Export** — Fake-quantized FP16 weights compatible with Hugging Face Transformers.
## Files
| File | Description |
|------|-------------|
| `config.json` | Llama architecture + RL-MPQ metadata |
| `model.safetensors` | Fake-quantized weights |
| `rlmpq_policy.json` | Per-layer bit-width policy |
| `rlmpq_metrics.json` | Validation & PPL summary |
## Citation
```bibtex
@misc{rlmpq_llama_2_7b_balanced_2026,
title = {RL-MPQ Balanced: Llama 2 7B Mixed-Precision Quantization},
author = {AvoCahDoe},
year = {2026},
url = {https://huggingface.co/AvoCahDoe/llama-2-7b-rlmpq-balanced}
}
```

49
config.json Normal file
View File

@@ -0,0 +1,49 @@
{
"architectures": [
"LlamaForCausalLM"
],
"attention_bias": false,
"attention_dropout": 0.0,
"bos_token_id": 1,
"dtype": "float16",
"eos_token_id": 2,
"head_dim": 128,
"hidden_act": "silu",
"hidden_size": 4096,
"initializer_range": 0.02,
"intermediate_size": 11008,
"max_position_embeddings": 4096,
"mlp_bias": false,
"model_type": "llama",
"num_attention_heads": 32,
"num_hidden_layers": 32,
"num_key_value_heads": 32,
"pad_token_id": null,
"pretraining_tp": 1,
"rms_norm_eps": 1e-05,
"rope_parameters": {
"rope_theta": 10000.0,
"rope_type": "default",
"type": "default"
},
"tie_word_embeddings": false,
"transformers_version": "5.11.0",
"use_cache": true,
"vocab_size": 32000,
"base_model": "meta-llama/Llama-2-7b-hf",
"quantization": {
"method": "rl-mpq",
"format": "fake-quant-fp16",
"scenario": "Balanced",
"avg_bits": 4.375,
"description": "Per-layer mixed bit-width via PPO-trained policy (not GPTQ/AWQ)"
},
"rlmpq": {
"framework": "RL-NMP-Model-Quantasation",
"scenario": "Balanced",
"scenario_label": "Balanced",
"repo_id": "AvoCahDoe/llama-2-7b-rlmpq-balanced",
"grouped_repo": "AvoCahDoe/llama-2-7b-rlmpq",
"collection_title": "RL-MPQ \u2014 Llama 2 7B"
}
}

10
generation_config.json Normal file
View File

@@ -0,0 +1,10 @@
{
"bos_token_id": 1,
"do_sample": true,
"eos_token_id": 2,
"max_length": 4096,
"pad_token_id": 0,
"temperature": 0.6,
"top_p": 0.9,
"transformers_version": "5.11.0"
}

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e825c624ea11056bef28bdb62d44a6b458b45260533539fdde154ddfcdf46132
size 13476864944

23
rlmpq_metrics.json Normal file
View File

@@ -0,0 +1,23 @@
{
"framework": "RL-NMP-Model-Quantasation",
"method": "RL-MPQ",
"repo_id": "AvoCahDoe/llama-2-7b-rlmpq-balanced",
"base_model": "meta-llama/Llama-2-7b-hf",
"model_slug": "llama_2_7b",
"scenario": "Balanced",
"scenario_label": "Balanced",
"avg_bits_per_weight": 4.375,
"compression_vs_fp16": 3.6571,
"wikitext2_perplexity": 5.0437,
"bit_distribution": {
"4": 29,
"8": 3
},
"quantization": {
"type": "fake-quant-fp16",
"group_size": 128,
"scheme": "per-layer asymmetric group-wise",
"packed_format": false
},
"exported_at": "2026-06-11T16:40:33.183918"
}

60
rlmpq_policy.json Normal file
View File

@@ -0,0 +1,60 @@
{
"slug": "llama_2_7b",
"hf_id": "meta-llama/Llama-2-7b-hf",
"scenario": "Balanced",
"params": {
"lambda_mse": 1.0,
"lambda_bit": 0.25,
"max_mse_clip": 1.0,
"target_bits": 4.5,
"lambda_budget": 5.0
},
"policy": [
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
8,
8,
8
],
"num_layers": 32,
"avg_bits": 4.375,
"total_reward": -4.832758,
"compression_ratio": 3.6571,
"approx_size_gb": 3.828,
"bit_distribution": {
"4": 29,
"8": 3
},
"avg_mse_per_bit": {
"4": 0.28526766,
"8": 3.942e-05
},
"validation_elapsed_s": 0.0583
}

277129
tokenizer.json Normal file

File diff suppressed because it is too large Load Diff

16
tokenizer_config.json Normal file
View File

@@ -0,0 +1,16 @@
{
"add_prefix_space": null,
"backend": "tokenizers",
"bos_token": "<s>",
"clean_up_tokenization_spaces": false,
"eos_token": "</s>",
"is_local": false,
"local_files_only": false,
"model_max_length": 1000000000000000019884624838656,
"pad_token": null,
"padding_side": "right",
"sp_model_kwargs": {},
"tokenizer_class": "LlamaTokenizer",
"unk_token": "<unk>",
"use_default_system_prompt": false
}