|
|
--- |
|
|
base_model: Lo-Renz-O/Mistral-7B-CPT-Malagasy-v2-bnb-4bit |
|
|
tags: |
|
|
- text-generation-inference |
|
|
- transformers |
|
|
- unsloth |
|
|
- mistral |
|
|
license: apache-2.0 |
|
|
language: |
|
|
- en |
|
|
datasets: |
|
|
- Lo-Renz-O/alpaca-gpt4-MG |
|
|
--- |
|
|
## Model Description |
|
|
|
|
|
This model is an **Instruction Fine-Tuned** adaptation of |
|
|
[**Mistral-7B-CPT-Malagasy-v2-bnb-4bit**](https://huggingface.co/Lo-Renz-O/Mistral-7B-CPT-Malagasy-v2-bnb-4bit), optimized to **follow instructions in the Malagasy language**. |
|
|
|
|
|
It is designed to serve as a **Malagasy AI assistant** with ability to: |
|
|
- Follow instructions |
|
|
- Answer questions and explain concepts in Malagasy |
|
|
- Structure outputs (steps, lists, comparisons) |
|
|
- Perform everyday reasoning tasks |
|
|
|
|
|
This version is specifically meant for **chat & assistant usage**. |
|
|
|
|
|
--- |
|
|
|
|
|
## Intended Uses & Limitations |
|
|
|
|
|
✅ **Recommended Use Cases** |
|
|
- RAG (Retrivial Augmented Generation) |
|
|
- Malagasy conversational AI assistant |
|
|
- Task-oriented instructions (How-to, Q&A, explanations) |
|
|
- Educational and government chatbots |
|
|
- Research on Malagasy instruction-following LLMs |
|
|
- Cultural and contextual language research |
|
|
|
|
|
⚠️ **Limitations** |
|
|
- May hallucinate if asked for unknown facts |
|
|
- Not aligned |
|
|
|
|
|
--- |
|
|
|
|
|
## Training Details |
|
|
|
|
|
- **Base Model:** Lo-Renz-O/Mistral-7B-CPT-Malagasy-v2-bnb-4bit |
|
|
- **Method:** Instruction Fine-Tuning (SFT) with LoRA adapters |
|
|
- **Dataset:** [Malagasy instruction dataset](https://huggingface.co/datasets/Lo-Renz-O/alpaca-gpt4-MG) |
|
|
- **Hardware:** 1 × GPU T4 |
|
|
- **Number of Epochs:** 1 |
|
|
- **Training Time:** ~65 hours |
|
|
- **Objective:** Improve task-following in Malagasy |
|
|
|
|
|
**Training Loss Curve:** |
|
|
<p align="left"> |
|
|
<img src=https://cdn-uploads.huggingface.co/production/uploads/67a3188ac7d276b8df08d11f/5vjekdGyRs3NKEHe9k6Qr.png alt="Training Loss Curve" width="900"/> |
|
|
</p> |
|
|
|
|
|
--- |
|
|
|
|
|
## Inference Example Usage |
|
|
**code** |
|
|
```python |
|
|
from unsloth import FastLanguageModel |
|
|
from transformers import TextStreamer |
|
|
|
|
|
model_name = "Lo-Renz-O/Mistral-7B-instruct-Malagasy-bnb-4bit" |
|
|
model, tokenizer = FastLanguageModel.from_pretrained( |
|
|
model_name=model_name, |
|
|
max_seq_length=2048, |
|
|
load_in_4bit=True, |
|
|
) |
|
|
FastLanguageModel.for_inference(model) |
|
|
|
|
|
conversation_history = [] |
|
|
|
|
|
system_message = ( |
|
|
"Ianao dia mpanampy manampahaizana sy mahafantatra tsara izay mamaly " |
|
|
"amin'ny teny Malagasy. Valio amin'ny fomba mazava, am-pahatsorana, " |
|
|
"ary omeo fanazavana feno raha ilaina. Ataovy voalamina tsara ny valiny, " |
|
|
"mampiasa lohateny, lohateny kely, sy teboka miavaka rehefa ilaina." |
|
|
) |
|
|
|
|
|
def build_messages(history, user_message): |
|
|
messages = [{"role": "system", "content": system_message}] |
|
|
for turn in history: |
|
|
messages.append({"role": "user", "content": turn["user"]}) |
|
|
messages.append({"role": "assistant", "content": turn["assistant"]}) |
|
|
messages.append({"role": "user", "content": user_message}) |
|
|
return messages |
|
|
|
|
|
print("*-----------------Ampidiro ny fanontaniana-----------------*") |
|
|
|
|
|
while True: |
|
|
user_input = input("User: ") |
|
|
if user_input.lower() in ["exit", "quit"]: |
|
|
break |
|
|
|
|
|
messages = build_messages(conversation_history, user_input) |
|
|
prompt = tokenizer.apply_chat_template( |
|
|
messages, |
|
|
tokenize=False, |
|
|
add_generation_prompt=True, |
|
|
) |
|
|
|
|
|
inputs = tokenizer(prompt, return_tensors="pt").to("cuda") |
|
|
streamer = TextStreamer(tokenizer, skip_special_tokens=True, skip_prompt=True) |
|
|
|
|
|
print("\nAssistant:", end=" ", flush=True) |
|
|
output = model.generate( |
|
|
**inputs, |
|
|
max_new_tokens=1024, |
|
|
temperature=0.7, |
|
|
top_p=0.9, |
|
|
top_k=50, |
|
|
repetition_penalty=1.15, |
|
|
do_sample=True, |
|
|
eos_token_id=tokenizer.eos_token_id, |
|
|
streamer=streamer, |
|
|
) |
|
|
|
|
|
generated_text = tokenizer.decode(output[0], skip_special_tokens=True) |
|
|
assistant_response = generated_text.split("Assistant:")[-1].strip() |
|
|
|
|
|
conversation_history.append( |
|
|
{"user": user_input, "assistant": assistant_response} |
|
|
) |
|
|
print() |
|
|
``` |
|
|
**output** |
|
|
``` |
|
|
*-----------------Ampidiro ny fanontaniana-----------------* |
|
|
User: Inona no paikady hanampiana ny fampandrosoana any ambanivohitra? |
|
|
|
|
|
Assistant: Ny fampandrosoana any ambanivohitra dia manondro ny fivoaran'ny faritra ivelan'ny tanàn-dehibe, ary misy paikady maromaro azo ampiharina mba hanatsarana izany. |
|
|
Ny sasany amin'ireo paikady fototra indrindra dia ahitana: 1. Fampiroboroboana ny fampandrosoana maharitra: Fampiroboroboana ny fampandrosoana maharitra ny faritra |
|
|
ambanivohitra izay manantitrantitra ny fiarovana ny tontolo iainana, ny fiarovana ny kolontsaina ary ny famoronana asa maharitra. Izany dia azo atao amin'ny alalan'ny |
|
|
fanomezana tolotra sy fotodrafitrasa ilaina toy ny fitateram-bahoaka, toeram-pambolena sy fambolena maharitra, sehatry ny angovo azo havaozina, ary sehatry ny teknolojia |
|
|
maharitra. 2. Fanohanana ny orinasa eo an-toerana: Manampy amin'ny fampihenana ny fahasahiranan'ny orinasa madinika eo an-toerana ny fanohanana ny fampivoarana azy ireo. |
|
|
Ny fanomezana tontolo iainana tsara ho an'ny fandraharahana, toy ny fidirana amin'ny fampindramam-bola, ny fanofanana ary ny fanampiana, dia afaka manampy amin'ny |
|
|
fampiroboroboana ny faharetan'ny orinasa madinika, ka mahatonga azy ireo ho maharitra kokoa. 3. Fanomezana fahafahana ho an'ny asa: Manampy amin'ny famoronana asa sy |
|
|
fampihenana ny fahantrana ny fanomezana asa, indrindra any |
|
|
``` |
|
|
# Uploaded finetuned model |
|
|
- **Developed by:** Lo-Renz-O |
|
|
- **License:** apache-2.0 |
|
|
- **Finetuned from model :** Lo-Renz-O/Mistral-7B-CPT-Malagasy-v2-bnb-4bit |
|
|
|
|
|
This mistral model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library. |
|
|
|
|
|
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth) |