VishnuPJ commited on
Commit
5e5c9fe
1 Parent(s): 324ecc0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +108 -3
README.md CHANGED
@@ -1,3 +1,108 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ ---
4
+ # MalayaLLM: Gemma [മലയാളം/Malayalam]
5
+
6
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/64e65800e44b2668a56f9731/bipVMulaNJ9um46ecYpR4.png" alt="Baby MalayaLLM" width="300" height="200">
7
+
8
+ # Introducing the Developer:
9
+ Discover the mind behind this model and stay updated on their contributions to the field
10
+ https://www.linkedin.com/in/vishnu-prasad-j/
11
+
12
+ # Model description
13
+ The MalayaLLM models have been improved and customized expanding upon the groundwork laid by the original Gemma model.
14
+
15
+ - **Model type:** A 9B Gemma-2 finetuned model on Malayalam tokens.
16
+ - **Language(s):** Malayalam and English
17
+ - **Datasets:** [CohereForAI/aya_dataset](https://huggingface.co/datasets/CohereForAI/aya_dataset)
18
+ - **Source Model:** [MalayaLLM_Gemma_7B_Base_V1](https://huggingface.co/VishnuPJ/MalayaLLM_Gemma_7B_Base_V1)
19
+ - **Training Precision:** `float16`
20
+ - **Code:** 'Will be released soon '
21
+
22
+ ## A simple example code
23
+
24
+ ```python
25
+ # Installs Unsloth, Xformers (Flash Attention) and all other packages!
26
+ #!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
27
+ #!pip install --no-deps xformers "trl<0.9.0" peft accelerate bitsandbytes
28
+
29
+ import sentencepiece as spm
30
+ from unsloth import FastLanguageModel
31
+ import torch
32
+ max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally!
33
+ dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
34
+ load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
35
+ model, tokenizer = FastLanguageModel.from_pretrained(
36
+ model_name="VishnuPJ/MalayaLLM_Gemma_2_7B_Instruct_V1.0",
37
+ max_seq_length=max_seq_length,
38
+ dtype=dtype,
39
+ load_in_4bit=load_in_4bit,
40
+ )
41
+ EOS_TOKEN = tokenizer.eos_token # Must add EOS_TOKEN
42
+ FastLanguageModel.for_inference(model) # Enable native 2x faster inference
43
+ #### Giving Instruction with Input
44
+ '''
45
+ alpaca_prompt_1 = """ഒരു ചുമതല വിവരിക്കുന്ന ഒരു നിർദ്ദേശം ചുവടെയുണ്ട്.
46
+ അഭ്യർത്ഥന ശരിയായി പൂർത്തിയാക്കുന്ന ഒരു പ്രതികരണം എഴുതുക.".
47
+ ### നിർദ്ദേശം:
48
+ {}
49
+ ### ഇൻപുട്ട്:
50
+ {}
51
+ ### പ്രതികരണം:
52
+ {}"""
53
+ inputs = tokenizer([
54
+ alpaca_prompt_1.format(
55
+ # "Continue the fibonnaci sequence.", # instruction
56
+ """താഴെ ഉള്ള വാക്യത്തിൽ "അത്" എന്ന് പറയുന്നത് എന്തിനെ ആണ് ?""", # instruction
57
+ """ ഒരു വാഹനം കയറ്റം കയറുക ആയിരുന്നു .അതിൽ 4 ആൾക്കാർ ഉണ്ടായിരുന്നു. """, # input
58
+ "", # output - leave this blank for generation!
59
+ )
60
+ ], return_tensors = "pt").to("cuda")
61
+ outputs = model.generate(**inputs, max_new_tokens=128, use_cache=True)
62
+ # Printing the result
63
+ print(tokenizer.batch_decode(outputs)[0].split("പ്രതികരണം:\n")[-1])
64
+ '''
65
+ ## Giving Instruction only.
66
+ alpaca_prompt_2 = """ഒരു ചുമതല വിവരിക്കുന്ന ഒരു നിർദ്ദേശം ചുവടെയുണ്ട്.
67
+ അഭ്യർത്ഥന ശരിയായി പൂർത്തിയാക്കുന്ന ഒരു പ്രതികരണം എഴുതുക.".
68
+ ### നിർദ്ദേശം:
69
+ {}
70
+ ### പ്രതികരണം:
71
+ {}"""
72
+ while True:
73
+ # Taking user input for the instruction
74
+ instruction = input("Enter the instruction (or type 'exit' to quit): ")
75
+ if instruction.lower() == 'exit':
76
+ break
77
+ # Preparing the input for the model
78
+ inputs = tokenizer([
79
+ alpaca_prompt_2.format(
80
+ instruction,
81
+ "", # output - leave this blank for generation!
82
+ )
83
+ ], return_tensors="pt").to("cuda")
84
+ # Generating the output
85
+ outputs = model.generate(**inputs, max_new_tokens=128, use_cache=True)
86
+ # Printing the result
87
+ print(tokenizer.batch_decode(outputs)[0].split("പ്രതികരണം:\n")[-1])
88
+ print("Program terminated.")
89
+
90
+ ```
91
+ ## Example Output
92
+ ```
93
+ Enter instruction (or 'exit' to end): ഒരു സമചതുരത്തിന്റെ ഒരു വശം 4 cm ആണെങ്കിൽ , അതിന്റെ area കണ്ടുപിടിക്കുക..
94
+ സമചതുരത്തിന്റെ area 16 cm2 ആണ്.<eos>.
95
+ Enter instruction (or 'exit' to end): ഇന്ത്യയുടെ അടുത്ത് സ്ഥിതി ചെയുന്ന നാല് രാജ്യങ്ങളുടെ പേര് പറയുക.
96
+ "ഇന്ത്യയ്ക്ക് സമീപമുള്ള നാല് രാജ്യങ്ങൾ ഇവയാണ്:
97
+ - നേപ്പാൾ
98
+ - ഭൂട്ടാൻ
99
+ - ടിബറ്റ് (ചൈന)
100
+ - പാകിസ്ഥാൻ"<eos>
101
+ Enter instruction (or 'exit' to end):exit
102
+ ```
103
+ ## Made Using UNSLOTH
104
+
105
+ Thanks to [Unsloth](https://github.com/unslothai/unsloth), the process of fine-tuning large language models (LLMs) has become much easier and more efficient.
106
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/64e65800e44b2668a56f9731/WPt_FKUWDdc6--l_Qnb-G.png" alt="Unsloth" width="300" height="200">
107
+
108
+ # 🌟Happy coding💻🌟