Update README.md
Browse files
README.md
CHANGED
@@ -41,7 +41,43 @@ outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
|
|
41 |
tokenizer.batch_decode(outputs)
|
42 |
```
|
43 |
|
|
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
This mistral model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
46 |
|
47 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
41 |
tokenizer.batch_decode(outputs)
|
42 |
```
|
43 |
|
44 |
+
## Inference with Transformers 🤗
|
45 |
|
46 |
+
```sh
|
47 |
+
!pip install -q -U bitsandbytes
|
48 |
+
!pip install -q -U git+https://github.com/huggingface/transformers.git
|
49 |
+
!pip install -q -U git+https://github.com/huggingface/peft.git
|
50 |
+
!pip install -q -U git+https://github.com/huggingface/accelerate.git
|
51 |
+
```
|
52 |
+
|
53 |
+
```py
|
54 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
55 |
+
import torch
|
56 |
+
|
57 |
+
quantization_config = BitsAndBytesConfig(
|
58 |
+
load_in_4bit=True,
|
59 |
+
bnb_4bit_compute_dtype=torch.bfloat16
|
60 |
+
)
|
61 |
+
|
62 |
+
tokenizer = AutoTokenizer.from_pretrained("Svngoku/kongostral")
|
63 |
+
model = AutoModelForCausalLM.from_pretrained("Svngoku/kongostral", quantization_config=quantization_config)
|
64 |
+
|
65 |
+
prompt = "Inki kele Nsangu ya kisika yai ?"
|
66 |
+
|
67 |
+
model_inputs = tokenizer([prompt], return_tensors="pt").to("cuda")
|
68 |
+
|
69 |
+
generated_ids = model.generate(**model_inputs, max_new_tokens=500, do_sample=True)
|
70 |
+
tokenizer.batch_decode(generated_ids)[0]
|
71 |
+
|
72 |
+
```
|
73 |
+
|
74 |
+
|
75 |
+
## Observation
|
76 |
+
|
77 |
+
The model may produce results that are not accurate as requested by the user.
|
78 |
+
There is still work to be done to align and get more accurate results.
|
79 |
+
|
80 |
+
### Note
|
81 |
This mistral model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
82 |
|
83 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|