asif00 commited on
Commit
c44b3b0
·
verified ·
1 Parent(s): a8b25aa

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +62 -0
README.md CHANGED
@@ -10,3 +10,65 @@ tags:
10
  - trl
11
  base_model: unsloth/mistral-7b-v0.3-bnb-4bit
12
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  - trl
11
  base_model: unsloth/mistral-7b-v0.3-bnb-4bit
12
  ---
13
+ # How to Use:
14
+
15
+ You can use the model with a pipeline for a high-level helper or load the model directly. Here's how:
16
+
17
+ ```python
18
+ # Use a pipeline as a high-level helper
19
+ from transformers import pipeline
20
+ pipe = pipeline("question-answering", model="asif00/mistral-bangla-lora")
21
+ ```
22
+
23
+ ```python
24
+ # Load model directly
25
+ from transformers import AutoTokenizer, AutoModelForCausalLM
26
+ tokenizer = AutoTokenizer.from_pretrained("asif00/mistral-bangla-lora")
27
+ model = AutoModelForCausalLM.from_pretrained("asif00/mistral-bangla-lora")
28
+ ```
29
+
30
+ # General Prompt Structure:
31
+
32
+ ```python
33
+ prompt = """Below is an instruction in Bengali language that describes a task, paired with an input also in Bengali language that provides further context. Write a response in Bengali language that appropriately completes the request.
34
+
35
+ ### Instruction:
36
+ {}
37
+
38
+ ### Input:
39
+ {}
40
+
41
+ ### Response:
42
+ {}
43
+ """
44
+ ```
45
+
46
+ # To get a cleaned up version of the response, you can use the `generate_response` function:
47
+
48
+ ```python
49
+ def generate_response(question, context):
50
+ inputs = tokenizer([prompt.format(question, context, "")], return_tensors="pt").to("cuda")
51
+ outputs = model.generate(**inputs, max_new_tokens=1024, use_cache=True)
52
+ responses = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
53
+ response_start = responses.find("### Response:") + len("### Response:")
54
+ response = responses[response_start:].strip()
55
+ return response
56
+ ```
57
+
58
+ # Example Usage:
59
+
60
+ ```python
61
+ question = "ভারতীয় বাঙালি কথাসাহিত্যিক মহাশ্বেতা দেবীর মৃত্যু কবে হয় ?"
62
+ context = "২০১৬ সালের ২৩ জুলাই হৃদরোগে আক্রান্ত হয়ে মহাশ্বেতা দেবী কলকাতার বেল ভিউ ক্লিনিকে ভর্তি হন। সেই বছরই ২৮ জুলাই একাধিক অঙ্গ বিকল হয়ে তাঁর মৃত্যু ঘটে। তিনি মধুমেহ, সেপ্টিসেমিয়া ও মূত্র সংক্রমণ রোগেও ভুগছিলেন।"
63
+ answer = generate_response(question, context)
64
+ print(answer)
65
+ ```
66
+
67
+
68
+ # Disclaimer:
69
+
70
+ The Bangla LLaMA-4bit model has been trained on a limited dataset, and its responses may not always be perfect or accurate. The model's performance is dependent on the quality and quantity of the data it has been trained on. Given more resources, such as high-quality data and longer training time, the model's performance can be significantly improved.
71
+
72
+
73
+ # Resources:
74
+ Work in progress...