Dorjzodovsuren commited on
Commit
7d21752
·
verified ·
1 Parent(s): 6c0ec9e

Update README.md

Browse files

initial description details

Files changed (1) hide show
  1. README.md +101 -168
README.md CHANGED
@@ -1,13 +1,7 @@
1
  ---
2
  library_name: peft
3
- base_model: unsloth/llama-3-8b-bnb-4bit
4
  ---
5
 
6
- # Model Card for Model ID
7
-
8
- <!-- Provide a quick summary of what the model is/does. -->
9
-
10
-
11
 
12
  ## Model Details
13
 
@@ -15,49 +9,33 @@ base_model: unsloth/llama-3-8b-bnb-4bit
15
 
16
  <!-- Provide a longer summary of what this model is. -->
17
 
 
18
 
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
29
-
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
-
36
- ## Uses
37
-
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
 
44
  [More Information Needed]
45
 
46
- ### Downstream Use [optional]
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
 
50
- [More Information Needed]
51
 
52
- ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
 
56
- [More Information Needed]
57
 
58
- ## Bias, Risks, and Limitations
 
 
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
 
62
  [More Information Needed]
63
 
@@ -65,138 +43,93 @@ base_model: unsloth/llama-3-8b-bnb-4bit
65
 
66
  <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
 
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
 
69
 
70
  ## How to Get Started with the Model
71
 
72
  Use the code below to get started with the model.
73
 
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
-
189
- ## More Information [optional]
190
-
191
- [More Information Needed]
192
-
193
- ## Model Card Authors [optional]
194
-
195
- [More Information Needed]
196
-
197
- ## Model Card Contact
198
-
199
- [More Information Needed]
200
- ### Framework versions
201
-
202
- - PEFT 0.10.0
 
1
  ---
2
  library_name: peft
 
3
  ---
4
 
 
 
 
 
 
5
 
6
  ## Model Details
7
 
 
9
 
10
  <!-- Provide a longer summary of what this model is. -->
11
 
12
+ Mongolian-Llama3 is an instruction-tuned language model for Mongolian & English users with various abilities such as roleplaying & tool-using built upon the quantized Meta-Llama-3-8B model.
13
 
14
+ Developed by: Dorjzodovsuren
15
+ License: Llama-3 License
16
+ Base Model: llama-3-8b-bnb-4bit
17
+ Model Size: 8.03B
18
+ Context length: 8K
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  [More Information Needed]
21
 
22
+ ## Bias, Risks, and Limitations
23
 
24
+ To combat fake news, current strategies rely heavily on synthetic and translated data. However, these approaches have inherent biases, risks, and limitations:
25
 
26
+ 1. **Synthetic Data Bias**: Algorithms may inadvertently perpetuate biases present in training data.
27
 
28
+ 2. **Translation Inaccuracy**: Translations can distort meaning or lose context, leading to misinformation.
29
 
30
+ 3. **Cultural Nuances**: Synthetic and translated data may miss cultural intricacies, risking amplification of stereotypes.
31
 
32
+ 4. **Algorithmic Limits**: Effectiveness is constrained by algorithm capabilities and training data quality.
33
 
34
+ 5. **Dependency on Data**: Accuracy hinges on quality and representativeness of training data.
35
+
36
+ 6. **Adversarial Attacks**: Malicious actors can exploit vulnerabilities to manipulate content.
37
 
38
+ 7. **Different answer based on language**: Answer might be a bit different based on language.
39
 
40
  [More Information Needed]
41
 
 
43
 
44
  <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
45
 
46
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
47
+ Due to hallucinations and pretraining datasets characteristics, some information might be misleading, and answer might be a bit different based on language. Please ask in Mongolian if possible.
48
 
49
  ## How to Get Started with the Model
50
 
51
  Use the code below to get started with the model.
52
 
53
+ ```
54
+ import torch
55
+ import gradio as gr
56
+ from threading import Thread
57
+ from peft import PeftModel, PeftConfig
58
+ from unsloth import FastLanguageModel
59
+ from transformers import TextStreamer
60
+ from transformers import AutoModelForCausalLM, AutoTokenizer, StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer
61
+
62
+ config = PeftConfig.from_pretrained("Dorjzodovsuren/Mongolian_llama3")
63
+ model = AutoModelForCausalLM.from_pretrained("unsloth/llama-3-8b-bnb-4bit", torch_dtype = torch.float16)
64
+ model = PeftModel.from_pretrained(model, "Dorjzodovsuren/Mongolian_llama3")
65
+
66
+ #load tokenizer
67
+ tokenizer = AutoTokenizer.from_pretrained("Dorjzodovsuren/Mn_llama3")
68
+
69
+ alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
70
+
71
+ ### Instruction:
72
+ {}
73
+
74
+ ### Input:
75
+ {}
76
+
77
+ ### Response:
78
+ {}"""
79
+
80
+
81
+ # Enable native 2x faster inference
82
+ FastLanguageModel.for_inference(model)
83
+
84
+ # Create a text streamer
85
+ text_streamer = TextStreamer(tokenizer, skip_prompt=False,skip_special_tokens=True)
86
+
87
+ # Get the device based on GPU availability
88
+ device = 'cuda' if torch.cuda.is_available() else 'cpu'
89
+
90
+ # Move model into device
91
+ model = model.to(device)
92
+
93
+ class StopOnTokens(StoppingCriteria):
94
+ def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
95
+ stop_ids = [29, 0]
96
+ for stop_id in stop_ids:
97
+ if input_ids[0][-1] == stop_id:
98
+ return True
99
+ return False
100
+
101
+ # Current implementation does not support conversation based on previous conversation.
102
+ # Highly recommend to experiment on various hyper parameters to compare qualities.
103
+ def predict(message, history):
104
+ stop = StopOnTokens()
105
+ messages = alpaca_prompt.format(
106
+ message,
107
+ "",
108
+ "",
109
+ )
110
+
111
+ model_inputs = tokenizer([messages], return_tensors="pt").to(device)
112
+
113
+ streamer = TextIteratorStreamer(tokenizer, timeout=10., skip_prompt=True, skip_special_tokens=True)
114
+ generate_kwargs = dict(
115
+ model_inputs,
116
+ streamer=streamer,
117
+ max_new_tokens=1024,
118
+ top_p=0.95,
119
+ temperature=0.001,
120
+ repetition_penalty=1.1,
121
+ stopping_criteria=StoppingCriteriaList([stop])
122
+ )
123
+ t = Thread(target=model.generate, kwargs=generate_kwargs)
124
+ t.start()
125
+
126
+ partial_message = ""
127
+ for new_token in streamer:
128
+ if new_token != '<':
129
+ partial_message += new_token
130
+ yield partial_message
131
+
132
+ gr.ChatInterface(predict).launch(debug=True, share=True, show_api=True)
133
+ ```
134
+
135
+ https://colab.research.google.com/drive/1LC0xx4i9xqFmwn9l8T6vw25RIr-BP0Tq?usp=sharing