File size: 5,724 Bytes
5e5c9fe
 
 
58d350d
5e5c9fe
b7da443
5e5c9fe
 
 
 
 
 
7a4221b
5e5c9fe
 
 
 
c47e8c1
d7f9e94
5e5c9fe
bd6e50c
5e5c9fe
3c86f5f
 
 
5e5c9fe
 
 
 
 
 
 
 
 
 
 
 
 
 
58d350d
5e5c9fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
---
license: mit
---
# MalayaLLM: Gemma_2_9B [മലയാളം/Malayalam]

<img src="https://cdn-uploads.huggingface.co/production/uploads/64e65800e44b2668a56f9731/MztEunp8nG4Qy-LSds0SZ.png" alt="Baby MalayaLLM" width="300" height="200">

# Introducing the Developer:
Discover the mind behind this model and stay updated on their contributions to the field
https://www.linkedin.com/in/vishnu-prasad-j/

# Model description
The MalayaLLM models have been improved and customized expanding upon the groundwork laid by the original Gemma-2 model.

- **Model type:** A 9B Gemma-2 finetuned model on Malayalam tokens.
- **Language(s):** Malayalam and English
- **Datasets:**  [CohereForAI/aya_dataset](https://huggingface.co/datasets/CohereForAI/aya_dataset)
- **Source Model:** [MalayaLLM_Gemma_2_9B_Base_V1.0](https://huggingface.co/VishnuPJ/MalayaLLM_Gemma_2_9B_Base_V1.0)
- **GGUF Model:** [MalayaLLM_Gemma_2_9B_Instruct_V1.0_GGUF](https://huggingface.co/VishnuPJ/MalayaLLM_Gemma_2_9B_Instruct_V1.0_GGUF)
- **Training Precision:** `float16`
- **Github Repo:** [MalayaLLM-Gemma2-9B](https://github.com/VishnuPJ/MalayaLLM-Gemma2-9B)

# Old Model
Gemma trained model is here :[MalayaLLM: Gemma-7B](https://huggingface.co/collections/VishnuPJ/malayallm-malayalam-gemma-7b-66851df5e809bed18c2abd25)

## A simple example code

```python
# Installs Unsloth, Xformers (Flash Attention) and all other packages!
#!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
#!pip install --no-deps xformers "trl<0.9.0" peft accelerate bitsandbytes

import sentencepiece as spm
from unsloth import FastLanguageModel
import torch
max_seq_length = 2048  # Choose any! We auto support RoPE Scaling internally!
dtype = None  # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
load_in_4bit = True  # Use 4bit quantization to reduce memory usage. Can be False.
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name="VishnuPJ/MalayaLLM_Gemma_2_9B_Instruct_V1.0",
    max_seq_length=max_seq_length,
    dtype=dtype,
    load_in_4bit=load_in_4bit,
)
EOS_TOKEN = tokenizer.eos_token  # Must add EOS_TOKEN
FastLanguageModel.for_inference(model)  # Enable native 2x faster inference
#### Giving Instruction with Input
'''
alpaca_prompt_1 = """ഒരു  ചുമതല  വിവരിക്കുന്ന  ഒരു  നിർദ്ദേശം  ചുവടെയുണ്ട്.
 അഭ്യർത്ഥന  ശരിയായി  പൂർത്തിയാക്കുന്ന  ഒരു  പ്രതികരണം  എഴുതുക.".
### നിർദ്ദേശം:
{}
### ഇൻപുട്ട്:
{}
### പ്രതികരണം:
{}"""
inputs = tokenizer([
    alpaca_prompt_1.format(
        # "Continue the fibonnaci sequence.", # instruction
        """താഴെ ഉള്ള വാക്യത്തിൽ "അത്" എന്ന് പറയുന്നത് എന്തിനെ ആണ് ?""", # instruction
""" ഒരു വാഹനം കയറ്റം കയറുക ആയിരുന്നു .അതിൽ 4 ആൾക്കാർ ഉണ്ടായിരുന്നു. """, # input
        "", # output - leave this blank for generation!
    )
], return_tensors = "pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=128, use_cache=True)
# Printing the result
print(tokenizer.batch_decode(outputs)[0].split("പ്രതികരണം:\n")[-1])
'''
## Giving Instruction only.
alpaca_prompt_2 = """ഒരു  ചുമതല  വിവരിക്കുന്ന  ഒരു  നിർദ്ദേശം  ചുവടെയുണ്ട്.
 അഭ്യർത്ഥന  ശരിയായി  പൂർത്തിയാക്കുന്ന  ഒരു  പ്രതികരണം  എഴുതുക.".
### നിർദ്ദേശം:
{}
### പ്രതികരണം:
{}"""
while True:
    # Taking user input for the instruction
    instruction = input("Enter the instruction (or type 'exit' to quit): ")
    if instruction.lower() == 'exit':
        break
    # Preparing the input for the model
    inputs = tokenizer([
        alpaca_prompt_2.format(
            instruction,
            "",  # output - leave this blank for generation!
        )
    ], return_tensors="pt").to("cuda")
    # Generating the output
    outputs = model.generate(**inputs, max_new_tokens=128, use_cache=True)
    # Printing the result
    print(tokenizer.batch_decode(outputs)[0].split("പ്രതികരണം:\n")[-1])
print("Program terminated.")

```
## Example Output
```
Enter instruction (or 'exit' to end): ഒരു സമചതുരത്തിന്റെ ഒരു വശം 4 cm ആണെങ്കിൽ , അതിന്റെ area കണ്ടുപിടിക്കുക..
സമചതുരത്തിന്റെ area 16 cm2 ആണ്.<eos>.
Enter instruction (or 'exit' to end): ഇന്ത്യയുടെ അടുത്ത് സ്ഥിതി ചെയുന്ന നാല് രാജ്യങ്ങളുടെ പേര് പറയുക.
"ഇന്ത്യയ്ക്ക് സമീപമുള്ള നാല് രാജ്യങ്ങൾ ഇവയാണ്:
- നേപ്പാൾ
- ഭൂട്ടാൻ
- ടിബറ്റ് (ചൈന)
- പാകിസ്ഥാൻ"<eos>
Enter instruction (or 'exit' to end):exit
```
## Made Using UNSLOTH

Thanks to [Unsloth](https://github.com/unslothai/unsloth), the process of fine-tuning large language models (LLMs) has become much easier and more efficient.
<img src="https://cdn-uploads.huggingface.co/production/uploads/64e65800e44b2668a56f9731/WPt_FKUWDdc6--l_Qnb-G.png" alt="Unsloth" width="300" height="200">

# 🌟Happy coding💻🌟