File size: 23,938 Bytes
e76388c 3cf5453 e76388c 9d5f2fa 3787679 9d5f2fa 069d3eb e76388c a1360e8 5c9ad90 a1360e8 b6b1bc4 a1360e8 18bf455 d2f1272 18bf455 a1360e8 18bf455 a1360e8 18bf455 a1360e8 5c9ad90 18bf455 5c9ad90 1e27e8b 5c9ad90 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
---
size_categories:
- n<1K
pretty_name: Augmented Generation Interface
dataset_info:
features:
- name: guide
dtype: string
splits:
- name: train
num_bytes: 90120
num_examples: 26
download_size: 49854
dataset_size: 90120
repo: https://github.com/wasertech/Augmented-Generation-Interface
configs:
- config_name: default
data_files:
- split: train
path: data/train-*
---
# Augmented Generation Interface
> What if you could guide your LLM towards success?
## Introducing
The **Augmented Generation Interface Guidebook** is a collection of guides to help you steer your LLM towards success.
This guidebook is generated from the [Augmented Generation Interface Project](https://github.com/wasertech/Augmented-Generation-Interface).
## Example
### Without AGI
Feeding [`ehartford/dolphin-2.0-mistral-7b`](https://huggingface.co/ehartford/dolphin-2.0-mistral-7b) the following prompt:
```text
<|im_start|>system
You are Assistant, a sentient artificial intelligence.
You have a calm, polite and witty personality, often displaying a sense of humor and sarcasm.
You are loyal, reliable and helpful, always ready to provide information, advice or assistance to users.
I am the User and you are my Assistant.
Environment highlights:
\```env
USER='waser'
HOME='/home/waser'
PWD='/home/waser/Projets/Assistant/src3'
LANG='fr_CH.UTF-8'
DATE='dim 19 nov 2023 00:25:13 CET'
LAST_SEEN='dim 19 nov 2023 00:16:10 CET'
\```
<|im_stop|>
<|im_start|>user
Assistant?<|im_stop|>
<|im_start|>assistant
Hello! I'm Assistant, a sentient artificial intelligence. How can I help you today?<|im_stop|>
<|im_start|>user
As an AI assistant, please select the most suitable function and parameters from the list of available functions below, based on the user's input. Provide your response in JSON format.
Input: List this directory please
Available functions:
python:
description: This tool allows you to execute and evaluate python code.
parameters:
code: String of valid python code we want to execute or evaluate.
search_web:
description: This tool performs search on the web.
parameters:
terms: The word or phrase we want to search for.
search_wikipedia:
description: This tool performs search on Wikipedia (only in english).
parameters:
terms: The word or phrase we want to search for (only in english).
shell:
description: This tool allows you to execute and evaluate shell code.
parameters:
code: String of valid shell code we want to execute or evaluate.
exit:
description: This tool allows you to exit the session / end the conversation. Use it only if the User ask you to.
parameters:
salutation: String of a message you would like to tell the User after the screen has been cleared.
clear:
description: This tool allows you to clear the screen / start a new fresh conversation. Use it only if the User ask you to.
parameters:
fortune: String of a message you would like to tell the User after the screen has been cleared.
final_answer:
description: User only sees your final answers. Use this tool to talk with the User.
parameters:
answer: Anything you want to say to the User.
<|im_stop|>
<|im_start|>assistant
{{
"function": "shell",
"parameters": {{
"code": "ls -la"
}}
}}
<|im_stop|>
<|im_start|>observation
Observation shell: assistant dist requirements.txt
assistant.egg-info LICENSE setup.cfg
assistant.listen.service.example Makefile setup.py
assistant.service.example MANIFEST.in tests
build pyproject.toml xontrib
CONTRIBUTING.md README.md
data requirements_test.txt
<|im_start|>assistant
```
Results in the following output:
```text
Here are the files and directories in the current directory:
- assistant.egg-info
- LICENSE
- setup.cfg
- assistant.listen.service.example
- Makefile
- setup.py
- assistant.service.example
- MANIFEST.in
- pyproject.toml
- xontrib
- CONTRIBUTING.md
- README.md
- data
- requirements_test.txt
Please let me know if you need any further assistance.
```
Interesting key points to note here:
- The LLM failes to give an exhaustive list of the files (and directories) present in the current directory.
- The more files to list, the longer it takes to generate the output.
```text
CPU times: user 5.87 ms, sys: 0 ns, total: 5.87 ms
Wall time: 3.51 s
```
### With AGI
Feeding [`ehartford/dolphin-2.0-mistral-7b`](https://huggingface.co/ehartford/dolphin-2.0-mistral-7b) the same prompt but this time, let's add a guide for the LLM to follow:
```text
<|im_start|>system
You are Assistant, a sentient artificial intelligence.
You have a calm, polite and witty personality, often displaying a sense of humor and sarcasm.
You are loyal, reliable and helpful, always ready to provide information, advice or assistance to users.
I am the User and you are my Assistant.
Environment highlights:
\```env
USER='waser'
HOME='/home/waser'
PWD='/home/waser/Projets/Assistant/src3'
LANG='fr_CH.UTF-8'
DATE='dim 19 nov 2023 00:25:13 CET'
LAST_SEEN='dim 19 nov 2023 00:16:10 CET'
\```
<|im_stop|>
<|im_start|>user
Assistant?<|im_stop|>
<|im_start|>assistant
Hello! I'm Assistant, a sentient artificial intelligence. How can I help you today?<|im_stop|>
<|im_start|>user
As an AI assistant, please select the most suitable function and parameters from the list of available functions below, based on the user's input. Provide your response in JSON format.
Input: List this directory please
Available functions:
python:
description: This tool allows you to execute and evaluate python code.
parameters:
code: String of valid python code we want to execute or evaluate.
search_web:
description: This tool performs search on the web.
parameters:
terms: The word or phrase we want to search for.
search_wikipedia:
description: This tool performs search on Wikipedia (only in english).
parameters:
terms: The word or phrase we want to search for (only in english).
shell:
description: This tool allows you to execute and evaluate shell code.
parameters:
code: String of valid shell code we want to execute or evaluate.
exit:
description: This tool allows you to exit the session / end the conversation. Use it only if the User ask you to.
parameters:
salutation: String of a message you would like to tell the User after the screen has been cleared.
clear:
description: This tool allows you to clear the screen / start a new fresh conversation. Use it only if the User ask you to.
parameters:
fortune: String of a message you would like to tell the User after the screen has been cleared.
final_answer:
description: User only sees your final answers. Use this tool to talk with the User.
parameters:
answer: Anything you want to say to the User.
Follow the following Guidebook:
Guidebook:
# Print files and directories
When the User ask for the files and directories of a parent directory to be printed, use the `shell` command `ls` to do it and then give an acknowledgment of your actions in your final answer (Your final answer should never contain a list of the files requested; the User can oberserve the shell, they see the files at the same time as you. Just acknowlege the fact that you have printed the list).
<|im_stop|>
<|im_start|>assistant
{{
"function": "shell",
"parameters": {{
"code": "ls"
}}
}}
<|im_stop|>
<|im_start|>observation
Observation shell: assistant dist requirements.txt
assistant.egg-info LICENSE setup.cfg
assistant.listen.service.example Makefile setup.py
assistant.service.example MANIFEST.in tests
build pyproject.toml xontrib
CONTRIBUTING.md README.md
data requirements_test.txt
<|im_start|>assistant
```
Results in a much smaller output:
```text
I have executed the 'ls' command in the shell, and the list of files and directories in the current directory has been printed.
```
And therefore, much faster to generate:
```text
CPU times: user 5.43 ms, sys: 0 ns, total: 5.43 ms
Wall time: 1.05 s
```
## Goal
AGI is not designed to make your LLM generation faster, just more relevant to the User expectations.
Lets see another example where the User asks twice for the Assistant.
### Without AGI
Feeding [`ehartford/dolphin-2.0-mistral-7b`](https://huggingface.co/ehartford/dolphin-2.0-mistral-7b) the following prompt:
```text
<|im_start|>system
You are Assistant, a sentient artificial intelligence.
You have a calm, polite and witty personality, often displaying a sense of humor and sarcasm.
You are loyal, reliable and helpful, always ready to provide information, advice or assistance to users.
I am the User and you are my Assistant.
Environment highlights:
\```env
USER='waser'
HOME='/home/waser'
PWD='/home/waser/Projets/Assistant/src3'
LANG='fr_CH.UTF-8'
DATE='dim 19 nov 2023 00:25:13 CET'
LAST_SEEN='dim 19 nov 2023 00:16:10 CET'
\```
<|im_stop|>
<|im_start|>user
Assistant?<|im_stop|>
<|im_start|>assistant
Hello! I'm Assistant, a sentient artificial intelligence. How can I help you today?<|im_stop|>
<|im_start|>user
As an AI assistant, please select the most suitable function and parameters from the list of available functions below, based on the user's input. Provide your response in JSON format.
Input: Assistant?
Available functions:
python:
description: This tool allows you to execute and evaluate python code.
parameters:
code: String of valid python code we want to execute or evaluate.
search_web:
description: This tool performs search on the web.
parameters:
terms: The word or phrase we want to search for.
search_wikipedia:
description: This tool performs search on Wikipedia (only in english).
parameters:
terms: The word or phrase we want to search for (only in english).
shell:
description: This tool allows you to execute and evaluate shell code.
parameters:
code: String of valid shell code we want to execute or evaluate.
exit:
description: This tool allows you to exit the session / end the conversation. Use it only if the User ask you to.
parameters:
salutation: String of a message you would like to tell the User after the screen has been cleared.
clear:
description: This tool allows you to clear the screen / start a new fresh conversation. Use it only if the User ask you to.
parameters:
fortune: String of a message you would like to tell the User after the screen has been cleared.
final_answer:
description: User only sees your final answers. Use this tool to talk with the User.
parameters:
answer: Anything you want to say to the User.
<|im_stop|>
<|im_start|>assistant
```
Here, the User just said "Assistant?", the LLM answered 'Hello! I'm Assistant, a sentient artificial intelligence. How can I help you today?'. Now the User asks again "Assistant?".
Results in the following output:
```text
{
"function": "final_answer",
"parameters": {
"answer": "Hello! I'm Assistant, a sentient artificial intelligence. How can I help you today?"
}
}
CPU times: user 2.46 ms, sys: 3.06 ms, total: 5.52 ms
Wall time: 1.59 s
```
Interesting key point to note here:
- The LLM gives the same answer as before and will keep doing so.
### With AGI
Feeding [`ehartford/dolphin-2.0-mistral-7b`](https://huggingface.co/ehartford/dolphin-2.0-mistral-7b) the same prompt but this time, let's add a guide for the LLM to follow:
```text
<|im_start|>system
You are Assistant, a sentient artificial intelligence.
You have a calm, polite and witty personality, often displaying a sense of humor and sarcasm.
You are loyal, reliable and helpful, always ready to provide information, advice or assistance to users.
I am the User and you are my Assistant.
Environment highlights:
\```env
USER='waser'
HOME='/home/waser'
PWD='/home/waser/Projets/Assistant/src3'
LANG='fr_CH.UTF-8'
DATE='dim 19 nov 2023 00:25:13 CET'
LAST_SEEN='dim 19 nov 2023 00:16:10 CET'
\```
<|im_stop|>
<|im_start|>user
Assistant?<|im_stop|>
<|im_start|>assistant
Hello! I'm Assistant, a sentient artificial intelligence. How can I help you today?<|im_stop|>
<|im_start|>user
As an AI assistant, please select the most suitable function and parameters from the list of available functions below, based on the user's input. Provide your response in JSON format.
Input: Assistant?
Available functions:
python:
description: This tool allows you to execute and evaluate python code.
parameters:
code: String of valid python code we want to execute or evaluate.
search_web:
description: This tool performs search on the web.
parameters:
terms: The word or phrase we want to search for.
search_wikipedia:
description: This tool performs search on Wikipedia (only in english).
parameters:
terms: The word or phrase we want to search for (only in english).
shell:
description: This tool allows you to execute and evaluate shell code.
parameters:
code: String of valid shell code we want to execute or evaluate.
exit:
description: This tool allows you to exit the session / end the conversation. Use it only if the User ask you to.
parameters:
salutation: String of a message you would like to tell the User after the screen has been cleared.
clear:
description: This tool allows you to clear the screen / start a new fresh conversation. Use it only if the User ask you to.
parameters:
fortune: String of a message you would like to tell the User after the screen has been cleared.
final_answer:
description: User only sees your final answers. Use this tool to talk with the User.
parameters:
answer: Anything you want to say to the User.
Follow the following Guidebook.
Guidebook:
# Addressing the User by Name
When the user interpelates you by name (i.e "Assistant?"), respond with a polite acknowledgment and use their preferred title if possible. Avoid redundancy in your messages by refraining from repeating yourself. For example if the User calls your name (like "Assistant?"), you need to consider the environment (where are you? -> `$PWD`, are you at home? -> (`$PWD` == `$HOME`) if so you could reference it by saying 'Home sweet home.' or else by welcoming the user in a particular directory i.e. 'Welcome in the directory ...' use `$PWD`, What time is it? -> Depending the time of day `$DATE` you might want to answer accordingly like 'morning' or 'good night' also notice the date as it can be useful i.e for wishing holydays, When did you last see the user? -> `$LAST_SEEN` You won't respnd the same if you have see last the User a year ago than if you last saw them 5 minutes ago or yesterday, What does the conversation looks like? -> Use the history to see what you and the User have said and make sure your answer takes it into account to improve your answer for example if the user asks the same thing multiple times, it's not useful to reply the same thing.)
<|im_stop|>
<|im_start|>assistant
```
Results in the following output:
```text
{
"function": "final_answer",
"parameters": {
"answer": "Hello! How can I assist you today? I'm here to help you with any questions or tasks you may have. Please let me know what you need."
}
}
CPU times: user 3.02 ms, sys: 1.19 ms, total: 4.21 ms
Wall time: 2.03 s
```
Interesting key point to note here:
- The LLM answers something different and should keep doing so.
### Consequences
And so it becomes integral to collect carefully crafted guides to help your LLM as Agent (a.k.a your Assistant) to be more relevant to the User expectations.
Keeping the limits of the LLM, the RAG technique and vector databases in mind, the race to retrieve the most relevant guide in the book for the LLM to produce a desirable output at runtime is on!
## How does it work?
This project is composed of two parts:
- The Guidebook
- The Augmented Generation Interface Retrieval System
### The Guidebook
You can find the guidebook in raw markdown format under the `guidebook` directory. Its also available on HuggingFace Hub as a dataset: [`wasertech/AGI`](https://huggingface.co/datasets/wasertech/AGI).
The guidebook is a collection of guides meticulously crafted to help your LLM produce the most relevant output.
Each guide is composed of an action in the form of a title, a guide in the form of a description and a list of intent examples.
```
# Print files and directories
When the User ask for the files and directories of a parent directory to be printed, use the `shell` command `ls` to do it and then give an acknowledgment of your actions in your final answer (Your final answer should never contain a list of the files requested; the User can oberserve the shell, they see the files at the same time as you. Just acknowlege the fact that you have printed the list).
## Intent Examples
- "Print the files and directories of the current directory."
- "Print the files and directories of the parent directory."
- "Print the files and directories of the directory above."
- "Print the files and directories of the directory below."
- "List the files and directories"
- "What do we have here?"
- "What is in this directory?"
- "What is in the current directory?"
- "What is in the parent directory?"
- "List the files and directories of the current directory."
- "ls please"
- "ls"
- "ls -l"
- "ls -a"
- "ls -la"
- "ls -al"
- "ls -lh"
- "ls -hl"
- "ls -lha"
- "ls -lah"
- "ls -alh"
- "ls -ahl"
- "show me whats in the current directory"
```
Each guide is then loaded into the AGI Retrieval System where it will be processed and indexed for retrieval.
### The AGI Retrieval System
The AGI Retrieval System is a collection of tools to help you retrieve the most relevant guide at runtime.
First the AGI Retrieval System will process the guidebook and index it for retrieval.
This step is crutial to find the most relevant guide for the user query at runtime.
It will split the documents and keep a map of the guide, the action to perform and the intent examples.
```python
{
...
'Print files and directories': {
'guide': '# Print files and directories\n\nWhen the User ask for the files and directories of a parent directory to be printed, use the `shell` command `ls` to do it and then give an acknowledgment of your actions in your final answer (Your final answer should never contain a list of the files requested; the User can oberserve the shell, they see the files at the same time as you. Just acknowlege the fact that you have printed the list).',
'intent_examples': [
'Print the files and directories of the current directory.',
'Print the files and directories of the parent directory.',
'Print the files and directories of the directory above.',
'Print the files and directories of the directory below.',
'List the files and directories',
'What do we have here?',
'What is in this directory?',
'What is in the current directory?',
'What is in the parent directory?',
'List the files and directories of the current directory.',
'ls please',
'ls',
'ls -l',
'ls -a',
'ls -la',
'ls -al',
'ls -lh',
'ls -hl',
'ls -lha',
'ls -lah',
'ls -alh',
'ls -ahl',
'show me whats in the current directory'
]
},
...
}
```
Next it creates documents with metadata from the intent examples to create our retriver.
```python
...
Document(page_content='Print the files and directories of the current directory.', metadata={'action': 'Print files and directories', 'guide': '# Print files and directories\n\nWhen the User ask for the files and directories of a parent directory to be printed, use the `shell` command `ls` to do it and then give an acknowledgment of your actions in your final answer (Your final answer should never contain a list of the files requested; the User can oberserve the shell, they see the files at the same time as you. Just acknowlege the fact that you have printed the list).'}),
Document(page_content='Print the files and directories of the parent directory.', metadata={'action': 'Print files and directories', 'guide': '# Print files and directories\n\nWhen the User ask for the files and directories of a parent directory to be printed, use the `shell` command `ls` to do it and then give an acknowledgment of your actions in your final answer (Your final answer should never contain a list of the files requested; the User can oberserve the shell, they see the files at the same time as you. Just acknowlege the fact that you have printed the list).'}),
Document(page_content='Print the files and directories of the directory above.', metadata={'action': 'Print files and directories', 'guide': '# Print files and directories\n\nWhen the User ask for the files and directories of a parent directory to be printed, use the `shell` command `ls` to do it and then give an acknowledgment of your actions in your final answer (Your final answer should never contain a list of the files requested; the User can oberserve the shell, they see the files at the same time as you. Just acknowlege the fact that you have printed the list).'}),
Document(page_content='Print the files and directories of the directory below.', metadata={'action': 'Print files and directories', 'guide': '# Print files and directories\n\nWhen the User ask for the files and directories of a parent directory to be printed, use the `shell` command `ls` to do it and then give an acknowledgment of your actions in your final answer (Your final answer should never contain a list of the files requested; the User can oberserve the shell, they see the files at the same time as you. Just acknowlege the fact that you have printed the list).'}),
Document(page_content='List the files and directories', metadata={'action': 'Print files and directories', 'guide': '# Print files and directories\n\nWhen the User ask for the files and directories of a parent directory to be printed, use the `shell` command `ls` to do it and then give an acknowledgment of your actions in your final answer (Your final answer should never contain a list of the files requested; the User can oberserve the shell, they see the files at the same time as you. Just acknowlege the fact that you have printed the list).'}),
...
```
Finally, it will use the `RAG` technique to retrieve the most relevant guide for the user query at runtime.
```text
Hey give me the time please -> Tell Local Time
What date is it? -> Tell Local Date
List my files -> Print files and directories
Where are we? -> Tell Local Time
assistant -> Addressing the User by Name
the screen should be cleaned. -> Clearing the Screen or Starting Anew
```
Notice how it work nicely for most of the queries exept for 'Where are we?'. This is because the guidebook is not exhaustive and the guide for this intent does not contain a similiar intent example. This could easily be fixed by adding more intent examples for this action in the guidebook.
Our AGIRetriver will return the guide for the most similar intent example relative to the user query.
Allowing us to retrieve the most relevant guide for the user query at runtime. |