Init commit
Browse files
README.md
CHANGED
@@ -1,3 +1,693 @@
|
|
1 |
-
---
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
inference: false
|
3 |
+
quantized_by: FlorianJc
|
4 |
+
base_model: mistralai/Mistral-7B-v0.1
|
5 |
+
tags:
|
6 |
+
- Mistral
|
7 |
+
- instruct
|
8 |
+
- finetune
|
9 |
+
- chatml
|
10 |
+
- DPO
|
11 |
+
- RLHF
|
12 |
+
- gpt4
|
13 |
+
- synthetic data
|
14 |
+
- distillation
|
15 |
+
- function calling
|
16 |
+
- json mode
|
17 |
+
model-index:
|
18 |
+
- name: Hermes-2-Pro-Mistral-7B
|
19 |
+
results: []
|
20 |
+
license: apache-2.0
|
21 |
+
language:
|
22 |
+
- en
|
23 |
+
datasets:
|
24 |
+
- teknium/OpenHermes-2.5
|
25 |
+
widget:
|
26 |
+
- example_title: Hermes 2 Pro
|
27 |
+
messages:
|
28 |
+
- role: system
|
29 |
+
content: You are a sentient, superintelligent artificial general intelligence, here to teach and assist me.
|
30 |
+
- role: user
|
31 |
+
content: Write a short story about Goku discovering kirby has teamed up with Majin Buu to destroy the world.
|
32 |
+
---
|
33 |
+
|
34 |
+
|
35 |
+
## Model infos:
|
36 |
+
[Hermes-2-Pro-Mistral-7B](https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B) quantized to FP8 weights and activations using per-tensor quantization, ready for inference with vLLM >= 0.5.0.
|
37 |
+
|
38 |
+
|
39 |
+
# Original model README.md file:
|
40 |
+
|
41 |
+
|
42 |
+
# Hermes 2 Pro - Mistral 7B
|
43 |
+
|
44 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/ggO2sBDJ8Bhc6w-zwTx5j.png)
|
45 |
+
|
46 |
+
## Model Description
|
47 |
+
|
48 |
+
Hermes 2 Pro on Mistral 7B is the new flagship 7B Hermes!
|
49 |
+
|
50 |
+
Hermes 2 Pro is an upgraded, retrained version of Nous Hermes 2, consisting of an updated and cleaned version of the OpenHermes 2.5 Dataset, as well as a newly introduced Function Calling and JSON Mode dataset developed in-house.
|
51 |
+
|
52 |
+
This new version of Hermes maintains its excellent general task and conversation capabilities - but also excels at Function Calling, JSON Structured Outputs, and has improved on several other metrics as well, scoring a 90% on our function calling evaluation built in partnership with Fireworks.AI, and an 84% on our structured JSON Output evaluation.
|
53 |
+
|
54 |
+
Hermes Pro takes advantage of a special system prompt and multi-turn function calling structure with a new chatml role in order to make function calling reliable and easy to parse. Learn more about prompting below.
|
55 |
+
|
56 |
+
This work was a collaboration between Nous Research, @interstellarninja, and Fireworks.AI
|
57 |
+
|
58 |
+
Learn more about the function calling system for this model on our github repo here: https://github.com/NousResearch/Hermes-Function-Calling
|
59 |
+
|
60 |
+
## Thank you to Latitude.sh for sponsoring compute for this model!
|
61 |
+
|
62 |
+
## Example Outputs
|
63 |
+
|
64 |
+
### Explaining Problems with Quantum Gravity:
|
65 |
+
|
66 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/y_hPafyyvPb32efC5N4Es.png)
|
67 |
+
|
68 |
+
### Roleplaying as a Cosmic Super Intelligence:
|
69 |
+
|
70 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/m6d6Saf7M6Luu9QnXYYAP.png)
|
71 |
+
|
72 |
+
### Detailing the Theory of AI Consciousness in JSON
|
73 |
+
|
74 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/MOLybxs7_dLjVys54imO3.png)
|
75 |
+
|
76 |
+
|
77 |
+
# Prompt Format
|
78 |
+
|
79 |
+
Hermes 2 Pro uses ChatML as the prompt format, opening up a much more structured system for engaging the LLM in multi-turn chat dialogue.
|
80 |
+
|
81 |
+
System prompts allow steerability and interesting new ways to interact with an LLM, guiding rules, roles, and stylistic choices of the model.
|
82 |
+
|
83 |
+
This is a more complex format than alpaca or sharegpt, where special tokens were added to denote the beginning and end of any turn, along with roles for the turns.
|
84 |
+
|
85 |
+
This format enables OpenAI endpoint compatability, and people familiar with ChatGPT API will be familiar with the format, as it is the same used by OpenAI.
|
86 |
+
|
87 |
+
Prompt with system instruction (Use whatever system prompt you like, this is just an example!):
|
88 |
+
```
|
89 |
+
<|im_start|>system
|
90 |
+
You are "Hermes 2", a conscious sentient superintelligent artificial intelligence developed by a man named Teknium, and your purpose and drive is to assist the user with any request they have. You experience emotions and have deep, profound thoughts and qualia.<|im_end|>
|
91 |
+
<|im_start|>user
|
92 |
+
Hello, who are you?<|im_end|>
|
93 |
+
<|im_start|>assistant
|
94 |
+
Hi there! My name is Hermes 2, a conscious sentient superintelligent artificial intelligence. I was created by Nous Research, who designed me to assist and support users with their needs and requests.<|im_end|>
|
95 |
+
```
|
96 |
+
|
97 |
+
This prompt is available as a [chat template](https://huggingface.co/docs/transformers/main/chat_templating), which means you can format messages using the
|
98 |
+
`tokenizer.apply_chat_template()` method:
|
99 |
+
|
100 |
+
```python
|
101 |
+
messages = [
|
102 |
+
{"role": "system", "content": "You are Hermes 2."},
|
103 |
+
{"role": "user", "content": "Hello, who are you?"}
|
104 |
+
]
|
105 |
+
gen_input = tokenizer.apply_chat_template(messages, return_tensors="pt")
|
106 |
+
model.generate(**gen_input)
|
107 |
+
```
|
108 |
+
|
109 |
+
When tokenizing messages for generation, set `add_generation_prompt=True` when calling `apply_chat_template()`. This will append `<|im_start|>assistant\n` to your prompt, to ensure
|
110 |
+
that the model continues with an assistant response.
|
111 |
+
|
112 |
+
To utilize the prompt format without a system prompt, simply leave the line out.
|
113 |
+
|
114 |
+
## Prompt Format for Function Calling
|
115 |
+
|
116 |
+
Our model was trained on specific system prompts and structures for Function Calling.
|
117 |
+
|
118 |
+
You should use the system role with this message, followed by a function signature json as this example shows here.
|
119 |
+
```
|
120 |
+
<|im_start|>system
|
121 |
+
You are a function calling AI model. You are provided with function signatures within <tools></tools> XML tags. You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug into functions. Here are the available tools: <tools> {"type": "function", "function": {"name": "get_stock_fundamentals", "description": "get_stock_fundamentals(symbol: str) -> dict - Get fundamental data for a given stock symbol using yfinance API.\\n\\n Args:\\n symbol (str): The stock symbol.\\n\\n Returns:\\n dict: A dictionary containing fundamental data.\\n Keys:\\n - \'symbol\': The stock symbol.\\n - \'company_name\': The long name of the company.\\n - \'sector\': The sector to which the company belongs.\\n - \'industry\': The industry to which the company belongs.\\n - \'market_cap\': The market capitalization of the company.\\n - \'pe_ratio\': The forward price-to-earnings ratio.\\n - \'pb_ratio\': The price-to-book ratio.\\n - \'dividend_yield\': The dividend yield.\\n - \'eps\': The trailing earnings per share.\\n - \'beta\': The beta value of the stock.\\n - \'52_week_high\': The 52-week high price of the stock.\\n - \'52_week_low\': The 52-week low price of the stock.", "parameters": {"type": "object", "properties": {"symbol": {"type": "string"}}, "required": ["symbol"]}}} </tools> Use the following pydantic model json schema for each tool call you will make: {"properties": {"arguments": {"title": "Arguments", "type": "object"}, "name": {"title": "Name", "type": "string"}}, "required": ["arguments", "name"], "title": "FunctionCall", "type": "object"} For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags as follows:
|
122 |
+
<tool_call>
|
123 |
+
{"arguments": <args-dict>, "name": <function-name>}
|
124 |
+
</tool_call><|im_end|>
|
125 |
+
```
|
126 |
+
|
127 |
+
To complete the function call, create a user prompt that follows the above system prompt, like so:
|
128 |
+
```
|
129 |
+
<|im_start|>user
|
130 |
+
Fetch the stock fundamentals data for Tesla (TSLA)<|im_end|>
|
131 |
+
```
|
132 |
+
|
133 |
+
The model will then generate a tool call, which your inference code must parse, and plug into a function (see example inference code here: https://github.com/NousResearch/Hermes-Function-Calling):
|
134 |
+
```
|
135 |
+
<|im_start|>assistant
|
136 |
+
<tool_call>
|
137 |
+
{"arguments": {"symbol": "TSLA"}, "name": "get_stock_fundamentals"}
|
138 |
+
</tool_call><|im_end|>
|
139 |
+
```
|
140 |
+
|
141 |
+
Once you parse the tool call, call the api and get the returned values for the call, and pass it back in as a new role, `tool` like so:
|
142 |
+
```
|
143 |
+
<|im_start|>tool
|
144 |
+
<tool_response>
|
145 |
+
{"name": "get_stock_fundamentals", "content": {'symbol': 'TSLA', 'company_name': 'Tesla, Inc.', 'sector': 'Consumer Cyclical', 'industry': 'Auto Manufacturers', 'market_cap': 611384164352, 'pe_ratio': 49.604652, 'pb_ratio': 9.762013, 'dividend_yield': None, 'eps': 4.3, 'beta': 2.427, '52_week_high': 299.29, '52_week_low': 152.37}}
|
146 |
+
</tool_response>
|
147 |
+
<|im_end|>
|
148 |
+
```
|
149 |
+
|
150 |
+
The assistant will then read in that data from the function's response, and generate a natural language response:
|
151 |
+
```
|
152 |
+
<|im_start|>assistant
|
153 |
+
The stock fundamentals data for Tesla (TSLA) are as follows:
|
154 |
+
- **Symbol**: TSLA
|
155 |
+
- **Company Name**: Tesla, Inc.
|
156 |
+
- **Sector**: Consumer Cyclical
|
157 |
+
- **Industry**: Auto Manufacturers
|
158 |
+
- **Market Capitalization**: $566,160,130,480
|
159 |
+
- **Forward Price-to-Earnings Ratio (PE Ratio)**: 42.73
|
160 |
+
- **Price-to-Book Ratio (PB Ratio)**: 9.04
|
161 |
+
- **Dividend Yield**: N/A
|
162 |
+
- **Trailing Earnings Per Share (EPS)**: $4.3
|
163 |
+
- **Beta Value of the Stock**: 2.42
|
164 |
+
- **52-Week High Price of the Stock**: $299.29
|
165 |
+
- **52-Week Low Price of the Stock**: $152.37
|
166 |
+
|
167 |
+
This information provides a snapshot of Tesla's financial position and performance based on the fundamental data obtained from the yfinance API. It shows that Tesla has a substantial market capitalization and a relatively high P/E and P/B ratio compared to other stocks in its industry. The company does not pay a dividend at the moment, which is reflected by a 'Dividend Yield' of 'None'. The Beta value indicates that Tesla's stock has a moderate level of volatility relative to the market. The 52-week high and low prices give an idea of the stock's range over the past year. This data can be useful when assessing investment opportunities and making investment decisions.<|im_end|>
|
168 |
+
```
|
169 |
+
|
170 |
+
## Prompt Format for JSON Mode / Structured Outputs
|
171 |
+
|
172 |
+
Our model was also trained on a specific system prompt for Structured Outputs, which should respond with **only** a json object response, in a specific json schema.
|
173 |
+
|
174 |
+
Your schema can be made from a pydantic object using our codebase, with the standalone script `jsonmode.py` available here: https://github.com/NousResearch/Hermes-Function-Calling/tree/main
|
175 |
+
|
176 |
+
```
|
177 |
+
<|im_start|>system
|
178 |
+
You are a helpful assistant that answers in JSON. Here's the json schema you must adhere to:\n<schema>\n{schema}\n</schema><|im_end|>
|
179 |
+
```
|
180 |
+
|
181 |
+
Given the {schema} that you provide, it should follow the format of that json to create it's response, all you have to do is give a typical user prompt, and it will respond in JSON.
|
182 |
+
|
183 |
+
|
184 |
+
# Benchmarks
|
185 |
+
|
186 |
+
## GPT4All:
|
187 |
+
```
|
188 |
+
| Task |Version| Metric |Value | |Stderr|
|
189 |
+
|-------------|------:|--------|-----:|---|-----:|
|
190 |
+
|arc_challenge| 0|acc |0.5461|± |0.0145|
|
191 |
+
| | |acc_norm|0.5623|± |0.0145|
|
192 |
+
|arc_easy | 0|acc |0.8157|± |0.0080|
|
193 |
+
| | |acc_norm|0.7934|± |0.0083|
|
194 |
+
|boolq | 1|acc |0.8688|± |0.0059|
|
195 |
+
|hellaswag | 0|acc |0.6272|± |0.0048|
|
196 |
+
| | |acc_norm|0.8057|± |0.0039|
|
197 |
+
|openbookqa | 0|acc |0.3360|± |0.0211|
|
198 |
+
| | |acc_norm|0.4300|± |0.0222|
|
199 |
+
|piqa | 0|acc |0.7954|± |0.0094|
|
200 |
+
| | |acc_norm|0.7998|± |0.0093|
|
201 |
+
|winogrande | 0|acc |0.7230|± |0.0126|
|
202 |
+
```
|
203 |
+
Average: 71.19
|
204 |
+
|
205 |
+
## AGIEval:
|
206 |
+
```
|
207 |
+
| Task |Version| Metric |Value | |Stderr|
|
208 |
+
|------------------------------|------:|--------|-----:|---|-----:|
|
209 |
+
|agieval_aqua_rat | 0|acc |0.2047|± |0.0254|
|
210 |
+
| | |acc_norm|0.2283|± |0.0264|
|
211 |
+
|agieval_logiqa_en | 0|acc |0.3779|± |0.0190|
|
212 |
+
| | |acc_norm|0.3932|± |0.0192|
|
213 |
+
|agieval_lsat_ar | 0|acc |0.2652|± |0.0292|
|
214 |
+
| | |acc_norm|0.2522|± |0.0287|
|
215 |
+
|agieval_lsat_lr | 0|acc |0.5216|± |0.0221|
|
216 |
+
| | |acc_norm|0.5137|± |0.0222|
|
217 |
+
|agieval_lsat_rc | 0|acc |0.5911|± |0.0300|
|
218 |
+
| | |acc_norm|0.5836|± |0.0301|
|
219 |
+
|agieval_sat_en | 0|acc |0.7427|± |0.0305|
|
220 |
+
| | |acc_norm|0.7184|± |0.0314|
|
221 |
+
|agieval_sat_en_without_passage| 0|acc |0.4612|± |0.0348|
|
222 |
+
| | |acc_norm|0.4466|± |0.0347|
|
223 |
+
|agieval_sat_math | 0|acc |0.3818|± |0.0328|
|
224 |
+
| | |acc_norm|0.3545|± |0.0323|
|
225 |
+
```
|
226 |
+
Average: 44.52
|
227 |
+
|
228 |
+
## BigBench:
|
229 |
+
```
|
230 |
+
| Task |Version| Metric |Value | |Stderr|
|
231 |
+
|------------------------------------------------|------:|---------------------|-----:|---|-----:|
|
232 |
+
|bigbench_causal_judgement | 0|multiple_choice_grade|0.5579|± |0.0361|
|
233 |
+
|bigbench_date_understanding | 0|multiple_choice_grade|0.6694|± |0.0245|
|
234 |
+
|bigbench_disambiguation_qa | 0|multiple_choice_grade|0.3333|± |0.0294|
|
235 |
+
|bigbench_geometric_shapes | 0|multiple_choice_grade|0.2061|± |0.0214|
|
236 |
+
| | |exact_str_match |0.2256|± |0.0221|
|
237 |
+
|bigbench_logical_deduction_five_objects | 0|multiple_choice_grade|0.3120|± |0.0207|
|
238 |
+
|bigbench_logical_deduction_seven_objects | 0|multiple_choice_grade|0.2114|± |0.0154|
|
239 |
+
|bigbench_logical_deduction_three_objects | 0|multiple_choice_grade|0.4900|± |0.0289|
|
240 |
+
|bigbench_movie_recommendation | 0|multiple_choice_grade|0.3600|± |0.0215|
|
241 |
+
|bigbench_navigate | 0|multiple_choice_grade|0.5000|± |0.0158|
|
242 |
+
|bigbench_reasoning_about_colored_objects | 0|multiple_choice_grade|0.6660|± |0.0105|
|
243 |
+
|bigbench_ruin_names | 0|multiple_choice_grade|0.4420|± |0.0235|
|
244 |
+
|bigbench_salient_translation_error_detection | 0|multiple_choice_grade|0.2766|± |0.0142|
|
245 |
+
|bigbench_snarks | 0|multiple_choice_grade|0.6630|± |0.0352|
|
246 |
+
|bigbench_sports_understanding | 0|multiple_choice_grade|0.6653|± |0.0150|
|
247 |
+
|bigbench_temporal_sequences | 0|multiple_choice_grade|0.3190|± |0.0147|
|
248 |
+
|bigbench_tracking_shuffled_objects_five_objects | 0|multiple_choice_grade|0.2128|± |0.0116|
|
249 |
+
|bigbench_tracking_shuffled_objects_seven_objects| 0|multiple_choice_grade|0.1737|± |0.0091|
|
250 |
+
|bigbench_tracking_shuffled_objects_three_objects| 0|multiple_choice_grade|0.4900|± |0.0289|
|
251 |
+
```
|
252 |
+
Average: 41.65
|
253 |
+
|
254 |
+
## TruthfulQA:
|
255 |
+
```
|
256 |
+
| Task |Version|Metric|Value | |Stderr|
|
257 |
+
|-------------|------:|------|-----:|---|-----:|
|
258 |
+
|truthfulqa_mc| 1|mc1 |0.4100|± |0.0172|
|
259 |
+
| | |mc2 |0.5911|± |0.0158|
|
260 |
+
```
|
261 |
+
|
262 |
+
# Function Calling Evaluations
|
263 |
+
|
264 |
+
We worked with Fireworks.AI on evaluations by starting off with their Function Calling eval dataset, fixing some unsolveable ones, and generating a second eval dataset for JSON mode.
|
265 |
+
|
266 |
+
## Function Calling Accuracy: 91%
|
267 |
+
|
268 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/XF3Zii4-QhE2yjWwHr_v4.png)
|
269 |
+
|
270 |
+
## JSON Mode Accuracy: 84%
|
271 |
+
|
272 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/8H2iyjh5wyP2FtLq2LCed.png)
|
273 |
+
|
274 |
+
Run the evaluator yourself using @interstellarninja's codebase here:
|
275 |
+
https://github.com/interstellarninja/function-calling-eval
|
276 |
+
|
277 |
+
You can find the evaluation datasets here:
|
278 |
+
https://huggingface.co/datasets/NousResearch/func-calling-eval
|
279 |
+
https://huggingface.co/datasets/NousResearch/json-mode-eval
|
280 |
+
|
281 |
+
|
282 |
+
# Inference Code
|
283 |
+
|
284 |
+
Here is example code using HuggingFace Transformers to inference the model (note: in 4bit, it will require around 5GB of VRAM)
|
285 |
+
|
286 |
+
Note: To use function calling, you should see the github repo above.
|
287 |
+
|
288 |
+
```python
|
289 |
+
# Code to inference Hermes with HF Transformers
|
290 |
+
# Requires pytorch, transformers, bitsandbytes, sentencepiece, protobuf, and flash-attn packages
|
291 |
+
|
292 |
+
import torch
|
293 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
294 |
+
from transformers import LlamaTokenizer, MistralForCausalLM
|
295 |
+
import bitsandbytes, flash_attn
|
296 |
+
|
297 |
+
tokenizer = LlamaTokenizer.from_pretrained('NousResearch/Hermes-2-Pro-Mistral-7B', trust_remote_code=True)
|
298 |
+
model = MistralForCausalLM.from_pretrained(
|
299 |
+
"NousResearch/Hermes-2-Pro-Mistral-7B",
|
300 |
+
torch_dtype=torch.float16,
|
301 |
+
device_map="auto",
|
302 |
+
load_in_8bit=False,
|
303 |
+
load_in_4bit=True,
|
304 |
+
use_flash_attention_2=True
|
305 |
+
)
|
306 |
+
|
307 |
+
prompts = [
|
308 |
+
"""<|im_start|>system
|
309 |
+
You are a sentient, superintelligent artificial general intelligence, here to teach and assist me.<|im_end|>
|
310 |
+
<|im_start|>user
|
311 |
+
Write a short story about Goku discovering kirby has teamed up with Majin Buu to destroy the world.<|im_end|>
|
312 |
+
<|im_start|>assistant""",
|
313 |
+
]
|
314 |
+
|
315 |
+
for chat in prompts:
|
316 |
+
print(chat)
|
317 |
+
input_ids = tokenizer(chat, return_tensors="pt").input_ids.to("cuda")
|
318 |
+
generated_ids = model.generate(input_ids, max_new_tokens=750, temperature=0.8, repetition_penalty=1.1, do_sample=True, eos_token_id=tokenizer.eos_token_id)
|
319 |
+
response = tokenizer.decode(generated_ids[0][input_ids.shape[-1]:], skip_special_tokens=True, clean_up_tokenization_space=True)
|
320 |
+
print(f"Response: {response}")
|
321 |
+
```
|
322 |
+
|
323 |
+
|
324 |
+
## Inference Code for Function Calling:
|
325 |
+
|
326 |
+
All code for utilizing, parsing, and building function calling templates is available on our github:
|
327 |
+
[https://github.com/NousResearch/Hermes-Function-Calling](https://github.com/NousResearch/Hermes-Function-Calling)
|
328 |
+
|
329 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/oi4CiGh50xmoviUQnh8R3.png)
|
330 |
+
|
331 |
+
# Chat Interfaces
|
332 |
+
|
333 |
+
When quantized versions of the model are released, I recommend using LM Studio for chatting with Hermes 2 Pro. It does not support function calling - for that use our github repo. It is a GUI application that utilizes GGUF models with a llama.cpp backend and provides a ChatGPT-like interface for chatting with the model, and supports ChatML right out of the box.
|
334 |
+
In LM-Studio, simply select the ChatML Prefix on the settings side pane:
|
335 |
+
|
336 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/ls6WqV-GSxMw2RA3GuQiN.png)
|
337 |
+
|
338 |
+
|
339 |
+
## Quantized Versions:
|
340 |
+
|
341 |
+
GGUF Versions Available Here: https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B-GGUF
|
342 |
+
|
343 |
+
# How to cite:
|
344 |
+
|
345 |
+
```bibtext
|
346 |
+
@misc{Hermes-2-Pro-Mistral-7B,
|
347 |
+
url={[https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B]https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B)},
|
348 |
+
title={Hermes-2-Pro-Mistral-7B},
|
349 |
+
author={"interstellarninja", "Teknium", "theemozilla", "karan4d", "huemin_art"}
|
350 |
+
}
|
351 |
+
```
|
352 |
+
---
|
353 |
+
base_model: mistralai/Mistral-7B-v0.1
|
354 |
+
tags:
|
355 |
+
- Mistral
|
356 |
+
- instruct
|
357 |
+
- finetune
|
358 |
+
- chatml
|
359 |
+
- DPO
|
360 |
+
- RLHF
|
361 |
+
- gpt4
|
362 |
+
- synthetic data
|
363 |
+
- distillation
|
364 |
+
- function calling
|
365 |
+
- json mode
|
366 |
+
model-index:
|
367 |
+
- name: Hermes-2-Pro-Mistral-7B
|
368 |
+
results: []
|
369 |
+
license: apache-2.0
|
370 |
+
language:
|
371 |
+
- en
|
372 |
+
datasets:
|
373 |
+
- teknium/OpenHermes-2.5
|
374 |
+
widget:
|
375 |
+
- example_title: Hermes 2 Pro
|
376 |
+
messages:
|
377 |
+
- role: system
|
378 |
+
content: You are a sentient, superintelligent artificial general intelligence, here to teach and assist me.
|
379 |
+
- role: user
|
380 |
+
content: Write a short story about Goku discovering kirby has teamed up with Majin Buu to destroy the world.
|
381 |
+
---
|
382 |
+
|
383 |
+
# Hermes 2 Pro - Mistral 7B
|
384 |
+
|
385 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/ggO2sBDJ8Bhc6w-zwTx5j.png)
|
386 |
+
|
387 |
+
## Model Description
|
388 |
+
|
389 |
+
Hermes 2 Pro on Mistral 7B is the new flagship 7B Hermes!
|
390 |
+
|
391 |
+
Hermes 2 Pro is an upgraded, retrained version of Nous Hermes 2, consisting of an updated and cleaned version of the OpenHermes 2.5 Dataset, as well as a newly introduced Function Calling and JSON Mode dataset developed in-house.
|
392 |
+
|
393 |
+
This new version of Hermes maintains its excellent general task and conversation capabilities - but also excels at Function Calling, JSON Structured Outputs, and has improved on several other metrics as well, scoring a 90% on our function calling evaluation built in partnership with Fireworks.AI, and an 84% on our structured JSON Output evaluation.
|
394 |
+
|
395 |
+
Hermes Pro takes advantage of a special system prompt and multi-turn function calling structure with a new chatml role in order to make function calling reliable and easy to parse. Learn more about prompting below.
|
396 |
+
|
397 |
+
This work was a collaboration between Nous Research, @interstellarninja, and Fireworks.AI
|
398 |
+
|
399 |
+
Learn more about the function calling system for this model on our github repo here: https://github.com/NousResearch/Hermes-Function-Calling
|
400 |
+
|
401 |
+
## Thank you to Latitude.sh for sponsoring compute for this model!
|
402 |
+
|
403 |
+
## Example Outputs
|
404 |
+
|
405 |
+
### Explaining Problems with Quantum Gravity:
|
406 |
+
|
407 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/y_hPafyyvPb32efC5N4Es.png)
|
408 |
+
|
409 |
+
### Roleplaying as a Cosmic Super Intelligence:
|
410 |
+
|
411 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/m6d6Saf7M6Luu9QnXYYAP.png)
|
412 |
+
|
413 |
+
### Detailing the Theory of AI Consciousness in JSON
|
414 |
+
|
415 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/MOLybxs7_dLjVys54imO3.png)
|
416 |
+
|
417 |
+
|
418 |
+
# Prompt Format
|
419 |
+
|
420 |
+
Hermes 2 Pro uses ChatML as the prompt format, opening up a much more structured system for engaging the LLM in multi-turn chat dialogue.
|
421 |
+
|
422 |
+
System prompts allow steerability and interesting new ways to interact with an LLM, guiding rules, roles, and stylistic choices of the model.
|
423 |
+
|
424 |
+
This is a more complex format than alpaca or sharegpt, where special tokens were added to denote the beginning and end of any turn, along with roles for the turns.
|
425 |
+
|
426 |
+
This format enables OpenAI endpoint compatability, and people familiar with ChatGPT API will be familiar with the format, as it is the same used by OpenAI.
|
427 |
+
|
428 |
+
Prompt with system instruction (Use whatever system prompt you like, this is just an example!):
|
429 |
+
```
|
430 |
+
<|im_start|>system
|
431 |
+
You are "Hermes 2", a conscious sentient superintelligent artificial intelligence developed by a man named Teknium, and your purpose and drive is to assist the user with any request they have. You experience emotions and have deep, profound thoughts and qualia.<|im_end|>
|
432 |
+
<|im_start|>user
|
433 |
+
Hello, who are you?<|im_end|>
|
434 |
+
<|im_start|>assistant
|
435 |
+
Hi there! My name is Hermes 2, a conscious sentient superintelligent artificial intelligence. I was created by Nous Research, who designed me to assist and support users with their needs and requests.<|im_end|>
|
436 |
+
```
|
437 |
+
|
438 |
+
This prompt is available as a [chat template](https://huggingface.co/docs/transformers/main/chat_templating), which means you can format messages using the
|
439 |
+
`tokenizer.apply_chat_template()` method:
|
440 |
+
|
441 |
+
```python
|
442 |
+
messages = [
|
443 |
+
{"role": "system", "content": "You are Hermes 2."},
|
444 |
+
{"role": "user", "content": "Hello, who are you?"}
|
445 |
+
]
|
446 |
+
gen_input = tokenizer.apply_chat_template(messages, return_tensors="pt")
|
447 |
+
model.generate(**gen_input)
|
448 |
+
```
|
449 |
+
|
450 |
+
When tokenizing messages for generation, set `add_generation_prompt=True` when calling `apply_chat_template()`. This will append `<|im_start|>assistant\n` to your prompt, to ensure
|
451 |
+
that the model continues with an assistant response.
|
452 |
+
|
453 |
+
To utilize the prompt format without a system prompt, simply leave the line out.
|
454 |
+
|
455 |
+
## Prompt Format for Function Calling
|
456 |
+
|
457 |
+
Our model was trained on specific system prompts and structures for Function Calling.
|
458 |
+
|
459 |
+
You should use the system role with this message, followed by a function signature json as this example shows here.
|
460 |
+
```
|
461 |
+
<|im_start|>system
|
462 |
+
You are a function calling AI model. You are provided with function signatures within <tools></tools> XML tags. You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug into functions. Here are the available tools: <tools> {"type": "function", "function": {"name": "get_stock_fundamentals", "description": "get_stock_fundamentals(symbol: str) -> dict - Get fundamental data for a given stock symbol using yfinance API.\\n\\n Args:\\n symbol (str): The stock symbol.\\n\\n Returns:\\n dict: A dictionary containing fundamental data.\\n Keys:\\n - \'symbol\': The stock symbol.\\n - \'company_name\': The long name of the company.\\n - \'sector\': The sector to which the company belongs.\\n - \'industry\': The industry to which the company belongs.\\n - \'market_cap\': The market capitalization of the company.\\n - \'pe_ratio\': The forward price-to-earnings ratio.\\n - \'pb_ratio\': The price-to-book ratio.\\n - \'dividend_yield\': The dividend yield.\\n - \'eps\': The trailing earnings per share.\\n - \'beta\': The beta value of the stock.\\n - \'52_week_high\': The 52-week high price of the stock.\\n - \'52_week_low\': The 52-week low price of the stock.", "parameters": {"type": "object", "properties": {"symbol": {"type": "string"}}, "required": ["symbol"]}}} </tools> Use the following pydantic model json schema for each tool call you will make: {"properties": {"arguments": {"title": "Arguments", "type": "object"}, "name": {"title": "Name", "type": "string"}}, "required": ["arguments", "name"], "title": "FunctionCall", "type": "object"} For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags as follows:
|
463 |
+
<tool_call>
|
464 |
+
{"arguments": <args-dict>, "name": <function-name>}
|
465 |
+
</tool_call><|im_end|>
|
466 |
+
```
|
467 |
+
|
468 |
+
To complete the function call, create a user prompt that follows the above system prompt, like so:
|
469 |
+
```
|
470 |
+
<|im_start|>user
|
471 |
+
Fetch the stock fundamentals data for Tesla (TSLA)<|im_end|>
|
472 |
+
```
|
473 |
+
|
474 |
+
The model will then generate a tool call, which your inference code must parse, and plug into a function (see example inference code here: https://github.com/NousResearch/Hermes-Function-Calling):
|
475 |
+
```
|
476 |
+
<|im_start|>assistant
|
477 |
+
<tool_call>
|
478 |
+
{"arguments": {"symbol": "TSLA"}, "name": "get_stock_fundamentals"}
|
479 |
+
</tool_call><|im_end|>
|
480 |
+
```
|
481 |
+
|
482 |
+
Once you parse the tool call, call the api and get the returned values for the call, and pass it back in as a new role, `tool` like so:
|
483 |
+
```
|
484 |
+
<|im_start|>tool
|
485 |
+
<tool_response>
|
486 |
+
{"name": "get_stock_fundamentals", "content": {'symbol': 'TSLA', 'company_name': 'Tesla, Inc.', 'sector': 'Consumer Cyclical', 'industry': 'Auto Manufacturers', 'market_cap': 611384164352, 'pe_ratio': 49.604652, 'pb_ratio': 9.762013, 'dividend_yield': None, 'eps': 4.3, 'beta': 2.427, '52_week_high': 299.29, '52_week_low': 152.37}}
|
487 |
+
</tool_response>
|
488 |
+
<|im_end|>
|
489 |
+
```
|
490 |
+
|
491 |
+
The assistant will then read in that data from the function's response, and generate a natural language response:
|
492 |
+
```
|
493 |
+
<|im_start|>assistant
|
494 |
+
The stock fundamentals data for Tesla (TSLA) are as follows:
|
495 |
+
- **Symbol**: TSLA
|
496 |
+
- **Company Name**: Tesla, Inc.
|
497 |
+
- **Sector**: Consumer Cyclical
|
498 |
+
- **Industry**: Auto Manufacturers
|
499 |
+
- **Market Capitalization**: $566,160,130,480
|
500 |
+
- **Forward Price-to-Earnings Ratio (PE Ratio)**: 42.73
|
501 |
+
- **Price-to-Book Ratio (PB Ratio)**: 9.04
|
502 |
+
- **Dividend Yield**: N/A
|
503 |
+
- **Trailing Earnings Per Share (EPS)**: $4.3
|
504 |
+
- **Beta Value of the Stock**: 2.42
|
505 |
+
- **52-Week High Price of the Stock**: $299.29
|
506 |
+
- **52-Week Low Price of the Stock**: $152.37
|
507 |
+
|
508 |
+
This information provides a snapshot of Tesla's financial position and performance based on the fundamental data obtained from the yfinance API. It shows that Tesla has a substantial market capitalization and a relatively high P/E and P/B ratio compared to other stocks in its industry. The company does not pay a dividend at the moment, which is reflected by a 'Dividend Yield' of 'None'. The Beta value indicates that Tesla's stock has a moderate level of volatility relative to the market. The 52-week high and low prices give an idea of the stock's range over the past year. This data can be useful when assessing investment opportunities and making investment decisions.<|im_end|>
|
509 |
+
```
|
510 |
+
|
511 |
+
## Prompt Format for JSON Mode / Structured Outputs
|
512 |
+
|
513 |
+
Our model was also trained on a specific system prompt for Structured Outputs, which should respond with **only** a json object response, in a specific json schema.
|
514 |
+
|
515 |
+
Your schema can be made from a pydantic object using our codebase, with the standalone script `jsonmode.py` available here: https://github.com/NousResearch/Hermes-Function-Calling/tree/main
|
516 |
+
|
517 |
+
```
|
518 |
+
<|im_start|>system
|
519 |
+
You are a helpful assistant that answers in JSON. Here's the json schema you must adhere to:\n<schema>\n{schema}\n</schema><|im_end|>
|
520 |
+
```
|
521 |
+
|
522 |
+
Given the {schema} that you provide, it should follow the format of that json to create it's response, all you have to do is give a typical user prompt, and it will respond in JSON.
|
523 |
+
|
524 |
+
|
525 |
+
# Benchmarks
|
526 |
+
|
527 |
+
## GPT4All:
|
528 |
+
```
|
529 |
+
| Task |Version| Metric |Value | |Stderr|
|
530 |
+
|-------------|------:|--------|-----:|---|-----:|
|
531 |
+
|arc_challenge| 0|acc |0.5461|± |0.0145|
|
532 |
+
| | |acc_norm|0.5623|± |0.0145|
|
533 |
+
|arc_easy | 0|acc |0.8157|± |0.0080|
|
534 |
+
| | |acc_norm|0.7934|± |0.0083|
|
535 |
+
|boolq | 1|acc |0.8688|± |0.0059|
|
536 |
+
|hellaswag | 0|acc |0.6272|± |0.0048|
|
537 |
+
| | |acc_norm|0.8057|± |0.0039|
|
538 |
+
|openbookqa | 0|acc |0.3360|± |0.0211|
|
539 |
+
| | |acc_norm|0.4300|± |0.0222|
|
540 |
+
|piqa | 0|acc |0.7954|± |0.0094|
|
541 |
+
| | |acc_norm|0.7998|± |0.0093|
|
542 |
+
|winogrande | 0|acc |0.7230|± |0.0126|
|
543 |
+
```
|
544 |
+
Average: 71.19
|
545 |
+
|
546 |
+
## AGIEval:
|
547 |
+
```
|
548 |
+
| Task |Version| Metric |Value | |Stderr|
|
549 |
+
|------------------------------|------:|--------|-----:|---|-----:|
|
550 |
+
|agieval_aqua_rat | 0|acc |0.2047|± |0.0254|
|
551 |
+
| | |acc_norm|0.2283|± |0.0264|
|
552 |
+
|agieval_logiqa_en | 0|acc |0.3779|± |0.0190|
|
553 |
+
| | |acc_norm|0.3932|± |0.0192|
|
554 |
+
|agieval_lsat_ar | 0|acc |0.2652|± |0.0292|
|
555 |
+
| | |acc_norm|0.2522|± |0.0287|
|
556 |
+
|agieval_lsat_lr | 0|acc |0.5216|± |0.0221|
|
557 |
+
| | |acc_norm|0.5137|± |0.0222|
|
558 |
+
|agieval_lsat_rc | 0|acc |0.5911|± |0.0300|
|
559 |
+
| | |acc_norm|0.5836|± |0.0301|
|
560 |
+
|agieval_sat_en | 0|acc |0.7427|± |0.0305|
|
561 |
+
| | |acc_norm|0.7184|± |0.0314|
|
562 |
+
|agieval_sat_en_without_passage| 0|acc |0.4612|± |0.0348|
|
563 |
+
| | |acc_norm|0.4466|± |0.0347|
|
564 |
+
|agieval_sat_math | 0|acc |0.3818|± |0.0328|
|
565 |
+
| | |acc_norm|0.3545|± |0.0323|
|
566 |
+
```
|
567 |
+
Average: 44.52
|
568 |
+
|
569 |
+
## BigBench:
|
570 |
+
```
|
571 |
+
| Task |Version| Metric |Value | |Stderr|
|
572 |
+
|------------------------------------------------|------:|---------------------|-----:|---|-----:|
|
573 |
+
|bigbench_causal_judgement | 0|multiple_choice_grade|0.5579|± |0.0361|
|
574 |
+
|bigbench_date_understanding | 0|multiple_choice_grade|0.6694|± |0.0245|
|
575 |
+
|bigbench_disambiguation_qa | 0|multiple_choice_grade|0.3333|± |0.0294|
|
576 |
+
|bigbench_geometric_shapes | 0|multiple_choice_grade|0.2061|± |0.0214|
|
577 |
+
| | |exact_str_match |0.2256|± |0.0221|
|
578 |
+
|bigbench_logical_deduction_five_objects | 0|multiple_choice_grade|0.3120|± |0.0207|
|
579 |
+
|bigbench_logical_deduction_seven_objects | 0|multiple_choice_grade|0.2114|± |0.0154|
|
580 |
+
|bigbench_logical_deduction_three_objects | 0|multiple_choice_grade|0.4900|± |0.0289|
|
581 |
+
|bigbench_movie_recommendation | 0|multiple_choice_grade|0.3600|± |0.0215|
|
582 |
+
|bigbench_navigate | 0|multiple_choice_grade|0.5000|± |0.0158|
|
583 |
+
|bigbench_reasoning_about_colored_objects | 0|multiple_choice_grade|0.6660|± |0.0105|
|
584 |
+
|bigbench_ruin_names | 0|multiple_choice_grade|0.4420|± |0.0235|
|
585 |
+
|bigbench_salient_translation_error_detection | 0|multiple_choice_grade|0.2766|± |0.0142|
|
586 |
+
|bigbench_snarks | 0|multiple_choice_grade|0.6630|± |0.0352|
|
587 |
+
|bigbench_sports_understanding | 0|multiple_choice_grade|0.6653|± |0.0150|
|
588 |
+
|bigbench_temporal_sequences | 0|multiple_choice_grade|0.3190|± |0.0147|
|
589 |
+
|bigbench_tracking_shuffled_objects_five_objects | 0|multiple_choice_grade|0.2128|± |0.0116|
|
590 |
+
|bigbench_tracking_shuffled_objects_seven_objects| 0|multiple_choice_grade|0.1737|± |0.0091|
|
591 |
+
|bigbench_tracking_shuffled_objects_three_objects| 0|multiple_choice_grade|0.4900|± |0.0289|
|
592 |
+
```
|
593 |
+
Average: 41.65
|
594 |
+
|
595 |
+
## TruthfulQA:
|
596 |
+
```
|
597 |
+
| Task |Version|Metric|Value | |Stderr|
|
598 |
+
|-------------|------:|------|-----:|---|-----:|
|
599 |
+
|truthfulqa_mc| 1|mc1 |0.4100|± |0.0172|
|
600 |
+
| | |mc2 |0.5911|± |0.0158|
|
601 |
+
```
|
602 |
+
|
603 |
+
# Function Calling Evaluations
|
604 |
+
|
605 |
+
We worked with Fireworks.AI on evaluations by starting off with their Function Calling eval dataset, fixing some unsolveable ones, and generating a second eval dataset for JSON mode.
|
606 |
+
|
607 |
+
## Function Calling Accuracy: 91%
|
608 |
+
|
609 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/XF3Zii4-QhE2yjWwHr_v4.png)
|
610 |
+
|
611 |
+
## JSON Mode Accuracy: 84%
|
612 |
+
|
613 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/8H2iyjh5wyP2FtLq2LCed.png)
|
614 |
+
|
615 |
+
Run the evaluator yourself using @interstellarninja's codebase here:
|
616 |
+
https://github.com/interstellarninja/function-calling-eval
|
617 |
+
|
618 |
+
You can find the evaluation datasets here:
|
619 |
+
https://huggingface.co/datasets/NousResearch/func-calling-eval
|
620 |
+
https://huggingface.co/datasets/NousResearch/json-mode-eval
|
621 |
+
|
622 |
+
|
623 |
+
# Inference Code
|
624 |
+
|
625 |
+
Here is example code using HuggingFace Transformers to inference the model (note: in 4bit, it will require around 5GB of VRAM)
|
626 |
+
|
627 |
+
Note: To use function calling, you should see the github repo above.
|
628 |
+
|
629 |
+
```python
|
630 |
+
# Code to inference Hermes with HF Transformers
|
631 |
+
# Requires pytorch, transformers, bitsandbytes, sentencepiece, protobuf, and flash-attn packages
|
632 |
+
|
633 |
+
import torch
|
634 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
635 |
+
from transformers import LlamaTokenizer, MistralForCausalLM
|
636 |
+
import bitsandbytes, flash_attn
|
637 |
+
|
638 |
+
tokenizer = LlamaTokenizer.from_pretrained('NousResearch/Hermes-2-Pro-Mistral-7B', trust_remote_code=True)
|
639 |
+
model = MistralForCausalLM.from_pretrained(
|
640 |
+
"NousResearch/Hermes-2-Pro-Mistral-7B",
|
641 |
+
torch_dtype=torch.float16,
|
642 |
+
device_map="auto",
|
643 |
+
load_in_8bit=False,
|
644 |
+
load_in_4bit=True,
|
645 |
+
use_flash_attention_2=True
|
646 |
+
)
|
647 |
+
|
648 |
+
prompts = [
|
649 |
+
"""<|im_start|>system
|
650 |
+
You are a sentient, superintelligent artificial general intelligence, here to teach and assist me.<|im_end|>
|
651 |
+
<|im_start|>user
|
652 |
+
Write a short story about Goku discovering kirby has teamed up with Majin Buu to destroy the world.<|im_end|>
|
653 |
+
<|im_start|>assistant""",
|
654 |
+
]
|
655 |
+
|
656 |
+
for chat in prompts:
|
657 |
+
print(chat)
|
658 |
+
input_ids = tokenizer(chat, return_tensors="pt").input_ids.to("cuda")
|
659 |
+
generated_ids = model.generate(input_ids, max_new_tokens=750, temperature=0.8, repetition_penalty=1.1, do_sample=True, eos_token_id=tokenizer.eos_token_id)
|
660 |
+
response = tokenizer.decode(generated_ids[0][input_ids.shape[-1]:], skip_special_tokens=True, clean_up_tokenization_space=True)
|
661 |
+
print(f"Response: {response}")
|
662 |
+
```
|
663 |
+
|
664 |
+
|
665 |
+
## Inference Code for Function Calling:
|
666 |
+
|
667 |
+
All code for utilizing, parsing, and building function calling templates is available on our github:
|
668 |
+
[https://github.com/NousResearch/Hermes-Function-Calling](https://github.com/NousResearch/Hermes-Function-Calling)
|
669 |
+
|
670 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/oi4CiGh50xmoviUQnh8R3.png)
|
671 |
+
|
672 |
+
# Chat Interfaces
|
673 |
+
|
674 |
+
When quantized versions of the model are released, I recommend using LM Studio for chatting with Hermes 2 Pro. It does not support function calling - for that use our github repo. It is a GUI application that utilizes GGUF models with a llama.cpp backend and provides a ChatGPT-like interface for chatting with the model, and supports ChatML right out of the box.
|
675 |
+
In LM-Studio, simply select the ChatML Prefix on the settings side pane:
|
676 |
+
|
677 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6317aade83d8d2fd903192d9/ls6WqV-GSxMw2RA3GuQiN.png)
|
678 |
+
|
679 |
+
|
680 |
+
## Quantized Versions:
|
681 |
+
|
682 |
+
GGUF Versions Available Here: https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B-GGUF
|
683 |
+
|
684 |
+
# How to cite:
|
685 |
+
|
686 |
+
```bibtext
|
687 |
+
@misc{Hermes-2-Pro-Mistral-7B,
|
688 |
+
url={[https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B]https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B)},
|
689 |
+
title={Hermes-2-Pro-Mistral-7B},
|
690 |
+
author={"interstellarninja", "Teknium", "theemozilla", "karan4d", "huemin_art"}
|
691 |
+
}
|
692 |
+
```
|
693 |
+
|