Create Readme.md
Browse files
README.md
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- saucam/sans_data
|
5 |
+
language:
|
6 |
+
- sa
|
7 |
+
---
|
8 |
+
![](https://raw.githubusercontent.com/saucam/models/main/rudra.png)
|
9 |
+
|
10 |
+
# 🔱 Rudra-7b
|
11 |
+
|
12 |
+
**Rudra-7b is a LoRA fine-tune of [gemma-7b](https://huggingface.co/google/gemma-7b) on sanskrit data**
|
13 |
+
|
14 |
+
This is a text-completion model for Sanskrit language. The model was finetuned using unsloth library.
|
15 |
+
I hope this paves the way for future work for Sanskrit models.
|
16 |
+
|
17 |
+
![](https://raw.githubusercontent.com/unslothai/unsloth/main/images/made%20with%20unsloth.png)
|
18 |
+
|
19 |
+
## 💻 Usage
|
20 |
+
|
21 |
+
### Unsloth
|
22 |
+
|
23 |
+
```
|
24 |
+
from unsloth import FastLanguageModel
|
25 |
+
|
26 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
27 |
+
model_name = "saucam/Rudra-7b", # YOUR MODEL YOU USED FOR TRAINING
|
28 |
+
max_seq_length = 2048,
|
29 |
+
dtype = None,
|
30 |
+
load_in_4bit = False,
|
31 |
+
)
|
32 |
+
FastLanguageModel.for_inference(model) # Enable native 2x faster inference
|
33 |
+
|
34 |
+
inputs = tokenizer(
|
35 |
+
[
|
36 |
+
"संस्कृतम्"
|
37 |
+
], return_tensors = "pt").to("cuda")
|
38 |
+
|
39 |
+
|
40 |
+
outputs = model.generate(**inputs, max_new_tokens = 256, use_cache = True, repetition_penalty=1.0, temperature=1.0, )
|
41 |
+
out = tokenizer.batch_decode(outputs)
|
42 |
+
print(out)
|
43 |
+
```
|
44 |
+
|
45 |
+
### Transformers
|
46 |
+
|
47 |
+
```python
|
48 |
+
!pip install -qU transformers accelerate
|
49 |
+
|
50 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
51 |
+
import transformers
|
52 |
+
import torch
|
53 |
+
|
54 |
+
model_name = "saucam/Rudra-7b"
|
55 |
+
|
56 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
57 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
58 |
+
|
59 |
+
inputs = tokenizer("संस्कृतम्", return_tensors = "pt")#.to("cuda")
|
60 |
+
|
61 |
+
outputs = model.generate(**inputs, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
|
62 |
+
print(tokenizer.decode(outputs[0]))
|
63 |
+
```
|
64 |
+
|
65 |
+
Sample output from above script
|
66 |
+
|
67 |
+
```
|
68 |
+
Gemma's activation function should be approximate GeLU and not exact GeLU.
|
69 |
+
Changing the activation function to `gelu_pytorch_tanh`.if you want to use the legacy `gelu`, edit the `model.config` to set `hidden_activation=gelu` instead of `hidden_act`. See https://github.com/huggingface/transformers/pull/29402 for more details.
|
70 |
+
Loading checkpoint shards: 100%|████████████████████████████| 4/4 [00:01<00:00, 2.54it/s]
|
71 |
+
<bos>संस्कृतम् भारतस्य राष्ट्रभाषा इति भारतसर्वकारस्य 1987तमे वर्षे निर्णयः । प्रायः 125 कोटि जनाः संस्कृतम् एव पठन्ति इति अनुमानम् । संस्कृतम् भारतस्य ध्रुवम् आङ्ग्लानुभाष्यम् । संस्कृतम् अत्यन्तम् प्राचीनम् । संस्कृतम् शैथिल्यात् यदा यदा बहिर्निर्याति तदा तदा एव साम्प्रतकाले संस्कृतेन सह तस्य देशस्य संस्कृतिः सह जगतः संस्कृतिः सह सङ्गच्छति इति । संस्कृतेन सह देशस्य संस्कृतिः सह नगरस्य संस्कृतिः सह क्रीडायाः संस्कृतिः सह राजकीयः, सामाजिकः, सांस्कृतिकः, आर्थिकः, सांविभागिकः, नैतिकः, शिक्षणम्, आवासीयः, साम्प्रदायिकः, धार्मिकः, आध्यात्मिकः, विनोदः, प्रौद्योगिकी, विद्यार्थ
|
72 |
+
```
|