From 8ee7a4803fbb338f3d5d54be186d872f8c4a5cf5 Mon Sep 17 00:00:00 2001 From: ModelHub XC Date: Sun, 9 Aug 2026 14:27:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=EF=BC=8C=E7=94=B1ModelHub=20XC=E7=A4=BE=E5=8C=BA=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Model: Intel/gemma-2b-int4-inc Source: Original Platform --- .gitattributes | 49 ++++++++++++++++ README.md | 126 ++++++++++++++++++++++++++++++++++++++++ config.json | 49 ++++++++++++++++ configuration.json | 1 + model.safetensors | 3 + quantize_config.json | 20 +++++++ special_tokens_map.json | 30 ++++++++++ tokenizer.json | 3 + tokenizer.model | 3 + tokenizer_config.json | 49 ++++++++++++++++ 10 files changed, 333 insertions(+) create mode 100644 .gitattributes create mode 100644 README.md create mode 100644 config.json create mode 100644 configuration.json create mode 100644 model.safetensors create mode 100644 quantize_config.json create mode 100644 special_tokens_map.json create mode 100644 tokenizer.json create mode 100644 tokenizer.model create mode 100644 tokenizer_config.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..21b3632 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,49 @@ +*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bin.* filter=lfs diff=lfs merge=lfs -text +*.bz2 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 +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack 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 +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +saved_model/**/* 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 +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zstandard filter=lfs diff=lfs merge=lfs -text +*.tfevents* filter=lfs diff=lfs merge=lfs -text +*.db* filter=lfs diff=lfs merge=lfs -text +*.ark* filter=lfs diff=lfs merge=lfs -text +**/*ckpt*data* filter=lfs diff=lfs merge=lfs -text +**/*ckpt*.meta filter=lfs diff=lfs merge=lfs -text +**/*ckpt*.index filter=lfs diff=lfs merge=lfs -text +*.safetensors filter=lfs diff=lfs merge=lfs -text +*.ckpt filter=lfs diff=lfs merge=lfs -text +*.gguf* filter=lfs diff=lfs merge=lfs -text +*.ggml filter=lfs diff=lfs merge=lfs -text +*.llamafile* filter=lfs diff=lfs merge=lfs -text +*.pt2 filter=lfs diff=lfs merge=lfs -text +*.mlmodel filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.npz filter=lfs diff=lfs merge=lfs -text +*.pickle filter=lfs diff=lfs merge=lfs -text +*.pkl filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.wasm 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 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..f88b3b5 --- /dev/null +++ b/README.md @@ -0,0 +1,126 @@ +--- +license: apache-2.0 +datasets: +- NeelNanda/pile-10k +--- + + + + + + +## Model Details + +This model is an int4 model with group_size 128 of [google/gemma-2b](https://huggingface.co/google/gemma-2b) generated by [intel/auto-round](https://github.com/intel/auto-round). + + + +### Use the model +### INT4 Inference with ITREX on CPU +Install the latest [intel-extension-for-transformers]( +https://github.com/intel/intel-extension-for-transformers) +```python +from intel_extension_for_transformers.transformers import AutoModelForCausalLM +from transformers import AutoTokenizer +quantized_model_dir = "Intel/gemma-2b-int4-inc" +model = AutoModelForCausalLM.from_pretrained(quantized_model_dir, + device_map="auto", + trust_remote_code=False, + use_neural_speed=False, + ) +tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir, use_fast=True) +print(tokenizer.decode(model.generate(**tokenizer("There is a girl who likes adventure,", return_tensors="pt").to(model.device),max_new_tokens=50)[0])) +""" +There is a girl who likes adventure, and she is a girl who likes to travel. She is a girl who likes to explore the world and see new things. She is a girl who likes to meet new people and learn about their cultures. She is a girl who likes to take risks +""" +``` + + +### INT4 Inference with AutoGPTQ's kernel + +```python +##pip install auto-gptq +from transformers import AutoModelForCausalLM, AutoTokenizer +quantized_model_dir = "Intel/gemma-2b-int4-inc" +tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir) +model = AutoModelForCausalLM.from_pretrained(quantized_model_dir, + device_map="auto", + trust_remote_code=False, + ) +tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir, use_fast=True) +text = "There is a girl who likes adventure," +inputs = tokenizer(text, return_tensors="pt").to(model.device) +print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50)[0])) +##There is a girl who likes adventure, and she is a girl who likes to travel. She is a girl who likes to explore the world and see new things. She is a girl who likes to meet new people and learn about their cultures. She is a girl who likes to take risks +``` + + + +### Evaluate the model + +pip3 install lm-eval==0.4.2 + +pip install auto-gptq + +Please note that there is a discrepancy between the baseline result and the official data, which is a known issue within the official model card community. + +```bash +lm_eval --model hf --model_args pretrained="Intel/gemma-2b-int4-inc",autogptq=True,gptq_use_triton=True --device cuda:0 --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu --batch_size 16 +``` + + + +| Metric | BF16 | FP16 | AutoRound v0.1 | AutoRound v0.2 | +| -------------- | ------ | ------ | -------------- | -------------- | +| Avg. | 0.5263 | 0.5277 | 0.5235 | 0.5248 | +| mmlu | 0.3287 | 0.3287 | 0.3297 | 0.3309 | +| lambada_openai | 0.6344 | 0.6375 | 0.6307 | 0.6379 | +| hellaswag | 0.5273 | 0.5281 | 0.5159 | 0.5184 | +| winogrande | 0.6504 | 0.6488 | 0.6543 | 0.6575 | +| piqa | 0.7671 | 0.7720 | 0.7612 | 0.7606 | +| truthfulqa_mc1 | 0.2203 | 0.2203 | 0.2203 | 0.2191 | +| openbookqa | 0.2980 | 0.3020 | 0.3000 | 0.3060 | +| boolq | 0.6927 | 0.6936 | 0.6939 | 0.6966 | +| arc_easy | 0.7420 | 0.7403 | 0.7353 | 0.7357 | +| arc_challenge | 0.4019 | 0.4061 | 0.3933 | 0.3857 | + + + +Here is the sample command to reproduce the model + +```bash +git clone https://github.com/intel/auto-round +cd auto-round/examples/language-modeling +pip install -r requirements.txt +python3 main.py \ +--model_name google/gemma-2b \ +--device 0 \ +--group_size 128 \ +--bits 4 \ +--iters 400 \ +--model_dtype "float16" \ +--deployment_device 'gpu' \ +--output_dir "./tmp_autoround" + +``` + + + +## Ethical Considerations and Limitations + +The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs. + +Therefore, before deploying any applications of the model, developers should perform safety testing. + +## Caveats and Recommendations + +Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. + +Here are a couple of useful links to learn more about Intel's AI software: + +* Intel Neural Compressor [link](https://github.com/intel/neural-compressor) +* Intel Extension for Transformers [link](https://github.com/intel/intel-extension-for-transformers) + +## Disclaimer + +The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes. \ No newline at end of file diff --git a/config.json b/config.json new file mode 100644 index 0000000..d2eaa0d --- /dev/null +++ b/config.json @@ -0,0 +1,49 @@ +{ + "_name_or_path": "/models/gemma-2b", + "architectures": [ + "GemmaForCausalLM" + ], + "attention_bias": false, + "attention_dropout": 0.0, + "bos_token_id": 2, + "eos_token_id": 1, + "head_dim": 256, + "hidden_act": "gelu", + "hidden_activation": null, + "hidden_size": 2048, + "initializer_range": 0.02, + "intermediate_size": 16384, + "max_position_embeddings": 8192, + "model_type": "gemma", + "num_attention_heads": 8, + "num_hidden_layers": 18, + "num_key_value_heads": 1, + "pad_token_id": 0, + "quantization_config": { + "autoround_version": "0.2.0.dev", + "bits": 4, + "damp_percent": 0.01, + "desc_act": false, + "enable_minmax_tuning": true, + "enable_quanted_input": true, + "group_size": 128, + "is_marlin_format": false, + "iters": 400, + "lr": 0.0025, + "minmax_lr": 0.0025, + "model_file_base_name": "model", + "model_name_or_path": null, + "quant_method": "gptq", + "scale_dtype": "float16", + "static_groups": false, + "sym": false, + "true_sequential": false + }, + "rms_norm_eps": 1e-06, + "rope_scaling": null, + "rope_theta": 10000.0, + "torch_dtype": "float16", + "transformers_version": "4.40.2", + "use_cache": true, + "vocab_size": 256000 +} 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/model.safetensors b/model.safetensors new file mode 100644 index 0000000..66d10fd --- /dev/null +++ b/model.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fcbf563b9667464d9217348e712763af0ae6acd26c5b53dc15483c18d51e910d +size 3130472744 diff --git a/quantize_config.json b/quantize_config.json new file mode 100644 index 0000000..20de645 --- /dev/null +++ b/quantize_config.json @@ -0,0 +1,20 @@ +{ + "bits": 4, + "group_size": 128, + "damp_percent": 0.01, + "desc_act": false, + "static_groups": false, + "sym": false, + "true_sequential": false, + "model_name_or_path": null, + "model_file_base_name": "model", + "is_marlin_format": false, + "quant_method": "intel/auto-round", + "autoround_version": "0.2.0.dev", + "iters": 400, + "lr": 0.0025, + "minmax_lr": 0.0025, + "enable_minmax_tuning": true, + "enable_quanted_input": true, + "scale_dtype": "float16" +} \ No newline at end of file diff --git a/special_tokens_map.json b/special_tokens_map.json new file mode 100644 index 0000000..f611958 --- /dev/null +++ b/special_tokens_map.json @@ -0,0 +1,30 @@ +{ + "bos_token": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "eos_token": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "pad_token": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "unk_token": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + } +} diff --git a/tokenizer.json b/tokenizer.json new file mode 100644 index 0000000..d04de1f --- /dev/null +++ b/tokenizer.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4db21bfaffa1fd75fd741df2d95dc51e539d5cc38b07934bae0d7d129db90662 +size 17477581 diff --git a/tokenizer.model b/tokenizer.model new file mode 100644 index 0000000..796efe9 --- /dev/null +++ b/tokenizer.model @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:61a7b147390c64585d6c3543dd6fc636906c9af3865a5548f27f31aee1d4c8e2 +size 4241003 diff --git a/tokenizer_config.json b/tokenizer_config.json new file mode 100644 index 0000000..c22f33a --- /dev/null +++ b/tokenizer_config.json @@ -0,0 +1,49 @@ +{ + "add_bos_token": true, + "add_eos_token": false, + "added_tokens_decoder": { + "0": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "1": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "2": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "3": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + } + }, + "bos_token": "", + "clean_up_tokenization_spaces": false, + "eos_token": "", + "legacy": null, + "model_max_length": 1000000000000000019884624838656, + "pad_token": "", + "sp_model_kwargs": {}, + "spaces_between_special_tokens": false, + "tokenizer_class": "GemmaTokenizer", + "unk_token": "", + "use_default_system_prompt": false +}