Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,52 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model:
|
| 4 |
+
- ibm-granite/granite-3.3-8b-instruct
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
# Micro-G3.3-8B-Instruct-1B
|
| 8 |
+
|
| 9 |
+
**Model Summary:**
|
| 10 |
+
Micro-G3.3-8B-Instruct-1B is a 1-billion parameter micro language model fine-tuned for reasoning and instruction-following capabilities. Built on top of Granite-3.3-8B-Instruct, with only 3 hidden layers, this model is trained to maximize performance and hardware compatibility at minimal compute cost.
|
| 11 |
+
|
| 12 |
+
**Generation:**
|
| 13 |
+
This is a simple example of how to use Micro-G3.3-8B-Instruct-1B model.
|
| 14 |
+
|
| 15 |
+
Install the following libraries:
|
| 16 |
+
|
| 17 |
+
```shell
|
| 18 |
+
pip install torch torchvision torchaudio
|
| 19 |
+
pip install accelerate
|
| 20 |
+
pip install transformers
|
| 21 |
+
```
|
| 22 |
+
Then, copy the snippet from the section that is relevant for your use case.
|
| 23 |
+
|
| 24 |
+
```python
|
| 25 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, set_seed
|
| 26 |
+
import torch
|
| 27 |
+
|
| 28 |
+
model_path="ibm-ai-platform/micro-g3.3-8b-instruct-1b"
|
| 29 |
+
device="cuda"
|
| 30 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 31 |
+
model_path,
|
| 32 |
+
device_map=device,
|
| 33 |
+
torch_dtype=torch.bfloat16,
|
| 34 |
+
)
|
| 35 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 36 |
+
model_path
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
conv = [{"role": "user", "content":"What is your favorite color?"}]
|
| 40 |
+
|
| 41 |
+
input_ids = tokenizer.apply_chat_template(conv, return_tensors="pt", thinking=True, return_dict=True, add_generation_prompt=True).to(device)
|
| 42 |
+
|
| 43 |
+
set_seed(42)
|
| 44 |
+
output = model.generate(
|
| 45 |
+
**input_ids,
|
| 46 |
+
max_new_tokens=8,
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
prediction = tokenizer.decode(output[0, input_ids["input_ids"].shape[1]:], skip_special_tokens=True)
|
| 50 |
+
print(prediction)
|
| 51 |
+
```
|
| 52 |
+
|