Text Generation
Transformers
Safetensors
gpt_bigcode
code
granite
conversational
Eval Results (legacy)
text-generation-inference
Instructions to use ibm-granite/granite-20b-code-instruct-8k with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ibm-granite/granite-20b-code-instruct-8k with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ibm-granite/granite-20b-code-instruct-8k") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ibm-granite/granite-20b-code-instruct-8k") model = AutoModelForCausalLM.from_pretrained("ibm-granite/granite-20b-code-instruct-8k", 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 ibm-granite/granite-20b-code-instruct-8k with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ibm-granite/granite-20b-code-instruct-8k" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ibm-granite/granite-20b-code-instruct-8k", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ibm-granite/granite-20b-code-instruct-8k
- SGLang
How to use ibm-granite/granite-20b-code-instruct-8k 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 "ibm-granite/granite-20b-code-instruct-8k" \ --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": "ibm-granite/granite-20b-code-instruct-8k", "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 "ibm-granite/granite-20b-code-instruct-8k" \ --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": "ibm-granite/granite-20b-code-instruct-8k", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ibm-granite/granite-20b-code-instruct-8k with Docker Model Runner:
docker model run hf.co/ibm-granite/granite-20b-code-instruct-8k
Commit ·
61baea1
1
Parent(s): 3950ec0
update model
Browse files- config.json +3 -3
- generation_config.json +1 -1
- model-00001-of-00009.safetensors +1 -1
- model-00002-of-00009.safetensors +1 -1
- model-00003-of-00009.safetensors +1 -1
- model-00004-of-00009.safetensors +1 -1
- model-00005-of-00009.safetensors +1 -1
- model-00006-of-00009.safetensors +1 -1
- model-00007-of-00009.safetensors +1 -1
- model-00008-of-00009.safetensors +1 -1
- model-00009-of-00009.safetensors +1 -1
- special_tokens_map.json +0 -0
- tokenizer.json +1 -0
- tokenizer_config.json +0 -0
config.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"activation_function": "
|
| 3 |
"architectures": [
|
| 4 |
"GPTBigCodeForCausalLM"
|
| 5 |
],
|
|
@@ -22,7 +22,7 @@
|
|
| 22 |
"scale_attention_softmax_in_fp32": true,
|
| 23 |
"scale_attn_weights": true,
|
| 24 |
"torch_dtype": "bfloat16",
|
| 25 |
-
"transformers_version": "4.41.
|
| 26 |
-
"use_cache":
|
| 27 |
"vocab_size": 49152
|
| 28 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"activation_function": "gelu",
|
| 3 |
"architectures": [
|
| 4 |
"GPTBigCodeForCausalLM"
|
| 5 |
],
|
|
|
|
| 22 |
"scale_attention_softmax_in_fp32": true,
|
| 23 |
"scale_attn_weights": true,
|
| 24 |
"torch_dtype": "bfloat16",
|
| 25 |
+
"transformers_version": "4.41.2",
|
| 26 |
+
"use_cache": false,
|
| 27 |
"vocab_size": 49152
|
| 28 |
}
|
generation_config.json
CHANGED
|
@@ -3,5 +3,5 @@
|
|
| 3 |
"bos_token_id": 0,
|
| 4 |
"eos_token_id": 0,
|
| 5 |
"pad_token_id": 0,
|
| 6 |
-
"transformers_version": "4.41.
|
| 7 |
}
|
|
|
|
| 3 |
"bos_token_id": 0,
|
| 4 |
"eos_token_id": 0,
|
| 5 |
"pad_token_id": 0,
|
| 6 |
+
"transformers_version": "4.41.2"
|
| 7 |
}
|
model-00001-of-00009.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 4952185256
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:55d1681c37520a4e6009d3b595f9c062aca59fd6df3cd3fa1030837a771a62a2
|
| 3 |
size 4952185256
|
model-00002-of-00009.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 4930227792
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:37dea2993966d6a4454c0912c727f54721fbcf180d0fee64a495eb8aefad436a
|
| 3 |
size 4930227792
|
model-00003-of-00009.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 4927118464
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d811f778ac946f8bd6d9b575219567f8f5e16e299517dc750ffda7c0f576a544
|
| 3 |
size 4927118464
|
model-00004-of-00009.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 4930227864
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0013c2cca1844674e87693199bbbcf76d319ac1f4a6240be10468b3030bf2099
|
| 3 |
size 4930227864
|
model-00005-of-00009.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 4927118464
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5838930baf3c8d10fc75d43deb076eff69fef08950eac9a0f07014322a2110cf
|
| 3 |
size 4927118464
|
model-00006-of-00009.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 4930227864
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:acbba4bad1fbedb0cafb388c03748a72f3644fdfc7bfcb714e560366a828a78e
|
| 3 |
size 4930227864
|
model-00007-of-00009.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 4927118464
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:77c560778bfb84119c7b74cfe755f084ae1734d345c421dd29aae1365fe73d71
|
| 3 |
size 4927118464
|
model-00008-of-00009.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 4930227864
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bfb0611b88a1d48cdbd5e244bd3ea9e4af0dcf63027e43628a62a402a864ca03
|
| 3 |
size 4930227864
|
model-00009-of-00009.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 679601176
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f666a85b0d908ac07f85bbe7503c18cab2762374e6edc3517f0b1953584a8c6a
|
| 3 |
size 679601176
|
special_tokens_map.json
CHANGED
|
File without changes
|
tokenizer.json
CHANGED
|
@@ -206,6 +206,7 @@
|
|
| 206 |
"end_of_word_suffix": null,
|
| 207 |
"fuse_unk": false,
|
| 208 |
"byte_fallback": false,
|
|
|
|
| 209 |
"vocab": {
|
| 210 |
"<|endoftext|>": 0,
|
| 211 |
"<fim_prefix>": 1,
|
|
|
|
| 206 |
"end_of_word_suffix": null,
|
| 207 |
"fuse_unk": false,
|
| 208 |
"byte_fallback": false,
|
| 209 |
+
"ignore_merges": false,
|
| 210 |
"vocab": {
|
| 211 |
"<|endoftext|>": 0,
|
| 212 |
"<fim_prefix>": 1,
|
tokenizer_config.json
CHANGED
|
File without changes
|