piratos commited on
Commit
f416ae8
β€’
1 Parent(s): 22b959e
.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
+ blog2-fc.png filter=lfs diff=lfs merge=lfs -text
37
+ NexusRaven.png filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ base_model: codellama/CodeLlama-13b-Instruct-hf
4
+ model-index:
5
+ - name: NexusRaven-13B
6
+ results: []
7
+ ---
8
+ # NexusRaven-13B: Surpassing GPT-4 for Zero-shot Function Calling
9
+ <p align="center">
10
+ <a href="https://huggingface.co/Nexusflow" target="_blank">Nexusflow HF</a> - <a href="https://discord.gg/HDSVmNAs3y" target="_blank">Nexusflow Discord</a> - <a href="http://nexusflow.ai/blogs/ravenv2" target="_blank">NexusRaven-V2 blog post</a> - <a href="https://colab.research.google.com/drive/19JYixRPPlanmW5q49WYi_tU8rhHeCEKW?usp=sharing" target="_blank">Prompting Notebook CoLab</a> - <a href="https://huggingface.co/spaces/Nexusflow/Nexus_Function_Calling_Leaderboard" target="_blank">Leaderboard</a> - <a href="https://huggingface.co/spaces/Nexusflow/NexusRaven-V2-Demo" target="_blank">Read-World Demo</a> - <a href="https://github.com/nexusflowai/NexusRaven-V2" target="_blank">NexusRaven-V2-13B Github</a>
11
+ </p>
12
+
13
+ <p align="center" width="100%">
14
+ <a><img src="NexusRaven.png" alt="NexusRaven" style="width: 40%; min-width: 300px; display: block; margin: auto;"></a>
15
+ </p>
16
+
17
+ ## Introducing NexusRaven-V2-13B
18
+ NexusRaven is an open-source and commercially viable function calling LLM that surpasses the state-of-the-art in function calling capabilities.
19
+
20
+ πŸ’ͺ **Versatile Function Calling Capability**: NexusRaven-V2 is capable of generating single function calls, nested calls, and parallel calls in many challenging cases.
21
+
22
+ πŸ€“ **Fully Explainable**: NexusRaven-V2 is capable of generating very detailed explanations for the function calls it generates. This behavior can be turned off, to save tokens during inference.
23
+
24
+ πŸ“Š **Performance Highlights**: NexusRaven-V2 surpasses GPT-4 by 7% in function calling success rates in human-generated use cases involving nested and composite functions.
25
+
26
+ πŸ”§ **Generalization to the Unseen**: NexusRaven-V2 has never been trained on the functions used in evaluation.
27
+
28
+ πŸ”₯ **Commercially Permissive**: The training of NexusRaven-V2 does not involve any data generated by proprietary LLMs such as GPT-4. You have full control of the model when deployed in commercial applications.
29
+
30
+ Please checkout the following links!
31
+ - [Prompting Notebook CoLab](https://colab.research.google.com/drive/19JYixRPPlanmW5q49WYi_tU8rhHeCEKW?usp=sharing)
32
+ - [Evaluation Leaderboard](https://huggingface.co/spaces/Nexusflow/Nexus_Function_Calling_Leaderboard)
33
+ - [NexusRaven-V2 Real-World Demo](https://huggingface.co/spaces/Nexusflow/NexusRaven-V2-Demo)
34
+
35
+
36
+ ## NexusRaven-V2 model usage
37
+
38
+ NexusRaven-V2 accepts a list of python functions. These python functions can do anything (including sending GET/POST requests to external APIs!). The two requirements include the python function signature and the appropriate docstring to generate the function call.
39
+
40
+ ### NexusRaven-V2's Capabilities
41
+
42
+ NexusRaven-V2 is capable of generating deeply nested function calls, parallel function calls, and simple single calls. It can also justify the function calls it generated. If you would like to generate the call only, please set a stop criteria of \"\<bot\_end\>\". Otherwise, please allow NexusRaven-V2 to run until its stop token (i.e. "\<\/s\>").
43
+
44
+ ### Quick Start Prompting Guide
45
+
46
+ Please refer to our notebook, [How-To-Prompt.ipynb](https://colab.research.google.com/drive/19JYixRPPlanmW5q49WYi_tU8rhHeCEKW?usp=sharing), for more advanced tutorials on using NexusRaven-V2!
47
+
48
+ 1. We strongly recommend to set sampling to False when prompting NexusRaven-V2.
49
+ 2. We strongly recommend a very low temperature (~0.001).
50
+ 3. We strongly recommend following the prompting style below.
51
+
52
+ ### Quickstart
53
+ You can run the model on a GPU using the following code.
54
+ ```python
55
+ # Please `pip install transformers accelerate`
56
+ from transformers import pipeline
57
+
58
+
59
+ pipeline = pipeline(
60
+ "text-generation",
61
+ model="Nexusflow/NexusRaven-V2-13B",
62
+ torch_dtype="auto",
63
+ device_map="auto",
64
+ )
65
+
66
+ prompt_template = \
67
+ '''
68
+ Function:
69
+ def get_weather_data(coordinates):
70
+ """
71
+ Fetches weather data from the Open-Meteo API for the given latitude and longitude.
72
+
73
+ Args:
74
+ coordinates (tuple): The latitude of the location.
75
+
76
+ Returns:
77
+ float: The current temperature in the coordinates you've asked for
78
+ """
79
+
80
+ Function:
81
+ def get_coordinates_from_city(city_name):
82
+ """
83
+ Fetches the latitude and longitude of a given city name using the Maps.co Geocoding API.
84
+
85
+ Args:
86
+ city_name (str): The name of the city.
87
+
88
+ Returns:
89
+ tuple: The latitude and longitude of the city.
90
+ """
91
+
92
+ User Query: {query}<human_end>
93
+
94
+ '''
95
+
96
+ prompt = prompt_template.format(query="What's the weather like in Seattle right now?")
97
+
98
+ result = pipeline(prompt, max_new_tokens=2048, return_full_text=False, do_sample=False, temperature=0.001)[0]["generated_text"]
99
+ print (result)
100
+ ```
101
+
102
+ This should generate the following:
103
+ ```
104
+ Call: get_weather_data(coordinates=get_coordinates_from_city(city_name='Seattle'))<bot_end>
105
+ Thought: The function call `get_weather_data(coordinates=get_coordinates_from_city(city_name='Seattle'))` answers the question "What's the weather like in Seattle right now?" by following these steps:
106
+
107
+ 1. `get_coordinates_from_city(city_name='Seattle')`: This function call fetches the latitude and longitude of the city "Seattle" using the Maps.co Geocoding API.
108
+ 2. `get_weather_data(coordinates=...)`: This function call fetches the current weather data for the coordinates returned by the previous function call.
109
+
110
+ Therefore, the function call `get_weather_data(coordinates=get_coordinates_from_city(city_name='Seattle'))` answers the question "What's the weather like in Seattle right now?" by first fetching the coordinates of the city "Seattle" and then fetching the current weather data for those coordinates.
111
+ ```
112
+
113
+ If you would like to prevent the generation of the explanation of the function call (for example, to save on inference tokens), please set a stopping criteria of \<bot_end\>.
114
+
115
+ Please follow this prompting template to maximize the performance of RavenV2.
116
+
117
+ ### Using with OpenAI FC Schematics
118
+
119
+ [If you currently have a workflow that is built around OpenAI's function calling and you want to try NexusRaven-V2, we have a package that helps you drop in NexusRaven-V2.](https://github.com/nexusflowai/nexusraven-pip)
120
+
121
+
122
+ ## Evaluation
123
+
124
+ <p align="center" width="100%">
125
+ <a><img src="blog2-fc.png" alt="NexusRaven" style="width: 80%; min-width: 300px; display: block; margin: auto;"></a>
126
+ <a><img src="radar-2.png" alt="NexusRaven" style="width: 80%; min-width: 300px; display: block; margin: auto;"></a>
127
+ </p>
128
+
129
+ For a deeper dive into the results, please see our [Github README](https://github.com/nexusflowai/NexusRaven).
130
+
131
+ # Limitations
132
+ 1. The model works best when it is connected with a retriever when there are a multitude of functions, as a large number of functions will saturate the context window of this model.
133
+ 2. The model can be prone to generate incorrect calls. Please ensure proper guardrails to capture errant behavior is in place.
134
+ 3. The explanations generated by NexusRaven-V2 might be incorrect. Please ensure proper guardrails are present to capture errant behavior.
135
+
136
+ ## License
137
+ This model was trained on commercially viable data and is licensed under the [Llama 2 community license](https://huggingface.co/codellama/CodeLlama-13b-hf/blob/main/LICENSE) following the original [CodeLlama-13b-hf](https://huggingface.co/codellama/CodeLlama-13b-hf/) model.
138
+
139
+
140
+ ## References
141
+ We thank the CodeLlama team for their amazing models!
142
+
143
+ ```
144
+ @misc{rozière2023code,
145
+ title={Code Llama: Open Foundation Models for Code},
146
+ author={Baptiste Rozière and Jonas Gehring and Fabian Gloeckle and Sten Sootla and Itai Gat and Xiaoqing Ellen Tan and Yossi Adi and Jingyu Liu and Tal Remez and Jérémy Rapin and Artyom Kozhevnikov and Ivan Evtimov and Joanna Bitton and Manish Bhatt and Cristian Canton Ferrer and Aaron Grattafiori and Wenhan Xiong and Alexandre Défossez and Jade Copet and Faisal Azhar and Hugo Touvron and Louis Martin and Nicolas Usunier and Thomas Scialom and Gabriel Synnaeve},
147
+ year={2023},
148
+ eprint={2308.12950},
149
+ archivePrefix={arXiv},
150
+ primaryClass={cs.CL}
151
+ }
152
+ ```
153
+
154
+
155
+ ## Citation
156
+ ```
157
+ @misc{nexusraven,
158
+ title={NexusRaven-V2: Surpassing GPT-4 for Zero-shot Function Calling},
159
+ author={Nexusflow.ai team},
160
+ year={2023},
161
+ url={https://nexusflow.ai/blogs/ravenv2}
162
+ }
163
+ ```
164
+
165
+ ## Contact
166
+ Please join our [Discord Channel](https://discord.gg/HDSVmNAs3y) to reach out for any issues and comments!
config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "eos_token": "</s>",
4
+ "layer_norm_epsilon": 1e-05,
5
+ "unk_token": "<unk>"
6
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "transformers_version": "4.33.0"
6
+ }
model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f4ed1338575e7562ace010b2d75a22ae6752ad567ee9ea8ff4cf5de2a56bd5bc
3
+ size 13025336177
special_tokens_map.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<human>:",
4
+ "<bot>:",
5
+ "<human_end>",
6
+ "<bot_end>",
7
+ "<func_start>",
8
+ "<func_end>",
9
+ "<docstring_start>",
10
+ "<docstring_end>"
11
+ ],
12
+ "bos_token": {
13
+ "content": "<s>",
14
+ "lstrip": false,
15
+ "normalized": true,
16
+ "rstrip": false,
17
+ "single_word": false
18
+ },
19
+ "eos_token": {
20
+ "content": "</s>",
21
+ "lstrip": false,
22
+ "normalized": true,
23
+ "rstrip": false,
24
+ "single_word": false
25
+ },
26
+ "pad_token": "</s>",
27
+ "unk_token": {
28
+ "content": "<unk>",
29
+ "lstrip": false,
30
+ "normalized": true,
31
+ "rstrip": false,
32
+ "single_word": false
33
+ }
34
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "▁<PRE>",
4
+ "▁<MID>",
5
+ "▁<SUF>",
6
+ "▁<EOT>"
7
+ ],
8
+ "bos_token": {
9
+ "__type": "AddedToken",
10
+ "content": "<s>",
11
+ "lstrip": false,
12
+ "normalized": true,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "clean_up_tokenization_spaces": false,
17
+ "eos_token": {
18
+ "__type": "AddedToken",
19
+ "content": "</s>",
20
+ "lstrip": false,
21
+ "normalized": true,
22
+ "rstrip": false,
23
+ "single_word": false
24
+ },
25
+ "eot_token": "▁<EOT>",
26
+ "fill_token": "<FILL_ME>",
27
+ "legacy": null,
28
+ "middle_token": "▁<MID>",
29
+ "model_max_length": 8192,
30
+ "pad_token": null,
31
+ "prefix_token": "▁<PRE>",
32
+ "sp_model_kwargs": {},
33
+ "suffix_token": "▁<SUF>",
34
+ "tokenizer_class": "CodeLlamaTokenizer",
35
+ "truncation_side": "left",
36
+ "unk_token": {
37
+ "__type": "AddedToken",
38
+ "content": "<unk>",
39
+ "lstrip": false,
40
+ "normalized": true,
41
+ "rstrip": false,
42
+ "single_word": false
43
+ },
44
+ "use_default_system_prompt": false
45
+ }
vocabulary.json ADDED
The diff for this file is too large to render. See raw diff