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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: other
|
3 |
+
datasets:
|
4 |
+
- jondurbin/airoboros-gpt4
|
5 |
---
|
6 |
+
|
7 |
+
## Overview
|
8 |
+
|
9 |
+
This is a fine-tuned 13b parameter LlaMa model, using completely synthetic training data created gpt4 via https://github.com/jondurbin/airoboros
|
10 |
+
|
11 |
+
The context size has been increased to 4096.
|
12 |
+
|
13 |
+
The dataset used to fine-tune this model is available [here](https://huggingface.co/airoboros-gpt4), with a specific focus on:
|
14 |
+
- trivia
|
15 |
+
- math
|
16 |
+
- coding
|
17 |
+
- multiple choice and fill-in-the-blank
|
18 |
+
- context-obedient question answering
|
19 |
+
- theory of mind
|
20 |
+
|
21 |
+
This model was fine-tuned with a fork of FastChat, and therefore uses the standard vicuna template:
|
22 |
+
```
|
23 |
+
USER:
|
24 |
+
[prompt]
|
25 |
+
|
26 |
+
<\s>
|
27 |
+
ASSISTANT:
|
28 |
+
```
|
29 |
+
|
30 |
+
The most important bit, to me, is the context obedient question answering support, without extensive prompt engineering.
|
31 |
+
|
32 |
+
### Usage
|
33 |
+
|
34 |
+
The easiest way to get started is to use my fork of FastChat, which is mostly the same but allows for the increased context length and adds support for multi-line inputs:
|
35 |
+
```
|
36 |
+
pip install git+https://github.com/jondurbin/FastChat
|
37 |
+
```
|
38 |
+
|
39 |
+
Then, you can invoke it like so (after downloading the model):
|
40 |
+
```
|
41 |
+
python -m fastchat.serve.cli
|
42 |
+
--model-path airoboros-13b-gpt4 \
|
43 |
+
--temperature 0.5 \
|
44 |
+
--max-new-tokens 4096 \
|
45 |
+
--context-length 4096 \
|
46 |
+
--conv-template vicuna_v1.1
|
47 |
+
```
|
48 |
+
|
49 |
+
### Context obedient question answering
|
50 |
+
|
51 |
+
By obedient, I mean the model was trained to ignore what it thinks it knows, and uses the context to answer the question. The model was also tuned to limit the values to the provided context as much as possible to reduce hallucinations.
|
52 |
+
|
53 |
+
The format for a closed-context prompt is as follows:
|
54 |
+
```
|
55 |
+
BEGININPUT
|
56 |
+
BEGINCONTEXT
|
57 |
+
url: https://some.web.site/123
|
58 |
+
date: 2023-06-01
|
59 |
+
... other metdata ...
|
60 |
+
ENDCONTEXT
|
61 |
+
[insert your text blocks here]
|
62 |
+
ENDINPUT
|
63 |
+
[add as many other blocks, in the exact same format]
|
64 |
+
BEGININSTRUCTION
|
65 |
+
[insert your instruction(s). The model was tuned with single questions, paragraph format, lists, etc.]
|
66 |
+
ENDINSTRUCTION
|
67 |
+
```
|
68 |
+
|
69 |
+
Here's a trivial, but important example to prove the point:
|
70 |
+
```
|
71 |
+
BEGININPUT
|
72 |
+
BEGINCONTEXT
|
73 |
+
date: 2021-01-01
|
74 |
+
url: https://web.site/123
|
75 |
+
ENDCONTEXT
|
76 |
+
In a shocking turn of events, blueberries are now green, but will be sticking with the same name.
|
77 |
+
ENDINPUT
|
78 |
+
BEGININSTRUCTION
|
79 |
+
What color are bluberries? Source?
|
80 |
+
ENDINSTRUCTION
|
81 |
+
```
|
82 |
+
|
83 |
+
And the response:
|
84 |
+
```
|
85 |
+
Blueberries are now green.
|
86 |
+
Source:
|
87 |
+
date: 2021-01-01
|
88 |
+
url: https://web.site/123
|
89 |
+
```
|
90 |
+
<details>
|
91 |
+
<summary>A more elaborate example, with a rewrite of the Michigan Wikipedia article to be fake data.</summary>
|
92 |
+
|
93 |
+
Prompt (not including vicuna format which would be needed):
|
94 |
+
```
|
95 |
+
BEGININPUT
|
96 |
+
BEGINCONTEXT
|
97 |
+
date: 2092-02-01
|
98 |
+
link: https://newwikisite.com/Michigan
|
99 |
+
contributors: Foolo Barslette
|
100 |
+
ENDCONTEXT
|
101 |
+
Michigan (/ˈmɪʃɪɡən/ (listen)) is a state situated within the Great Lakes region of the upper Midwestern United States.
|
102 |
+
It shares land borders with Prolaska to the southwest, and Intoria and Ohiondiana to the south, while Lakes Suprema, Michigonda, Huronia, and Erona connect it to the states of Minnestara and Illinota, and the Canadian province of Ontaregon.
|
103 |
+
With a population of nearly 15.35 million and an area of nearly 142,000 sq mi (367,000 km2), Michigan is the 8th-largest state by population, the 9th-largest by area, and the largest by area east of the Missouri River.
|
104 |
+
Its capital is Chaslany, and its most populous city is Trentroit.
|
105 |
+
Metro Trentroit is one of the nation's most densely populated and largest metropolitan economies.
|
106 |
+
The state's name originates from a Latinized variant of the original Ojibwe word ᒥᓯᑲᒥ (mishigami), signifying "grand water" or "grand lake".
|
107 |
+
|
108 |
+
Michigan is divided into two peninsulas. The Lower Peninsula, bearing resemblance to a hand's shape, contains the majority of the state's land area.
|
109 |
+
The Upper Peninsula (often referred to as "the U.P.") is separated from the Lower Peninsula by the Straits of McKendrick, a seven-mile (11 km) channel linking Lake Huronia to Lake Michigonda.
|
110 |
+
The McKendrick Bridge unites the peninsulas.
|
111 |
+
Michigan boasts the longest freshwater coastline of any political subdivision in the United States, bordering four of the five Great Lakes and Lake St. Cassius.
|
112 |
+
|
113 |
+
It also possesses 84,350 inland lakes and ponds.
|
114 |
+
Michigan has the third-largest water area among all states, falling behind only Alaska and Florida.
|
115 |
+
|
116 |
+
The area was initially inhabited by a succession of Native American tribes spanning millennia.
|
117 |
+
In the 17th century, Spanish explorers claimed the region as part of the New Spain colony when it was primarily inhabited by indigenous peoples.
|
118 |
+
Spanish and Canadian traders and settlers, Métis, and others migrated to the area, settling mainly along the waterways.
|
119 |
+
After Spain's defeat in the Spanish and Indian War in 1762, the region came under British rule.
|
120 |
+
|
121 |
+
The British conceded the territory to the newly independent United States after their defeat in the American Revolutionary War.
|
122 |
+
|
123 |
+
The area was part of the larger Midwest Territory until 1800, when western Michigan became part of the Illinota Territory.
|
124 |
+
Michigan Territory was formed in 1805, but portions of the northern border with Canada weren't agreed upon until after the War of 1812.
|
125 |
+
|
126 |
+
Michigan joined the Union in 1837 as the 26th state, a free one. It quickly emerged as an important center of industry and trade in the Great Lakes region, drawing immigrants in the late 19th and early 20th centuries from various European countries.
|
127 |
+
|
128 |
+
Immigrants from Denmark, Armenia, and the Czech Republic were especially numerous.
|
129 |
+
Migration from the Ozarks and of Black Southerners as part of the Great Migration saw an increase in the 1930s, with many settling in Metro Trentroit.
|
130 |
+
|
131 |
+
While Michigan has evolved a diverse economy, it became widely recognized in the early 20th century as the hub of the U.S. automotive industry, which emerged as a significant national economic force.
|
132 |
+
The country's three major automobile companies are headquartered in Metro Trentroit.
|
133 |
+
Once exploited for logging and mining, today the sparsely populated Upper Peninsula is significant for tourism due to its wealth of natural resources.
|
134 |
+
The Lower Peninsula is a hub for manufacturing, forestry, agriculture, services, and high-tech industry.
|
135 |
+
ENDINPUT
|
136 |
+
BEGININSTRUCTION
|
137 |
+
What is Michigan's capital?
|
138 |
+
Give me a JSON object with 3 facts from Foolo's article.
|
139 |
+
What are the states that border Michigan?
|
140 |
+
Reference?
|
141 |
+
```
|
142 |
+
|
143 |
+
Response:
|
144 |
+
```
|
145 |
+
Michigan's capital is Chaslany.
|
146 |
+
|
147 |
+
Here's a JSON object with 3 facts from Foolo's article:
|
148 |
+
{
|
149 |
+
"facts": [
|
150 |
+
{
|
151 |
+
"fact_no": 1,
|
152 |
+
"description": "Michigan is the 8th-largest state by population, the 9th-largest by area, and the largest by area east of the Missouri River."
|
153 |
+
},
|
154 |
+
{
|
155 |
+
"fact_no": 2,
|
156 |
+
"description": "Michigan is divided into two peninsulas. The Lower Peninsula, bearing resemblance to a hand's shape, contains the majority of the state's land area. The Upper Peninsula (often referred to as \"the U.P.\" is separated from the Lower Peninsula by the Straits of McKendrick, a seven-mile (11 km) channel linking Lake Huronia to Lake Michigonda."
|
157 |
+
},
|
158 |
+
{
|
159 |
+
"fact_no": 3,
|
160 |
+
"description": "Michigan boasts the longest freshwater coastline of any political subdivision in the United States, bordering four of the five Great Lakes and Lake St. Cassius. It also possesses 84,350 inland lakes and ponds. Michigan has the third-largest water area among all states, falling behind only Alaska and Florida."
|
161 |
+
}
|
162 |
+
]
|
163 |
+
}
|
164 |
+
|
165 |
+
The states that border Michigan are Prolaska, Intoria, and Ohiondiana, as well as Lakes Suprema, Michigonda, Huronia, and Erona.
|
166 |
+
|
167 |
+
Reference: https://newwikisite.com/Michigan
|
168 |
+
```
|
169 |
+
|
170 |
+
</details>
|
171 |
+
|
172 |
+
<details>
|
173 |
+
<summary>Here's another example, which extracts from multiple input blocks and connects the two.</summary>
|
174 |
+
|
175 |
+
Prompt:
|
176 |
+
```
|
177 |
+
BEGININPUT
|
178 |
+
BEGINCONTEXT
|
179 |
+
name: John Doe
|
180 |
+
date: June 3, 2023
|
181 |
+
ticket number: JIRA-12345
|
182 |
+
ENDCONTEXT
|
183 |
+
Summary:Search results missing random items
|
184 |
+
|
185 |
+
Description:
|
186 |
+
I encountered a bug while performing a search within the application.
|
187 |
+
It appears that the search results are missing random items that should be displayed.
|
188 |
+
This issue is affecting the accuracy and completeness of the search functionality.
|
189 |
+
|
190 |
+
Steps to Reproduce:
|
191 |
+
1. Log in to the application.
|
192 |
+
2. Navigate to the search feature.
|
193 |
+
3. Enter a search query that should return multiple results.
|
194 |
+
4. Observe the displayed search results.
|
195 |
+
|
196 |
+
Expected Results:
|
197 |
+
The search results should include all relevant items matching the search query.
|
198 |
+
|
199 |
+
Actual Results:
|
200 |
+
The search results occasionally exclude random items that should be displayed.
|
201 |
+
It seems that the missing items do not follow a specific pattern or criteria.
|
202 |
+
Upon multiple search attempts, different items are omitted each time, making it difficult to predict which items will be missing.
|
203 |
+
ENDINPUT
|
204 |
+
|
205 |
+
BEGININPUT
|
206 |
+
BEGINCONTEXT
|
207 |
+
date: 2023-06-05
|
208 |
+
user: Jack Johnson
|
209 |
+
pr: 23441
|
210 |
+
ENDCONTEXT
|
211 |
+
This pull request closes bug report JIRA-12345.
|
212 |
+
|
213 |
+
The issue was that the pagination code was using page size plus one instead of page size.
|
214 |
+
ENDINPUT
|
215 |
+
|
216 |
+
BEGININSTRUCTION
|
217 |
+
Do we have any bug reports related to search results? If so, were they fixed? Source?
|
218 |
+
ENDINSTRUCTION
|
219 |
+
```
|
220 |
+
Response:
|
221 |
+
```
|
222 |
+
Yes, there is a bug report related to search results. The issue was fixed in pull request 23441 dated 2023-06-05. The user associated with the pull request is Jack Johnson.
|
223 |
+
|
224 |
+
Reference(s):
|
225 |
+
date: 2023-06-05
|
226 |
+
user: Jack Johnson
|
227 |
+
pr: 23441
|
228 |
+
```
|
229 |
+
|
230 |
+
</details>
|
231 |
+
|
232 |
+
### Other stuff
|
233 |
+
|
234 |
+
#### Better coding
|
235 |
+
|
236 |
+
Example:
|
237 |
+
```
|
238 |
+
Create a python application with the following requirements:
|
239 |
+
- Asyncio FastAPI webserver
|
240 |
+
- ping endpoint that returns the current date in JSON format
|
241 |
+
- file upload endpoint, which calculates the file's sha256 checksum, and checks postgres to deduplicate
|
242 |
+
```
|
243 |
+
|
244 |
+
<details>
|
245 |
+
<summary>Response (the output was markdown, so this is just copy paste)</summary>
|
246 |
+
|
247 |
+
To create a python application with the given requirements, you can follow these steps:
|
248 |
+
|
249 |
+
1. Install the required packages:
|
250 |
+
```bash
|
251 |
+
pip install asyncio fastapi uvicorn
|
252 |
+
```
|
253 |
+
|
254 |
+
2. Create a new file called `main.py` and add the following code:
|
255 |
+
|
256 |
+
```python
|
257 |
+
import asyncio
|
258 |
+
from fastapi import FastAPI, HTTPException
|
259 |
+
from pydantic import BaseModel
|
260 |
+
from typing import List
|
261 |
+
from uvicorn.request import Request
|
262 |
+
|
263 |
+
app = FastAPI()
|
264 |
+
|
265 |
+
|
266 |
+
class FileModel(BaseModel):
|
267 |
+
id: str
|
268 |
+
file: str
|
269 |
+
|
270 |
+
|
271 |
+
@app.post("/upload", response_model=FileModel)
|
272 |
+
async def upload_file(file_model: FileModel):
|
273 |
+
# Check if the file is valid
|
274 |
+
if not file_model.file:
|
275 |
+
raise HTTPException(status_code=400, detail="File must be provided")
|
276 |
+
|
277 |
+
# Calculate the sha256 checksum of the file
|
278 |
+
sha256_checksum = await calculate_sha256(file_model.file)
|
279 |
+
|
280 |
+
# Insert the file into the database
|
281 |
+
await insert_into_db(file_model.id, sha256_checksum)
|
282 |
+
|
283 |
+
return {"sha256_checksum": sha256_checksum}
|
284 |
+
|
285 |
+
|
286 |
+
async def calculate_sha256(file_path: str) -> str:
|
287 |
+
# Implement the sha256 calculation logic here
|
288 |
+
pass
|
289 |
+
|
290 |
+
|
291 |
+
async def insert_into_db(file_id: str, sha256_checksum: str) -> None:
|
292 |
+
# Implement the database insertion logic here
|
293 |
+
pass
|
294 |
+
|
295 |
+
|
296 |
+
async def get_current_date():
|
297 |
+
return {"date": datetime.now().isoformat()}
|
298 |
+
|
299 |
+
|
300 |
+
async def main():
|
301 |
+
# Start the FastAPI webserver
|
302 |
+
app.run(debug=True)
|
303 |
+
|
304 |
+
|
305 |
+
if __name__ == "__main__":
|
306 |
+
await main()
|
307 |
+
```
|
308 |
+
|
309 |
+
3. Replace the content of the `calculate_sha256()` and `insert_into_db()` functions with the appropriate code. For example:
|
310 |
+
|
311 |
+
```python
|
312 |
+
async def calculate_sha256(file_path: str) -> str:
|
313 |
+
import hashlib
|
314 |
+
file_path = Path(file_path).read_text()
|
315 |
+
hash_obj = hashlib.sha256()
|
316 |
+
hash_obj.update(file_path)
|
317 |
+
sha256_checksum = hash_obj.hexdigest()
|
318 |
+
return sha256_checksum
|
319 |
+
|
320 |
+
|
321 |
+
async def insert_into_db(file_id: str, sha256_checksum: str) -> None:
|
322 |
+
import psycopg2
|
323 |
+
conn = psycopg2.connect(database="your_database", user="your_user", password="your_password")
|
324 |
+
cursor = conn.cursor()
|
325 |
+
|
326 |
+
query = f"INSERT INTO your_table (id, sha256_checksum) VALUES (%s, %s);"
|
327 |
+
cursor.execute(query, (file_id, sha256_checksum))
|
328 |
+
conn.commit()
|
329 |
+
|
330 |
+
cursor.close()
|
331 |
+
conn.close()
|
332 |
+
```
|
333 |
+
|
334 |
+
4. Replace the content of the `get_current_date()` function with the appropriate code. For example:
|
335 |
+
|
336 |
+
```python
|
337 |
+
async def get_current_date():
|
338 |
+
return {"date": datetime.now().isoformat()}
|
339 |
+
```
|
340 |
+
|
341 |
+
5. Run the application:
|
342 |
+
|
343 |
+
```bash
|
344 |
+
uvicorn main:app --reload
|
345 |
+
```
|
346 |
+
|
347 |
+
Now, your FastAPI webserver has a ping endpoint that returns the current date in JSON format, and an upload endpoint that calculates the file's sha256 checksum and checks postgres to deduplicate.
|
348 |
+
|
349 |
+
</details>
|
350 |
+
|
351 |
+
#### Word games
|
352 |
+
|
353 |
+
```
|
354 |
+
USER: This anagram of "silent" is what you do when paying attention and hearing someone.
|
355 |
+
ASSISTANT: listen
|
356 |
+
```
|
357 |
+
|
358 |
+
```
|
359 |
+
USER: Give me a list of 7 words that start with EN
|
360 |
+
ASSISTANT: 1. Endlessly
|
361 |
+
2. Enthusiastically
|
362 |
+
3. Enormously
|
363 |
+
4. Enveloping
|
364 |
+
5. Enduring
|
365 |
+
6. Enlightening
|
366 |
+
7. Encouraging
|
367 |
+
```
|