commit 41f1f5aff6a84857a9ca1ee3b43a87644c7036f3 Author: ModelHub XC Date: Tue Jun 2 20:45:12 2026 +0800 初始化项目,由ModelHub XC社区提供模型 Model: RedHatAI/granite-3.1-8b-instruct Source: Original Platform diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..a6344aa --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..a380b94 --- /dev/null +++ b/README.md @@ -0,0 +1,559 @@ +--- +language: +- en +- de +- es +- fr +- ja +- pt +- ar +- cs +- it +- ko +- nl +- zh +base_model: +- ibm-granite/granite-3.1-8b-instruct +pipeline_tag: text-generation +tags: +- granite +- language +- granite-3.1 +- conversational +- text-generation-inference +license: apache-2.0 +license_name: apache-2.0 +name: RedHatAI/granite-3.1-8b-instruct +description: The model is designed to respond to general instructions and can be used to build AI assistants for multiple domains, including business applications. +readme: https://huggingface.co/RedHatAI/granite-3.1-8b-instruct/main/README.md +tasks: +- text-to-text +provider: IBM +license_link: https://www.apache.org/licenses/LICENSE-2.0 +validated_on: + - RHOAI 2.20 + - RHAIIS 3.0 + - RHELAI 1.5 +--- +

+ Granite-3.1-8B-Instruct + Model Icon +

+ + +Validated Badge + + +**Validated on:** RHOAI 2.20, RHAIIS 3.0, RHELAI 1.5 + +**Model Summary:** +Granite-3.1-8B-Instruct is a 8B parameter long-context instruct model finetuned from Granite-3.1-8B-Base using a combination of open source instruction datasets with permissive license and internally collected synthetic datasets tailored for solving long context problems. This model is developed using a diverse set of techniques with a structured chat format, including supervised finetuning, model alignment using reinforcement learning, and model merging. + +- **Developers:** Granite Team, IBM +- **GitHub Repository:** [ibm-granite/granite-3.1-language-models](https://github.com/ibm-granite/granite-3.1-language-models) +- **Website**: [Granite Docs](https://www.ibm.com/granite/docs/) +- **Paper:** [Granite 3.1 Language Models (coming soon)](https://huggingface.co/collections/ibm-granite/granite-31-language-models-6751dbbf2f3389bec5c6f02d) +- **Release Date**: December 18th, 2024 +- **License:** [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) + +## Deployment + +This model can be deployed efficiently on vLLM, Red Hat Enterprise Linux AI, and Openshift AI, as shown in the example below. + +Deploy on vLLM + +```python +from vllm import LLM, SamplingParams + +from transformers import AutoTokenizer + +model_id = "RedHatAI/granite-3.1-8b-instruct" +number_gpus = 1 + +sampling_params = SamplingParams(temperature=0.7, top_p=0.8, max_tokens=256) + +tokenizer = AutoTokenizer.from_pretrained(model_id) + +prompt = "Give me a short introduction to large language model." + +llm = LLM(model=model_id, tensor_parallel_size=number_gpus) + +outputs = llm.generate(prompt, sampling_params) + +generated_text = outputs[0].outputs[0].text +print(generated_text) +``` + +vLLM also supports OpenAI-compatible serving. See the [documentation](https://docs.vllm.ai/en/latest/) for more details. + +
+ Deploy on Red Hat AI Inference Server + +```bash +podman run --rm -it --device nvidia.com/gpu=all -p 8000:8000 \ + --ipc=host \ +--env "HUGGING_FACE_HUB_TOKEN=$HF_TOKEN" \ +--env "HF_HUB_OFFLINE=0" -v ~/.cache/vllm:/home/vllm/.cache \ +--name=vllm \ +registry.access.redhat.com/rhaiis/rh-vllm-cuda \ +vllm serve \ +--tensor-parallel-size 1 \ +--max-model-len 32768 \ +--enforce-eager --model RedHatAI/granite-3.1-8b-instruct +``` +​​See [Red Hat AI Inference Server documentation](https://docs.redhat.com/en/documentation/red_hat_ai_inference_server/) for more details. +
+ +
+ Deploy on Red Hat Enterprise Linux AI + +```bash +# Download model from Red Hat Registry via docker +# Note: This downloads the model to ~/.cache/instructlab/models unless --model-dir is specified. +ilab model download --repository docker://registry.redhat.io/rhelai1/granite-3-1-8b-instruct:1.5 +``` + +```bash +# Serve model via ilab +ilab model serve --model-path ~/.cache/instructlab/models/granite-3-1-8b-instruct -- --trust-remote-code + +# Chat with model +ilab model chat --model ~/.cache/instructlab/models/granite-3-1-8b-instruct +``` +See [Red Hat Enterprise Linux AI documentation](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux_ai/1.4) for more details. +
+ +
+ Deploy on Red Hat Openshift AI + +```python +# Setting up vllm server with ServingRuntime +# Save as: vllm-servingruntime.yaml +apiVersion: serving.kserve.io/v1alpha1 +kind: ServingRuntime +metadata: + name: vllm-cuda-runtime # OPTIONAL CHANGE: set a unique name + annotations: + openshift.io/display-name: vLLM NVIDIA GPU ServingRuntime for KServe + opendatahub.io/recommended-accelerators: '["nvidia.com/gpu"]' + labels: + opendatahub.io/dashboard: 'true' +spec: + annotations: + prometheus.io/port: '8080' + prometheus.io/path: '/metrics' + multiModel: false + supportedModelFormats: + - autoSelect: true + name: vLLM + containers: + - name: kserve-container + image: quay.io/modh/vllm:rhoai-2.20-cuda # CHANGE if needed. If AMD: quay.io/modh/vllm:rhoai-2.20-rocm + command: + - python + - -m + - vllm.entrypoints.openai.api_server + args: + - "--port=8080" + - "--model=/mnt/models" + - "--served-model-name={{.Name}}" + env: + - name: HF_HOME + value: /tmp/hf_home + ports: + - containerPort: 8080 + protocol: TCP +``` + +```python +# Attach model to vllm server. This is an NVIDIA template +# Save as: inferenceservice.yaml +apiVersion: serving.kserve.io/v1beta1 +kind: InferenceService +metadata: + annotations: + openshift.io/display-name: granite-3-1-8b-instruct # OPTIONAL CHANGE + serving.kserve.io/deploymentMode: RawDeployment + name: granite-3-1-8b-instruct # specify model name. This value will be used to invoke the model in the payload + labels: + opendatahub.io/dashboard: 'true' +spec: + predictor: + maxReplicas: 1 + minReplicas: 1 + model: + args: + - '--trust-remote-code' + modelFormat: + name: vLLM + name: '' + resources: + limits: + cpu: '2' # this is model specific + memory: 8Gi # this is model specific + nvidia.com/gpu: '1' # this is accelerator specific + requests: # same comment for this block + cpu: '1' + memory: 4Gi + nvidia.com/gpu: '1' + runtime: vllm-cuda-runtime # must match the ServingRuntime name above + storageUri: oci://registry.redhat.io/rhelai1/modelcar-granite-3-1-8b-instruct:1.5 + tolerations: + - effect: NoSchedule + key: nvidia.com/gpu + operator: Exists +``` + +```bash +# make sure first to be in the project where you want to deploy the model +# oc project + +# apply both resources to run model + +# Apply the ServingRuntime +oc apply -f vllm-servingruntime.yaml + +# Apply the InferenceService +oc apply -f qwen-inferenceservice.yaml +``` + +```python +# Replace and below: +# - Run `oc get inferenceservice` to find your URL if unsure. + +# Call the server using curl: +curl https://-predictor-default./v1/chat/completions + -H "Content-Type: application/json" \ + -d '{ + "model": "granite-3-1-8b-instruct", + "stream": true, + "stream_options": { + "include_usage": true + }, + "max_tokens": 1, + "messages": [ + { + "role": "user", + "content": "How can a bee fly when its wings are so small?" + } + ] +}' + +``` + +See [Red Hat Openshift AI documentation](https://docs.redhat.com/en/documentation/red_hat_openshift_ai/2025) for more details. +
+ + +**Supported Languages:** +English, German, Spanish, French, Japanese, Portuguese, Arabic, Czech, Italian, Korean, Dutch, and Chinese. Users may finetune Granite 3.1 models for languages beyond these 12 languages. + +**Intended Use:** +The model is designed to respond to general instructions and can be used to build AI assistants for multiple domains, including business applications. + +*Capabilities* +* Summarization +* Text classification +* Text extraction +* Question-answering +* Retrieval Augmented Generation (RAG) +* Code related tasks +* Function-calling tasks +* Multilingual dialog use cases +* Long-context tasks including long document/meeting summarization, long document QA, etc. + +**Generation:** +This is a simple example of how to use Granite-3.1-8B-Instruct model. + +Install the following libraries: + +```shell +pip install torch torchvision torchaudio +pip install accelerate +pip install transformers +``` +Then, copy the snippet from the section that is relevant for your use case. + +```python +import torch +from transformers import AutoModelForCausalLM, AutoTokenizer + +device = "auto" +model_path = "ibm-granite/granite-3.1-8b-instruct" +tokenizer = AutoTokenizer.from_pretrained(model_path) +# drop device_map if running on CPU +model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device) +model.eval() +# change input text as desired +chat = [ + { "role": "user", "content": "Please list one IBM Research laboratory located in the United States. You should only output its name and location." }, +] +chat = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True) +# tokenize the text +input_tokens = tokenizer(chat, return_tensors="pt").to(device) +# generate output tokens +output = model.generate(**input_tokens, + max_new_tokens=100) +# decode output tokens into text +output = tokenizer.batch_decode(output) +# print output +print(output) +``` +**Evaluation Results:** + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
HuggingFace Open LLM Leaderboard V1
ModelsARC-ChallengeHellaswagMMLUTruthfulQAWinograndeGSM8KAvg
Granite-3.1-8B-Instruct62.6284.4865.3466.2375.3773.8471.31
Granite-3.1-2B-Instruct54.6175.1455.3159.4267.4852.7660.79
Granite-3.1-3B-A800M-Instruct50.4273.0152.1949.7164.8748.9756.53
Granite-3.1-1B-A400M-Instruct42.6665.9726.1346.7762.3533.8846.29
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
HuggingFace Open LLM Leaderboard V2
ModelsIFEvalBBHMATH Lvl 5GPQAMUSRMMLU-ProAvg
Granite-3.1-8B-Instruct72.0834.0921.688.2819.0128.1930.55
Granite-3.1-2B-Instruct62.8621.8211.335.264.8720.2121.06
Granite-3.1-3B-A800M-Instruct55.1616.6910.355.152.5112.7517.1
Granite-3.1-1B-A400M-Instruct46.866.184.0800.782.4110.05
+ +**Model Architecture:** +Granite-3.1-8B-Instruct is based on a decoder-only dense transformer architecture. Core components of this architecture are: GQA and RoPE, MLP with SwiGLU, RMSNorm, and shared input/output embeddings. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Model2B Dense8B Dense1B MoE3B MoE
Embedding size2048409610241536
Number of layers40402432
Attention head size641286464
Number of attention heads32321624
Number of KV heads8888
MLP hidden size819212800512512
MLP activationSwiGLUSwiGLUSwiGLUSwiGLU
Number of experts3240
MoE TopK88
Initialization std0.10.10.10.1
Sequence length128K128K128K128K
Position embeddingRoPERoPERoPERoPE
# Parameters2.5B8.1B1.3B3.3B
# Active parameters2.5B8.1B400M800M
# Training tokens12T12T10T10T
+ +**Training Data:** +Overall, our SFT data is largely comprised of three key sources: (1) publicly available datasets with permissive license, (2) internal synthetic data targeting specific capabilities including long-context tasks, and (3) very small amounts of human-curated data. A detailed attribution of datasets can be found in the [Granite 3.0 Technical Report](https://github.com/ibm-granite/granite-3.0-language-models/blob/main/paper.pdf), [Granite 3.1 Technical Report (coming soon)](https://huggingface.co/collections/ibm-granite/granite-31-language-models-6751dbbf2f3389bec5c6f02d), and [Accompanying Author List](https://github.com/ibm-granite/granite-3.0-language-models/blob/main/author-ack.pdf). + +**Infrastructure:** +We train Granite 3.1 Language Models using IBM's super computing cluster, Blue Vela, which is outfitted with NVIDIA H100 GPUs. This cluster provides a scalable and efficient infrastructure for training our models over thousands of GPUs. + +**Ethical Considerations and Limitations:** +Granite 3.1 Instruct Models are primarily finetuned using instruction-response pairs mostly in English, but also multilingual data covering eleven languages. Although this model can handle multilingual dialog use cases, its performance might not be similar to English tasks. In such case, introducing a small number of examples (few-shot) can help the model in generating more accurate outputs. While this model has been aligned by keeping safety in consideration, the model may in some cases produce inaccurate, biased, or unsafe responses to user prompts. So we urge the community to use this model with proper safety testing and tuning tailored for their specific tasks. + +**Resources** +- ⭐️ Learn about the latest updates with Granite: https://www.ibm.com/granite +- 📄 Get started with tutorials, best practices, and prompt engineering advice: https://www.ibm.com/granite/docs/ +- 💡 Learn about the latest Granite learning resources: https://ibm.biz/granite-learning-resources + + \ No newline at end of file diff --git a/added_tokens.json b/added_tokens.json new file mode 100644 index 0000000..183eb81 --- /dev/null +++ b/added_tokens.json @@ -0,0 +1,5 @@ +{ + "<|end_of_role|>": 49153, + "<|start_of_role|>": 49152, + "<|tool_call|>": 49154 +} diff --git a/config.json b/config.json new file mode 100644 index 0000000..9e06dd7 --- /dev/null +++ b/config.json @@ -0,0 +1,32 @@ +{ + "architectures": [ + "GraniteForCausalLM" + ], + "attention_bias": false, + "attention_dropout": 0.1, + "attention_multiplier": 0.0078125, + "bos_token_id": 0, + "embedding_multiplier": 12.0, + "eos_token_id": 0, + "hidden_act": "silu", + "hidden_size": 4096, + "initializer_range": 0.02, + "intermediate_size": 12800, + "logits_scaling": 16.0, + "max_position_embeddings": 131072, + "mlp_bias": false, + "model_type": "granite", + "num_attention_heads": 32, + "num_hidden_layers": 40, + "num_key_value_heads": 8, + "pad_token_id": 0, + "residual_multiplier": 0.22, + "rms_norm_eps": 1e-05, + "rope_scaling": null, + "rope_theta": 10000000.0, + "tie_word_embeddings": true, + "torch_dtype": "bfloat16", + "transformers_version": "4.47.0", + "use_cache": true, + "vocab_size": 49155 +} 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..0e7ca8f --- /dev/null +++ b/generation_config.json @@ -0,0 +1,7 @@ +{ + "_from_model_config": true, + "bos_token_id": 0, + "eos_token_id": 0, + "pad_token_id": 0, + "transformers_version": "4.47.0" +} diff --git a/merges.txt b/merges.txt new file mode 100644 index 0000000..f9f6899 --- /dev/null +++ b/merges.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:303127a244b0078878156c17229f36d11b7a3a3f8e47b7cfdbb304ff46be5030 +size 441810 diff --git a/model-00001-of-00004.safetensors b/model-00001-of-00004.safetensors new file mode 100644 index 0000000..6083f51 --- /dev/null +++ b/model-00001-of-00004.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:191c4e9c6263d9cf591104f2d16ab2c39dcc43c1ad0680cc5a34d5c86d61ee41 +size 4974661520 diff --git a/model-00002-of-00004.safetensors b/model-00002-of-00004.safetensors new file mode 100644 index 0000000..9340fad --- /dev/null +++ b/model-00002-of-00004.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7c38b0d5a436775b09d764465ed6e6eb7a8c4e302d05e301e151c96e3076f22 +size 4991447808 diff --git a/model-00003-of-00004.safetensors b/model-00003-of-00004.safetensors new file mode 100644 index 0000000..06d26e6 --- /dev/null +++ b/model-00003-of-00004.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f02784b72391fa04e9b986313c1a1720ce88f0eb40f7ae81fa0daadc93049457 +size 4970460032 diff --git a/model-00004-of-00004.safetensors b/model-00004-of-00004.safetensors new file mode 100644 index 0000000..c298372 --- /dev/null +++ b/model-00004-of-00004.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9d86d201ff8e73d8a46e92b543c9dd44f133e60b35ccada4a76439af62f22212 +size 1405169256 diff --git a/model.safetensors.index.json b/model.safetensors.index.json new file mode 100644 index 0000000..7ed5cd4 --- /dev/null +++ b/model.safetensors.index.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:32fab6382f4cba5428af1b28ed350b6b33d6a413863e952fc10cc286328324e6 +size 29836 diff --git a/special_tokens_map.json b/special_tokens_map.json new file mode 100644 index 0000000..386500a --- /dev/null +++ b/special_tokens_map.json @@ -0,0 +1,35 @@ +{ + "additional_special_tokens": [ + "<|start_of_role|>", + "<|end_of_role|>", + "<|tool_call|>" + ], + "bos_token": { + "content": "<|end_of_text|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "eos_token": { + "content": "<|end_of_text|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "pad_token": { + "content": "<|end_of_text|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "unk_token": { + "content": "<|end_of_text|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + } +} diff --git a/tokenizer.json b/tokenizer.json new file mode 100644 index 0000000..de710f0 --- /dev/null +++ b/tokenizer.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed944c0b3d71e2d651a5ba0f8e7b350faff30031c8e3353de70b12b9c1bf5654 +size 3475806 diff --git a/tokenizer_config.json b/tokenizer_config.json new file mode 100644 index 0000000..0fe3c95 --- /dev/null +++ b/tokenizer_config.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab17e0d532ecf47e9d8451939dd81f25dd98c5fba4b6742584549bbf9c1f06b9 +size 8072 diff --git a/vocab.json b/vocab.json new file mode 100644 index 0000000..8236182 --- /dev/null +++ b/vocab.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:80ab859339a2525fdfbda14bc39df02dffb824aefdaf86426217bbb146d17e01 +size 776995