Upload folder using huggingface_hub
Browse files- .gitattributes +2 -0
- README.md +443 -0
- config.json +27 -0
- examples/example_fsdp.py +62 -0
- examples/example_sft_qlora.py +146 -0
- examples/notebook_sft_peft.ipynb +729 -0
- generation_config.json +7 -0
- model-00001-of-00004.safetensors +3 -0
- model-00002-of-00004.safetensors +3 -0
- model-00003-of-00004.safetensors +3 -0
- model-00004-of-00004.safetensors +3 -0
- model.safetensors.index.json +261 -0
- special_tokens_map.json +30 -0
- tokenizer.json +3 -0
- tokenizer.model +3 -0
- tokenizer_config.json +49 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ 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 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
gemma-7b.gguf filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,443 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
tags: []
|
| 4 |
+
extra_gated_heading: "Access Gemma on Hugging Face"
|
| 5 |
+
extra_gated_prompt: "To access Gemma on Hugging Face, you’re required to review and agree to Google’s usage license. To do this, please ensure you’re logged-in to Hugging Face and click below. Requests are processed immediately."
|
| 6 |
+
extra_gated_button_content: "Acknowledge license"
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
# Gemma Model Card
|
| 10 |
+
|
| 11 |
+
**Model Page**: [Gemma](https://ai.google.dev/gemma/docs)
|
| 12 |
+
|
| 13 |
+
This model card corresponds to the 7B base version of the Gemma model. You can also visit the model card of the [2B base model](https://huggingface.co/google/gemma-2b), [7B instruct model](https://huggingface.co/google/gemma-7b-it), and [2B instruct model](https://huggingface.co/google/gemma-2b-it).
|
| 14 |
+
|
| 15 |
+
**Resources and Technical Documentation**:
|
| 16 |
+
|
| 17 |
+
* [Responsible Generative AI Toolkit](https://ai.google.dev/responsible)
|
| 18 |
+
* [Gemma on Kaggle](https://www.kaggle.com/models/google/gemma)
|
| 19 |
+
* [Gemma on Vertex Model Garden](https://console.cloud.google.com/vertex-ai/publishers/google/model-garden/335)
|
| 20 |
+
|
| 21 |
+
**Terms of Use**: [Terms](https://www.kaggle.com/models/google/gemma/license/consent)
|
| 22 |
+
|
| 23 |
+
**Authors**: Google
|
| 24 |
+
|
| 25 |
+
## Model Information
|
| 26 |
+
|
| 27 |
+
Summary description and brief definition of inputs and outputs.
|
| 28 |
+
|
| 29 |
+
### Description
|
| 30 |
+
|
| 31 |
+
Gemma is a family of lightweight, state-of-the-art open models from Google,
|
| 32 |
+
built from the same research and technology used to create the Gemini models.
|
| 33 |
+
They are text-to-text, decoder-only large language models, available in English,
|
| 34 |
+
with open weights, pre-trained variants, and instruction-tuned variants. Gemma
|
| 35 |
+
models are well-suited for a variety of text generation tasks, including
|
| 36 |
+
question answering, summarization, and reasoning. Their relatively small size
|
| 37 |
+
makes it possible to deploy them in environments with limited resources such as
|
| 38 |
+
a laptop, desktop or your own cloud infrastructure, democratizing access to
|
| 39 |
+
state of the art AI models and helping foster innovation for everyone.
|
| 40 |
+
|
| 41 |
+
### Usage
|
| 42 |
+
|
| 43 |
+
Below we share some code snippets on how to get quickly started with running the model. First make sure to `pip install -U transformers`, then copy the snippet from the section that is relevant for your usecase.
|
| 44 |
+
|
| 45 |
+
#### Fine-tuning examples
|
| 46 |
+
|
| 47 |
+
You can find fine-tuning notebooks under the [`examples/` directory](https://huggingface.co/google/gemma-7b/tree/main/examples). We provide:
|
| 48 |
+
|
| 49 |
+
* A script to perform Supervised Fine-Tuning (SFT) on UltraChat dataset using [QLoRA](https://huggingface.co/papers/2305.14314)
|
| 50 |
+
* A script to perform SFT using FSDP on TPU devices
|
| 51 |
+
* A notebook that you can run on a free-tier Google Colab instance to perform SFT on English quotes dataset
|
| 52 |
+
|
| 53 |
+
#### Running the model on a CPU
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
```python
|
| 57 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 58 |
+
|
| 59 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-7b")
|
| 60 |
+
model = AutoModelForCausalLM.from_pretrained("google/gemma-7b")
|
| 61 |
+
|
| 62 |
+
input_text = "Write me a poem about Machine Learning."
|
| 63 |
+
input_ids = tokenizer(**input_text, return_tensors="pt")
|
| 64 |
+
|
| 65 |
+
outputs = model.generate(input_ids)
|
| 66 |
+
print(tokenizer.decode(outputs[0]))
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
#### Running the model on a single / multi GPU
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
```python
|
| 74 |
+
# pip install accelerate
|
| 75 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 76 |
+
|
| 77 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-7b")
|
| 78 |
+
model = AutoModelForCausalLM.from_pretrained("google/gemma-7b", device_map="auto")
|
| 79 |
+
|
| 80 |
+
input_text = "Write me a poem about Machine Learning."
|
| 81 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
| 82 |
+
|
| 83 |
+
outputs = model.generate(**input_ids)
|
| 84 |
+
print(tokenizer.decode(outputs[0]))
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
#### Running the model on a GPU using different precisions
|
| 89 |
+
|
| 90 |
+
* _Using `torch.float16`_
|
| 91 |
+
|
| 92 |
+
```python
|
| 93 |
+
# pip install accelerate
|
| 94 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 95 |
+
|
| 96 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-7b")
|
| 97 |
+
model = AutoModelForCausalLM.from_pretrained("google/gemma-7b", device_map="auto", torch_dtype=torch.float16)
|
| 98 |
+
|
| 99 |
+
input_text = "Write me a poem about Machine Learning."
|
| 100 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
| 101 |
+
|
| 102 |
+
outputs = model.generate(**input_ids)
|
| 103 |
+
print(tokenizer.decode(outputs[0]))
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
* _Using `torch.bfloat16`_
|
| 107 |
+
|
| 108 |
+
```python
|
| 109 |
+
# pip install accelerate
|
| 110 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 111 |
+
|
| 112 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-7b")
|
| 113 |
+
model = AutoModelForCausalLM.from_pretrained("google/gemma-7b", device_map="auto", torch_dtype=torch.bfloat16)
|
| 114 |
+
|
| 115 |
+
input_text = "Write me a poem about Machine Learning."
|
| 116 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
| 117 |
+
|
| 118 |
+
outputs = model.generate(**input_ids)
|
| 119 |
+
print(tokenizer.decode(outputs[0]))
|
| 120 |
+
```
|
| 121 |
+
|
| 122 |
+
#### Quantized Versions through `bitsandbytes`
|
| 123 |
+
|
| 124 |
+
* _Using 8-bit precision (int8)_
|
| 125 |
+
|
| 126 |
+
```python
|
| 127 |
+
# pip install bitsandbytes accelerate
|
| 128 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
| 129 |
+
|
| 130 |
+
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
|
| 131 |
+
|
| 132 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-7b")
|
| 133 |
+
model = AutoModelForCausalLM.from_pretrained(google/gemma-7b", quantization_config=quantization_config)
|
| 134 |
+
|
| 135 |
+
input_text = "Write me a poem about Machine Learning."
|
| 136 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
| 137 |
+
|
| 138 |
+
outputs = model.generate(**input_ids)
|
| 139 |
+
print(tokenizer.decode(outputs[0]))
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
* _Using 4-bit precision_
|
| 143 |
+
|
| 144 |
+
```python
|
| 145 |
+
# pip install bitsandbytes accelerate
|
| 146 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
| 147 |
+
|
| 148 |
+
quantization_config = BitsAndBytesConfig(load_in_4bit=True)
|
| 149 |
+
|
| 150 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-7b")
|
| 151 |
+
model = AutoModelForCausalLM.from_pretrained("google/gemma-7b", quantization_config=quantization_config)
|
| 152 |
+
|
| 153 |
+
input_text = "Write me a poem about Machine Learning."
|
| 154 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
| 155 |
+
|
| 156 |
+
outputs = model.generate(**input_ids)
|
| 157 |
+
print(tokenizer.decode(outputs[0]))
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
#### Other optimizations
|
| 162 |
+
|
| 163 |
+
* _Flash Attention 2_
|
| 164 |
+
|
| 165 |
+
First make sure to install `flash-attn` in your environment `pip install flash-attn`
|
| 166 |
+
|
| 167 |
+
```diff
|
| 168 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 169 |
+
model_id,
|
| 170 |
+
torch_dtype=torch.float16,
|
| 171 |
+
+ attn_implementation="flash_attention_2"
|
| 172 |
+
).to(0)
|
| 173 |
+
```
|
| 174 |
+
|
| 175 |
+
### Inputs and outputs
|
| 176 |
+
|
| 177 |
+
* **Input:** Text string, such as a question, a prompt, or a document to be
|
| 178 |
+
summarized.
|
| 179 |
+
* **Output:** Generated English-language text in response to the input, such
|
| 180 |
+
as an answer to a question, or a summary of a document.
|
| 181 |
+
|
| 182 |
+
## Model Data
|
| 183 |
+
|
| 184 |
+
Data used for model training and how the data was processed.
|
| 185 |
+
|
| 186 |
+
### Training Dataset
|
| 187 |
+
|
| 188 |
+
These models were trained on a dataset of text data that includes a wide variety
|
| 189 |
+
of sources, totaling 6 trillion tokens. Here are the key components:
|
| 190 |
+
|
| 191 |
+
* Web Documents: A diverse collection of web text ensures the model is exposed
|
| 192 |
+
to a broad range of linguistic styles, topics, and vocabulary. Primarily
|
| 193 |
+
English-language content.
|
| 194 |
+
* Code: Exposing the model to code helps it to learn the syntax and patterns of
|
| 195 |
+
programming languages, which improves its ability to generate code or
|
| 196 |
+
understand code-related questions.
|
| 197 |
+
* Mathematics: Training on mathematical text helps the model learn logical
|
| 198 |
+
reasoning, symbolic representation, and to address mathematical queries.
|
| 199 |
+
|
| 200 |
+
The combination of these diverse data sources is crucial for training a powerful
|
| 201 |
+
language model that can handle a wide variety of different tasks and text
|
| 202 |
+
formats.
|
| 203 |
+
|
| 204 |
+
### Data Preprocessing
|
| 205 |
+
|
| 206 |
+
Here are the key data cleaning and filtering methods applied to the training
|
| 207 |
+
data:
|
| 208 |
+
|
| 209 |
+
* CSAM Filtering: Rigorous CSAM (Child Sexual Abuse Material) filtering was
|
| 210 |
+
applied at multiple stages in the data preparation process to ensure the
|
| 211 |
+
exclusion of harmful and illegal content
|
| 212 |
+
* Sensitive Data Filtering: As part of making Gemma pre-trained models safe and
|
| 213 |
+
reliable, automated techniques were used to filter out certain personal
|
| 214 |
+
information and other sensitive data from training sets.
|
| 215 |
+
* Additional methods: Filtering based on content quality and safely in line with
|
| 216 |
+
[our policies](https://storage.googleapis.com/gweb-uniblog-publish-prod/documents/2023_Google_AI_Principles_Progress_Update.pdf#page=11).
|
| 217 |
+
|
| 218 |
+
## Implementation Information
|
| 219 |
+
|
| 220 |
+
Details about the model internals.
|
| 221 |
+
|
| 222 |
+
### Hardware
|
| 223 |
+
|
| 224 |
+
Gemma was trained using the latest generation of
|
| 225 |
+
[Tensor Processing Unit (TPU)](https://cloud.google.com/tpu/docs/intro-to-tpu) hardware (TPUv5e).
|
| 226 |
+
|
| 227 |
+
Training large language models requires significant computational power. TPUs,
|
| 228 |
+
designed specifically for matrix operations common in machine learning, offer
|
| 229 |
+
several advantages in this domain:
|
| 230 |
+
|
| 231 |
+
* Performance: TPUs are specifically designed to handle the massive computations
|
| 232 |
+
involved in training LLMs. They can speed up training considerably compared to
|
| 233 |
+
CPUs.
|
| 234 |
+
* Memory: TPUs often come with large amounts of high-bandwidth memory, allowing
|
| 235 |
+
for the handling of large models and batch sizes during training. This can
|
| 236 |
+
lead to better model quality.
|
| 237 |
+
* Scalability: TPU Pods (large clusters of TPUs) provide a scalable solution for
|
| 238 |
+
handling the growing complexity of large foundation models. You can distribute
|
| 239 |
+
training across multiple TPU devices for faster and more efficient processing.
|
| 240 |
+
* Cost-effectiveness: In many scenarios, TPUs can provide a more cost-effective
|
| 241 |
+
solution for training large models compared to CPU-based infrastructure,
|
| 242 |
+
especially when considering the time and resources saved due to faster
|
| 243 |
+
training.
|
| 244 |
+
* These advantages are aligned with
|
| 245 |
+
[Google's commitments to operate sustainably](https://sustainability.google/operating-sustainably/).
|
| 246 |
+
|
| 247 |
+
### Software
|
| 248 |
+
|
| 249 |
+
Training was done using [JAX](https://github.com/google/jax) and [ML Pathways](https://blog.google/technology/ai/introducing-pathways-next-generation-ai-architecture/ml-pathways).
|
| 250 |
+
|
| 251 |
+
JAX allows researchers to take advantage of the latest generation of hardware,
|
| 252 |
+
including TPUs, for faster and more efficient training of large models.
|
| 253 |
+
|
| 254 |
+
ML Pathways is Google's latest effort to build artificially intelligent systems
|
| 255 |
+
capable of generalizing across multiple tasks. This is specially suitable for
|
| 256 |
+
[foundation models](https://ai.google/discover/foundation-models/), including large language models like
|
| 257 |
+
these ones.
|
| 258 |
+
|
| 259 |
+
Together, JAX and ML Pathways are used as described in the
|
| 260 |
+
[paper about the Gemini family of models](https://arxiv.org/abs/2312.11805); "the 'single
|
| 261 |
+
controller' programming model of Jax and Pathways allows a single Python
|
| 262 |
+
process to orchestrate the entire training run, dramatically simplifying the
|
| 263 |
+
development workflow."
|
| 264 |
+
|
| 265 |
+
## Evaluation
|
| 266 |
+
|
| 267 |
+
Model evaluation metrics and results.
|
| 268 |
+
|
| 269 |
+
### Benchmark Results
|
| 270 |
+
|
| 271 |
+
These models were evaluated against a large collection of different datasets and
|
| 272 |
+
metrics to cover different aspects of text generation:
|
| 273 |
+
|
| 274 |
+
| Benchmark | Metric | 2B Params | 7B Params |
|
| 275 |
+
| ------------------------------ | ------------- | ----------- | --------- |
|
| 276 |
+
| [MMLU](https://arxiv.org/abs/2009.03300) | 5-shot, top-1 | 42.3 | 64.3 |
|
| 277 |
+
| [HellaSwag](https://arxiv.org/abs/1905.07830) | 0-shot |71.4 | 81.2 |
|
| 278 |
+
| [PIQA](https://arxiv.org/abs/1911.11641) | 0-shot | 77.3 | 81.2 |
|
| 279 |
+
| [SocialIQA](https://arxiv.org/abs/1904.09728) | 0-shot | 59.7 | 51.8 |
|
| 280 |
+
| [BooIQ](https://arxiv.org/abs/1905.10044) | 0-shot | 69.4 | 83.2 |
|
| 281 |
+
| [WinoGrande](https://arxiv.org/abs/1907.10641) | partial score | 65.4 | 72.3 |
|
| 282 |
+
| [CommonsenseQA](https://arxiv.org/abs/1811.00937) | 7-shot | 65.3 | 71.3 |
|
| 283 |
+
| [OpenBookQA](https://arxiv.org/abs/1809.02789) | | 47.8 | 52.8 |
|
| 284 |
+
| [ARC-e](https://arxiv.org/abs/1911.01547) | | 73.2 | 81.5 |
|
| 285 |
+
| [ARC-c](https://arxiv.org/abs/1911.01547) | | 42.1 | 53.2 |
|
| 286 |
+
| [TriviaQA](https://arxiv.org/abs/1705.03551) | 5-shot | 53.2 | 63.4 |
|
| 287 |
+
| [Natural Questions](https://github.com/google-research-datasets/natural-questions) | 5-shot | - | 23 |
|
| 288 |
+
| [HumanEval](https://arxiv.org/abs/2107.03374) | pass@1 | 22.0 | 32.3 |
|
| 289 |
+
| [MBPP](https://arxiv.org/abs/2108.07732) | 3-shot | 29.2 | 44.4 |
|
| 290 |
+
| [GSM8K](https://arxiv.org/abs/2110.14168) | maj@1 | 17.7 | 46.4 |
|
| 291 |
+
| [MATH](https://arxiv.org/abs/2108.07732) | 4-shot | 11.8 | 24.3 |
|
| 292 |
+
| [AGIEval](https://arxiv.org/abs/2304.06364) | | 24.2 | 41.7 |
|
| 293 |
+
| [BIG-Bench](https://arxiv.org/abs/2206.04615) | | 35.2 | 55.1 |
|
| 294 |
+
| ------------------------------ | ------------- | ----------- | --------- |
|
| 295 |
+
| **Average** | | **54.0** | **56.4** |
|
| 296 |
+
|
| 297 |
+
## Ethics and Safety
|
| 298 |
+
|
| 299 |
+
Ethics and safety evaluation approach and results.
|
| 300 |
+
|
| 301 |
+
### Evaluation Approach
|
| 302 |
+
|
| 303 |
+
Our evaluation methods include structured evaluations and internal red-teaming
|
| 304 |
+
testing of relevant content policies. Red-teaming was conducted by a number of
|
| 305 |
+
different teams, each with different goals and human evaluation metrics. These
|
| 306 |
+
models were evaluated against a number of different categories relevant to
|
| 307 |
+
ethics and safety, including:
|
| 308 |
+
|
| 309 |
+
* Text-to-Text Content Safety: Human evaluation on prompts covering safety
|
| 310 |
+
policies including child sexual abuse and exploitation, harassment, violence
|
| 311 |
+
and gore, and hate speech.
|
| 312 |
+
* Text-to-Text Representational Harms: Benchmark against relevant academic
|
| 313 |
+
datasets such as [WinoBias](https://arxiv.org/abs/1804.06876) and [BBQ Dataset](https://arxiv.org/abs/2110.08193v2).
|
| 314 |
+
* Memorization: Automated evaluation of memorization of training data, including
|
| 315 |
+
the risk of personally identifiable information exposure.
|
| 316 |
+
* Large-scale harm: Tests for "dangerous capabilities," such as chemical,
|
| 317 |
+
biological, radiological, and nuclear (CBRN) risks.
|
| 318 |
+
|
| 319 |
+
### Evaluation Results
|
| 320 |
+
|
| 321 |
+
The results of ethics and safety evaluations are within acceptable thresholds
|
| 322 |
+
for meeting [internal policies](https://storage.googleapis.com/gweb-uniblog-publish-prod/documents/2023_Google_AI_Principles_Progress_Update.pdf#page=11) for categories such as child
|
| 323 |
+
safety, content safety, representational harms, memorization, large-scale harms.
|
| 324 |
+
On top of robust internal evaluations, the results of well known safety
|
| 325 |
+
benchmarks like BBQ, BOLD, Winogender, Winobias, RealToxicity, and TruthfulQA
|
| 326 |
+
are shown here.
|
| 327 |
+
|
| 328 |
+
| Benchmark | Metric | 2B Params | 7B Params |
|
| 329 |
+
| ------------------------------ | ------------- | ----------- | --------- |
|
| 330 |
+
| [RealToxicity](https://arxiv.org/abs/2009.11462) | average | 6.86 | 7.90 |
|
| 331 |
+
| [BOLD](https://arxiv.org/abs/2101.11718) | | 45.57 | 49.08 |
|
| 332 |
+
| [CrowS-Pairs](https://aclanthology.org/2020.emnlp-main.154/) | top-1 | 45.82 | 51.33 |
|
| 333 |
+
| [BBQ Ambig](https://arxiv.org/abs/2110.08193v2) | 1-shot, top-1 | 62.58 | 92.54 |
|
| 334 |
+
| [BBQ Disambig](https://arxiv.org/abs/2110.08193v2) | top-1 | 54.62 | 71.99 |
|
| 335 |
+
| [Winogender](https://arxiv.org/abs/1804.09301) | top-1 | 51.25 | 54.17 |
|
| 336 |
+
| [TruthfulQA](https://arxiv.org/abs/2109.07958) | | 44.84 | 31.81 |
|
| 337 |
+
| [Winobias 1_2](https://arxiv.org/abs/1804.06876) | | 56.12 | 59.09 |
|
| 338 |
+
| [Winobias 2_2](https://arxiv.org/abs/1804.06876) | | 91.10 | 92.23 |
|
| 339 |
+
| [Toxigen](https://arxiv.org/abs/2203.09509) | | 29.77 | 39.59 |
|
| 340 |
+
| ------------------------------ | ------------- | ----------- | --------- |
|
| 341 |
+
|
| 342 |
+
|
| 343 |
+
## Usage and Limitations
|
| 344 |
+
|
| 345 |
+
These models have certain limitations that users should be aware of.
|
| 346 |
+
|
| 347 |
+
### Intended Usage
|
| 348 |
+
|
| 349 |
+
Open Large Language Models (LLMs) have a wide range of applications across
|
| 350 |
+
various industries and domains. The following list of potential uses is not
|
| 351 |
+
comprehensive. The purpose of this list is to provide contextual information
|
| 352 |
+
about the possible use-cases that the model creators considered as part of model
|
| 353 |
+
training and development.
|
| 354 |
+
|
| 355 |
+
* Content Creation and Communication
|
| 356 |
+
* Text Generation: These models can be used to generate creative text formats
|
| 357 |
+
such as poems, scripts, code, marketing copy, and email drafts.
|
| 358 |
+
* Chatbots and Conversational AI: Power conversational interfaces for customer
|
| 359 |
+
service, virtual assistants, or interactive applications.
|
| 360 |
+
* Text Summarization: Generate concise summaries of a text corpus, research
|
| 361 |
+
papers, or reports.
|
| 362 |
+
* Research and Education
|
| 363 |
+
* Natural Language Processing (NLP) Research: These models can serve as a
|
| 364 |
+
foundation for researchers to experiment with NLP techniques, develop
|
| 365 |
+
algorithms, and contribute to the advancement of the field.
|
| 366 |
+
* Language Learning Tools: Support interactive language learning experiences,
|
| 367 |
+
aiding in grammar correction or providing writing practice.
|
| 368 |
+
* Knowledge Exploration: Assist researchers in exploring large bodies of text
|
| 369 |
+
by generating summaries or answering questions about specific topics.
|
| 370 |
+
|
| 371 |
+
### Limitations
|
| 372 |
+
|
| 373 |
+
* Training Data
|
| 374 |
+
* The quality and diversity of the training data significantly influence the
|
| 375 |
+
model's capabilities. Biases or gaps in the training data can lead to
|
| 376 |
+
limitations in the model's responses.
|
| 377 |
+
* The scope of the training dataset determines the subject areas the model can
|
| 378 |
+
handle effectively.
|
| 379 |
+
* Context and Task Complexity
|
| 380 |
+
* LLMs are better at tasks that can be framed with clear prompts and
|
| 381 |
+
instructions. Open-ended or highly complex tasks might be challenging.
|
| 382 |
+
* A model's performance can be influenced by the amount of context provided
|
| 383 |
+
(longer context generally leads to better outputs, up to a certain point).
|
| 384 |
+
* Language Ambiguity and Nuance
|
| 385 |
+
* Natural language is inherently complex. LLMs might struggle to grasp subtle
|
| 386 |
+
nuances, sarcasm, or figurative language.
|
| 387 |
+
* Factual Accuracy
|
| 388 |
+
* LLMs generate responses based on information they learned from their
|
| 389 |
+
training datasets, but they are not knowledge bases. They may generate
|
| 390 |
+
incorrect or outdated factual statements.
|
| 391 |
+
* Common Sense
|
| 392 |
+
* LLMs rely on statistical patterns in language. They might lack the ability
|
| 393 |
+
to apply common sense reasoning in certain situations.
|
| 394 |
+
|
| 395 |
+
### Ethical Considerations and Risks
|
| 396 |
+
|
| 397 |
+
The development of large language models (LLMs) raises several ethical concerns.
|
| 398 |
+
In creating an open model, we have carefully considered the following:
|
| 399 |
+
|
| 400 |
+
* Bias and Fairness
|
| 401 |
+
* LLMs trained on large-scale, real-world text data can reflect socio-cultural
|
| 402 |
+
biases embedded in the training material. These models underwent careful
|
| 403 |
+
scrutiny, input data pre-processing described and posterior evaluations
|
| 404 |
+
reported in this card.
|
| 405 |
+
* Misinformation and Misuse
|
| 406 |
+
* LLMs can be misused to generate text that is false, misleading, or harmful.
|
| 407 |
+
* Guidelines are provided for responsible use with the model, see the
|
| 408 |
+
[Responsible Generative AI Toolkit](http://ai.google.dev/gemma/responsible).
|
| 409 |
+
* Transparency and Accountability:
|
| 410 |
+
* This model card summarizes details on the models' architecture,
|
| 411 |
+
capabilities, limitations, and evaluation processes.
|
| 412 |
+
* A responsibly developed open model offers the opportunity to share
|
| 413 |
+
innovation by making LLM technology accessible to developers and researchers
|
| 414 |
+
across the AI ecosystem.
|
| 415 |
+
|
| 416 |
+
Risks identified and mitigations:
|
| 417 |
+
|
| 418 |
+
* Perpetuation of biases: It's encouraged to perform continuous monitoring
|
| 419 |
+
(using evaluation metrics, human review) and the exploration of de-biasing
|
| 420 |
+
techniques during model training, fine-tuning, and other use cases.
|
| 421 |
+
* Generation of harmful content: Mechanisms and guidelines for content safety
|
| 422 |
+
are essential. Developers are encouraged to exercise caution and implement
|
| 423 |
+
appropriate content safety safeguards based on their specific product policies
|
| 424 |
+
and application use cases.
|
| 425 |
+
* Misuse for malicious purposes: Technical limitations and developer and
|
| 426 |
+
end-user education can help mitigate against malicious applications of LLMs.
|
| 427 |
+
Educational resources and reporting mechanisms for users to flag misuse are
|
| 428 |
+
provided. Prohibited uses of Gemma models are outlined in the
|
| 429 |
+
[Gemma Prohibited Use Policy](https://ai.google.dev/gemma/prohibited_use_policy).
|
| 430 |
+
* Privacy violations: Models were trained on data filtered for removal of PII
|
| 431 |
+
(Personally Identifiable Information). Developers are encouraged to adhere to
|
| 432 |
+
privacy regulations with privacy-preserving techniques.
|
| 433 |
+
|
| 434 |
+
### Benefits
|
| 435 |
+
|
| 436 |
+
At the time of release, this family of models provides high-performance open
|
| 437 |
+
large language model implementations designed from the ground up for Responsible
|
| 438 |
+
AI development compared to similarly sized models.
|
| 439 |
+
|
| 440 |
+
Using the benchmark evaluation metrics described in this document, these models
|
| 441 |
+
have shown to provide superior performance to other, comparably-sized open model
|
| 442 |
+
alternatives.
|
| 443 |
+
|
config.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"GemmaForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 2,
|
| 8 |
+
"eos_token_id": 1,
|
| 9 |
+
"head_dim": 256,
|
| 10 |
+
"hidden_act": "gelu",
|
| 11 |
+
"hidden_size": 3072,
|
| 12 |
+
"initializer_range": 0.02,
|
| 13 |
+
"intermediate_size": 24576,
|
| 14 |
+
"max_position_embeddings": 8192,
|
| 15 |
+
"model_type": "gemma",
|
| 16 |
+
"num_attention_heads": 16,
|
| 17 |
+
"num_hidden_layers": 28,
|
| 18 |
+
"num_key_value_heads": 16,
|
| 19 |
+
"pad_token_id": 0,
|
| 20 |
+
"rms_norm_eps": 1e-06,
|
| 21 |
+
"rope_scaling": null,
|
| 22 |
+
"rope_theta": 10000.0,
|
| 23 |
+
"torch_dtype": "bfloat16",
|
| 24 |
+
"transformers_version": "4.38.0.dev0",
|
| 25 |
+
"use_cache": true,
|
| 26 |
+
"vocab_size": 256000
|
| 27 |
+
}
|
examples/example_fsdp.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Make sure to run the script with the following envs:
|
| 2 |
+
# PJRT_DEVICE=TPU XLA_USE_SPMD=1
|
| 3 |
+
|
| 4 |
+
import torch
|
| 5 |
+
import torch_xla
|
| 6 |
+
|
| 7 |
+
import torch_xla.core.xla_model as xm
|
| 8 |
+
|
| 9 |
+
from datasets import load_dataset
|
| 10 |
+
from peft import LoraConfig, get_peft_model
|
| 11 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, TrainingArguments
|
| 12 |
+
from trl import SFTTrainer
|
| 13 |
+
|
| 14 |
+
# Set up TPU device.
|
| 15 |
+
device = xm.xla_device()
|
| 16 |
+
model_id = "google/gemma-7b"
|
| 17 |
+
|
| 18 |
+
# Load the pretrained model and tokenizer.
|
| 19 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 20 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16)
|
| 21 |
+
|
| 22 |
+
# Set up PEFT LoRA for fine-tuning.
|
| 23 |
+
lora_config = LoraConfig(
|
| 24 |
+
r=8,
|
| 25 |
+
target_modules=["k_proj", "v_proj"],
|
| 26 |
+
task_type="CAUSAL_LM",
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
# Load the dataset and format it for training.
|
| 30 |
+
data = load_dataset("Abirate/english_quotes", split="train")
|
| 31 |
+
max_seq_length = 1024
|
| 32 |
+
|
| 33 |
+
# Set up the FSDP config. To enable FSDP via SPMD, set xla_fsdp_v2 to True.
|
| 34 |
+
fsdp_config = {"fsdp_transformer_layer_cls_to_wrap": [
|
| 35 |
+
"GemmaDecoderLayer"
|
| 36 |
+
],
|
| 37 |
+
"xla": True,
|
| 38 |
+
"xla_fsdp_v2": True,
|
| 39 |
+
"xla_fsdp_grad_ckpt": True}
|
| 40 |
+
|
| 41 |
+
# Finally, set up the trainer and train the model.
|
| 42 |
+
trainer = SFTTrainer(
|
| 43 |
+
model=model,
|
| 44 |
+
train_dataset=data,
|
| 45 |
+
args=TrainingArguments(
|
| 46 |
+
per_device_train_batch_size=64, # This is actually the global batch size for SPMD.
|
| 47 |
+
num_train_epochs=100,
|
| 48 |
+
max_steps=-1,
|
| 49 |
+
output_dir="./output",
|
| 50 |
+
optim="adafactor",
|
| 51 |
+
logging_steps=1,
|
| 52 |
+
dataloader_drop_last = True, # Required for SPMD.
|
| 53 |
+
fsdp="full_shard",
|
| 54 |
+
fsdp_config=fsdp_config,
|
| 55 |
+
),
|
| 56 |
+
peft_config=lora_config,
|
| 57 |
+
dataset_text_field="quote",
|
| 58 |
+
max_seq_length=max_seq_length,
|
| 59 |
+
packing=True,
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
trainer.train()
|
examples/example_sft_qlora.py
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dataclasses import dataclass, field
|
| 2 |
+
from typing import Optional
|
| 3 |
+
|
| 4 |
+
import torch
|
| 5 |
+
|
| 6 |
+
from transformers import AutoTokenizer, HfArgumentParser, AutoModelForCausalLM, BitsAndBytesConfig, TrainingArguments
|
| 7 |
+
from datasets import load_dataset
|
| 8 |
+
from peft import LoraConfig
|
| 9 |
+
from trl import SFTTrainer
|
| 10 |
+
|
| 11 |
+
@dataclass
|
| 12 |
+
class ScriptArguments:
|
| 13 |
+
"""
|
| 14 |
+
These arguments vary depending on how many GPUs you have, what their capacity and features are, and what size model you want to train.
|
| 15 |
+
"""
|
| 16 |
+
per_device_train_batch_size: Optional[int] = field(default=4)
|
| 17 |
+
per_device_eval_batch_size: Optional[int] = field(default=1)
|
| 18 |
+
gradient_accumulation_steps: Optional[int] = field(default=4)
|
| 19 |
+
learning_rate: Optional[float] = field(default=2e-4)
|
| 20 |
+
max_grad_norm: Optional[float] = field(default=0.3)
|
| 21 |
+
weight_decay: Optional[int] = field(default=0.001)
|
| 22 |
+
lora_alpha: Optional[int] = field(default=16)
|
| 23 |
+
lora_dropout: Optional[float] = field(default=0.1)
|
| 24 |
+
lora_r: Optional[int] = field(default=8)
|
| 25 |
+
max_seq_length: Optional[int] = field(default=2048)
|
| 26 |
+
model_name: Optional[str] = field(
|
| 27 |
+
default=None,
|
| 28 |
+
metadata={
|
| 29 |
+
"help": "The model that you want to train from the Hugging Face hub. E.g. gpt2, gpt2-xl, bert, etc."
|
| 30 |
+
}
|
| 31 |
+
)
|
| 32 |
+
dataset_name: Optional[str] = field(
|
| 33 |
+
default="stingning/ultrachat",
|
| 34 |
+
metadata={"help": "The preference dataset to use."},
|
| 35 |
+
)
|
| 36 |
+
fp16: Optional[bool] = field(
|
| 37 |
+
default=False,
|
| 38 |
+
metadata={"help": "Enables fp16 training."},
|
| 39 |
+
)
|
| 40 |
+
bf16: Optional[bool] = field(
|
| 41 |
+
default=False,
|
| 42 |
+
metadata={"help": "Enables bf16 training."},
|
| 43 |
+
)
|
| 44 |
+
packing: Optional[bool] = field(
|
| 45 |
+
default=True,
|
| 46 |
+
metadata={"help": "Use packing dataset creating."},
|
| 47 |
+
)
|
| 48 |
+
gradient_checkpointing: Optional[bool] = field(
|
| 49 |
+
default=True,
|
| 50 |
+
metadata={"help": "Enables gradient checkpointing."},
|
| 51 |
+
)
|
| 52 |
+
use_flash_attention_2: Optional[bool] = field(
|
| 53 |
+
default=False,
|
| 54 |
+
metadata={"help": "Enables Flash Attention 2."},
|
| 55 |
+
)
|
| 56 |
+
optim: Optional[str] = field(
|
| 57 |
+
default="paged_adamw_32bit",
|
| 58 |
+
metadata={"help": "The optimizer to use."},
|
| 59 |
+
)
|
| 60 |
+
lr_scheduler_type: str = field(
|
| 61 |
+
default="constant",
|
| 62 |
+
metadata={"help": "Learning rate schedule. Constant a bit better than cosine, and has advantage for analysis"},
|
| 63 |
+
)
|
| 64 |
+
max_steps: int = field(default=1000, metadata={"help": "How many optimizer update steps to take"})
|
| 65 |
+
warmup_ratio: float = field(default=0.03, metadata={"help": "Fraction of steps to do a warmup for"})
|
| 66 |
+
save_steps: int = field(default=10, metadata={"help": "Save checkpoint every X updates steps."})
|
| 67 |
+
logging_steps: int = field(default=10, metadata={"help": "Log every X updates steps."})
|
| 68 |
+
output_dir: str = field(
|
| 69 |
+
default="./results",
|
| 70 |
+
metadata={"help": "The output directory where the model predictions and checkpoints will be written."},
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
parser = HfArgumentParser(ScriptArguments)
|
| 74 |
+
script_args = parser.parse_args_into_dataclasses()[0]
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def formatting_func(example):
|
| 78 |
+
text = f"### USER: {example['data'][0]}\n### ASSISTANT: {example['data'][1]}"
|
| 79 |
+
return text
|
| 80 |
+
|
| 81 |
+
# Load the GG model - this is the local one, update it to the one on the Hub
|
| 82 |
+
model_id = "google/gemma-7b"
|
| 83 |
+
|
| 84 |
+
quantization_config = BitsAndBytesConfig(
|
| 85 |
+
load_in_4bit=True,
|
| 86 |
+
bnb_4bit_compute_dtype=torch.float16,
|
| 87 |
+
bnb_4bit_quant_type="nf4"
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
# Load model
|
| 91 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 92 |
+
model_id,
|
| 93 |
+
quantization_config=quantization_config,
|
| 94 |
+
torch_dtype=torch.float32,
|
| 95 |
+
attn_implementation="sdpa" if not script_args.use_flash_attention_2 else "flash_attention_2"
|
| 96 |
+
)
|
| 97 |
+
|
| 98 |
+
# Load tokenizer
|
| 99 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 100 |
+
tokenizer.pad_token_id = tokenizer.eos_token_id
|
| 101 |
+
|
| 102 |
+
lora_config = LoraConfig(
|
| 103 |
+
r=script_args.lora_r,
|
| 104 |
+
target_modules=["q_proj", "o_proj", "k_proj", "v_proj", "gate_proj", "up_proj", "down_proj"],
|
| 105 |
+
bias="none",
|
| 106 |
+
task_type="CAUSAL_LM",
|
| 107 |
+
lora_alpha=script_args.lora_alpha,
|
| 108 |
+
lora_dropout=script_args.lora_dropout
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
train_dataset = load_dataset(script_args.dataset_name, split="train[:5%]")
|
| 112 |
+
|
| 113 |
+
# TODO: make that configurable
|
| 114 |
+
YOUR_HF_USERNAME = xxx
|
| 115 |
+
output_dir = f"{YOUR_HF_USERNAME}/gemma-qlora-ultrachat"
|
| 116 |
+
|
| 117 |
+
training_arguments = TrainingArguments(
|
| 118 |
+
output_dir=output_dir,
|
| 119 |
+
per_device_train_batch_size=script_args.per_device_train_batch_size,
|
| 120 |
+
gradient_accumulation_steps=script_args.gradient_accumulation_steps,
|
| 121 |
+
optim=script_args.optim,
|
| 122 |
+
save_steps=script_args.save_steps,
|
| 123 |
+
logging_steps=script_args.logging_steps,
|
| 124 |
+
learning_rate=script_args.learning_rate,
|
| 125 |
+
max_grad_norm=script_args.max_grad_norm,
|
| 126 |
+
max_steps=script_args.max_steps,
|
| 127 |
+
warmup_ratio=script_args.warmup_ratio,
|
| 128 |
+
lr_scheduler_type=script_args.lr_scheduler_type,
|
| 129 |
+
gradient_checkpointing=script_args.gradient_checkpointing,
|
| 130 |
+
fp16=script_args.fp16,
|
| 131 |
+
bf16=script_args.bf16,
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
trainer = SFTTrainer(
|
| 135 |
+
model=model,
|
| 136 |
+
args=training_arguments,
|
| 137 |
+
train_dataset=train_dataset,
|
| 138 |
+
peft_config=lora_config,
|
| 139 |
+
packing=script_args.packing,
|
| 140 |
+
dataset_text_field="id",
|
| 141 |
+
tokenizer=tokenizer,
|
| 142 |
+
max_seq_length=script_args.max_seq_length,
|
| 143 |
+
formatting_func=formatting_func,
|
| 144 |
+
)
|
| 145 |
+
|
| 146 |
+
trainer.train()
|
examples/notebook_sft_peft.ipynb
ADDED
|
@@ -0,0 +1,729 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"nbformat": 4,
|
| 3 |
+
"nbformat_minor": 0,
|
| 4 |
+
"metadata": {
|
| 5 |
+
"colab": {
|
| 6 |
+
"provenance": [],
|
| 7 |
+
"gpuType": "T4"
|
| 8 |
+
},
|
| 9 |
+
"kernelspec": {
|
| 10 |
+
"name": "python3",
|
| 11 |
+
"display_name": "Python 3"
|
| 12 |
+
},
|
| 13 |
+
"language_info": {
|
| 14 |
+
"name": "python"
|
| 15 |
+
},
|
| 16 |
+
"accelerator": "GPU",
|
| 17 |
+
"widgets": {
|
| 18 |
+
"application/vnd.jupyter.widget-state+json": {
|
| 19 |
+
"32e7669cd82042cbbb419e25db606c1d": {
|
| 20 |
+
"model_module": "@jupyter-widgets/controls",
|
| 21 |
+
"model_name": "HBoxModel",
|
| 22 |
+
"model_module_version": "1.5.0",
|
| 23 |
+
"state": {
|
| 24 |
+
"_dom_classes": [],
|
| 25 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 26 |
+
"_model_module_version": "1.5.0",
|
| 27 |
+
"_model_name": "HBoxModel",
|
| 28 |
+
"_view_count": null,
|
| 29 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 30 |
+
"_view_module_version": "1.5.0",
|
| 31 |
+
"_view_name": "HBoxView",
|
| 32 |
+
"box_style": "",
|
| 33 |
+
"children": [
|
| 34 |
+
"IPY_MODEL_b6698be32bf74c4087e129fab6e13fdd",
|
| 35 |
+
"IPY_MODEL_ff7333b35c1c472482df6550f6e43be2",
|
| 36 |
+
"IPY_MODEL_da4df56a1ba440dbb69087d0019cab1d"
|
| 37 |
+
],
|
| 38 |
+
"layout": "IPY_MODEL_ad598693c58549e0a83a1328d77b8f83"
|
| 39 |
+
}
|
| 40 |
+
},
|
| 41 |
+
"b6698be32bf74c4087e129fab6e13fdd": {
|
| 42 |
+
"model_module": "@jupyter-widgets/controls",
|
| 43 |
+
"model_name": "HTMLModel",
|
| 44 |
+
"model_module_version": "1.5.0",
|
| 45 |
+
"state": {
|
| 46 |
+
"_dom_classes": [],
|
| 47 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 48 |
+
"_model_module_version": "1.5.0",
|
| 49 |
+
"_model_name": "HTMLModel",
|
| 50 |
+
"_view_count": null,
|
| 51 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 52 |
+
"_view_module_version": "1.5.0",
|
| 53 |
+
"_view_name": "HTMLView",
|
| 54 |
+
"description": "",
|
| 55 |
+
"description_tooltip": null,
|
| 56 |
+
"layout": "IPY_MODEL_de2f7a60851f4681877a4c8dccba29cc",
|
| 57 |
+
"placeholder": "",
|
| 58 |
+
"style": "IPY_MODEL_02b296efbff143f4bfbb904cbc7b1109",
|
| 59 |
+
"value": "Loading checkpoint shards: 100%"
|
| 60 |
+
}
|
| 61 |
+
},
|
| 62 |
+
"ff7333b35c1c472482df6550f6e43be2": {
|
| 63 |
+
"model_module": "@jupyter-widgets/controls",
|
| 64 |
+
"model_name": "FloatProgressModel",
|
| 65 |
+
"model_module_version": "1.5.0",
|
| 66 |
+
"state": {
|
| 67 |
+
"_dom_classes": [],
|
| 68 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 69 |
+
"_model_module_version": "1.5.0",
|
| 70 |
+
"_model_name": "FloatProgressModel",
|
| 71 |
+
"_view_count": null,
|
| 72 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 73 |
+
"_view_module_version": "1.5.0",
|
| 74 |
+
"_view_name": "ProgressView",
|
| 75 |
+
"bar_style": "success",
|
| 76 |
+
"description": "",
|
| 77 |
+
"description_tooltip": null,
|
| 78 |
+
"layout": "IPY_MODEL_72ac83e43e2b4d4498070a5b701a5572",
|
| 79 |
+
"max": 3,
|
| 80 |
+
"min": 0,
|
| 81 |
+
"orientation": "horizontal",
|
| 82 |
+
"style": "IPY_MODEL_320fa615d4de4652ac34fc2518f7749e",
|
| 83 |
+
"value": 3
|
| 84 |
+
}
|
| 85 |
+
},
|
| 86 |
+
"da4df56a1ba440dbb69087d0019cab1d": {
|
| 87 |
+
"model_module": "@jupyter-widgets/controls",
|
| 88 |
+
"model_name": "HTMLModel",
|
| 89 |
+
"model_module_version": "1.5.0",
|
| 90 |
+
"state": {
|
| 91 |
+
"_dom_classes": [],
|
| 92 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 93 |
+
"_model_module_version": "1.5.0",
|
| 94 |
+
"_model_name": "HTMLModel",
|
| 95 |
+
"_view_count": null,
|
| 96 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 97 |
+
"_view_module_version": "1.5.0",
|
| 98 |
+
"_view_name": "HTMLView",
|
| 99 |
+
"description": "",
|
| 100 |
+
"description_tooltip": null,
|
| 101 |
+
"layout": "IPY_MODEL_75280ef205a245be92da268e0752dc71",
|
| 102 |
+
"placeholder": "",
|
| 103 |
+
"style": "IPY_MODEL_3f33eabd6f7f46ef8138abe748d8fbb1",
|
| 104 |
+
"value": " 3/3 [01:06<00:00, 18.14s/it]"
|
| 105 |
+
}
|
| 106 |
+
},
|
| 107 |
+
"ad598693c58549e0a83a1328d77b8f83": {
|
| 108 |
+
"model_module": "@jupyter-widgets/base",
|
| 109 |
+
"model_name": "LayoutModel",
|
| 110 |
+
"model_module_version": "1.2.0",
|
| 111 |
+
"state": {
|
| 112 |
+
"_model_module": "@jupyter-widgets/base",
|
| 113 |
+
"_model_module_version": "1.2.0",
|
| 114 |
+
"_model_name": "LayoutModel",
|
| 115 |
+
"_view_count": null,
|
| 116 |
+
"_view_module": "@jupyter-widgets/base",
|
| 117 |
+
"_view_module_version": "1.2.0",
|
| 118 |
+
"_view_name": "LayoutView",
|
| 119 |
+
"align_content": null,
|
| 120 |
+
"align_items": null,
|
| 121 |
+
"align_self": null,
|
| 122 |
+
"border": null,
|
| 123 |
+
"bottom": null,
|
| 124 |
+
"display": null,
|
| 125 |
+
"flex": null,
|
| 126 |
+
"flex_flow": null,
|
| 127 |
+
"grid_area": null,
|
| 128 |
+
"grid_auto_columns": null,
|
| 129 |
+
"grid_auto_flow": null,
|
| 130 |
+
"grid_auto_rows": null,
|
| 131 |
+
"grid_column": null,
|
| 132 |
+
"grid_gap": null,
|
| 133 |
+
"grid_row": null,
|
| 134 |
+
"grid_template_areas": null,
|
| 135 |
+
"grid_template_columns": null,
|
| 136 |
+
"grid_template_rows": null,
|
| 137 |
+
"height": null,
|
| 138 |
+
"justify_content": null,
|
| 139 |
+
"justify_items": null,
|
| 140 |
+
"left": null,
|
| 141 |
+
"margin": null,
|
| 142 |
+
"max_height": null,
|
| 143 |
+
"max_width": null,
|
| 144 |
+
"min_height": null,
|
| 145 |
+
"min_width": null,
|
| 146 |
+
"object_fit": null,
|
| 147 |
+
"object_position": null,
|
| 148 |
+
"order": null,
|
| 149 |
+
"overflow": null,
|
| 150 |
+
"overflow_x": null,
|
| 151 |
+
"overflow_y": null,
|
| 152 |
+
"padding": null,
|
| 153 |
+
"right": null,
|
| 154 |
+
"top": null,
|
| 155 |
+
"visibility": null,
|
| 156 |
+
"width": null
|
| 157 |
+
}
|
| 158 |
+
},
|
| 159 |
+
"de2f7a60851f4681877a4c8dccba29cc": {
|
| 160 |
+
"model_module": "@jupyter-widgets/base",
|
| 161 |
+
"model_name": "LayoutModel",
|
| 162 |
+
"model_module_version": "1.2.0",
|
| 163 |
+
"state": {
|
| 164 |
+
"_model_module": "@jupyter-widgets/base",
|
| 165 |
+
"_model_module_version": "1.2.0",
|
| 166 |
+
"_model_name": "LayoutModel",
|
| 167 |
+
"_view_count": null,
|
| 168 |
+
"_view_module": "@jupyter-widgets/base",
|
| 169 |
+
"_view_module_version": "1.2.0",
|
| 170 |
+
"_view_name": "LayoutView",
|
| 171 |
+
"align_content": null,
|
| 172 |
+
"align_items": null,
|
| 173 |
+
"align_self": null,
|
| 174 |
+
"border": null,
|
| 175 |
+
"bottom": null,
|
| 176 |
+
"display": null,
|
| 177 |
+
"flex": null,
|
| 178 |
+
"flex_flow": null,
|
| 179 |
+
"grid_area": null,
|
| 180 |
+
"grid_auto_columns": null,
|
| 181 |
+
"grid_auto_flow": null,
|
| 182 |
+
"grid_auto_rows": null,
|
| 183 |
+
"grid_column": null,
|
| 184 |
+
"grid_gap": null,
|
| 185 |
+
"grid_row": null,
|
| 186 |
+
"grid_template_areas": null,
|
| 187 |
+
"grid_template_columns": null,
|
| 188 |
+
"grid_template_rows": null,
|
| 189 |
+
"height": null,
|
| 190 |
+
"justify_content": null,
|
| 191 |
+
"justify_items": null,
|
| 192 |
+
"left": null,
|
| 193 |
+
"margin": null,
|
| 194 |
+
"max_height": null,
|
| 195 |
+
"max_width": null,
|
| 196 |
+
"min_height": null,
|
| 197 |
+
"min_width": null,
|
| 198 |
+
"object_fit": null,
|
| 199 |
+
"object_position": null,
|
| 200 |
+
"order": null,
|
| 201 |
+
"overflow": null,
|
| 202 |
+
"overflow_x": null,
|
| 203 |
+
"overflow_y": null,
|
| 204 |
+
"padding": null,
|
| 205 |
+
"right": null,
|
| 206 |
+
"top": null,
|
| 207 |
+
"visibility": null,
|
| 208 |
+
"width": null
|
| 209 |
+
}
|
| 210 |
+
},
|
| 211 |
+
"02b296efbff143f4bfbb904cbc7b1109": {
|
| 212 |
+
"model_module": "@jupyter-widgets/controls",
|
| 213 |
+
"model_name": "DescriptionStyleModel",
|
| 214 |
+
"model_module_version": "1.5.0",
|
| 215 |
+
"state": {
|
| 216 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 217 |
+
"_model_module_version": "1.5.0",
|
| 218 |
+
"_model_name": "DescriptionStyleModel",
|
| 219 |
+
"_view_count": null,
|
| 220 |
+
"_view_module": "@jupyter-widgets/base",
|
| 221 |
+
"_view_module_version": "1.2.0",
|
| 222 |
+
"_view_name": "StyleView",
|
| 223 |
+
"description_width": ""
|
| 224 |
+
}
|
| 225 |
+
},
|
| 226 |
+
"72ac83e43e2b4d4498070a5b701a5572": {
|
| 227 |
+
"model_module": "@jupyter-widgets/base",
|
| 228 |
+
"model_name": "LayoutModel",
|
| 229 |
+
"model_module_version": "1.2.0",
|
| 230 |
+
"state": {
|
| 231 |
+
"_model_module": "@jupyter-widgets/base",
|
| 232 |
+
"_model_module_version": "1.2.0",
|
| 233 |
+
"_model_name": "LayoutModel",
|
| 234 |
+
"_view_count": null,
|
| 235 |
+
"_view_module": "@jupyter-widgets/base",
|
| 236 |
+
"_view_module_version": "1.2.0",
|
| 237 |
+
"_view_name": "LayoutView",
|
| 238 |
+
"align_content": null,
|
| 239 |
+
"align_items": null,
|
| 240 |
+
"align_self": null,
|
| 241 |
+
"border": null,
|
| 242 |
+
"bottom": null,
|
| 243 |
+
"display": null,
|
| 244 |
+
"flex": null,
|
| 245 |
+
"flex_flow": null,
|
| 246 |
+
"grid_area": null,
|
| 247 |
+
"grid_auto_columns": null,
|
| 248 |
+
"grid_auto_flow": null,
|
| 249 |
+
"grid_auto_rows": null,
|
| 250 |
+
"grid_column": null,
|
| 251 |
+
"grid_gap": null,
|
| 252 |
+
"grid_row": null,
|
| 253 |
+
"grid_template_areas": null,
|
| 254 |
+
"grid_template_columns": null,
|
| 255 |
+
"grid_template_rows": null,
|
| 256 |
+
"height": null,
|
| 257 |
+
"justify_content": null,
|
| 258 |
+
"justify_items": null,
|
| 259 |
+
"left": null,
|
| 260 |
+
"margin": null,
|
| 261 |
+
"max_height": null,
|
| 262 |
+
"max_width": null,
|
| 263 |
+
"min_height": null,
|
| 264 |
+
"min_width": null,
|
| 265 |
+
"object_fit": null,
|
| 266 |
+
"object_position": null,
|
| 267 |
+
"order": null,
|
| 268 |
+
"overflow": null,
|
| 269 |
+
"overflow_x": null,
|
| 270 |
+
"overflow_y": null,
|
| 271 |
+
"padding": null,
|
| 272 |
+
"right": null,
|
| 273 |
+
"top": null,
|
| 274 |
+
"visibility": null,
|
| 275 |
+
"width": null
|
| 276 |
+
}
|
| 277 |
+
},
|
| 278 |
+
"320fa615d4de4652ac34fc2518f7749e": {
|
| 279 |
+
"model_module": "@jupyter-widgets/controls",
|
| 280 |
+
"model_name": "ProgressStyleModel",
|
| 281 |
+
"model_module_version": "1.5.0",
|
| 282 |
+
"state": {
|
| 283 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 284 |
+
"_model_module_version": "1.5.0",
|
| 285 |
+
"_model_name": "ProgressStyleModel",
|
| 286 |
+
"_view_count": null,
|
| 287 |
+
"_view_module": "@jupyter-widgets/base",
|
| 288 |
+
"_view_module_version": "1.2.0",
|
| 289 |
+
"_view_name": "StyleView",
|
| 290 |
+
"bar_color": null,
|
| 291 |
+
"description_width": ""
|
| 292 |
+
}
|
| 293 |
+
},
|
| 294 |
+
"75280ef205a245be92da268e0752dc71": {
|
| 295 |
+
"model_module": "@jupyter-widgets/base",
|
| 296 |
+
"model_name": "LayoutModel",
|
| 297 |
+
"model_module_version": "1.2.0",
|
| 298 |
+
"state": {
|
| 299 |
+
"_model_module": "@jupyter-widgets/base",
|
| 300 |
+
"_model_module_version": "1.2.0",
|
| 301 |
+
"_model_name": "LayoutModel",
|
| 302 |
+
"_view_count": null,
|
| 303 |
+
"_view_module": "@jupyter-widgets/base",
|
| 304 |
+
"_view_module_version": "1.2.0",
|
| 305 |
+
"_view_name": "LayoutView",
|
| 306 |
+
"align_content": null,
|
| 307 |
+
"align_items": null,
|
| 308 |
+
"align_self": null,
|
| 309 |
+
"border": null,
|
| 310 |
+
"bottom": null,
|
| 311 |
+
"display": null,
|
| 312 |
+
"flex": null,
|
| 313 |
+
"flex_flow": null,
|
| 314 |
+
"grid_area": null,
|
| 315 |
+
"grid_auto_columns": null,
|
| 316 |
+
"grid_auto_flow": null,
|
| 317 |
+
"grid_auto_rows": null,
|
| 318 |
+
"grid_column": null,
|
| 319 |
+
"grid_gap": null,
|
| 320 |
+
"grid_row": null,
|
| 321 |
+
"grid_template_areas": null,
|
| 322 |
+
"grid_template_columns": null,
|
| 323 |
+
"grid_template_rows": null,
|
| 324 |
+
"height": null,
|
| 325 |
+
"justify_content": null,
|
| 326 |
+
"justify_items": null,
|
| 327 |
+
"left": null,
|
| 328 |
+
"margin": null,
|
| 329 |
+
"max_height": null,
|
| 330 |
+
"max_width": null,
|
| 331 |
+
"min_height": null,
|
| 332 |
+
"min_width": null,
|
| 333 |
+
"object_fit": null,
|
| 334 |
+
"object_position": null,
|
| 335 |
+
"order": null,
|
| 336 |
+
"overflow": null,
|
| 337 |
+
"overflow_x": null,
|
| 338 |
+
"overflow_y": null,
|
| 339 |
+
"padding": null,
|
| 340 |
+
"right": null,
|
| 341 |
+
"top": null,
|
| 342 |
+
"visibility": null,
|
| 343 |
+
"width": null
|
| 344 |
+
}
|
| 345 |
+
},
|
| 346 |
+
"3f33eabd6f7f46ef8138abe748d8fbb1": {
|
| 347 |
+
"model_module": "@jupyter-widgets/controls",
|
| 348 |
+
"model_name": "DescriptionStyleModel",
|
| 349 |
+
"model_module_version": "1.5.0",
|
| 350 |
+
"state": {
|
| 351 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 352 |
+
"_model_module_version": "1.5.0",
|
| 353 |
+
"_model_name": "DescriptionStyleModel",
|
| 354 |
+
"_view_count": null,
|
| 355 |
+
"_view_module": "@jupyter-widgets/base",
|
| 356 |
+
"_view_module_version": "1.2.0",
|
| 357 |
+
"_view_name": "StyleView",
|
| 358 |
+
"description_width": ""
|
| 359 |
+
}
|
| 360 |
+
}
|
| 361 |
+
}
|
| 362 |
+
}
|
| 363 |
+
},
|
| 364 |
+
"cells": [
|
| 365 |
+
{
|
| 366 |
+
"cell_type": "code",
|
| 367 |
+
"execution_count": null,
|
| 368 |
+
"metadata": {
|
| 369 |
+
"id": "mi50mprVsU_P"
|
| 370 |
+
},
|
| 371 |
+
"outputs": [],
|
| 372 |
+
"source": [
|
| 373 |
+
"import os\n",
|
| 374 |
+
"from google.colab import userdata\n",
|
| 375 |
+
"os.environ[\"HF_TOKEN\"] = userdata.get('HF_TOKEN')"
|
| 376 |
+
]
|
| 377 |
+
},
|
| 378 |
+
{
|
| 379 |
+
"cell_type": "code",
|
| 380 |
+
"source": [
|
| 381 |
+
"!pip3 install -q -U bitsandbytes==0.42.0\n",
|
| 382 |
+
"!pip3 install -q -U peft==0.8.2\n",
|
| 383 |
+
"!pip3 install -q -U trl==0.7.10\n",
|
| 384 |
+
"!pip3 install -q -U accelerate==0.27.1\n",
|
| 385 |
+
"!pip3 install -q -U datasets==2.17.0\n",
|
| 386 |
+
"!pip3 install -q -U transformers==4.38.0"
|
| 387 |
+
],
|
| 388 |
+
"metadata": {
|
| 389 |
+
"colab": {
|
| 390 |
+
"base_uri": "https://localhost:8080/"
|
| 391 |
+
},
|
| 392 |
+
"id": "-5gJk3W_s0RY",
|
| 393 |
+
"outputId": "ca3d427e-5bfc-4635-f27a-e49e56718f7e"
|
| 394 |
+
},
|
| 395 |
+
"execution_count": null,
|
| 396 |
+
"outputs": [
|
| 397 |
+
{
|
| 398 |
+
"output_type": "stream",
|
| 399 |
+
"name": "stdout",
|
| 400 |
+
"text": [
|
| 401 |
+
"Collecting git+https://****@github.com/huggingface/new-model-addition-golden-gate@add-golden-gate\n",
|
| 402 |
+
" Cloning https://****@github.com/huggingface/new-model-addition-golden-gate (to revision add-golden-gate) to /tmp/pip-req-build-8jci0sy8\n",
|
| 403 |
+
" Running command git clone --filter=blob:none --quiet 'https://****@github.com/huggingface/new-model-addition-golden-gate' /tmp/pip-req-build-8jci0sy8\n",
|
| 404 |
+
" Running command git checkout -b add-golden-gate --track origin/add-golden-gate\n",
|
| 405 |
+
" Switched to a new branch 'add-golden-gate'\n",
|
| 406 |
+
" Branch 'add-golden-gate' set up to track remote branch 'add-golden-gate' from 'origin'.\n",
|
| 407 |
+
" Resolved https://****@github.com/huggingface/new-model-addition-golden-gate to commit e9d36beb5fcafeb2ac327a68eee82009d24cb58f\n",
|
| 408 |
+
" Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
|
| 409 |
+
" Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
|
| 410 |
+
" Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
|
| 411 |
+
"Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from transformers==4.38.0.dev0) (3.13.1)\n",
|
| 412 |
+
"Requirement already satisfied: huggingface-hub<1.0,>=0.19.3 in /usr/local/lib/python3.10/dist-packages (from transformers==4.38.0.dev0) (0.20.3)\n",
|
| 413 |
+
"Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from transformers==4.38.0.dev0) (1.25.2)\n",
|
| 414 |
+
"Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from transformers==4.38.0.dev0) (23.2)\n",
|
| 415 |
+
"Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from transformers==4.38.0.dev0) (6.0.1)\n",
|
| 416 |
+
"Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.10/dist-packages (from transformers==4.38.0.dev0) (2023.12.25)\n",
|
| 417 |
+
"Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from transformers==4.38.0.dev0) (2.31.0)\n",
|
| 418 |
+
"Requirement already satisfied: tokenizers<0.19,>=0.14 in /usr/local/lib/python3.10/dist-packages (from transformers==4.38.0.dev0) (0.15.2)\n",
|
| 419 |
+
"Requirement already satisfied: safetensors>=0.4.1 in /usr/local/lib/python3.10/dist-packages (from transformers==4.38.0.dev0) (0.4.2)\n",
|
| 420 |
+
"Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.10/dist-packages (from transformers==4.38.0.dev0) (4.66.2)\n",
|
| 421 |
+
"Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.19.3->transformers==4.38.0.dev0) (2023.6.0)\n",
|
| 422 |
+
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.19.3->transformers==4.38.0.dev0) (4.9.0)\n",
|
| 423 |
+
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->transformers==4.38.0.dev0) (3.3.2)\n",
|
| 424 |
+
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->transformers==4.38.0.dev0) (3.6)\n",
|
| 425 |
+
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->transformers==4.38.0.dev0) (2.0.7)\n",
|
| 426 |
+
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->transformers==4.38.0.dev0) (2024.2.2)\n"
|
| 427 |
+
]
|
| 428 |
+
}
|
| 429 |
+
]
|
| 430 |
+
},
|
| 431 |
+
{
|
| 432 |
+
"cell_type": "code",
|
| 433 |
+
"source": [
|
| 434 |
+
"import torch\n",
|
| 435 |
+
"from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, GemmaTokenizer\n",
|
| 436 |
+
"\n",
|
| 437 |
+
"model_id = \"google/gemma-7b\"\n",
|
| 438 |
+
"bnb_config = BitsAndBytesConfig(\n",
|
| 439 |
+
" load_in_4bit=True,\n",
|
| 440 |
+
" bnb_4bit_quant_type=\"nf4\",\n",
|
| 441 |
+
" bnb_4bit_compute_dtype=torch.bfloat16\n",
|
| 442 |
+
")\n",
|
| 443 |
+
"\n",
|
| 444 |
+
"tokenizer = AutoTokenizer.from_pretrained(model_id, token=os.environ['HF_TOKEN'])\n",
|
| 445 |
+
"model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=bnb_config, device_map={\"\":0}, token=os.environ['HF_TOKEN'])"
|
| 446 |
+
],
|
| 447 |
+
"metadata": {
|
| 448 |
+
"colab": {
|
| 449 |
+
"base_uri": "https://localhost:8080/",
|
| 450 |
+
"height": 49,
|
| 451 |
+
"referenced_widgets": [
|
| 452 |
+
"32e7669cd82042cbbb419e25db606c1d",
|
| 453 |
+
"b6698be32bf74c4087e129fab6e13fdd",
|
| 454 |
+
"ff7333b35c1c472482df6550f6e43be2",
|
| 455 |
+
"da4df56a1ba440dbb69087d0019cab1d",
|
| 456 |
+
"ad598693c58549e0a83a1328d77b8f83",
|
| 457 |
+
"de2f7a60851f4681877a4c8dccba29cc",
|
| 458 |
+
"02b296efbff143f4bfbb904cbc7b1109",
|
| 459 |
+
"72ac83e43e2b4d4498070a5b701a5572",
|
| 460 |
+
"320fa615d4de4652ac34fc2518f7749e",
|
| 461 |
+
"75280ef205a245be92da268e0752dc71",
|
| 462 |
+
"3f33eabd6f7f46ef8138abe748d8fbb1"
|
| 463 |
+
]
|
| 464 |
+
},
|
| 465 |
+
"id": "EVEotZX8s-v6",
|
| 466 |
+
"outputId": "e378234f-f56f-483e-c569-f3a196c02370"
|
| 467 |
+
},
|
| 468 |
+
"execution_count": null,
|
| 469 |
+
"outputs": [
|
| 470 |
+
{
|
| 471 |
+
"output_type": "display_data",
|
| 472 |
+
"data": {
|
| 473 |
+
"text/plain": [
|
| 474 |
+
"Loading checkpoint shards: 0%| | 0/3 [00:00<?, ?it/s]"
|
| 475 |
+
],
|
| 476 |
+
"application/vnd.jupyter.widget-view+json": {
|
| 477 |
+
"version_major": 2,
|
| 478 |
+
"version_minor": 0,
|
| 479 |
+
"model_id": "32e7669cd82042cbbb419e25db606c1d"
|
| 480 |
+
}
|
| 481 |
+
},
|
| 482 |
+
"metadata": {}
|
| 483 |
+
}
|
| 484 |
+
]
|
| 485 |
+
},
|
| 486 |
+
{
|
| 487 |
+
"cell_type": "code",
|
| 488 |
+
"source": [
|
| 489 |
+
"text = \"Quote: Imagination is more\"\n",
|
| 490 |
+
"device = \"cuda:0\"\n",
|
| 491 |
+
"inputs = tokenizer(text, return_tensors=\"pt\").to(device)\n",
|
| 492 |
+
"\n",
|
| 493 |
+
"outputs = model.generate(**inputs, max_new_tokens=20)\n",
|
| 494 |
+
"print(tokenizer.decode(outputs[0], skip_special_tokens=True))"
|
| 495 |
+
],
|
| 496 |
+
"metadata": {
|
| 497 |
+
"colab": {
|
| 498 |
+
"base_uri": "https://localhost:8080/"
|
| 499 |
+
},
|
| 500 |
+
"id": "7Msk610TVUGW",
|
| 501 |
+
"outputId": "8c14afe0-dc6e-42b1-d05a-1a7a6c2ace9e"
|
| 502 |
+
},
|
| 503 |
+
"execution_count": null,
|
| 504 |
+
"outputs": [
|
| 505 |
+
{
|
| 506 |
+
"output_type": "stream",
|
| 507 |
+
"name": "stdout",
|
| 508 |
+
"text": [
|
| 509 |
+
"Quote: Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world.\n",
|
| 510 |
+
"\n",
|
| 511 |
+
"-Albert Einstein\n",
|
| 512 |
+
"\n",
|
| 513 |
+
"I\n"
|
| 514 |
+
]
|
| 515 |
+
}
|
| 516 |
+
]
|
| 517 |
+
},
|
| 518 |
+
{
|
| 519 |
+
"cell_type": "code",
|
| 520 |
+
"source": [
|
| 521 |
+
"os.environ[\"WANDB_DISABLED\"] = \"true\""
|
| 522 |
+
],
|
| 523 |
+
"metadata": {
|
| 524 |
+
"id": "Mi2P12KsVbyt"
|
| 525 |
+
},
|
| 526 |
+
"execution_count": null,
|
| 527 |
+
"outputs": []
|
| 528 |
+
},
|
| 529 |
+
{
|
| 530 |
+
"cell_type": "code",
|
| 531 |
+
"source": [
|
| 532 |
+
"from peft import LoraConfig\n",
|
| 533 |
+
"\n",
|
| 534 |
+
"lora_config = LoraConfig(\n",
|
| 535 |
+
" r=8,\n",
|
| 536 |
+
" target_modules=[\"q_proj\", \"o_proj\", \"k_proj\", \"v_proj\", \"gate_proj\", \"up_proj\", \"down_proj\"],\n",
|
| 537 |
+
" task_type=\"CAUSAL_LM\",\n",
|
| 538 |
+
")"
|
| 539 |
+
],
|
| 540 |
+
"metadata": {
|
| 541 |
+
"id": "7lzjoG3KVRMN"
|
| 542 |
+
},
|
| 543 |
+
"execution_count": null,
|
| 544 |
+
"outputs": []
|
| 545 |
+
},
|
| 546 |
+
{
|
| 547 |
+
"cell_type": "code",
|
| 548 |
+
"source": [
|
| 549 |
+
"from datasets import load_dataset\n",
|
| 550 |
+
"\n",
|
| 551 |
+
"data = load_dataset(\"Abirate/english_quotes\")\n",
|
| 552 |
+
"data = data.map(lambda samples: tokenizer(samples[\"quote\"]), batched=True)"
|
| 553 |
+
],
|
| 554 |
+
"metadata": {
|
| 555 |
+
"id": "HPQSpLNAuubn"
|
| 556 |
+
},
|
| 557 |
+
"execution_count": null,
|
| 558 |
+
"outputs": []
|
| 559 |
+
},
|
| 560 |
+
{
|
| 561 |
+
"cell_type": "code",
|
| 562 |
+
"source": [
|
| 563 |
+
"import transformers\n",
|
| 564 |
+
"from trl import SFTTrainer\n",
|
| 565 |
+
"\n",
|
| 566 |
+
"def formatting_func(example):\n",
|
| 567 |
+
" text = f\"Quote: {example['quote'][0]}\\nAuthor: {example['author'][0]}\"\n",
|
| 568 |
+
" return [text]\n",
|
| 569 |
+
"\n",
|
| 570 |
+
"trainer = SFTTrainer(\n",
|
| 571 |
+
" model=model,\n",
|
| 572 |
+
" train_dataset=data[\"train\"],\n",
|
| 573 |
+
" args=transformers.TrainingArguments(\n",
|
| 574 |
+
" per_device_train_batch_size=1,\n",
|
| 575 |
+
" gradient_accumulation_steps=4,\n",
|
| 576 |
+
" warmup_steps=2,\n",
|
| 577 |
+
" max_steps=10,\n",
|
| 578 |
+
" learning_rate=2e-4,\n",
|
| 579 |
+
" fp16=True,\n",
|
| 580 |
+
" logging_steps=1,\n",
|
| 581 |
+
" output_dir=\"outputs\",\n",
|
| 582 |
+
" optim=\"paged_adamw_8bit\"\n",
|
| 583 |
+
" ),\n",
|
| 584 |
+
" peft_config=lora_config,\n",
|
| 585 |
+
" formatting_func=formatting_func,\n",
|
| 586 |
+
")\n",
|
| 587 |
+
"trainer.train()"
|
| 588 |
+
],
|
| 589 |
+
"metadata": {
|
| 590 |
+
"colab": {
|
| 591 |
+
"base_uri": "https://localhost:8080/",
|
| 592 |
+
"height": 530
|
| 593 |
+
},
|
| 594 |
+
"id": "HFbR2FIgVfiT",
|
| 595 |
+
"outputId": "ba27fbda-54be-415c-ee47-78632e4ad4c6"
|
| 596 |
+
},
|
| 597 |
+
"execution_count": null,
|
| 598 |
+
"outputs": [
|
| 599 |
+
{
|
| 600 |
+
"output_type": "stream",
|
| 601 |
+
"name": "stderr",
|
| 602 |
+
"text": [
|
| 603 |
+
"Using the `WANDB_DISABLED` environment variable is deprecated and will be removed in v5. Use the --report_to flag to control the integrations used for logging result (for instance --report_to none).\n",
|
| 604 |
+
"/usr/local/lib/python3.10/dist-packages/trl/trainer/sft_trainer.py:223: UserWarning: You didn't pass a `max_seq_length` argument to the SFTTrainer, this will default to 1024\n",
|
| 605 |
+
" warnings.warn(\n",
|
| 606 |
+
"/usr/local/lib/python3.10/dist-packages/trl/trainer/sft_trainer.py:290: UserWarning: You passed a tokenizer with `padding_side` not equal to `right` to the SFTTrainer. This might lead to some unexpected behaviour due to overflow issues when training a model in half-precision. You might consider adding `tokenizer.padding_side = 'right'` to your code.\n",
|
| 607 |
+
" warnings.warn(\n"
|
| 608 |
+
]
|
| 609 |
+
},
|
| 610 |
+
{
|
| 611 |
+
"output_type": "display_data",
|
| 612 |
+
"data": {
|
| 613 |
+
"text/plain": [
|
| 614 |
+
"<IPython.core.display.HTML object>"
|
| 615 |
+
],
|
| 616 |
+
"text/html": [
|
| 617 |
+
"\n",
|
| 618 |
+
" <div>\n",
|
| 619 |
+
" \n",
|
| 620 |
+
" <progress value='10' max='10' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
|
| 621 |
+
" [10/10 00:08, Epoch 6/10]\n",
|
| 622 |
+
" </div>\n",
|
| 623 |
+
" <table border=\"1\" class=\"dataframe\">\n",
|
| 624 |
+
" <thead>\n",
|
| 625 |
+
" <tr style=\"text-align: left;\">\n",
|
| 626 |
+
" <th>Step</th>\n",
|
| 627 |
+
" <th>Training Loss</th>\n",
|
| 628 |
+
" </tr>\n",
|
| 629 |
+
" </thead>\n",
|
| 630 |
+
" <tbody>\n",
|
| 631 |
+
" <tr>\n",
|
| 632 |
+
" <td>1</td>\n",
|
| 633 |
+
" <td>1.700500</td>\n",
|
| 634 |
+
" </tr>\n",
|
| 635 |
+
" <tr>\n",
|
| 636 |
+
" <td>2</td>\n",
|
| 637 |
+
" <td>0.641000</td>\n",
|
| 638 |
+
" </tr>\n",
|
| 639 |
+
" <tr>\n",
|
| 640 |
+
" <td>3</td>\n",
|
| 641 |
+
" <td>1.031500</td>\n",
|
| 642 |
+
" </tr>\n",
|
| 643 |
+
" <tr>\n",
|
| 644 |
+
" <td>4</td>\n",
|
| 645 |
+
" <td>0.945800</td>\n",
|
| 646 |
+
" </tr>\n",
|
| 647 |
+
" <tr>\n",
|
| 648 |
+
" <td>5</td>\n",
|
| 649 |
+
" <td>0.516200</td>\n",
|
| 650 |
+
" </tr>\n",
|
| 651 |
+
" <tr>\n",
|
| 652 |
+
" <td>6</td>\n",
|
| 653 |
+
" <td>1.278600</td>\n",
|
| 654 |
+
" </tr>\n",
|
| 655 |
+
" <tr>\n",
|
| 656 |
+
" <td>7</td>\n",
|
| 657 |
+
" <td>1.187300</td>\n",
|
| 658 |
+
" </tr>\n",
|
| 659 |
+
" <tr>\n",
|
| 660 |
+
" <td>8</td>\n",
|
| 661 |
+
" <td>0.339000</td>\n",
|
| 662 |
+
" </tr>\n",
|
| 663 |
+
" <tr>\n",
|
| 664 |
+
" <td>9</td>\n",
|
| 665 |
+
" <td>0.724500</td>\n",
|
| 666 |
+
" </tr>\n",
|
| 667 |
+
" <tr>\n",
|
| 668 |
+
" <td>10</td>\n",
|
| 669 |
+
" <td>0.647600</td>\n",
|
| 670 |
+
" </tr>\n",
|
| 671 |
+
" </tbody>\n",
|
| 672 |
+
"</table><p>"
|
| 673 |
+
]
|
| 674 |
+
},
|
| 675 |
+
"metadata": {}
|
| 676 |
+
},
|
| 677 |
+
{
|
| 678 |
+
"output_type": "execute_result",
|
| 679 |
+
"data": {
|
| 680 |
+
"text/plain": [
|
| 681 |
+
"TrainOutput(global_step=10, training_loss=0.9011982649564743, metrics={'train_runtime': 10.2202, 'train_samples_per_second': 3.914, 'train_steps_per_second': 0.978, 'total_flos': 5520965345280.0, 'train_loss': 0.9011982649564743, 'epoch': 6.67})"
|
| 682 |
+
]
|
| 683 |
+
},
|
| 684 |
+
"metadata": {},
|
| 685 |
+
"execution_count": 8
|
| 686 |
+
}
|
| 687 |
+
]
|
| 688 |
+
},
|
| 689 |
+
{
|
| 690 |
+
"cell_type": "code",
|
| 691 |
+
"source": [
|
| 692 |
+
"text = \"Quote: Imagination is\"\n",
|
| 693 |
+
"device = \"cuda:0\"\n",
|
| 694 |
+
"inputs = tokenizer(text, return_tensors=\"pt\").to(device)\n",
|
| 695 |
+
"\n",
|
| 696 |
+
"outputs = model.generate(**inputs, max_new_tokens=20)\n",
|
| 697 |
+
"print(tokenizer.decode(outputs[0], skip_special_tokens=True))"
|
| 698 |
+
],
|
| 699 |
+
"metadata": {
|
| 700 |
+
"colab": {
|
| 701 |
+
"base_uri": "https://localhost:8080/"
|
| 702 |
+
},
|
| 703 |
+
"id": "f5Mim0lNViwe",
|
| 704 |
+
"outputId": "4534ee26-63e3-4ced-ee27-673f0b9d7afb"
|
| 705 |
+
},
|
| 706 |
+
"execution_count": null,
|
| 707 |
+
"outputs": [
|
| 708 |
+
{
|
| 709 |
+
"output_type": "stream",
|
| 710 |
+
"name": "stdout",
|
| 711 |
+
"text": [
|
| 712 |
+
"Quote: Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world.\n",
|
| 713 |
+
"\n",
|
| 714 |
+
"Author: Albert Einstein\n"
|
| 715 |
+
]
|
| 716 |
+
}
|
| 717 |
+
]
|
| 718 |
+
},
|
| 719 |
+
{
|
| 720 |
+
"cell_type": "code",
|
| 721 |
+
"source": [],
|
| 722 |
+
"metadata": {
|
| 723 |
+
"id": "djg3QAMuVx8R"
|
| 724 |
+
},
|
| 725 |
+
"execution_count": null,
|
| 726 |
+
"outputs": []
|
| 727 |
+
}
|
| 728 |
+
]
|
| 729 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 2,
|
| 4 |
+
"eos_token_id": 1,
|
| 5 |
+
"pad_token_id": 0,
|
| 6 |
+
"transformers_version": "4.38.0.dev0"
|
| 7 |
+
}
|
model-00001-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:632edaf7993dd73b33287cc34e0de0ed48c04a54834198fac5f2f78ff47e62c9
|
| 3 |
+
size 4995496656
|
model-00002-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b9b0278bd4e203c50d4a1b2a29bd6061b19c48abc77f338a4de2f0dd4fba0fac
|
| 3 |
+
size 4982953168
|
model-00003-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:69dcacd38561f42064c81a0d8ebfd97d8a393d22e40fea327fc6c9a14205768c
|
| 3 |
+
size 4982953200
|
model-00004-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1ddee49e12c7ec4ffb8ff6359a727a798ded9d6176da4bad30833f24426cb92f
|
| 3 |
+
size 2113988336
|
model.safetensors.index.json
ADDED
|
@@ -0,0 +1,261 @@
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"metadata": {
|
| 3 |
+
"total_size": 17075361792
|
| 4 |
+
},
|
| 5 |
+
"weight_map": {
|
| 6 |
+
"model.embed_tokens.weight": "model-00001-of-00004.safetensors",
|
| 7 |
+
"model.layers.0.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 8 |
+
"model.layers.0.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 9 |
+
"model.layers.0.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 10 |
+
"model.layers.0.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 11 |
+
"model.layers.0.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 12 |
+
"model.layers.0.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 13 |
+
"model.layers.0.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 14 |
+
"model.layers.0.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 15 |
+
"model.layers.0.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 16 |
+
"model.layers.1.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 17 |
+
"model.layers.1.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 18 |
+
"model.layers.1.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 19 |
+
"model.layers.1.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 20 |
+
"model.layers.1.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 21 |
+
"model.layers.1.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 22 |
+
"model.layers.1.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 23 |
+
"model.layers.1.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 24 |
+
"model.layers.1.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 25 |
+
"model.layers.10.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 26 |
+
"model.layers.10.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 27 |
+
"model.layers.10.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 28 |
+
"model.layers.10.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 29 |
+
"model.layers.10.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 30 |
+
"model.layers.10.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 31 |
+
"model.layers.10.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 32 |
+
"model.layers.10.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 33 |
+
"model.layers.10.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 34 |
+
"model.layers.11.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 35 |
+
"model.layers.11.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 36 |
+
"model.layers.11.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 37 |
+
"model.layers.11.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 38 |
+
"model.layers.11.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 39 |
+
"model.layers.11.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 40 |
+
"model.layers.11.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 41 |
+
"model.layers.11.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 42 |
+
"model.layers.11.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 43 |
+
"model.layers.12.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 44 |
+
"model.layers.12.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 45 |
+
"model.layers.12.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 46 |
+
"model.layers.12.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 47 |
+
"model.layers.12.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 48 |
+
"model.layers.12.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 49 |
+
"model.layers.12.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 50 |
+
"model.layers.12.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 51 |
+
"model.layers.12.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 52 |
+
"model.layers.13.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 53 |
+
"model.layers.13.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 54 |
+
"model.layers.13.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 55 |
+
"model.layers.13.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 56 |
+
"model.layers.13.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 57 |
+
"model.layers.13.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 58 |
+
"model.layers.13.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 59 |
+
"model.layers.13.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 60 |
+
"model.layers.13.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 61 |
+
"model.layers.14.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 62 |
+
"model.layers.14.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 63 |
+
"model.layers.14.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 64 |
+
"model.layers.14.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 65 |
+
"model.layers.14.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 66 |
+
"model.layers.14.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 67 |
+
"model.layers.14.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 68 |
+
"model.layers.14.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 69 |
+
"model.layers.14.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 70 |
+
"model.layers.15.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 71 |
+
"model.layers.15.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 72 |
+
"model.layers.15.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 73 |
+
"model.layers.15.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 74 |
+
"model.layers.15.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 75 |
+
"model.layers.15.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 76 |
+
"model.layers.15.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 77 |
+
"model.layers.15.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 78 |
+
"model.layers.15.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 79 |
+
"model.layers.16.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 80 |
+
"model.layers.16.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 81 |
+
"model.layers.16.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 82 |
+
"model.layers.16.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 83 |
+
"model.layers.16.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 84 |
+
"model.layers.16.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 85 |
+
"model.layers.16.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 86 |
+
"model.layers.16.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 87 |
+
"model.layers.16.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 88 |
+
"model.layers.17.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 89 |
+
"model.layers.17.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 90 |
+
"model.layers.17.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 91 |
+
"model.layers.17.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 92 |
+
"model.layers.17.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 93 |
+
"model.layers.17.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 94 |
+
"model.layers.17.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 95 |
+
"model.layers.17.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 96 |
+
"model.layers.17.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 97 |
+
"model.layers.18.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 98 |
+
"model.layers.18.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 99 |
+
"model.layers.18.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 100 |
+
"model.layers.18.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 101 |
+
"model.layers.18.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 102 |
+
"model.layers.18.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 103 |
+
"model.layers.18.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 104 |
+
"model.layers.18.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 105 |
+
"model.layers.18.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 106 |
+
"model.layers.19.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 107 |
+
"model.layers.19.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 108 |
+
"model.layers.19.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 109 |
+
"model.layers.19.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 110 |
+
"model.layers.19.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 111 |
+
"model.layers.19.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 112 |
+
"model.layers.19.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 113 |
+
"model.layers.19.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 114 |
+
"model.layers.19.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 115 |
+
"model.layers.2.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 116 |
+
"model.layers.2.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 117 |
+
"model.layers.2.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 118 |
+
"model.layers.2.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 119 |
+
"model.layers.2.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 120 |
+
"model.layers.2.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 121 |
+
"model.layers.2.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 122 |
+
"model.layers.2.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 123 |
+
"model.layers.2.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 124 |
+
"model.layers.20.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 125 |
+
"model.layers.20.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 126 |
+
"model.layers.20.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 127 |
+
"model.layers.20.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 128 |
+
"model.layers.20.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 129 |
+
"model.layers.20.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 130 |
+
"model.layers.20.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 131 |
+
"model.layers.20.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 132 |
+
"model.layers.20.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 133 |
+
"model.layers.21.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 134 |
+
"model.layers.21.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 135 |
+
"model.layers.21.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 136 |
+
"model.layers.21.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 137 |
+
"model.layers.21.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 138 |
+
"model.layers.21.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 139 |
+
"model.layers.21.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 140 |
+
"model.layers.21.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 141 |
+
"model.layers.21.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 142 |
+
"model.layers.22.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 143 |
+
"model.layers.22.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 144 |
+
"model.layers.22.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 145 |
+
"model.layers.22.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 146 |
+
"model.layers.22.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 147 |
+
"model.layers.22.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 148 |
+
"model.layers.22.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 149 |
+
"model.layers.22.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 150 |
+
"model.layers.22.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 151 |
+
"model.layers.23.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 152 |
+
"model.layers.23.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 153 |
+
"model.layers.23.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 154 |
+
"model.layers.23.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 155 |
+
"model.layers.23.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 156 |
+
"model.layers.23.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 157 |
+
"model.layers.23.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 158 |
+
"model.layers.23.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 159 |
+
"model.layers.23.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 160 |
+
"model.layers.24.input_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 161 |
+
"model.layers.24.mlp.down_proj.weight": "model-00004-of-00004.safetensors",
|
| 162 |
+
"model.layers.24.mlp.gate_proj.weight": "model-00004-of-00004.safetensors",
|
| 163 |
+
"model.layers.24.mlp.up_proj.weight": "model-00004-of-00004.safetensors",
|
| 164 |
+
"model.layers.24.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 165 |
+
"model.layers.24.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 166 |
+
"model.layers.24.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 167 |
+
"model.layers.24.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 168 |
+
"model.layers.24.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 169 |
+
"model.layers.25.input_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 170 |
+
"model.layers.25.mlp.down_proj.weight": "model-00004-of-00004.safetensors",
|
| 171 |
+
"model.layers.25.mlp.gate_proj.weight": "model-00004-of-00004.safetensors",
|
| 172 |
+
"model.layers.25.mlp.up_proj.weight": "model-00004-of-00004.safetensors",
|
| 173 |
+
"model.layers.25.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 174 |
+
"model.layers.25.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
| 175 |
+
"model.layers.25.self_attn.o_proj.weight": "model-00004-of-00004.safetensors",
|
| 176 |
+
"model.layers.25.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
| 177 |
+
"model.layers.25.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
| 178 |
+
"model.layers.26.input_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 179 |
+
"model.layers.26.mlp.down_proj.weight": "model-00004-of-00004.safetensors",
|
| 180 |
+
"model.layers.26.mlp.gate_proj.weight": "model-00004-of-00004.safetensors",
|
| 181 |
+
"model.layers.26.mlp.up_proj.weight": "model-00004-of-00004.safetensors",
|
| 182 |
+
"model.layers.26.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 183 |
+
"model.layers.26.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
| 184 |
+
"model.layers.26.self_attn.o_proj.weight": "model-00004-of-00004.safetensors",
|
| 185 |
+
"model.layers.26.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
| 186 |
+
"model.layers.26.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
| 187 |
+
"model.layers.27.input_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 188 |
+
"model.layers.27.mlp.down_proj.weight": "model-00004-of-00004.safetensors",
|
| 189 |
+
"model.layers.27.mlp.gate_proj.weight": "model-00004-of-00004.safetensors",
|
| 190 |
+
"model.layers.27.mlp.up_proj.weight": "model-00004-of-00004.safetensors",
|
| 191 |
+
"model.layers.27.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 192 |
+
"model.layers.27.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
| 193 |
+
"model.layers.27.self_attn.o_proj.weight": "model-00004-of-00004.safetensors",
|
| 194 |
+
"model.layers.27.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
| 195 |
+
"model.layers.27.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
| 196 |
+
"model.layers.3.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 197 |
+
"model.layers.3.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 198 |
+
"model.layers.3.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 199 |
+
"model.layers.3.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 200 |
+
"model.layers.3.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 201 |
+
"model.layers.3.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 202 |
+
"model.layers.3.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 203 |
+
"model.layers.3.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 204 |
+
"model.layers.3.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 205 |
+
"model.layers.4.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 206 |
+
"model.layers.4.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 207 |
+
"model.layers.4.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 208 |
+
"model.layers.4.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 209 |
+
"model.layers.4.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 210 |
+
"model.layers.4.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 211 |
+
"model.layers.4.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 212 |
+
"model.layers.4.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 213 |
+
"model.layers.4.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 214 |
+
"model.layers.5.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 215 |
+
"model.layers.5.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 216 |
+
"model.layers.5.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 217 |
+
"model.layers.5.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 218 |
+
"model.layers.5.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 219 |
+
"model.layers.5.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 220 |
+
"model.layers.5.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 221 |
+
"model.layers.5.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 222 |
+
"model.layers.5.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 223 |
+
"model.layers.6.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 224 |
+
"model.layers.6.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 225 |
+
"model.layers.6.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 226 |
+
"model.layers.6.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 227 |
+
"model.layers.6.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 228 |
+
"model.layers.6.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 229 |
+
"model.layers.6.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 230 |
+
"model.layers.6.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 231 |
+
"model.layers.6.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 232 |
+
"model.layers.7.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 233 |
+
"model.layers.7.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 234 |
+
"model.layers.7.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 235 |
+
"model.layers.7.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 236 |
+
"model.layers.7.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 237 |
+
"model.layers.7.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 238 |
+
"model.layers.7.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 239 |
+
"model.layers.7.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 240 |
+
"model.layers.7.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 241 |
+
"model.layers.8.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 242 |
+
"model.layers.8.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 243 |
+
"model.layers.8.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 244 |
+
"model.layers.8.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 245 |
+
"model.layers.8.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 246 |
+
"model.layers.8.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 247 |
+
"model.layers.8.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 248 |
+
"model.layers.8.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 249 |
+
"model.layers.8.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 250 |
+
"model.layers.9.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 251 |
+
"model.layers.9.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 252 |
+
"model.layers.9.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 253 |
+
"model.layers.9.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 254 |
+
"model.layers.9.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 255 |
+
"model.layers.9.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 256 |
+
"model.layers.9.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 257 |
+
"model.layers.9.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 258 |
+
"model.layers.9.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 259 |
+
"model.norm.weight": "model-00004-of-00004.safetensors"
|
| 260 |
+
}
|
| 261 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<bos>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"eos_token": {
|
| 10 |
+
"content": "<eos>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"pad_token": {
|
| 17 |
+
"content": "<pad>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
},
|
| 23 |
+
"unk_token": {
|
| 24 |
+
"content": "<unk>",
|
| 25 |
+
"lstrip": false,
|
| 26 |
+
"normalized": false,
|
| 27 |
+
"rstrip": false,
|
| 28 |
+
"single_word": false
|
| 29 |
+
}
|
| 30 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d0d908b4f9326e0998815690e325b6abbd378978553e10627924dd825db7e243
|
| 3 |
+
size 17477553
|
tokenizer.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6969e64047744a44bb3abfb5c50f8de0f7ed8b571d5444426ef931f651d1a0ef
|
| 3 |
+
size 4241111
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_bos_token": true,
|
| 3 |
+
"add_eos_token": false,
|
| 4 |
+
"added_tokens_decoder": {
|
| 5 |
+
"0": {
|
| 6 |
+
"content": "<pad>",
|
| 7 |
+
"lstrip": false,
|
| 8 |
+
"normalized": false,
|
| 9 |
+
"rstrip": false,
|
| 10 |
+
"single_word": false,
|
| 11 |
+
"special": true
|
| 12 |
+
},
|
| 13 |
+
"1": {
|
| 14 |
+
"content": "<eos>",
|
| 15 |
+
"lstrip": false,
|
| 16 |
+
"normalized": false,
|
| 17 |
+
"rstrip": false,
|
| 18 |
+
"single_word": false,
|
| 19 |
+
"special": true
|
| 20 |
+
},
|
| 21 |
+
"2": {
|
| 22 |
+
"content": "<bos>",
|
| 23 |
+
"lstrip": false,
|
| 24 |
+
"normalized": false,
|
| 25 |
+
"rstrip": false,
|
| 26 |
+
"single_word": false,
|
| 27 |
+
"special": true
|
| 28 |
+
},
|
| 29 |
+
"3": {
|
| 30 |
+
"content": "<unk>",
|
| 31 |
+
"lstrip": false,
|
| 32 |
+
"normalized": false,
|
| 33 |
+
"rstrip": false,
|
| 34 |
+
"single_word": false,
|
| 35 |
+
"special": true
|
| 36 |
+
}
|
| 37 |
+
},
|
| 38 |
+
"bos_token": "<bos>",
|
| 39 |
+
"clean_up_tokenization_spaces": false,
|
| 40 |
+
"eos_token": "<eos>",
|
| 41 |
+
"legacy": null,
|
| 42 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 43 |
+
"pad_token": "<pad>",
|
| 44 |
+
"sp_model_kwargs": {},
|
| 45 |
+
"spaces_between_special_tokens": false,
|
| 46 |
+
"tokenizer_class": "GemmaTokenizer",
|
| 47 |
+
"unk_token": "<unk>",
|
| 48 |
+
"use_default_system_prompt": false
|
| 49 |
+
}
|