Update README.md
Browse filesinitial description details
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 |
-
-
|
21 |
-
|
22 |
-
|
23 |
-
|
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 |
-
|
47 |
|
48 |
-
|
49 |
|
50 |
-
|
51 |
|
52 |
-
|
53 |
|
54 |
-
|
55 |
|
56 |
-
|
57 |
|
58 |
-
|
|
|
|
|
59 |
|
60 |
-
|
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.
|
|
|
69 |
|
70 |
## How to Get Started with the Model
|
71 |
|
72 |
Use the code below to get started with the model.
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|