Update README.md
Browse files
README.md
CHANGED
@@ -66,11 +66,31 @@ prompt_template =<s>"""சரியான பதிலுடன் வேலை
|
|
66 |
|
67 |
This format is available as a [chat template](https://huggingface.co/docs/transformers/main/chat_templating) via the `apply_chat_template()` method:
|
68 |
|
69 |
-
|
70 |
-
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
```
|
|
|
|
|
|
|
|
|
|
|
74 |
## Python function to format query
|
75 |
```python
|
76 |
def create_prompt(query,prompt_template=prompt_template):
|
|
|
66 |
|
67 |
This format is available as a [chat template](https://huggingface.co/docs/transformers/main/chat_templating) via the `apply_chat_template()` method:
|
68 |
|
69 |
+
## Kaggle demo link
|
70 |
+
https://www.kaggle.com/code/hemanthkumar21/tamil-mistral-instruct-v0-1-demo/
|
71 |
|
72 |
+
```python
|
73 |
+
from transformers import (AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig,TextStreamer,pipeline)
|
74 |
+
import torch
|
75 |
+
model_name = "Hemanth-thunder/Tamil-Mistral-7B-Instruct-v0.1"
|
76 |
+
nf4_config = BitsAndBytesConfig(load_in_4bit=True,bnb_4bit_quant_type="nf4",bnb_4bit_use_double_quant=True,
|
77 |
+
bnb_4bit_compute_dtype=torch.bfloat16
|
78 |
+
)
|
79 |
+
model = AutoModelForCausalLM.from_pretrained(model_name,device_map='auto',quantization_config=nf4_config,use_cache=False,low_cpu_mem_usage=True )
|
80 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
81 |
+
tokenizer.pad_token = tokenizer.eos_token
|
82 |
+
tokenizer.padding_side = "right"
|
83 |
+
streamer = TextStreamer(tokenizer)
|
84 |
+
pipe = pipeline("text-generation" ,model=model, tokenizer=tokenizer ,do_sample=True, repetition_penalty=1.15,top_p=0.95,streamer=streamer)
|
85 |
+
prompt = create_prompt("வாழ்க்கையில் ஆரோக்கியமாக இருப்பது எப்படி?")
|
86 |
+
result=pipe(prompt,max_length=512,pad_token_id=tokenizer.eos_token_id)
|
87 |
|
88 |
```
|
89 |
+
```
|
90 |
+
result:
|
91 |
+
- உடற்பயிற்சி - ஆரோக்கியமான உணவை உண்ணுங்கள் -2 புகைபிடிக்காதே - தவறாமல் உடற்பயிற்சி செய்</s>
|
92 |
+
```
|
93 |
+
|
94 |
## Python function to format query
|
95 |
```python
|
96 |
def create_prompt(query,prompt_template=prompt_template):
|