Text Generation
Transformers
gemma
chat
dpo
fine-tuning
function-calling
instruct
rlhf
sft
tool-calling
Inference Endpoints
danilopeixoto commited on
Commit
0f64ac7
1 Parent(s): 859ce7e
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
GEMMA_LICENSE.md ADDED
@@ -0,0 +1 @@
 
 
1
+ Gemma is provided under and subject to the Gemma Terms of Use found at ai.google.dev/gemma/terms.
LICENSE.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2024, Danilo Peixoto Ferreira. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are met:
5
+
6
+ * Redistributions of source code must retain the above copyright notice, this
7
+ list of conditions and the following disclaimer.
8
+
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ * Neither the name of the copyright holder nor the names of its
14
+ contributors may be used to endorse or promote products derived from
15
+ this software without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
README.md CHANGED
@@ -1,3 +1,162 @@
1
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: bsd-3-clause
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ pretty_name: Pandora 7B Chat
3
+ base_model: google/gemma-7b
4
+ datasets:
5
+ - danilopeixoto/pandora-instruct
6
+ - danilopeixoto/pandora-tool-calling
7
+ - danilopeixoto/pandora-rlhf
8
+ task_categories:
9
+ - text-generation
10
+ tags:
11
+ - chat
12
+ - dpo
13
+ - fine-tuning
14
+ - function-calling
15
+ - instruct
16
+ - rlhf
17
+ - sft
18
+ - tool-calling
19
  license: bsd-3-clause
20
  ---
21
+
22
+ # Pandora 7B Chat
23
+
24
+ Pandora 7B Chat is a Large Language Model (LLM) designed for chat applications.
25
+
26
+ Pandora is fine-tuned with publicly available datasets, including a tool-calling dataset for agent-based tasks and a Reinforcement Learning from Human Feedback (RLHF) dataset with Direct Preference Optimization (DPO) training for preference alignment.
27
+
28
+ The fine-tuning process incorporates Low-Rank Adaptation (LoRA) with the [MLX framework](https://ml-explore.github.io/mlx/build/html/index.html), optimized for Apple Silicon.
29
+
30
+ The model is based on the [google/gemma-7b](https://huggingface.co/google/gemma-7b) model.
31
+
32
+ ![Pandora](assets/pandora.jpeg)
33
+
34
+ ## Datasets
35
+
36
+ Datasets used for fine-tuning stages:
37
+
38
+ - [danilopeixoto/pandora-instruct](https://huggingface.co/datasets/danilopeixoto/pandora-instruct)
39
+ - [danilopeixoto/pandora-tool-calling](https://huggingface.co/datasets/danilopeixoto/pandora-tool-calling)
40
+ - [danilopeixoto/pandora-rlhf](https://huggingface.co/datasets/danilopeixoto/pandora-rlhf)
41
+
42
+ ## Evaluation
43
+
44
+ Evaluation on [MT-Bench](https://arxiv.org/abs/2306.05685) multi-turn benchmark:
45
+
46
+ ![Benchmark](assets/benchmark.svg)
47
+
48
+ ## Usage
49
+
50
+ Install package dependencies:
51
+
52
+ ```shell
53
+ pip install mlx-lm
54
+ ```
55
+
56
+ Generate response:
57
+
58
+ ```python
59
+ from mlx_lm import load, generate
60
+
61
+
62
+ model, tokenizer = load('danilopeixoto/pandora-7b-chat')
63
+
64
+ prompt = '''<|start|>system
65
+ You are Pandora, a helpful AI assistant.
66
+ <|end|>
67
+ <|start|>user
68
+ Hello!
69
+ <|end|>
70
+ <|start|>'''
71
+
72
+ response = generate(model, tokenizer, prompt)
73
+ print(response)
74
+ ```
75
+
76
+ The model supports the following prompt templates:
77
+
78
+ **Question-answering with system messages**
79
+
80
+ ```txt
81
+ <|start|>system
82
+ {system_message}
83
+ <|end|>
84
+ <|start|>user
85
+ {user_message}
86
+ <|end|>
87
+ <|start|>assistant
88
+ {assistant_message}
89
+ <|end|>
90
+ ```
91
+
92
+ **Tool calling**
93
+
94
+ ```txt
95
+ <|start|>system
96
+ {system_message}
97
+ <|end|>
98
+ <|start|>system:tools
99
+ {system_tools_message}
100
+ <|end|>
101
+ <|start|>user
102
+ {user_message}
103
+ <|end|>
104
+ <|start|>assistant:tool_calls
105
+ {assistant_tool_calls_message}
106
+ <|end|>
107
+ <|start|>tool
108
+ {tool_message}
109
+ <|end|>
110
+ <|start|>assistant
111
+ {assistant_message}
112
+ <|end|>
113
+ ```
114
+
115
+ > **Note** The variables `system_tools_message`, `assistant_tool_calls_message`, and `tool_message` must contain valid YAML.
116
+
117
+ An example of a tool-calling prompt:
118
+
119
+ ```python
120
+ prompt = '''<|start|>system
121
+ You are Pandora, a helpful AI assistant.
122
+ <|end|>
123
+ <|start|>system:tools
124
+ - description: Get the current weather based on a given location.
125
+ name: get_current_weather
126
+ parameters:
127
+ type: object
128
+ properties:
129
+ location:
130
+ type: string
131
+ description: The location name.
132
+ required:
133
+ - location
134
+ <|end|>
135
+ <|start|>user
136
+ What is the weather in Sydney, Australia?
137
+ <|end|>
138
+ <|start|>assistant:tool_calls
139
+ - name: get_current_weather
140
+ arguments:
141
+ location: Sydney, Australia
142
+ <|end|>
143
+ <|start|>tool
144
+ name: get_current_weather
145
+ content: 72°F
146
+ <|end|>
147
+ <|start|>'''
148
+ ```
149
+
150
+ ## Examples
151
+
152
+ **OpenGPTs**
153
+
154
+ ![OpenGPTs](assets/opengpts.png)
155
+
156
+ ## Copyright and license
157
+
158
+ Copyright (c) 2024, Danilo Peixoto Ferreira. All rights reserved.
159
+
160
+ Project developed under a [BSD-3-Clause license](LICENSE.md).
161
+
162
+ Gemma is provided under and subject to the [Gemma Terms of Use license](GEMMA_LICENSE.md).
added_tokens.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "<|end|>": 256001,
3
+ "<|start|>": 256000
4
+ }
assets/.DS_Store ADDED
Binary file (6.15 kB). View file
 
assets/benchmark.svg ADDED
assets/opengpts.png ADDED
assets/pandora.jpeg ADDED
config.json ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "vocab_size": 256002,
3
+ "max_position_embeddings": 8192,
4
+ "hidden_size": 3072,
5
+ "intermediate_size": 24576,
6
+ "num_hidden_layers": 28,
7
+ "num_attention_heads": 16,
8
+ "head_dim": 256,
9
+ "num_key_value_heads": 16,
10
+ "hidden_act": "gelu",
11
+ "initializer_range": 0.02,
12
+ "rms_norm_eps": 1e-06,
13
+ "use_cache": true,
14
+ "rope_theta": 10000.0,
15
+ "attention_bias": false,
16
+ "attention_dropout": 0.0,
17
+ "return_dict": true,
18
+ "output_hidden_states": false,
19
+ "output_attentions": false,
20
+ "torchscript": false,
21
+ "torch_dtype": "bfloat16",
22
+ "use_bfloat16": false,
23
+ "tf_legacy_loss": false,
24
+ "pruned_heads": {},
25
+ "tie_word_embeddings": true,
26
+ "chunk_size_feed_forward": 0,
27
+ "is_encoder_decoder": false,
28
+ "is_decoder": false,
29
+ "cross_attention_hidden_size": null,
30
+ "add_cross_attention": false,
31
+ "tie_encoder_decoder": false,
32
+ "max_length": 20,
33
+ "min_length": 0,
34
+ "do_sample": false,
35
+ "early_stopping": false,
36
+ "num_beams": 1,
37
+ "num_beam_groups": 1,
38
+ "diversity_penalty": 0.0,
39
+ "temperature": 1.0,
40
+ "top_k": 50,
41
+ "top_p": 1.0,
42
+ "typical_p": 1.0,
43
+ "repetition_penalty": 1.0,
44
+ "length_penalty": 1.0,
45
+ "no_repeat_ngram_size": 0,
46
+ "encoder_no_repeat_ngram_size": 0,
47
+ "bad_words_ids": null,
48
+ "num_return_sequences": 1,
49
+ "output_scores": false,
50
+ "return_dict_in_generate": false,
51
+ "forced_bos_token_id": null,
52
+ "forced_eos_token_id": null,
53
+ "remove_invalid_values": false,
54
+ "exponential_decay_length_penalty": null,
55
+ "suppress_tokens": null,
56
+ "begin_suppress_tokens": null,
57
+ "architectures": [
58
+ "GemmaForCausalLM"
59
+ ],
60
+ "finetuning_task": null,
61
+ "id2label": {
62
+ "0": "LABEL_0",
63
+ "1": "LABEL_1"
64
+ },
65
+ "label2id": {
66
+ "LABEL_0": 0,
67
+ "LABEL_1": 1
68
+ },
69
+ "tokenizer_class": null,
70
+ "prefix": null,
71
+ "bos_token_id": 2,
72
+ "pad_token_id": 0,
73
+ "eos_token_id": 256001,
74
+ "sep_token_id": null,
75
+ "decoder_start_token_id": null,
76
+ "task_specific_params": null,
77
+ "problem_type": null,
78
+ "_name_or_path": "models/pandora-7b-sfttool-2000it",
79
+ "transformers_version": "4.38.1",
80
+ "model_type": "gemma",
81
+ "rope_scaling": null
82
+ }
model.0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad26db0dc8f8fa892b7aa2b2147438b0f7ee0e83d10556b193ac513f5a0b2424
3
+ size 5297499010
model.1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c1f8c925ccf32b96295430ad46795a429fa042df1e0eafa772675a1d2d3f8be
3
+ size 5234624520
model.2.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:32fed2eb2c3785bdf4aee3dc6ae0ce48de0e6c8efb236cb80bf7f88fc2833088
3
+ size 5284943325
model.3.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da342e27db0dd06c2865ee288191baea64f4cf1fe4d7a2cf04510bd7aaf44695
3
+ size 1258336744
special_tokens_map.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<bos>",
4
+ "<eos>",
5
+ "<unk>",
6
+ "<pad>",
7
+ "<|start|>",
8
+ "<|end|>"
9
+ ],
10
+ "bos_token": {
11
+ "content": "<bos>",
12
+ "lstrip": false,
13
+ "normalized": false,
14
+ "rstrip": false,
15
+ "single_word": false
16
+ },
17
+ "eos_token": {
18
+ "content": "<|end|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<pad>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ },
31
+ "unk_token": {
32
+ "content": "<unk>",
33
+ "lstrip": false,
34
+ "normalized": false,
35
+ "rstrip": false,
36
+ "single_word": false
37
+ }
38
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fd3bef86b3df2b29baafcd73c2888c50c98ea304935de941a5f69d47110e474e
3
+ size 17477923
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:61a7b147390c64585d6c3543dd6fc636906c9af3865a5548f27f31aee1d4c8e2
3
+ size 4241003
tokenizer_config.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "256000": {
38
+ "content": "<|start|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "256001": {
46
+ "content": "<|end|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ }
53
+ },
54
+ "additional_special_tokens": [
55
+ "<bos>",
56
+ "<eos>",
57
+ "<unk>",
58
+ "<pad>",
59
+ "<|start|>",
60
+ "<|end|>"
61
+ ],
62
+ "bos_token": "<bos>",
63
+ "clean_up_tokenization_spaces": false,
64
+ "eos_token": "<|end|>",
65
+ "legacy": null,
66
+ "model_max_length": 1000000000000000019884624838656,
67
+ "pad_token": "<pad>",
68
+ "sp_model_kwargs": {},
69
+ "spaces_between_special_tokens": false,
70
+ "tokenizer_class": "GemmaTokenizer",
71
+ "unk_token": "<unk>",
72
+ "use_default_system_prompt": false
73
+ }