# Swahili Instruct

This is a [Mistral Instruct](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2) that has been fine-tuned on 1 epoch of the
[SwahiliPlatypus](mwitiderrick/SwahiliAlpaca) dataset.

## Prompt Template
```
### Maelekezo:

{query}

### Jibu:
<Leave new line for model to respond> 
```
## Usage 
```python
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline

tokenizer = AutoTokenizer.from_pretrained("mwitiderrick/SwahiliInstruct-v0.1")
model = AutoModelForCausalLM.from_pretrained("mwitiderrick/SwahiliInstruct-v0.1", device_map="auto")
query = "Nipe maagizo ya kutengeneza mkate wa mandizi"
text_gen = pipeline(task="text-generation", model=model, tokenizer=tokenizer, max_length=200, do_sample=True, repetition_penalty=1.1)
output = text_gen(f"### Maelekezo:\n{query}\n### Jibu:\n")
print(output[0]['generated_text'])
"""
Maagizo ya Kutengeneza Mkate wa Mandazi
1.Washa tanuri kamili hadi 350 ° F (175°C) na uweka sufuria ya kuoka katikati.
2. Katika bakuli, changanya mikasi yote pamoja na chumvi kitamu.
3. Ongeza mayai, siagi na sukari, koroga hadi viwe sawasawa.
4. Panda mchanganyiko kwenye pan katika mkusanyo unaotuleta tayari kwa mtiririko.
5. Kata misingo kuburudisha kila mahali na uwatazama ikiwa yanapasuka y

"""
```
## Before Swahili Fine-tuning 
```python
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline

tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2")
model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2", device_map="auto")
query = "Nipe maagizo ya kutengeneza mkate wa mandizi"
text_gen = pipeline(task="text-generation", model=model, tokenizer=tokenizer, max_length=500)
output = text_gen(f"### Instruction:\n{query}\n### Response:\n")
print(output[0]['generated_text'])

"""
To make a pancake, follow these steps:

1. In a large bowl, mix together 1 1/2 cups of all-purpose flour, 3 1/2 teaspoons of baking powder, 1 teaspoon of salt, and 1 tablespoon of sugar.
2. Make a well in the center of the flour mixture and pour in 1 1/2 cups of milk, 1 1/4 cups of buttermilk, 2 eggs, and 3 tablespoons of melted butter.
3. Mix the ingredients together until they are just combined. Do not overmix.
4. Let the batter rest for 30 minutes.
5. Heat a griddle or large skillet over medium heat. Brush it with oil or melted butter.
6. Using a 1/4 cup measure, scoop the batter onto the griddle or skillet. Cook until bubbles form on the surface and the edges start to look set, then flip and cook until the other side is golden brown.
7. Serve the pancakes warm with your favorite toppings, such as maple syrup, whipped cream, or fresh fruit. Enjoy!
"""
```

{"language": ["en"], "license": "apache-2.0", "library_name": "transformers", "tags": ["transformers"], "datasets": ["mwitiderrick/SwahiliAlpaca"], "base_model": "mistralai/Mistral-7B-Instruct-v0.2", "inference": true, "model_type": "llama", "prompt_template": "### Instruction:\\n\n{prompt}\n### Response:\n", "created_by": "mwitiderrick", "pipeline_tag": "text-generation"}
transformers safetensors mistral text-generation conversational en dataset:mwitiderrick/SwahiliAlpaca base_model:mistralai/Mistral-7B-Instruct-v0.2 license:apache-2.0 autotrain_compatible endpoints_compatible text-generation-inference region:us