---
base_model: mesolitica/malaysian-tinyllama-1.1b-16k-instructions
inference: false
language:
- ms
model_creator: mesolitica
model_name: malaysian-tinyllama-1.1b-16k-instructions
pipeline_tag: text-generation
quantized_by: afrideva
tags:
- gguf
- ggml
- quantized
- q2_k
- q3_k_m
- q4_k_m
- q5_k_m
- q6_k
- q8_0
---
# mesolitica/malaysian-tinyllama-1.1b-16k-instructions-GGUF
Quantized GGUF model files for [malaysian-tinyllama-1.1b-16k-instructions](https://huggingface.co/mesolitica/malaysian-tinyllama-1.1b-16k-instructions) from [mesolitica](https://huggingface.co/mesolitica)
| Name | Quant method | Size |
| ---- | ---- | ---- |
| [malaysian-tinyllama-1.1b-16k-instructions.q2_k.gguf](https://huggingface.co/afrideva/malaysian-tinyllama-1.1b-16k-instructions-GGUF/resolve/main/malaysian-tinyllama-1.1b-16k-instructions.q2_k.gguf) | q2_k | None |
| [malaysian-tinyllama-1.1b-16k-instructions.q3_k_m.gguf](https://huggingface.co/afrideva/malaysian-tinyllama-1.1b-16k-instructions-GGUF/resolve/main/malaysian-tinyllama-1.1b-16k-instructions.q3_k_m.gguf) | q3_k_m | None |
| [malaysian-tinyllama-1.1b-16k-instructions.q4_k_m.gguf](https://huggingface.co/afrideva/malaysian-tinyllama-1.1b-16k-instructions-GGUF/resolve/main/malaysian-tinyllama-1.1b-16k-instructions.q4_k_m.gguf) | q4_k_m | None |
| [malaysian-tinyllama-1.1b-16k-instructions.q5_k_m.gguf](https://huggingface.co/afrideva/malaysian-tinyllama-1.1b-16k-instructions-GGUF/resolve/main/malaysian-tinyllama-1.1b-16k-instructions.q5_k_m.gguf) | q5_k_m | None |
| [malaysian-tinyllama-1.1b-16k-instructions.q6_k.gguf](https://huggingface.co/afrideva/malaysian-tinyllama-1.1b-16k-instructions-GGUF/resolve/main/malaysian-tinyllama-1.1b-16k-instructions.q6_k.gguf) | q6_k | None |
| [malaysian-tinyllama-1.1b-16k-instructions.q8_0.gguf](https://huggingface.co/afrideva/malaysian-tinyllama-1.1b-16k-instructions-GGUF/resolve/main/malaysian-tinyllama-1.1b-16k-instructions.q8_0.gguf) | q8_0 | None |
## Original Model Card:
# Full Parameter Finetuning TinyLlama 16384 context length on Malaysian instructions dataset
README at https://github.com/mesolitica/malaya/tree/5.1/session/tiny-llama#instructions-7b-16384-context-length
We use exact Llama2 Instruct chat template, added with function call
WandB, https://wandb.ai/mesolitica/fpf-tinyllama-1.1b-hf-instructions-16k-function-call?workspace=user-husein-mesolitica
## how-to
```python
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
import torch
def parse_llama_chat(messages, function_call = None):
system = messages[0]['content']
user_query = messages[-1]['content']
users, assistants = [], []
for q in messages[1:-1]:
if q['role'] == 'user':
users.append(q['content'])
elif q['role'] == 'assistant':
assistants.append(q['content'])
texts = [f'[INST] <>\n{system}\n<>\n\n']
if function_call:
fs = []
for f in function_call:
f = json.dumps(f, indent=4)
fs.append(f)
fs = '\n\n'.join(fs)
texts.append(f'\n[FUNCTIONCALL]\n{fs}\n')
for u, a in zip(users, assistants):
texts.append(f'{u.strip()} [/INST] {a.strip()} [INST] ')
texts.append(f'{user_query.strip()} [/INST]')
prompt = ''.join(texts).strip()
return prompt
TORCH_DTYPE = 'bfloat16'
nf4_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type='nf4',
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=getattr(torch, TORCH_DTYPE)
)
tokenizer = AutoTokenizer.from_pretrained('mesolitica/malaysian-tinyllama-1.1b-16k-instructions')
model = AutoModelForCausalLM.from_pretrained(
'mesolitica/malaysian-tinyllama-1.1b-16k-instructions',
use_flash_attention_2 = True,
quantization_config = nf4_config
)
messages = [
{'role': 'system', 'content': 'awak adalah AI yang mampu jawab segala soalan'},
{'role': 'user', 'content': 'kwsp tu apa'}
]
prompt = parse_llama_chat(messages)
inputs = tokenizer([prompt], return_tensors='pt', add_special_tokens=False).to('cuda')
generate_kwargs = dict(
inputs,
max_new_tokens=1024,
top_p=0.95,
top_k=50,
temperature=0.9,
do_sample=True,
num_beams=1,
)
r = model.generate(**generate_kwargs)
print(tokenizer.decode(r[0]))
```
```text
' [INST] <>
awak adalah AI yang mampu jawab segala soalan
<>
kwsp tu apa [/INST] KWSP bermaksud Kumpulan Wang Persaraan. '
```
```python
messages = [
{'role': 'system', 'content': 'awak adalah AI yang mampu jawab segala soalan'},
{'role': 'user', 'content': 'awat malaysia ada jabatan koko, malaysia bukan buat keluaq koko banyak pun'}
]
prompt = parse_llama_chat(messages)
inputs = tokenizer([prompt], return_tensors='pt', add_special_tokens=False).to('cuda')
generate_kwargs = dict(
inputs,
max_new_tokens=1024,
top_p=0.95,
top_k=50,
temperature=0.9,
do_sample=True,
num_beams=1,
)
r = model.generate(**generate_kwargs)
print(tokenizer.decode(r[0]))
```
```text
[INST] <>
awak adalah AI yang mampu jawab segala soalan
<>
awat malaysia ada jabatan koko, malaysia bukan buat keluaq koko banyak pun [/INST] Jabatan ini bertanggungjawab untuk mengeluarkan dan mengagihkan produk koko ke pasaran tempatan dan antarabangsa. Mereka juga menyumbang kepada pembangunan industri koko dan memastikan penggunaan sumber asli yang bertanggungjawab. Selain itu, mereka menjalankan penyelidikan dan inovasi untuk meningkatkan proses pengeluaran dan meningkatkan daya saing produk koko.
```
```python
f2 = {
'name': 'parse_entities',
'description': 'extract entities from the text',
'parameters': {
'type': 'object',
'properties': {
'drink': {
'type': 'string',
'description': 'drink name',
},
'event': {
'type': 'string',
'description': 'event name',
},
'person_name': {
'type': 'string',
'description': 'person name',
}
},
'required': [
'drink',
'event',
'person_name'
]
}
}
messages = [
{'role': 'system', 'content': 'awak adalah AI yang mampu jawab segala soalan'},
{'role': 'user', 'content': 'nama saya husein bin zolkepli, saya sekarang berada di putrajaya merdeka 2023 sambil minum teh o ais'}
]
prompt = parse_llama_chat(messages, function_call = [f2])
inputs = tokenizer([prompt], return_tensors='pt', add_special_tokens=False).to('cuda')
generate_kwargs = dict(
inputs,
max_new_tokens=128,
top_p=0.95,
top_k=50,
temperature=0.9,
do_sample=True,
num_beams=1,
)
r = model.generate(**generate_kwargs)
print(tokenizer.decode(r[0]))
```
```text
[INST] <>
awak adalah AI yang mampu jawab segala soalan
<>
[FUNCTIONCALL]
{
"name": "parse_entities",
"description": "extract entities from the text",
"parameters": {
"type": "object",
"properties": {
"drink": {
"type": "string",
"description": "drink name"
},
"event": {
"type": "string",
"description": "event name"
},
"person_name": {
"type": "string",
"description": "person name"
}
},
"required": [
"drink",
"event",
"person_name"
]
}
}
nama saya husein bin zolkepli, saya sekarang berada di putrajaya merdeka 2023 sambil minum teh o ais [/INST] {"name": "parse_entities", "arguments": '{"drink": "teh o ais", "event": "Merdeka 2023", "person_name": "Husein bin Zolkepli"}'}
{"entities": [{"name": "Husein bin Zolkepli", "confidence": 0.95}]}
```