File size: 3,129 Bytes
cd6fe66 dddb126 cd6fe66 f941a29 cd6fe66 dddb126 82ce627 3446d65 5cec92a 71317bd cd6fe66 71317bd cd6fe66 71317bd cd6fe66 71317bd cd6fe66 71317bd cd6fe66 71317bd cd6fe66 71317bd cd6fe66 71317bd cd6fe66 71317bd cd6fe66 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
---
license: gemma
library_name: transformers
tags:
- sft
- generated_from_trainer
base_model: google/gemma-7b
model-index:
- name: gemma_ft_quote
results: []
pipeline_tag: text-generation
datasets:
- Abirate/english_quotes
language:
- en
widget:
- text: 'Quote: With great power comes'
example_title: Example 1
- text: 'Quote: Hasta la vista baby'
example_title: Example 2
- text: 'Quote: Elementary, my dear watson.'
example_title: Example 3
---
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->
# Gemma_ft_Quote
This model is a fine-tuned version of [google/gemma-7b](https://huggingface.co./google/gemma-7b) on the [english quote](https://huggingface.co./datasets/Abirate/english_quotes) dataset using [LoRA](https://arxiv.org/abs/2106.09685).
It is based on the example provided by google [here](https://huggingface.co./google/gemma-7b/blob/main/examples/notebook_sft_peft.ipynb).
The notebook used to fine-tune the model can be found [here](https://colab.research.google.com/drive/1OMvXuK77X7yxofrhQHERUkrn3NZORXFp?usp=sharing)
## Model description
The model can complete popular quotes given to it and add the author of the quote. For example, Given the qoute below:
```
Quote: With great power comes
```
The model would complete the quote and add the author of the quote:
```
Quote: With great power comes great responsibility. Author: Ben Parker.
```
Given a complete Quoute the model would add the author:
```
Quote: I'll be back. Author: Arnold Schwarzenegger.
```
## Usage
The model can be used with [transformers](https://huggingface.co./docs/transformers/en/index) library. Here's an example of loading the model
in 4 bit quantization mode:
```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
model_id = "Eteims/gemma_ft_quote"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=bnb_config, device_map="cuda:0")
```
This code would easily run in a free colab tier.
After loading the model you can use it for inference:
```python
text = "Quote: Elementary, my dear watson."
device = "cuda:0"
inputs = tokenizer(text, return_tensors="pt").to(device)
outputs = model.generate(**inputs, max_new_tokens=20)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```
### Training hyperparameters
The following hyperparameters were used during fine-tuning:
- learning_rate: 0.0002
- train_batch_size: 1
- eval_batch_size: 8
- seed: 42
- gradient_accumulation_steps: 4
- total_train_batch_size: 4
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- lr_scheduler_warmup_steps: 2
- training_steps: 10
- mixed_precision_training: Native AMP
### Framework versions
- PEFT 0.8.2
- Transformers 4.38.1
- Pytorch 2.3.0+cu121
- Datasets 2.17.0
- Tokenizers 0.15.2 |