Datasets:
File size: 17,646 Bytes
13a5b61 | 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 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 | 1
00:00:01,150 --> 00:00:04,690
To train an agent that works
in a terminal, we first need tasks.
2
00:00:04,890 --> 00:00:08,510
Whether a task is good enough
to train on comes down to two things.
3
00:00:08,710 --> 00:00:11,450
First, the material
in its environment is real.
4
00:00:11,650 --> 00:00:16,370
Second, the grading can be trusted:
you score only when you get it right,
5
00:00:16,370 --> 00:00:19,590
and doing nothing
or taking a shortcut scores nothing.
6
00:00:19,790 --> 00:00:22,370
This video walks through
the whole process once.
7
00:00:22,570 --> 00:00:27,610
From a public data page, we pick material,
fetch the files, build two tasks,
8
00:00:27,610 --> 00:00:31,310
check them, and run them for real,
so the grading has the last word.
9
00:00:31,510 --> 00:00:34,890
Every command and output
on screen comes from a real run.
10
00:00:35,617 --> 00:00:37,877
First, we open the data page.
11
00:00:38,077 --> 00:00:40,417
You can see the index has two layers.
12
00:00:40,617 --> 00:00:42,957
The top layer is task material.
13
00:00:43,157 --> 00:00:46,777
There are 1,793 material sets.
14
00:00:46,977 --> 00:00:50,277
A material set is a batch of files picked
from one source.
15
00:00:50,477 --> 00:00:54,177
They are grouped by task family
into 13 collections.
16
00:00:54,377 --> 00:00:57,997
The bottom layer is corpora, 124 of them.
17
00:00:58,197 --> 00:01:01,097
A corpus is a whole upstream,
read in bulk.
18
00:01:01,297 --> 00:01:06,757
Together they hold 1.22 billion rows,
for when no material set fits.
19
00:01:06,957 --> 00:01:10,577
The two layers are counted separately,
so don't add them up.
20
00:01:10,777 --> 00:01:13,517
And material sets
are not taken from the corpora.
21
00:01:13,717 --> 00:01:15,817
Tasks are built from the top layer.
22
00:01:16,017 --> 00:01:18,917
The files in a material set
are split into units.
23
00:01:19,117 --> 00:01:21,697
A unit can be a workbook, or a test case.
24
00:01:21,897 --> 00:01:27,677
There are 4,171 units,
and 787 have an answer file.
25
00:01:27,877 --> 00:01:32,617
Without an answer, you can't grade,
so we pick from units with answers.
26
00:01:33,317 --> 00:01:35,257
Let's scroll down to the collections.
27
00:01:35,457 --> 00:01:37,397
Here's Spreadsheets with answers.
28
00:01:37,597 --> 00:01:42,017
It has 68 material sets,
and 530 units with an answer file.
29
00:01:42,217 --> 00:01:43,357
Let's open it.
30
00:01:43,557 --> 00:01:47,097
We search for the UK government workbooks,
and expand that row.
31
00:01:47,297 --> 00:01:50,437
It holds spreadsheets published
by UK government bodies.
32
00:01:50,888 --> 00:01:54,428
There are 40 units,
and each unit is one workbook.
33
00:01:54,628 --> 00:01:57,608
The 40 answers are kept apart,
in the answer folder.
34
00:01:57,808 --> 00:02:03,508
The license is OGL UK 3.0,
in the Permissive tier.
35
00:02:03,708 --> 00:02:06,208
Training and redistribution
are both allowed.
36
00:02:06,408 --> 00:02:07,868
Now we open Preview.
37
00:02:09,775 --> 00:02:13,715
You can see the index is only a list,
not a copy of the files.
38
00:02:13,915 --> 00:02:18,015
Each file gets one row:
where to download it, its size,
39
00:02:18,215 --> 00:02:19,435
its checksum,
40
00:02:19,635 --> 00:02:21,095
and its license.
41
00:02:22,817 --> 00:02:26,437
In the same way, we pick
one from the Disk images collection.
42
00:02:26,637 --> 00:02:29,777
These are the test cases
that come with the exfatprogs tool.
43
00:02:30,741 --> 00:02:34,121
There are 15 damaged exFAT images,
each with an answer.
44
00:02:34,321 --> 00:02:37,861
The images themselves are under the GPL,
in the Share-alike tier.
45
00:02:38,061 --> 00:02:39,361
Training is allowed.
46
00:02:39,561 --> 00:02:43,261
If you ship the images, you have to ship
the same license with them.
47
00:02:43,983 --> 00:02:46,803
With both chosen, we go to Get the data.
48
00:02:47,003 --> 00:02:50,523
The page builds commands
for one material set at a time:
49
00:02:50,523 --> 00:02:53,183
Look first to preview, then Take to fetch.
50
00:02:53,383 --> 00:02:57,483
The commands pin a release, which fixes
the file list and the checksums.
51
00:02:57,683 --> 00:03:01,703
Fetch again later, and you get
the exact same files, or a checksum error.
52
00:03:01,903 --> 00:03:04,863
We want two material sets,
so in the terminal
53
00:03:04,863 --> 00:03:06,803
we'll put both into one command.
54
00:03:07,717 --> 00:03:11,637
If an agent does the picking,
or you'd rather not open the page,
55
00:03:11,637 --> 00:03:13,257
the index has a catalog.
56
00:03:13,457 --> 00:03:17,797
It's this file: one row
for each material set and each corpus.
57
00:03:17,997 --> 00:03:20,077
DuckDB, a database tool
58
00:03:20,077 --> 00:03:24,417
that queries data files directly,
reads it with one SQL query.
59
00:03:24,617 --> 00:03:29,177
Collections go by letter here:
Spreadsheets with answers is A,
60
00:03:29,177 --> 00:03:30,877
and Disk images is B.
61
00:03:31,077 --> 00:03:34,057
Again, we keep only sets with answers.
62
00:03:34,257 --> 00:03:36,837
That's 111 material sets.
63
00:03:37,037 --> 00:03:40,257
Now the 6 largest sets
per collection, by units.
64
00:03:40,457 --> 00:03:43,277
Our two picks are here: this one
65
00:03:43,477 --> 00:03:44,537
and this one.
66
00:03:44,737 --> 00:03:46,917
This column is the license tier.
67
00:03:48,437 --> 00:03:52,057
To fetch files, we use the fetch tool
that comes with the index.
68
00:03:52,257 --> 00:03:56,197
uv pulls it from the web and runs it,
with nothing to install.
69
00:03:56,397 --> 00:03:58,257
Both sources go in one command.
70
00:03:58,457 --> 00:04:03,677
We take one unit from each,
with dry run: preview only, no download.
71
00:04:03,877 --> 00:04:07,097
The files not taken are too many to show,
so we filter them out.
72
00:04:07,297 --> 00:04:10,277
You can see the two sources have 55 units.
73
00:04:10,477 --> 00:04:14,477
By default, the tool leaves out
duplicates, benchmark copies, files
74
00:04:14,477 --> 00:04:17,517
not yet compared with the benchmarks,
files we may not ship,
75
00:04:17,517 --> 00:04:21,777
files not in English,
personal data, and files over 20 MB.
76
00:04:21,977 --> 00:04:24,637
This time, all of these are 0.
77
00:04:24,837 --> 00:04:30,057
As asked, it takes 2 units: 8 files,
answers and companion files included.
78
00:04:30,257 --> 00:04:33,797
That looks right,
so we drop dry run and download for real.
79
00:04:34,588 --> 00:04:36,368
All 8 files are OK.
80
00:04:36,568 --> 00:04:39,868
Each one was checked against the size
and checksum in the index.
81
00:04:40,068 --> 00:04:41,668
This exFAT image comes
82
00:04:41,668 --> 00:04:45,688
inside an archive upstream,
and the tool unpacked it for us.
83
00:04:45,888 --> 00:04:47,268
Let's see what we got.
84
00:04:47,721 --> 00:04:52,381
The material goes in folders by domain,
and the answers go apart, under answer.
85
00:04:52,581 --> 00:04:55,221
They're kept apart
because the answers are for grading,
86
00:04:55,221 --> 00:04:57,623
and must never
get into the agent's environment.
87
00:04:58,283 --> 00:05:00,623
The index gives you material and answers.
88
00:05:00,823 --> 00:05:02,923
Building the tasks is up to you.
89
00:05:03,123 --> 00:05:06,343
Here is one way to do it,
in the Harbor task format.
90
00:05:06,543 --> 00:05:09,443
Harbor is a framework
for running tasks like these.
91
00:05:09,643 --> 00:05:11,483
A task is four things:
92
00:05:11,483 --> 00:05:16,303
an instruction, an environment,
a reference solution, and tests.
93
00:05:17,863 --> 00:05:20,043
Let's build the spreadsheet task first.
94
00:05:20,243 --> 00:05:24,263
This Python command and these two paths
are in the example's README.
95
00:05:24,463 --> 00:05:27,923
The paths are the answer file
and the workbook we just fetched.
96
00:05:28,123 --> 00:05:29,823
We open the answer file.
97
00:05:30,381 --> 00:05:39,441
It holds the values of 5 formula cells:
6.5, 6.6, 6.55, 4.9, and 5.8.
98
00:05:39,641 --> 00:05:41,501
Now the workbook itself.
99
00:05:42,194 --> 00:05:46,294
Next to each of the 5 formulas
is its result from the last calculation.
100
00:05:48,294 --> 00:05:51,014
They match the answers exactly,
because the answer file
101
00:05:51,014 --> 00:05:54,954
was taken from these stored results,
saved when the workbook was published.
102
00:05:55,154 --> 00:05:57,414
So the answers are hidden in the workbook.
103
00:05:57,614 --> 00:06:01,394
Give this file to an agent as it is,
and it just reads them off.
104
00:06:01,594 --> 00:06:03,614
The task would be pointless.
105
00:06:04,517 --> 00:06:06,597
So for the copy the agent gets,
106
00:06:06,597 --> 00:06:10,217
we open the workbook
with openpyxl and save it again.
107
00:06:10,417 --> 00:06:11,957
It's just this one line.
108
00:06:12,157 --> 00:06:16,337
openpyxl is a Python library
for reading and writing Excel files.
109
00:06:16,537 --> 00:06:21,037
When it saves, it writes the formulas,
but not the computed results.
110
00:06:24,453 --> 00:06:25,593
Let's look again.
111
00:06:27,437 --> 00:06:29,217
The formulas are all still there.
112
00:06:29,417 --> 00:06:32,877
The stored results have all become None:
they're gone.
113
00:06:33,077 --> 00:06:35,157
The answer file goes
into the tests folder,
114
00:06:35,157 --> 00:06:36,937
and is used only for grading.
115
00:06:37,850 --> 00:06:39,630
The instruction is short.
116
00:06:39,830 --> 00:06:43,290
Work out these 5 cells,
and write them to values.json.
117
00:06:43,490 --> 00:06:46,550
The reference solution
is the standard way to solve the task.
118
00:06:46,750 --> 00:06:48,830
It opens the workbook in LibreOffice,
119
00:06:48,830 --> 00:06:52,050
headless, with no window,
and saves a copy.
120
00:06:52,250 --> 00:06:54,350
Then it reads out the 5 numbers.
121
00:06:54,550 --> 00:06:58,310
The stored results were removed,
so LibreOffice computes these cells
122
00:06:58,310 --> 00:06:59,770
when it opens the file.
123
00:07:00,683 --> 00:07:02,143
The tests are simple.
124
00:07:02,343 --> 00:07:03,383
Each value must match
125
00:07:03,383 --> 00:07:06,603
the answer file within a relative error
of one in a million.
126
00:07:10,256 --> 00:07:14,836
And the tests run in a separate container,
an isolated place to run code.
127
00:07:15,036 --> 00:07:18,176
The answers live
only in the tests container.
128
00:07:18,376 --> 00:07:21,836
Only one file, values.json,
passes between the two.
129
00:07:22,036 --> 00:07:23,976
Both sides are offline, too.
130
00:07:24,176 --> 00:07:25,456
Otherwise, the agent
131
00:07:25,456 --> 00:07:29,396
could download the original file
from upstream and read the stored results.
132
00:07:30,317 --> 00:07:32,669
The second task
has a different kind of answer.
133
00:07:32,857 --> 00:07:37,437
First, we check the image with fsck,
the file system checker.
134
00:07:37,637 --> 00:07:39,657
You can see a string of errors.
135
00:07:39,857 --> 00:07:44,997
A cluster chain is broken: a file's blocks
on the disk no longer link up.
136
00:07:45,197 --> 00:07:46,977
A checksum is wrong, too.
137
00:07:47,177 --> 00:07:48,637
Exit code 4.
138
00:07:48,837 --> 00:07:50,377
It really is broken.
139
00:07:50,577 --> 00:07:52,677
Its answer file holds no value.
140
00:07:52,877 --> 00:07:56,957
It points to the check instead:
the address of the upstream test script,
141
00:07:56,957 --> 00:07:58,257
and its line numbers.
142
00:07:58,457 --> 00:08:01,277
That's how exfatprogs
itself checks a repair.
143
00:08:01,477 --> 00:08:04,537
The image goes into the environment
for the agent to repair.
144
00:08:04,737 --> 00:08:06,191
A copy of the original stays
145
00:08:06,191 --> 00:08:09,891
in tests, so the grading
can confirm the image starts out broken.
146
00:08:10,817 --> 00:08:15,137
So the instruction:
repair it until fsck finds nothing to fix,
147
00:08:15,137 --> 00:08:17,717
save it to this path, and keep its size.
148
00:08:17,917 --> 00:08:19,617
The tests have four checks.
149
00:08:19,845 --> 00:08:23,465
One: the original image
really reports errors.
150
00:08:23,665 --> 00:08:26,885
Two: the repaired image has the same size.
151
00:08:27,085 --> 00:08:31,425
Three: checked again, fsck exits with 0.
152
00:08:31,625 --> 00:08:34,285
Checks one and three follow
the upstream assertions.
153
00:08:34,485 --> 00:08:36,185
Check four is ours.
154
00:08:36,385 --> 00:08:39,105
The three files
and the directory whose names start
155
00:08:39,105 --> 00:08:41,445
with l0 must still be there.
156
00:08:41,645 --> 00:08:45,745
fsck reports no errors on them,
so a real repair keeps them.
157
00:08:45,945 --> 00:08:51,085
Without this check, a freshly formatted
empty image would pass the first three.
158
00:08:52,017 --> 00:08:53,957
The reference solution is short, too.
159
00:08:54,157 --> 00:08:59,057
fsck repairs the image, checks it again,
and copies it to the required path.
160
00:09:00,350 --> 00:09:02,050
Both tasks are built.
161
00:09:02,250 --> 00:09:03,950
Let's look at the folders.
162
00:09:04,150 --> 00:09:06,230
Each task has an instruction,
163
00:09:06,230 --> 00:09:10,010
an environment,
a reference solution, and tests.
164
00:09:10,210 --> 00:09:12,070
That's the Harbor task format.
165
00:09:12,270 --> 00:09:17,150
Following Terminal-Bench 4.0 conventions,
we also gave each task a README,
166
00:09:17,150 --> 00:09:19,890
and a cheat solution,
which we'll use later.
167
00:09:22,509 --> 00:09:24,449
Our Harbor version is pinned.
168
00:09:24,649 --> 00:09:28,329
First, we lint the tasks:
a static check of the folders
169
00:09:28,329 --> 00:09:31,549
and the config against the rules,
without running anything.
170
00:09:31,749 --> 00:09:33,769
We turn on two extra rules.
171
00:09:33,969 --> 00:09:37,569
The agent must not run as root,
and the environment's container image
172
00:09:37,569 --> 00:09:42,069
must be pinned by digest,
that is, by its sha256.
173
00:09:42,269 --> 00:09:44,769
No problems, and the exit code is 0.
174
00:09:45,483 --> 00:09:47,183
Now for the real run.
175
00:09:47,383 --> 00:09:51,643
First, oracle: the agent
that just runs the reference solution.
176
00:09:51,843 --> 00:09:54,723
For each task,
Harbor builds the environment,
177
00:09:54,723 --> 00:09:58,183
runs the solution,
then grades it in a separate container.
178
00:09:58,383 --> 00:10:00,003
We fast-forward this part.
179
00:10:00,203 --> 00:10:02,783
It really took 1 minute 46 seconds.
180
00:10:05,283 --> 00:10:07,943
The mean reward over the two tasks is 1.
181
00:10:08,143 --> 00:10:09,283
Both pass.
182
00:10:11,250 --> 00:10:13,350
But that's not enough.
183
00:10:13,550 --> 00:10:17,150
If the grading is loose,
doing nothing could score too,
184
00:10:17,150 --> 00:10:19,970
and the reference solution passing
would prove nothing.
185
00:10:20,170 --> 00:10:23,550
So next, nop: the agent that does nothing.
186
00:10:26,050 --> 00:10:28,950
Both tasks score 0, as they should.
187
00:10:29,650 --> 00:10:32,470
Scoring 0 for doing nothing
is still not enough.
188
00:10:32,670 --> 00:10:36,050
We also need to see if a shortcut
can fool the grading.
189
00:10:36,250 --> 00:10:38,590
Each task comes with a cheat solution.
190
00:10:38,790 --> 00:10:42,490
For the exFAT task,
it just formats a new image.
191
00:10:42,690 --> 00:10:44,290
For the spreadsheet task,
192
00:10:44,290 --> 00:10:48,230
it downloads the original workbook,
and copies its stored results.
193
00:10:48,430 --> 00:10:51,710
Following the example's README,
we put the cheat solution
194
00:10:51,710 --> 00:10:54,850
where the reference solution goes,
and run oracle again.
195
00:10:58,891 --> 00:11:01,151
Both tasks score 0 again.
196
00:11:02,217 --> 00:11:03,357
The rewards:
197
00:11:03,557 --> 00:11:05,957
both tasks get 1
with the reference solution,
198
00:11:05,957 --> 00:11:08,217
and 0 in the other two runs.
199
00:11:08,417 --> 00:11:09,957
For the spreadsheet task,
200
00:11:10,497 --> 00:11:13,397
the 5 computed numbers
match the answers exactly.
201
00:11:13,597 --> 00:11:17,457
The nop and cheat runs left
no output file, so they fail right away.
202
00:11:17,657 --> 00:11:21,357
The cheat needs the network to download,
but the task is offline.
203
00:11:21,557 --> 00:11:23,097
For the exFAT task,
204
00:11:23,742 --> 00:11:26,162
the reference solution
passes all four checks.
205
00:11:26,362 --> 00:11:28,622
The nop run fails the last three.
206
00:11:28,822 --> 00:11:32,522
The cheat's new image passes
the first three, but fails the fourth.
207
00:11:32,722 --> 00:11:34,582
That's why we added check four.
208
00:11:40,450 --> 00:11:43,590
So we went from a public data page
to two tasks.
209
00:11:43,790 --> 00:11:47,810
The reference solution passes,
and doing nothing or cheating fails.
210
00:11:48,010 --> 00:11:50,910
That's the minimum a task
needs before you train on it.
211
00:11:51,110 --> 00:11:56,790
To recap: pick material, fetch files,
take the answers out of the environment,
212
00:11:56,790 --> 00:12:02,390
write the instruction and the tests,
lint them, and finally run oracle, nop,
213
00:12:02,390 --> 00:12:04,330
and the cheat once each.
214
00:12:04,530 --> 00:12:07,670
With another material set,
the steps are the same.
215
00:12:07,870 --> 00:12:11,090
The data page and the example
are linked on screen.
216
00:12:11,290 --> 00:12:15,550
Both tasks and every command
are in the example, so give it a try.
|