Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- README.md +214 -0
- mamba-gpt-3b-v2.Q4_0.gguf +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
mamba-gpt-3b-v2.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
library_name: transformers
|
5 |
+
tags:
|
6 |
+
- gpt
|
7 |
+
- llm
|
8 |
+
- large language model
|
9 |
+
inference: false
|
10 |
+
thumbnail: >-
|
11 |
+
https://h2o.ai/etc.clientlibs/h2o/clientlibs/clientlib-site/resources/images/favicon.ico
|
12 |
+
license: apache-2.0
|
13 |
+
---
|
14 |
+
# Model Card
|
15 |
+
|
16 |
+
**The Best 3B Model! Surpassing dolly-v2-12b**
|
17 |
+
|
18 |
+
The best 3B model on the [Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard), with performance surpassing dolly-v2-12b
|
19 |
+
|
20 |
+
| Metric | Value |
|
21 |
+
|-----------------------|-------|
|
22 |
+
| MMLU (5-shot) | 27.1 |
|
23 |
+
| ARC (25-shot) | 42.2 |
|
24 |
+
| HellaSwag (10-shot) | 71.5 |
|
25 |
+
| TruthfulQA (0-shot) | 36.7 |
|
26 |
+
| Avg. | 44.4 |
|
27 |
+
|
28 |
+
We use state-of-the-art [Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) to run the benchmark tests above.
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
## Summary
|
33 |
+
|
34 |
+
We have fine-tuned the open-lama model and surpassed the original model in multiple evaluation subtasks, making it currently the best performing 3B model with comparable performance to llama-7b
|
35 |
+
- Base model: [openlm-research/open_llama_3b_v2](https://huggingface.co/openlm-research/open_llama_3b_v2)
|
36 |
+
|
37 |
+
## Usage
|
38 |
+
|
39 |
+
To use the model with the `transformers` library on a machine with GPUs, first make sure you have the `transformers`, `accelerate` and `torch` libraries installed.
|
40 |
+
|
41 |
+
```bash
|
42 |
+
pip install transformers==4.29.2
|
43 |
+
pip install accelerate==0.19.0
|
44 |
+
pip install torch==2.0.0
|
45 |
+
```
|
46 |
+
|
47 |
+
```python
|
48 |
+
import torch
|
49 |
+
from transformers import pipeline
|
50 |
+
|
51 |
+
generate_text = pipeline(
|
52 |
+
model="CobraMamba/mamba-gpt-3b-v2",
|
53 |
+
torch_dtype="auto",
|
54 |
+
trust_remote_code=True,
|
55 |
+
use_fast=False,
|
56 |
+
device_map={"": "cuda:0"},
|
57 |
+
)
|
58 |
+
|
59 |
+
res = generate_text(
|
60 |
+
"Why is drinking water so healthy?",
|
61 |
+
min_new_tokens=2,
|
62 |
+
max_new_tokens=1024,
|
63 |
+
do_sample=False,
|
64 |
+
num_beams=1,
|
65 |
+
temperature=float(0.3),
|
66 |
+
repetition_penalty=float(1.2),
|
67 |
+
renormalize_logits=True
|
68 |
+
)
|
69 |
+
print(res[0]["generated_text"])
|
70 |
+
```
|
71 |
+
|
72 |
+
You can print a sample prompt after the preprocessing step to see how it is feed to the tokenizer:
|
73 |
+
|
74 |
+
```python
|
75 |
+
print(generate_text.preprocess("Why is drinking water so healthy?")["prompt_text"])
|
76 |
+
```
|
77 |
+
|
78 |
+
```bash
|
79 |
+
<|prompt|>Why is drinking water so healthy?</s><|answer|>
|
80 |
+
```
|
81 |
+
|
82 |
+
Alternatively, you can download the mamba_gpt_pipeline.py, store it alongside your notebook, and construct the pipeline yourself from the loaded model and tokenizer. If the model and the tokenizer are fully supported in the `transformers` package, this will allow you to set `trust_remote_code=False`.
|
83 |
+
|
84 |
+
```python
|
85 |
+
import torch
|
86 |
+
from mamba_gpt_pipeline import MambaGPTTextGenerationPipeline
|
87 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
88 |
+
|
89 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
90 |
+
"CobraMamba/mamba-gpt-3b-v2",
|
91 |
+
use_fast=False,
|
92 |
+
padding_side="left",
|
93 |
+
trust_remote_code=False,
|
94 |
+
)
|
95 |
+
model = AutoModelForCausalLM.from_pretrained(
|
96 |
+
"CobraMamba/mamba-gpt-3b-v2",
|
97 |
+
torch_dtype="auto",
|
98 |
+
device_map={"": "cuda:0"},
|
99 |
+
trust_remote_code=False,
|
100 |
+
)
|
101 |
+
generate_text = MambaGPTTextGenerationPipeline(model=model, tokenizer=tokenizer)
|
102 |
+
|
103 |
+
res = generate_text(
|
104 |
+
"Why is drinking water so healthy?",
|
105 |
+
min_new_tokens=2,
|
106 |
+
max_new_tokens=1024,
|
107 |
+
do_sample=False,
|
108 |
+
num_beams=1,
|
109 |
+
temperature=float(0.3),
|
110 |
+
repetition_penalty=float(1.2),
|
111 |
+
renormalize_logits=True
|
112 |
+
)
|
113 |
+
print(res[0]["generated_text"])
|
114 |
+
```
|
115 |
+
|
116 |
+
|
117 |
+
You may also construct the pipeline from the loaded model and tokenizer yourself and consider the preprocessing steps:
|
118 |
+
|
119 |
+
```python
|
120 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
121 |
+
|
122 |
+
model_name = "CobraMamba/mamba-gpt-3b-v2" # either local folder or huggingface model name
|
123 |
+
# Important: The prompt needs to be in the same format the model was trained with.
|
124 |
+
# You can find an example prompt in the experiment logs.
|
125 |
+
prompt = "<|prompt|>How are you?</s><|answer|>"
|
126 |
+
|
127 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
128 |
+
model_name,
|
129 |
+
use_fast=False,
|
130 |
+
trust_remote_code=False,
|
131 |
+
)
|
132 |
+
model = AutoModelForCausalLM.from_pretrained(
|
133 |
+
model_name,
|
134 |
+
torch_dtype="auto",
|
135 |
+
device_map={"": "cuda:0"},
|
136 |
+
trust_remote_code=False,
|
137 |
+
)
|
138 |
+
model.cuda().eval()
|
139 |
+
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to("cuda")
|
140 |
+
|
141 |
+
# generate configuration can be modified to your needs
|
142 |
+
tokens = model.generate(
|
143 |
+
**inputs,
|
144 |
+
min_new_tokens=2,
|
145 |
+
max_new_tokens=1024,
|
146 |
+
do_sample=False,
|
147 |
+
num_beams=1,
|
148 |
+
temperature=float(0.3),
|
149 |
+
repetition_penalty=float(1.2),
|
150 |
+
renormalize_logits=True
|
151 |
+
)[0]
|
152 |
+
|
153 |
+
tokens = tokens[inputs["input_ids"].shape[1]:]
|
154 |
+
answer = tokenizer.decode(tokens, skip_special_tokens=True)
|
155 |
+
print(answer)
|
156 |
+
```
|
157 |
+
|
158 |
+
## Model Architecture
|
159 |
+
|
160 |
+
```
|
161 |
+
LlamaForCausalLM(
|
162 |
+
(model): LlamaModel(
|
163 |
+
(embed_tokens): Embedding(32000, 4096, padding_idx=0)
|
164 |
+
(layers): ModuleList(
|
165 |
+
(0-31): 32 x LlamaDecoderLayer(
|
166 |
+
(self_attn): LlamaAttention(
|
167 |
+
(q_proj): Linear(in_features=4096, out_features=4096, bias=False)
|
168 |
+
(k_proj): Linear(in_features=4096, out_features=4096, bias=False)
|
169 |
+
(v_proj): Linear(in_features=4096, out_features=4096, bias=False)
|
170 |
+
(o_proj): Linear(in_features=4096, out_features=4096, bias=False)
|
171 |
+
(rotary_emb): LlamaRotaryEmbedding()
|
172 |
+
)
|
173 |
+
(mlp): LlamaMLP(
|
174 |
+
(gate_proj): Linear(in_features=4096, out_features=11008, bias=False)
|
175 |
+
(down_proj): Linear(in_features=11008, out_features=4096, bias=False)
|
176 |
+
(up_proj): Linear(in_features=4096, out_features=11008, bias=False)
|
177 |
+
(act_fn): SiLUActivation()
|
178 |
+
)
|
179 |
+
(input_layernorm): LlamaRMSNorm()
|
180 |
+
(post_attention_layernorm): LlamaRMSNorm()
|
181 |
+
)
|
182 |
+
)
|
183 |
+
(norm): LlamaRMSNorm()
|
184 |
+
)
|
185 |
+
(lm_head): Linear(in_features=4096, out_features=32000, bias=False)
|
186 |
+
)
|
187 |
+
```
|
188 |
+
|
189 |
+
## Citation
|
190 |
+
|
191 |
+
If this work is helpful, please kindly cite as:
|
192 |
+
|
193 |
+
```bibtex
|
194 |
+
@Misc{mamba-gpt-3b-v2,
|
195 |
+
title = {Mamba-GPT-3b-v2},
|
196 |
+
author = {chiliu},
|
197 |
+
howpublished = {\url{https://huggingface.co/CobraMamba/mamba-gpt-3b-v2}},
|
198 |
+
year = {2023}
|
199 |
+
}
|
200 |
+
```
|
201 |
+
|
202 |
+
|
203 |
+
## Disclaimer
|
204 |
+
|
205 |
+
Please read this disclaimer carefully before using the large language model provided in this repository. Your use of the model signifies your agreement to the following terms and conditions.
|
206 |
+
|
207 |
+
- Biases and Offensiveness: The large language model is trained on a diverse range of internet text data, which may contain biased, racist, offensive, or otherwise inappropriate content. By using this model, you acknowledge and accept that the generated content may sometimes exhibit biases or produce content that is offensive or inappropriate. The developers of this repository do not endorse, support, or promote any such content or viewpoints.
|
208 |
+
- Limitations: The large language model is an AI-based tool and not a human. It may produce incorrect, nonsensical, or irrelevant responses. It is the user's responsibility to critically evaluate the generated content and use it at their discretion.
|
209 |
+
- Use at Your Own Risk: Users of this large language model must assume full responsibility for any consequences that may arise from their use of the tool. The developers and contributors of this repository shall not be held liable for any damages, losses, or harm resulting from the use or misuse of the provided model.
|
210 |
+
- Ethical Considerations: Users are encouraged to use the large language model responsibly and ethically. By using this model, you agree not to use it for purposes that promote hate speech, discrimination, harassment, or any form of illegal or harmful activities.
|
211 |
+
- Reporting Issues: If you encounter any biased, offensive, or otherwise inappropriate content generated by the large language model, please report it to the repository maintainers through the provided channels. Your feedback will help improve the model and mitigate potential issues.
|
212 |
+
- Changes to this Disclaimer: The developers of this repository reserve the right to modify or update this disclaimer at any time without prior notice. It is the user's responsibility to periodically review the disclaimer to stay informed about any changes.
|
213 |
+
|
214 |
+
By using the large language model provided in this repository, you agree to accept and comply with the terms and conditions outlined in this disclaimer. If you do not agree with any part of this disclaimer, you should refrain from using the model and any content generated by it.
|
mamba-gpt-3b-v2.Q4_0.gguf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:994ec2ae37aae6db6e35d9cb93522e25b3abb1b0279ed0477acb575e37e9e882
|
3 |
+
size 1979924704
|