Text Generation
Transformers
Safetensors
llama
code
granite
Eval Results (legacy)
text-generation-inference
Instructions to use ibm-granite/granite-8b-code-base-4k with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ibm-granite/granite-8b-code-base-4k with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ibm-granite/granite-8b-code-base-4k")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ibm-granite/granite-8b-code-base-4k") model = AutoModelForCausalLM.from_pretrained("ibm-granite/granite-8b-code-base-4k", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ibm-granite/granite-8b-code-base-4k with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ibm-granite/granite-8b-code-base-4k" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ibm-granite/granite-8b-code-base-4k", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ibm-granite/granite-8b-code-base-4k
- SGLang
How to use ibm-granite/granite-8b-code-base-4k 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-8b-code-base-4k" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ibm-granite/granite-8b-code-base-4k", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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-8b-code-base-4k" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ibm-granite/granite-8b-code-base-4k", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ibm-granite/granite-8b-code-base-4k with Docker Model Runner:
docker model run hf.co/ibm-granite/granite-8b-code-base-4k
add warning
Browse files
README.md
CHANGED
|
@@ -235,6 +235,15 @@ for Code Intelligence](https://)
|
|
| 235 |
- **License:** [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0).
|
| 236 |
|
| 237 |
## Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
### Intended use
|
| 239 |
Prominent enterprise use cases of LLMs in software engineering productivity include code generation, code explanation, code fixing, generating unit tests, generating documentation, addressing technical debt issues, vulnerability detection, code translation, and more. All Granite Code Base models, including the **8B parameter model**, are able to handle these tasks as they were trained on a large amount of code data from 116 programming languages.
|
| 240 |
|
|
|
|
| 235 |
- **License:** [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0).
|
| 236 |
|
| 237 |
## Usage
|
| 238 |
+
> [!WARNING]
|
| 239 |
+
> **You need to build transformers from source to use this model correctly.**
|
| 240 |
+
> ```shell
|
| 241 |
+
> git clone https://github.com/huggingface/transformers
|
| 242 |
+
> cd transformers/
|
| 243 |
+
> pip install ./
|
| 244 |
+
> cd ..
|
| 245 |
+
> ```
|
| 246 |
+
|
| 247 |
### Intended use
|
| 248 |
Prominent enterprise use cases of LLMs in software engineering productivity include code generation, code explanation, code fixing, generating unit tests, generating documentation, addressing technical debt issues, vulnerability detection, code translation, and more. All Granite Code Base models, including the **8B parameter model**, are able to handle these tasks as they were trained on a large amount of code data from 116 programming languages.
|
| 249 |
|