Transformers
Safetensors
bodhicitta commited on
Commit
0d3cb78
·
verified ·
1 Parent(s): e501c9e

add model files

Browse files
.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
README.md ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ datasets:
4
+ - hypervariance/function-calling-sharegpt
5
+ ---
6
+
7
+ # Model Card for Model ID
8
+
9
+ Gemma 2B function calling. [google/gemma-2b-it](https://huggingface.co/google/gemma-2b-it) finetuned on [hypervariance/function-calling-sharegpt](https://huggingface.co/datasets/hypervariance/function-calling-sharegpt).
10
+
11
+ ## Usage
12
+
13
+ Make sure you have the [peft](https://huggingface.co/docs/peft/en/index) package installed. You can install it with `pip install peft`.
14
+
15
+
16
+ ```python
17
+ from transformers import AutoModelForCausalLM , AutoTokenizer
18
+
19
+ tokenizer = AutoTokenizer.from_pretrained("bodhicitta/gemma-2b-function-call", trust_remote_code=True)
20
+ model = AutoModelForCausalLM.from_pretrained("bodhicitta/gemma-2b-function-call", trust_remote_code=True, device_map="auto")
21
+
22
+ inputs = tokenizer(prompt,return_tensors="pt").to(model.device)
23
+
24
+ outputs = model.generate(**inputs,do_sample=True,temperature=0.1,top_p=0.95,max_new_tokens=100)
25
+
26
+ print(tokenizer.decode(outputs[0]))
27
+ ```
28
+
29
+ You can also use sharegpt formatted prompts:
30
+
31
+ ```python
32
+ from transformers import AutoModelForCausalLM , AutoTokenizer
33
+
34
+ tokenizer = AutoTokenizer.from_pretrained("bodhicitta/gemma-2b-function-call", trust_remote_code=True)
35
+ model = AutoModelForCausalLM.from_pretrained("bodhicitta/gemma-2b-function-call", trust_remote_code=True, device_map="auto")
36
+
37
+ chat = [
38
+ {
39
+ "from": "system",
40
+ "value": "SYSTEM PROMPT",
41
+ },
42
+ {
43
+ "from": "human",
44
+ "value": "USER QUESTION"
45
+ },
46
+ ]
47
+
48
+ prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
49
+
50
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
51
+
52
+ outputs = model.generate(**inputs,do_sample=True,temperature=0.1,top_p=0.95,max_new_tokens=100)
53
+
54
+ print(tokenizer.decode(outputs[0]))
55
+ ```
56
+
57
+ ## Prompt template
58
+
59
+ ```text
60
+ You are a helpful assistant with access to the following functions. Use them if required -
61
+ {
62
+ "name": "function name",
63
+ "description": "function description",
64
+ "parameters": {
65
+ "type": "type (object/number/string)",
66
+ "properties": {
67
+ "property_1": {
68
+ "type": "type",
69
+ "description": "property description"
70
+ }
71
+ },
72
+ "required": [
73
+ "property_1"
74
+ ]
75
+ }
76
+ }
77
+
78
+ To use these functions respond with:
79
+ <functioncall> {"name": "function_name", "arguments": {"arg_1": "value_1", "arg_1": "value_1", ...}} </functioncall>
80
+
81
+ Edge cases you must handle:
82
+ - If there are no functions that match the user request, you will respond politely that you cannot help.
83
+
84
+ User Question:
85
+ USER_QUESTION
86
+ ```
87
+
88
+ Function calls are enclosed in `<functioncall>` `</functioncall>`.
89
+
90
+ The model was trained using the same delimiters as [google/gemma-2b-it](https://huggingface.co/google/gemma-2b-it):
91
+
92
+ ```text
93
+ <bos><start_of_turn>user
94
+ Write a hello world program<end_of_turn>
95
+ <start_of_turn>model
96
+ ```
97
+
98
+ Use `<end_of_turn>` stop sequence to prevent the model from generating further text.
adapter_config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "google/gemma-2b-it",
5
+ "bias": "none",
6
+ "fan_in_fan_out": false,
7
+ "inference_mode": true,
8
+ "init_lora_weights": true,
9
+ "layers_pattern": null,
10
+ "layers_to_transform": null,
11
+ "loftq_config": {},
12
+ "lora_alpha": 16,
13
+ "lora_dropout": 0.1,
14
+ "megatron_config": null,
15
+ "megatron_core": "megatron.core",
16
+ "modules_to_save": null,
17
+ "peft_type": "LORA",
18
+ "r": 8,
19
+ "rank_pattern": {},
20
+ "revision": null,
21
+ "target_modules": [
22
+ "o_proj",
23
+ "q_proj",
24
+ "up_proj",
25
+ "k_proj",
26
+ "gate_proj",
27
+ "v_proj",
28
+ "down_proj"
29
+ ],
30
+ "task_type": "CAUSAL_LM",
31
+ "use_dora": false,
32
+ "use_rslora": false
33
+ }
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.1"
7
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<start_of_turn>",
4
+ "<end_of_turn>"
5
+ ],
6
+ "bos_token": {
7
+ "content": "<bos>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false
12
+ },
13
+ "eos_token": {
14
+ "content": "<eos>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false
19
+ },
20
+ "pad_token": {
21
+ "content": "<eos>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false
26
+ },
27
+ "unk_token": {
28
+ "content": "<unk>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false
33
+ }
34
+ }
tokenizer_config.json ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": true,
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
+ "106": {
38
+ "content": "<start_of_turn>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "107": {
46
+ "content": "<end_of_turn>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ }
53
+ },
54
+ "additional_special_tokens": [
55
+ "<start_of_turn>",
56
+ "<end_of_turn>"
57
+ ],
58
+ "bos_token": "<bos>",
59
+ "chat_template": "{% for message in messages %}{% if message['from'] == 'system' %}{{ '<start_of_turn>user\\n' + message['value'] }}{% elif message['from'] == 'human' %}{% if loop.index0 == 1 %}{{ '\\nUser Question:\\n' }}{% else %}{{ '<start_of_turn>user\\n' }}{% endif %}{{ message['value'] + '<end_of_turn>' }}{% elif message['from'] == 'gpt' %}{{ '<start_of_turn>model\\n' + message['value'] + ' ' + '<end_of_turn>' }}{% elif message['from'] == 'function_response' %}{{ '<start_of_turn>user\\n' + message['value'] + ' ' + '<end_of_turn>' }}{% endif %}{% if not loop.last %}{{ '\\n' }}{% endif %}{% endfor %}{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% if add_generation_prompt %}{{ '\\n<start_of_turn>model\\n' }}{% endif %}",
60
+ "clean_up_tokenization_spaces": false,
61
+ "eos_token": "<eos>",
62
+ "legacy": null,
63
+ "model_max_length": 1000000000000000019884624838656,
64
+ "pad_token": "<eos>",
65
+ "sp_model_kwargs": {},
66
+ "spaces_between_special_tokens": false,
67
+ "tokenizer_class": "GemmaTokenizer",
68
+ "unk_token": "<unk>",
69
+ "use_default_system_prompt": false
70
+ }