abhinand commited on
Commit
0b86dc8
·
verified ·
1 Parent(s): e782573

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +166 -0
README.md ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: abhinand/malayalam-llama-pt-v0
3
+ model-index:
4
+ - name: malayalam-llama-instruct-v0.1
5
+ results: []
6
+ license: gpl-3.0
7
+ language:
8
+ - en
9
+ - ml
10
+ ---
11
+
12
+ # Malayalam LLaMA 7B Instruct v0.1
13
+
14
+ Welcome to the inaugural release of the Malayalam LLaMA 7B instruct model – an important step in advancing LLMs for the Malayalam language. This model is ready for immediate inference and is also primed for further fine-tuning to cater to your specific NLP tasks.
15
+
16
+ To dive deep into the development and capabilities of this model, please read the [research paper](https://arxiv.org/abs/2311.05845) and the [introductory blog post (WIP)]() that outlines our journey and the model's potential impact.
17
+
18
+ > **Note:** This model is based on the Tamil LLaMA series of models. The GitHub repository remains the same - [https://github.com/abhinand5/tamil-llama](https://github.com/abhinand5/tamil-llama). The base models and the updated code for Tamil LLaMA v0.2 (which this work is based on) will be released soon.
19
+
20
+ If you appreciate this work and would like to support its continued development, consider [buying me a coffee](https://www.buymeacoffee.com/abhinand.b). Your support is invaluable and greatly appreciated.
21
+
22
+ [!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/abhinand.b)
23
+
24
+ ## Model description
25
+
26
+ The Malayalam LLaMA models have been enhanced and tailored specifically with an extensive Malayalam vocabulary of ~16,000 tokens, building upon the foundation set by the original LLaMA-2.
27
+
28
+ - **Model type:** A 7B parameter GPT-like model finetuned on ~500,000 samples consisting of an equal proportion of English and Malayalam samples. (Dataset will be released soon)
29
+ - **Language(s):** Bilingual. English and Malayalam.
30
+ - **License:** GNU General Public License v3.0
31
+ - **Finetuned from model:** [To be released soon]()
32
+ - **Training Precision:** `bfloat16`
33
+ - **Code:** [GitHub](https://github.com/abhinand5/tamil-llama) (To be updated soon)
34
+
35
+ ## Prompt Template: ChatML
36
+
37
+ ```
38
+ <|im_start|>system
39
+ {system_message}<|im_end|>
40
+ <|im_start|>user
41
+ {prompt}<|im_end|>
42
+ <|im_start|>assistant
43
+ ```
44
+
45
+ ## Benchmark Results
46
+
47
+ Benchmarking was done using [LLM-Autoeval](https://github.com/mlabonne/llm-autoeval) on an RTX 3090 on [runpod](https://www.runpod.io/).
48
+
49
+ | Benchmark | Llama 2 Chat | Tamil Llama v0.2 Instruct | Telugu Llama Instruct | Malayalam Llama Instruct |
50
+ |---------------|--------------|---------------------------|-----------------------|--------------------------|
51
+ | ARC Challenge (25-shot) | 52.9 | **53.75** | 52.47 | 52.82 |
52
+ | TruthfulQA (0-shot) | 45.57 | 47.23 | **48.47** | 47.46 |
53
+ | Hellaswag (10-shot) | **78.55** | 76.11 | 76.13 | 76.91 |
54
+ | Winogrande (5-shot) | 71.74 | **73.95** | 71.74 | 73.16 |
55
+ | AGI Eval (0-shot) | 29.3 | **30.95** | 28.44 | 29.6 |
56
+ | BigBench (0-shot) | 32.6 | 33.08 | 32.99 | **33.26** |
57
+ | Average | 51.78 | **52.51** | 51.71 | 52.2 |
58
+
59
+
60
+ ## Related Models
61
+
62
+ | Model | Type | Data | Base Model | # Params | Download Links |
63
+ |--------------------------|-----------------------------|-------------------|----------------------|------|------------------------------------------------------------------------|
64
+ | Tamil LLaMA 7B v0.1 Base | Base model | 12GB | LLaMA 7B | 7B | [HF Hub](https://huggingface.co/abhinand/tamil-llama-7b-base-v0.1) |
65
+ | Tamil LLaMA 13B v0.1 Base | Base model | 4GB | LLaMA 13B | 13B | [HF Hub](https://huggingface.co/abhinand/tamil-llama-13b-base-v0.1) |
66
+ | Tamil LLaMA 7B v0.1 Instruct | Instruction following model | 145k instructions | Tamil LLaMA 7B Base | 7B | [HF Hub](https://huggingface.co/abhinand/tamil-llama-7b-instruct-v0.1) |
67
+ | Tamil LLaMA 13B v0.1 Instruct | Instruction following model | 145k instructions | Tamil LLaMA 13B Base | 13B | [HF Hub](abhinand/tamil-llama-13b-instruct-v0.1) |
68
+ | Tamil LLaMA 7B v0.2 Instruct | Instruction/Chat model | 500k instructions | Tamil LLaMA 7B Base v0.2 | 7B | [HF Hub](abhinand/tamil-llama-13b-instruct-v0.1) |
69
+ | Malayalam LLaMA 7B v0.2 Instruct | Instruction/Chat model | 500k instructions | Malayalam LLaMA 7B Base v0.1 | 7B | [HF Hub](abhinand/tamil-llama-13b-instruct-v0.1) |
70
+
71
+ ## Example Usage
72
+
73
+ ```python
74
+ from transformers import LlamaForCausalLM, AutoTokenizer, pipeline
75
+
76
+ model = LlamaForCausalLM.from_pretrained(
77
+ "abhinand/malayalam-llama-instruct-v0.1",
78
+ #load_in_8bit=True, # Set this depending on the GPU you have
79
+ torch_dtype=torch.bfloat16,
80
+ device_map={"": 0}, # Set this depending on the number of GPUs you have
81
+ local_files_only=False # Optional
82
+ )
83
+ model.eval()
84
+
85
+ tokenizer = AutoTokenizer.from_pretrained("abhinand/malayalam-llama-instruct-v0.1")
86
+
87
+ inf_pipeline = pipeline("conversational", model=model, tokenizer=tokenizer)
88
+
89
+
90
+ def format_instruction(system_prompt, question, return_dict=False):
91
+ if system_prompt is None:
92
+ messages = [
93
+ {'content': question, 'role': 'user'},
94
+ ]
95
+ else:
96
+ messages = [
97
+ {'content': system_prompt, 'role': 'system'},
98
+ {'content': question, 'role': 'user'},
99
+ ]
100
+
101
+ if return_dict:
102
+ return messages
103
+
104
+ prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
105
+
106
+ return prompt
107
+
108
+
109
+ # Set the generation configuration according to your needs
110
+ temperature = 0.6
111
+ repetition_penalty = 1.1
112
+ max_new_tokens = 256
113
+
114
+ SYSTEM_PROMPT = "You are an AI assistant who follows instructions extremely well. Do your best your best to help."
115
+ INPUT = "Give 3 tips to lead a healthy life"
116
+
117
+ instruction = format_instruction(
118
+ system_prompt=SYSTEM_PROMPT,
119
+ question=INPUT,
120
+ return_dict=True,
121
+ )
122
+
123
+ output = inf_pipeline(
124
+ instruction,
125
+ temperature=temperature,
126
+ max_new_tokens=max_new_tokens,
127
+ repetition_penalty=repetition_penalty
128
+ )
129
+ print(output)
130
+
131
+ # =========== EXAMPLE OUTPUT ===========
132
+ # Conversation id: d57cdf33-01ff-4328-8efe-5c4fefdd6e77
133
+ # system: You are an AI assistant who follows instructions extremely well. Do your best your best to help.
134
+ # user: Give 3 tips to lead a healthy life
135
+ # assistant: 1. Establish a regular sleep schedule: Aim for 7-9 hours of sleep per night, which is crucial for overall health and well-being.
136
+ # 2. Engage in physical activity regularly: Incorporate exercise into your daily routine, even if it's just a brisk walk or some light stretching. Regular physical activity can help reduce stress, improve mood, and maintain a healthy weight.
137
+ # 3. Eat a balanced diet: Consume a variety of whole grains, lean proteins, fruits, vegetables, and healthy fats. Limit processed foods, sugary drinks, and excessive amounts of sodium.
138
+ # ======================================
139
+ ```
140
+
141
+ ## Usage Note
142
+
143
+ It's important to note that the models have not undergone detoxification/censorship. Therefore, while they possess impressive linguistic capabilities, there is a possibility for them to generate content that could be deemed harmful or offensive. We urge users to exercise discretion and supervise the model's outputs closely, especially in public or sensitive applications.
144
+
145
+ ## Meet the Developers
146
+
147
+ Get to know the creators behind this innovative model and follow their contributions to the field:
148
+
149
+ - [Abhinand Balachandran](https://www.linkedin.com/in/abhinand-05/)
150
+
151
+ ## Citation
152
+
153
+ If you use this model or any of the the Tamil-Llama related work in your research, please cite:
154
+
155
+ ```bibtex
156
+ @misc{balachandran2023tamilllama,
157
+ title={Tamil-Llama: A New Tamil Language Model Based on Llama 2},
158
+ author={Abhinand Balachandran},
159
+ year={2023},
160
+ eprint={2311.05845},
161
+ archivePrefix={arXiv},
162
+ primaryClass={cs.CL}
163
+ }
164
+ ```
165
+
166
+ We hope this model serves as a valuable tool in your NLP toolkit and look forward to seeing the advancements it will enable in the understanding and generation of the Tamil language.