Update README.md
Browse files
README.md
CHANGED
@@ -34,4 +34,58 @@ pipeline_tag: text-generation
|
|
34 |
|
35 |
This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
34 |
|
35 |
This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
36 |
|
37 |
+
|
38 |
+
## LlamaCPP Code
|
39 |
+
|
40 |
+
```sh
|
41 |
+
CMAKE_ARGS="-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" \
|
42 |
+
pip install llama-cpp-python
|
43 |
+
````
|
44 |
+
|
45 |
+
```py
|
46 |
+
from huggingface_hub import hf_hub_download
|
47 |
+
from llama_cpp import Llama
|
48 |
+
|
49 |
+
## Download the GGUF model
|
50 |
+
model_name = "vutuka/Llama-3.1-8B-african-aya"
|
51 |
+
model_file = "llama-3.1-8B-african-aya.Q8_0.gguf"
|
52 |
+
model_path = hf_hub_download(model_name, filename=model_file)
|
53 |
+
|
54 |
+
## Instantiate model from downloaded file
|
55 |
+
llm = Llama(
|
56 |
+
model_path=model_path,
|
57 |
+
n_ctx=4096,
|
58 |
+
n_gpu_layers=-1,
|
59 |
+
n_batch=512,
|
60 |
+
verbose=False,
|
61 |
+
)
|
62 |
+
|
63 |
+
|
64 |
+
## Run inference
|
65 |
+
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
66 |
+
|
67 |
+
### Instruction:
|
68 |
+
{}
|
69 |
+
|
70 |
+
### Input:
|
71 |
+
{}
|
72 |
+
|
73 |
+
### Response:
|
74 |
+
{}"""
|
75 |
+
|
76 |
+
prompt = alpaca_prompt.format(
|
77 |
+
"",
|
78 |
+
"Àwọn ajínigbé méjì ni wọ́n mú ní Supare Akoko, ṣàlàyé ìtàn náà.",
|
79 |
+
"",
|
80 |
+
)
|
81 |
+
|
82 |
+
print(prompt)
|
83 |
+
|
84 |
+
res = llm(prompt) # Res is a dictionary
|
85 |
+
|
86 |
+
## Unpack and the generated text from the LLM response dictionary and print it
|
87 |
+
print(res["choices"][0]["text"])
|
88 |
+
# res is short for result
|
89 |
+
```
|
90 |
+
|
91 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|