zjowowen commited on
Commit
4231e0d
1 Parent(s): 5b07706
.gitignore ADDED
@@ -0,0 +1,1225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Created by .ignore support plugin (hsz.mobi)
2
+ ### Example user template template
3
+ ### Example user template
4
+
5
+ # IntelliJ project files
6
+ .idea
7
+ *.iml
8
+ out
9
+ gen
10
+ ### CVS template
11
+ /CVS/*
12
+ **/CVS/*
13
+ .cvsignore
14
+ */.cvsignore
15
+
16
+ ### C++ template
17
+ # Prerequisites
18
+ *.d
19
+
20
+ # Compiled Object files
21
+ *.slo
22
+ *.lo
23
+ *.o
24
+ *.obj
25
+
26
+ # Precompiled Headers
27
+ *.gch
28
+ *.pch
29
+
30
+ # Compiled Dynamic libraries
31
+ *.so
32
+ *.dylib
33
+ *.dll
34
+
35
+ # Fortran module files
36
+ *.mod
37
+ *.smod
38
+
39
+ # Compiled Static libraries
40
+ *.lai
41
+ *.la
42
+ *.a
43
+ *.lib
44
+
45
+ # Executables
46
+ *.exe
47
+ *.out
48
+ *.app
49
+
50
+ ### CUDA template
51
+ *.i
52
+ *.ii
53
+ *.gpu
54
+ *.ptx
55
+ *.cubin
56
+ *.fatbin
57
+
58
+ ### SVN template
59
+ .svn/
60
+
61
+ ### Images template
62
+ # JPEG
63
+ *.jpe
64
+ *.jif
65
+ *.jfif
66
+ *.jfi
67
+
68
+ # JPEG 2000
69
+ *.jp2
70
+ *.j2k
71
+ *.jpf
72
+ *.jpx
73
+ *.jpm
74
+ *.mj2
75
+
76
+ # JPEG XR
77
+ *.jxr
78
+ *.hdp
79
+ *.wdp
80
+
81
+ # Graphics Interchange Format
82
+ *.gif
83
+
84
+ # RAW
85
+ *.raw
86
+
87
+ # Web P
88
+ *.webp
89
+
90
+ # Portable Network Graphics
91
+ #*.png
92
+
93
+ # Animated Portable Network Graphics
94
+ *.apng
95
+
96
+ # Multiple-image Network Graphics
97
+ *.mng
98
+
99
+ # Tagged Image File Format
100
+ *.tiff
101
+ *.tif
102
+
103
+ # Scalable Vector Graphics
104
+ *.svg
105
+ *.svgz
106
+
107
+ # Portable Document Format
108
+ *.pdf
109
+
110
+ # X BitMap
111
+ *.xbm
112
+
113
+ # BMP
114
+ *.bmp
115
+ *.dib
116
+
117
+ # ICO
118
+ *.ico
119
+
120
+ # 3D Images
121
+ *.3dm
122
+ *.max
123
+
124
+ ### Eclipse template
125
+ .metadata
126
+ bin/
127
+ tmp/
128
+ *.tmp
129
+ *.bak
130
+ *.swp
131
+ *~.nib
132
+ local.properties
133
+ .settings/
134
+ .loadpath
135
+ .recommenders
136
+
137
+ # External tool builders
138
+ .externalToolBuilders/
139
+
140
+ # Locally stored "Eclipse launch configurations"
141
+ *.launch
142
+
143
+ # PyDev specific (Python IDE for Eclipse)
144
+ *.pydevproject
145
+
146
+ # CDT-specific (C/C++ Development Tooling)
147
+ .cproject
148
+
149
+ # CDT- autotools
150
+ .autotools
151
+
152
+ # Java annotation processor (APT)
153
+ .factorypath
154
+
155
+ # PDT-specific (PHP Development Tools)
156
+ .buildpath
157
+
158
+ # sbteclipse plugin
159
+ .target
160
+
161
+ # Tern plugin
162
+ .tern-project
163
+
164
+ # TeXlipse plugin
165
+ .texlipse
166
+
167
+ # STS (Spring Tool Suite)
168
+ .springBeans
169
+
170
+ # Code Recommenders
171
+ .recommenders/
172
+
173
+ # Annotation Processing
174
+ .apt_generated/
175
+ .apt_generated_test/
176
+
177
+ # Scala IDE specific (Scala & Java development for Eclipse)
178
+ .cache-main
179
+ .scala_dependencies
180
+ .worksheet
181
+
182
+ # Uncomment this line if you wish to ignore the project description file.
183
+ # Typically, this file would be tracked if it contains build/dependency configurations:
184
+ #.project
185
+
186
+ ### Diff template
187
+ *.patch
188
+ *.diff
189
+
190
+ ### macOS template
191
+ # General
192
+ .DS_Store
193
+ .AppleDouble
194
+ .LSOverride
195
+
196
+ # Icon must end with two \r
197
+ Icon
198
+
199
+ # Thumbnails
200
+ ._*
201
+
202
+ # Files that might appear in the root of a volume
203
+ .DocumentRevisions-V100
204
+ .fseventsd
205
+ .Spotlight-V100
206
+ .TemporaryItems
207
+ .Trashes
208
+ .VolumeIcon.icns
209
+ .com.apple.timemachine.donotpresent
210
+
211
+ # Directories potentially created on remote AFP share
212
+ .AppleDB
213
+ .AppleDesktop
214
+ Network Trash Folder
215
+ Temporary Items
216
+ .apdisk
217
+
218
+ ### CMake template
219
+ CMakeLists.txt.user
220
+ CMakeCache.txt
221
+ CMakeFiles
222
+ CMakeScripts
223
+ Testing
224
+ cmake_install.cmake
225
+ install_manifest.txt
226
+ compile_commands.json
227
+ CTestTestfile.cmake
228
+ _deps
229
+
230
+ ### Linux template
231
+ *~
232
+
233
+ # temporary files which can be created if a process still has a handle open of a deleted file
234
+ .fuse_hidden*
235
+
236
+ # KDE directory preferences
237
+ .directory
238
+
239
+ # Linux trash folder which might appear on any partition or disk
240
+ .Trash-*
241
+
242
+ # .nfs files are created when an open file is removed but is still being accessed
243
+ .nfs*
244
+
245
+ ### MicrosoftOffice template
246
+ *.tmp
247
+
248
+ # Word temporary
249
+ ~$*.doc*
250
+
251
+ # Word Auto Backup File
252
+ Backup of *.doc*
253
+
254
+ # Excel temporary
255
+ ~$*.xls*
256
+
257
+ # Excel Backup File
258
+ *.xlk
259
+
260
+ # PowerPoint temporary
261
+ ~$*.ppt*
262
+
263
+ # Visio autosave temporary files
264
+ *.~vsd*
265
+
266
+ ### VisualStudio template
267
+ ## Ignore Visual Studio temporary files, build results, and
268
+ ## files generated by popular Visual Studio add-ons.
269
+ ##
270
+ ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
271
+
272
+ # User-specific files
273
+ *.rsuser
274
+ *.suo
275
+ *.user
276
+ *.userosscache
277
+ *.sln.docstates
278
+
279
+ # User-specific files (MonoDevelop/Xamarin Studio)
280
+ *.userprefs
281
+
282
+ # Mono auto generated files
283
+ mono_crash.*
284
+
285
+ # Build results
286
+ [Dd]ebug/
287
+ [Dd]ebugPublic/
288
+ [Rr]elease/
289
+ [Rr]eleases/
290
+ x64/
291
+ x86/
292
+ [Ww][Ii][Nn]32/
293
+ [Aa][Rr][Mm]/
294
+ [Aa][Rr][Mm]64/
295
+ bld/
296
+ [Bb]in/
297
+ [Oo]bj/
298
+ [Ll]og/
299
+ [Ll]ogs/
300
+
301
+ # Visual Studio 2015/2017 cache/options directory
302
+ .vs/
303
+ # Uncomment if you have tasks that create the project's static files in wwwroot
304
+ #wwwroot/
305
+
306
+ # Visual Studio 2017 auto generated files
307
+ Generated\ Files/
308
+
309
+ # MSTest test Results
310
+ [Tt]est[Rr]esult*/
311
+ [Bb]uild[Ll]og.*
312
+
313
+ # NUnit
314
+ *.VisualState.xml
315
+ TestResult.xml
316
+ nunit-*.xml
317
+
318
+ # Build Results of an ATL Project
319
+ [Dd]ebugPS/
320
+ [Rr]eleasePS/
321
+ dlldata.c
322
+
323
+ # Benchmark Results
324
+ BenchmarkDotNet.Artifacts/
325
+
326
+ # .NET Core
327
+ project.lock.json
328
+ project.fragment.lock.json
329
+ artifacts/
330
+
331
+ # ASP.NET Scaffolding
332
+ ScaffoldingReadMe.txt
333
+
334
+ # StyleCop
335
+ StyleCopReport.xml
336
+
337
+ # Files built by Visual Studio
338
+ *_i.c
339
+ *_p.c
340
+ *_h.h
341
+ *.ilk
342
+ *.meta
343
+ *.obj
344
+ *.iobj
345
+ *.pch
346
+ *.pdb
347
+ *.ipdb
348
+ *.pgc
349
+ *.pgd
350
+ *.rsp
351
+ *.sbr
352
+ *.tlb
353
+ *.tli
354
+ *.tlh
355
+ *.tmp
356
+ *.tmp_proj
357
+ *_wpftmp.csproj
358
+ *.log
359
+ *.vspscc
360
+ *.vssscc
361
+ .builds
362
+ *.pidb
363
+ *.svclog
364
+ *.scc
365
+
366
+ # Chutzpah Test files
367
+ _Chutzpah*
368
+
369
+ # Visual C++ cache files
370
+ ipch/
371
+ *.aps
372
+ *.ncb
373
+ *.opendb
374
+ *.opensdf
375
+ *.sdf
376
+ *.cachefile
377
+ *.VC.db
378
+ *.VC.VC.opendb
379
+
380
+ # Visual Studio profiler
381
+ *.psess
382
+ *.vsp
383
+ *.vspx
384
+ *.sap
385
+
386
+ # Visual Studio Trace Files
387
+ *.e2e
388
+
389
+ # TFS 2012 Local Workspace
390
+ $tf/
391
+
392
+ # Guidance Automation Toolkit
393
+ *.gpState
394
+
395
+ # ReSharper is a .NET coding add-in
396
+ _ReSharper*/
397
+ *.[Rr]e[Ss]harper
398
+ *.DotSettings.user
399
+
400
+ # TeamCity is a build add-in
401
+ _TeamCity*
402
+
403
+ # DotCover is a Code Coverage Tool
404
+ *.dotCover
405
+
406
+ # AxoCover is a Code Coverage Tool
407
+ .axoCover/*
408
+ !.axoCover/settings.json
409
+
410
+ # Coverlet is a free, cross platform Code Coverage Tool
411
+ coverage*.json
412
+ coverage*.xml
413
+ coverage*.info
414
+
415
+ # Visual Studio code coverage results
416
+ *.coverage
417
+ *.coveragexml
418
+
419
+ # NCrunch
420
+ _NCrunch_*
421
+ .*crunch*.local.xml
422
+ nCrunchTemp_*
423
+
424
+ # MightyMoose
425
+ *.mm.*
426
+ AutoTest.Net/
427
+
428
+ # Web workbench (sass)
429
+ .sass-cache/
430
+
431
+ # Installshield output folder
432
+ [Ee]xpress/
433
+
434
+ # DocProject is a documentation generator add-in
435
+ DocProject/buildhelp/
436
+ DocProject/Help/*.HxT
437
+ DocProject/Help/*.HxC
438
+ DocProject/Help/*.hhc
439
+ DocProject/Help/*.hhk
440
+ DocProject/Help/*.hhp
441
+ DocProject/Help/Html2
442
+ DocProject/Help/html
443
+
444
+ # Click-Once directory
445
+ publish/
446
+
447
+ # Publish Web Output
448
+ *.[Pp]ublish.xml
449
+ *.azurePubxml
450
+ # Note: Comment the next line if you want to checkin your web deploy settings,
451
+ # but database connection strings (with potential passwords) will be unencrypted
452
+ *.pubxml
453
+ *.publishproj
454
+
455
+ # Microsoft Azure Web App publish settings. Comment the next line if you want to
456
+ # checkin your Azure Web App publish settings, but sensitive information contained
457
+ # in these scripts will be unencrypted
458
+ PublishScripts/
459
+
460
+ # NuGet Packages
461
+ *.nupkg
462
+ # NuGet Symbol Packages
463
+ *.snupkg
464
+ # The packages folder can be ignored because of Package Restore
465
+ **/[Pp]ackages/*
466
+ # except build/, which is used as an MSBuild target.
467
+ !**/[Pp]ackages/build/
468
+ # Uncomment if necessary however generally it will be regenerated when needed
469
+ #!**/[Pp]ackages/repositories.config
470
+ # NuGet v3's project.json files produces more ignorable files
471
+ *.nuget.props
472
+ *.nuget.targets
473
+
474
+ # Microsoft Azure Build Output
475
+ csx/
476
+ *.build.csdef
477
+
478
+ # Microsoft Azure Emulator
479
+ ecf/
480
+ rcf/
481
+
482
+ # Windows Store app package directories and files
483
+ AppPackages/
484
+ BundleArtifacts/
485
+ Package.StoreAssociation.xml
486
+ _pkginfo.txt
487
+ *.appx
488
+ *.appxbundle
489
+ *.appxupload
490
+
491
+ # Visual Studio cache files
492
+ # files ending in .cache can be ignored
493
+ *.[Cc]ache
494
+ # but keep track of directories ending in .cache
495
+ !?*.[Cc]ache/
496
+
497
+ # Others
498
+ ClientBin/
499
+ ~$*
500
+ *~
501
+ *.dbmdl
502
+ *.dbproj.schemaview
503
+ *.jfm
504
+ *.pfx
505
+ *.publishsettings
506
+ orleans.codegen.cs
507
+
508
+ # Including strong name files can present a security risk
509
+ # (https://github.com/github/gitignore/pull/2483#issue-259490424)
510
+ #*.snk
511
+
512
+ # Since there are multiple workflows, uncomment next line to ignore bower_components
513
+ # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
514
+ #bower_components/
515
+
516
+ # RIA/Silverlight projects
517
+ Generated_Code/
518
+
519
+ # Backup & report files from converting an old project file
520
+ # to a newer Visual Studio version. Backup files are not needed,
521
+ # because we have git ;-)
522
+ _UpgradeReport_Files/
523
+ Backup*/
524
+ UpgradeLog*.XML
525
+ UpgradeLog*.htm
526
+ ServiceFabricBackup/
527
+ *.rptproj.bak
528
+
529
+ # SQL Server files
530
+ *.mdf
531
+ *.ldf
532
+ *.ndf
533
+
534
+ # Business Intelligence projects
535
+ *.rdl.data
536
+ *.bim.layout
537
+ *.bim_*.settings
538
+ *.rptproj.rsuser
539
+ *- [Bb]ackup.rdl
540
+ *- [Bb]ackup ([0-9]).rdl
541
+ *- [Bb]ackup ([0-9][0-9]).rdl
542
+
543
+ # Microsoft Fakes
544
+ FakesAssemblies/
545
+
546
+ # GhostDoc plugin setting file
547
+ *.GhostDoc.xml
548
+
549
+ # Node.js Tools for Visual Studio
550
+ .ntvs_analysis.dat
551
+ node_modules/
552
+
553
+ # Visual Studio 6 build log
554
+ *.plg
555
+
556
+ # Visual Studio 6 workspace options file
557
+ *.opt
558
+
559
+ # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
560
+ *.vbw
561
+
562
+ # Visual Studio LightSwitch build output
563
+ **/*.HTMLClient/GeneratedArtifacts
564
+ **/*.DesktopClient/GeneratedArtifacts
565
+ **/*.DesktopClient/ModelManifest.xml
566
+ **/*.Server/GeneratedArtifacts
567
+ **/*.Server/ModelManifest.xml
568
+ _Pvt_Extensions
569
+
570
+ # Paket dependency manager
571
+ .paket/paket.exe
572
+ paket-files/
573
+
574
+ # FAKE - F# Make
575
+ .fake/
576
+
577
+ # CodeRush personal settings
578
+ .cr/personal
579
+
580
+ # Python Tools for Visual Studio (PTVS)
581
+ __pycache__/
582
+ *.pyc
583
+
584
+ # Cake - Uncomment if you are using it
585
+ # tools/**
586
+ # !tools/packages.config
587
+
588
+ # Tabs Studio
589
+ *.tss
590
+
591
+ # Telerik's JustMock configuration file
592
+ *.jmconfig
593
+
594
+ # BizTalk build output
595
+ *.btp.cs
596
+ *.btm.cs
597
+ *.odx.cs
598
+ *.xsd.cs
599
+
600
+ # OpenCover UI analysis results
601
+ OpenCover/
602
+
603
+ # Azure Stream Analytics local run output
604
+ ASALocalRun/
605
+
606
+ # MSBuild Binary and Structured Log
607
+ *.binlog
608
+
609
+ # NVidia Nsight GPU debugger configuration file
610
+ *.nvuser
611
+
612
+ # MFractors (Xamarin productivity tool) working folder
613
+ .mfractor/
614
+
615
+ # Local History for Visual Studio
616
+ .localhistory/
617
+
618
+ # BeatPulse healthcheck temp database
619
+ healthchecksdb
620
+
621
+ # Backup folder for Package Reference Convert tool in Visual Studio 2017
622
+ MigrationBackup/
623
+
624
+ # Ionide (cross platform F# VS Code tools) working folder
625
+ .ionide/
626
+
627
+ # Fody - auto-generated XML schema
628
+ FodyWeavers.xsd
629
+
630
+ ### Vim template
631
+ # Swap
632
+ [._]*.s[a-v][a-z]
633
+ !*.svg # comment out if you don't need vector files
634
+ [._]*.sw[a-p]
635
+ [._]s[a-rt-v][a-z]
636
+ [._]ss[a-gi-z]
637
+ [._]sw[a-p]
638
+
639
+ # Session
640
+ Session.vim
641
+ Sessionx.vim
642
+
643
+ # Temporary
644
+ .netrwhist
645
+ *~
646
+ # Auto-generated tag files
647
+ tags
648
+ # Persistent undo
649
+ [._]*.un~
650
+
651
+ ### Backup template
652
+ *.bak
653
+ *.gho
654
+ *.ori
655
+ *.orig
656
+ *.tmp
657
+
658
+ ### SublimeText template
659
+ # Cache files for Sublime Text
660
+ *.tmlanguage.cache
661
+ *.tmPreferences.cache
662
+ *.stTheme.cache
663
+
664
+ # Workspace files are user-specific
665
+ *.sublime-workspace
666
+
667
+ # Project files should be checked into the repository, unless a significant
668
+ # proportion of contributors will probably not be using Sublime Text
669
+ # *.sublime-project
670
+
671
+ # SFTP configuration file
672
+ sftp-config.json
673
+ sftp-config-alt*.json
674
+
675
+ # Package control specific files
676
+ Package Control.last-run
677
+ Package Control.ca-list
678
+ Package Control.ca-bundle
679
+ Package Control.system-ca-bundle
680
+ Package Control.cache/
681
+ Package Control.ca-certs/
682
+ Package Control.merged-ca-bundle
683
+ Package Control.user-ca-bundle
684
+ oscrypto-ca-bundle.crt
685
+ bh_unicode_properties.cache
686
+
687
+ # Sublime-github package stores a github token in this file
688
+ # https://packagecontrol.io/packages/sublime-github
689
+ GitHub.sublime-settings
690
+
691
+ ### C template
692
+ # Prerequisites
693
+ *.d
694
+
695
+ # Object files
696
+ *.o
697
+ *.ko
698
+ *.obj
699
+ *.elf
700
+
701
+ # Linker output
702
+ *.ilk
703
+ *.map
704
+ *.exp
705
+
706
+ # Precompiled Headers
707
+ *.gch
708
+ *.pch
709
+
710
+ # Libraries
711
+ *.lib
712
+ *.a
713
+ *.la
714
+ *.lo
715
+
716
+ # Shared objects (inc. Windows DLLs)
717
+ *.dll
718
+ *.so
719
+ *.so.*
720
+ *.dylib
721
+
722
+ # Executables
723
+ *.exe
724
+ *.out
725
+ *.app
726
+ *.i*86
727
+ *.x86_64
728
+ *.hex
729
+
730
+ # Debug files
731
+ *.dSYM/
732
+ *.su
733
+ *.idb
734
+ *.pdb
735
+
736
+ # Kernel Module Compile Results
737
+ *.mod*
738
+ *.cmd
739
+ .tmp_versions/
740
+ modules.order
741
+ Module.symvers
742
+ Mkfile.old
743
+ dkms.conf
744
+
745
+ ### VirtualEnv template
746
+ # Virtualenv
747
+ # http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
748
+ .Python
749
+ [Bb]in
750
+ [Ii]nclude
751
+ [Ll]ib
752
+ [Ll]ib64
753
+ [Ll]ocal
754
+ [Ss]cripts
755
+ pyvenv.cfg
756
+ .venv
757
+ pip-selfcheck.json
758
+
759
+ ### LibreOffice template
760
+ # LibreOffice locks
761
+ .~lock.*#
762
+
763
+ ### Xilinx template
764
+ # gitignore template for Xilinx Vivado Design Suite
765
+ # website: https://www.xilinx.com/support/download.html
766
+
767
+ # [home]
768
+ *.jou
769
+ *.log
770
+ *.debug
771
+ *.str
772
+ *.tmp
773
+ *.os
774
+ *.js
775
+ *.pb
776
+ *.dcp
777
+ *.hwdef
778
+ *.vds
779
+ *.veo
780
+ *.wdf
781
+ *.vdi
782
+ *.dmp
783
+ *.rpx
784
+ *.rpt
785
+ *_stub.v
786
+ *_stub.vhdl
787
+ *_funcsim.v
788
+ *_funcsim.vhdl
789
+ .project
790
+
791
+ # [dir]
792
+ *.cache
793
+ .metadata
794
+ *.data
795
+ *.ipdefs
796
+ .Xil
797
+ *.sdk
798
+ *.hw
799
+ *.ip_user_files
800
+
801
+ ### IP synth
802
+ *_synth_*
803
+
804
+ .jobs
805
+
806
+ ### project synth
807
+ */*.runs/synth*/*.xml
808
+ */*.runs/synth*/*.txt
809
+ */*.runs/synth*/*.sh
810
+ */*.runs/synth*/*.tcl
811
+ */*.runs/synth*/*.bat
812
+ */*.runs/synth*/*.xdc
813
+ !*/*.runs/synth*/*utilization*.rpt
814
+
815
+ *.runs/synth*/*.xml
816
+ *.runs/synth*/*.txt
817
+ *.runs/synth*/*.sh
818
+ *.runs/synth*/*.tcl
819
+ *.runs/synth*/*.bat
820
+ *.runs/synth*/*.xdc
821
+ !*.runs/synth*/*utilization*.rpt
822
+
823
+ ### project impl
824
+ */*.runs/impl*/*.xml
825
+ */*.runs/impl*/*.html
826
+ */*.runs/impl*/*.txt
827
+ */*.runs/impl*/*.sh
828
+ */*.runs/impl*/*.tcl
829
+ */*.runs/impl*/*.bat
830
+ !*/*.runs/impl*/*utilization*.rpt
831
+
832
+ *.runs/impl*/*.xml
833
+ *.runs/impl*/*.html
834
+ *.runs/impl*/*.txt
835
+ *.runs/impl*/*.sh
836
+ *.runs/impl*/*.tcl
837
+ *.runs/impl*/*.bat
838
+ !*.runs/impl*/*utilization*.rpt
839
+
840
+ ### block design
841
+ */*/bd/*/hdl
842
+ */*/*/bd/*/hdl
843
+
844
+ */*/bd/*/*.xdc
845
+ */*/*/bd/*/*.xdc
846
+
847
+ */*/bd/*/ip/*/*.xdc
848
+ */*/*/bd/*/ip/*/*.xdc
849
+
850
+ */*/bd/*/ip/*/*/
851
+ */*/*/bd/*/ip/*/*/
852
+
853
+ */*/bd/*/ip/*/*.vhd
854
+ */*/*/bd/*/ip/*/*.vhd
855
+
856
+ */*/bd/*/ip/*/*.xml
857
+ */*/*/bd/*/ip/*/*.xml
858
+
859
+ *.c
860
+ *.cpp
861
+ *.h
862
+ *.vho
863
+ */*/bd/*/ip/*/*.tcl
864
+ */*/*/bd/*/ip/*/*.tcl
865
+ hw_handoff
866
+ ipshared
867
+
868
+ ### Lua template
869
+ # Compiled Lua sources
870
+ luac.out
871
+
872
+ # luarocks build files
873
+ *.src.rock
874
+ *.zip
875
+
876
+ # Object files
877
+ *.o
878
+ *.os
879
+ *.ko
880
+ *.obj
881
+ *.elf
882
+
883
+ # Precompiled Headers
884
+ *.gch
885
+ *.pch
886
+
887
+ # Libraries
888
+ *.lib
889
+ *.a
890
+ *.la
891
+ *.lo
892
+ *.def
893
+ *.exp
894
+
895
+ # Shared objects (inc. Windows DLLs)
896
+ *.dll
897
+ *.so
898
+ *.so.*
899
+ *.dylib
900
+
901
+ # Executables
902
+ *.exe
903
+ *.out
904
+ *.app
905
+ *.i*86
906
+ *.x86_64
907
+ *.hex
908
+
909
+
910
+ ### Vagrant template
911
+ # General
912
+ .vagrant/
913
+
914
+ # Log files (if you are creating logs in debug mode, uncomment this)
915
+ # *.log
916
+
917
+ ### PuTTY template
918
+ # Private key
919
+ *.ppk
920
+
921
+ ### Patch template
922
+ *.orig
923
+ *.rej
924
+
925
+ ### Python template
926
+ # Byte-compiled / optimized / DLL files
927
+ __pycache__/
928
+ *.py[cod]
929
+ *$py.class
930
+
931
+ # C extensions
932
+ *.so
933
+
934
+ # Distribution / packaging
935
+ .Python
936
+ build/
937
+ develop-eggs/
938
+ /dist
939
+ wheelhouse/
940
+ downloads/
941
+ eggs/
942
+ .eggs/
943
+ lib/
944
+ lib64/
945
+ parts/
946
+ sdist/
947
+ var/
948
+ wheels/
949
+ share/python-wheels/
950
+ *.egg-info/
951
+ .installed.cfg
952
+ *.egg
953
+ MANIFEST
954
+
955
+ # PyInstaller
956
+ # Usually these files are written by a python script from a template
957
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
958
+ *.manifest
959
+ *.spec
960
+
961
+ # Installer logs
962
+ pip-log.txt
963
+ pip-delete-this-directory.txt
964
+
965
+ # Unit test / coverage reports
966
+ htmlcov/
967
+ .tox/
968
+ .nox/
969
+ .coverage
970
+ .coverage.*
971
+ .cache
972
+ nosetests.xml
973
+ coverage.xml
974
+ *.cover
975
+ *.py,cover
976
+ .hypothesis/
977
+ .pytest_cache/
978
+ cover/
979
+
980
+ # Translations
981
+ *.mo
982
+ *.pot
983
+
984
+ # Django stuff:
985
+ *.log
986
+ local_settings.py
987
+ db.sqlite3
988
+ db.sqlite3-journal
989
+
990
+ # Flask stuff:
991
+ instance/
992
+ .webassets-cache
993
+
994
+ # Scrapy stuff:
995
+ .scrapy
996
+
997
+ # Sphinx documentation
998
+ docs/_build/
999
+
1000
+ # PyBuilder
1001
+ .pybuilder/
1002
+ target/
1003
+
1004
+ # Jupyter Notebook
1005
+ .ipynb_checkpoints
1006
+
1007
+ # IPython
1008
+ profile_default/
1009
+ ipython_config.py
1010
+
1011
+ # pyenv
1012
+ # For a library or package, you might want to ignore these files since the code is
1013
+ # intended to run in multiple environments; otherwise, check them in:
1014
+ # .python-version
1015
+
1016
+ # pipenv
1017
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
1018
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
1019
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
1020
+ # install all needed dependencies.
1021
+ #Pipfile.lock
1022
+
1023
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
1024
+ __pypackages__/
1025
+
1026
+ # Celery stuff
1027
+ celerybeat-schedule
1028
+ celerybeat.pid
1029
+
1030
+ # SageMath parsed files
1031
+ *.sage.py
1032
+
1033
+ # Environments
1034
+ .env
1035
+ .venv
1036
+ /env/
1037
+ venv/
1038
+ ENV/
1039
+ env.bak/
1040
+ venv.bak/
1041
+
1042
+ # Spyder project settings
1043
+ .spyderproject
1044
+ .spyproject
1045
+
1046
+ # Rope project settings
1047
+ .ropeproject
1048
+
1049
+ # mkdocs documentation
1050
+ /site
1051
+
1052
+ # mypy
1053
+ .mypy_cache/
1054
+ .dmypy.json
1055
+ dmypy.json
1056
+
1057
+ # Pyre type checker
1058
+ .pyre/
1059
+
1060
+ # pytype static type analyzer
1061
+ .pytype/
1062
+
1063
+ # Cython debug symbols
1064
+ cython_debug/
1065
+
1066
+ ### Windows template
1067
+ # Windows thumbnail cache files
1068
+ Thumbs.db
1069
+ Thumbs.db:encryptable
1070
+ ehthumbs.db
1071
+ ehthumbs_vista.db
1072
+
1073
+ # Dump file
1074
+ *.stackdump
1075
+
1076
+ # Folder config file
1077
+ [Dd]esktop.ini
1078
+
1079
+ # Recycle Bin used on file shares
1080
+ $RECYCLE.BIN/
1081
+
1082
+ # Windows Installer files
1083
+ *.cab
1084
+ *.msi
1085
+ *.msix
1086
+ *.msm
1087
+ *.msp
1088
+
1089
+ # Windows shortcuts
1090
+ *.lnk
1091
+
1092
+ ### Xcode template
1093
+ # Xcode
1094
+ #
1095
+ # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
1096
+
1097
+ ## User settings
1098
+ xcuserdata/
1099
+
1100
+ ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
1101
+ *.xcscmblueprint
1102
+ *.xccheckout
1103
+
1104
+ ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
1105
+ build/
1106
+ DerivedData/
1107
+ *.moved-aside
1108
+ *.pbxuser
1109
+ !default.pbxuser
1110
+ *.mode1v3
1111
+ !default.mode1v3
1112
+ *.mode2v3
1113
+ !default.mode2v3
1114
+ *.perspectivev3
1115
+ !default.perspectivev3
1116
+
1117
+ ## Gcc Patch
1118
+ /*.gcno
1119
+
1120
+ ### JetBrains template
1121
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
1122
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
1123
+
1124
+ # User-specific stuff
1125
+ .idea/**/workspace.xml
1126
+ .idea/**/tasks.xml
1127
+ .idea/**/usage.statistics.xml
1128
+ .idea/**/dictionaries
1129
+ .idea/**/shelf
1130
+
1131
+ # Generated files
1132
+ .idea/**/contentModel.xml
1133
+
1134
+ # Sensitive or high-churn files
1135
+ .idea/**/dataSources/
1136
+ .idea/**/dataSources.ids
1137
+ .idea/**/dataSources.local.xml
1138
+ .idea/**/sqlDataSources.xml
1139
+ .idea/**/dynamic.xml
1140
+ .idea/**/uiDesigner.xml
1141
+ .idea/**/dbnavigator.xml
1142
+
1143
+ # Gradle
1144
+ .idea/**/gradle.xml
1145
+ .idea/**/libraries
1146
+
1147
+ # Gradle and Maven with auto-import
1148
+ # When using Gradle or Maven with auto-import, you should exclude module files,
1149
+ # since they will be recreated, and may cause churn. Uncomment if using
1150
+ # auto-import.
1151
+ # .idea/artifacts
1152
+ # .idea/compiler.xml
1153
+ # .idea/jarRepositories.xml
1154
+ # .idea/modules.xml
1155
+ # .idea/*.iml
1156
+ # .idea/modules
1157
+ # *.iml
1158
+ # *.ipr
1159
+
1160
+ # CMake
1161
+ cmake-build-*/
1162
+
1163
+ # Mongo Explorer plugin
1164
+ .idea/**/mongoSettings.xml
1165
+
1166
+ # File-based project format
1167
+ *.iws
1168
+
1169
+ # IntelliJ
1170
+ out/
1171
+
1172
+ # mpeltonen/sbt-idea plugin
1173
+ .idea_modules/
1174
+
1175
+ # JIRA plugin
1176
+ atlassian-ide-plugin.xml
1177
+
1178
+ # Cursive Clojure plugin
1179
+ .idea/replstate.xml
1180
+
1181
+ # Crashlytics plugin (for Android Studio and IntelliJ)
1182
+ com_crashlytics_export_strings.xml
1183
+ crashlytics.properties
1184
+ crashlytics-build.properties
1185
+ fabric.properties
1186
+
1187
+ # Editor-based Rest Client
1188
+ .idea/httpRequests
1189
+
1190
+ # Android studio 3.1+ serialized cache file
1191
+ .idea/caches/build_file_checksums.ser
1192
+
1193
+ /test_*
1194
+ .python-version
1195
+ /docs/build
1196
+ /public
1197
+ /docs/source/**/*.puml.svg
1198
+ /docs/source/**/*.puml.png
1199
+ /docs/source/**/*.gv.svg
1200
+ /docs/source/**/*.gv.png
1201
+ /docs/source/**/*.py.txt
1202
+ /docs/source/**/*.py.err
1203
+ /docs/source/**/*.py.exitcode
1204
+ /docs/source/**/*.sh.txt
1205
+ /docs/source/**/*.sh.err
1206
+ /docs/source/**/*.sh.exitcode
1207
+ /docs/source/**/*.dat.*
1208
+ !/docs/source/**/*.plot.py.svg
1209
+ !/docs/source/_static/**/*
1210
+ /docs/source/**/*.result.ipynb
1211
+ /cartpole_dqn_*
1212
+ /llmriddles/**/*.json
1213
+ /llmriddles/**/*.yaml
1214
+ /llmriddles/**/*.yml
1215
+ /extra
1216
+ /resource/yolort/*
1217
+ !/resource/yolort/Makefile
1218
+ !/test/testfile/**/*
1219
+ !/zoo/testfile/**/*
1220
+ /test/testfile/dataset
1221
+ /zoo/testfile/dataset
1222
+ /.train
1223
+ *.pt
1224
+ /runs
1225
+ /YOLOv8
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
README.md CHANGED
@@ -1,13 +1,108 @@
1
  ---
2
- title: LLMRiddlesChatGLMCN
3
- emoji: 🐠
4
- colorFrom: gray
5
- colorTo: blue
6
  sdk: gradio
7
- sdk_version: 4.1.2
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
 
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: LLMRiddles-ChatGLM-CN
3
+ emoji: 🚀
4
+ colorFrom: indigo
5
+ colorTo: green
6
  sdk: gradio
7
+ sdk_version: 4.1.1
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
11
+ python_version: 3.8
12
  ---
13
 
14
+ # LLMRiddles
15
+
16
+ <div align="center">
17
+ <br>
18
+ <a href="https://github.com/opendilab/LLMRiddles/blob/main/llmriddles/assets/banner.svg">
19
+ <img src="https://github.com/opendilab/LLMRiddles/blob/main/llmriddles/assets/banner.svg" width="1000" height="200" alt="Click to see the source">
20
+ </a>
21
+ <br>
22
+ </div>
23
+
24
+ English | [简体中文](https://github.com/opendilab/LLMRiddles/blob/main/README_zh.md)
25
+
26
+ ## :thinking: What's This
27
+ Welcome to LLM Riddles! This is a game of wits and courage with language models. In the game, you need to construct questions that interact with the language model to get answers that meet the requirements. In this process, you can use your brain and use all the methods you can think of to get the model to output the results required by the answer.
28
+
29
+ ## :space_invader: How to Play
30
+ We provide an online version for players to directly access and try out.
31
+ - [ChatGPT + English(w/o key)](https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGPTEN)
32
+ - [ChatGPT + Chinese(w/o key)](https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGPTCN)
33
+ - [Mistral + English(w/ key)](https://d9b451a97791dd8ef3.gradio.live)
34
+ - [ChatGPT + Chinese(w/ key)](http://llmriddles.opendilab.net/)
35
+
36
+ Local deployment can be done in the following ways:
37
+ ## Installation
38
+ ### Use ChatGPT / ChatGLM API
39
+ ```shell
40
+ pip3 install -r requirements.txt
41
+ ```
42
+ ### Deploy Mistral-7B-Instruct-v0.1 for local inference
43
+ ```shell
44
+ pip3 install -r requirements-dev.txt
45
+ ```
46
+ ## Launch
47
+ ### ChatGPT + Chinese
48
+ ```shell
49
+ QUESTION_LANG=cn QUESTION_LLM='chatgpt' QUESTION_LLM_KEY=<your API key> python3 -u app.py
50
+ ```
51
+ ### ChatGPT + English
52
+ ```shell
53
+ QUESTION_LANG=en QUESTION_LLM='chatgpt' QUESTION_LLM_KEY=<your API key> python3 -u app.py
54
+ ```
55
+ ### ChatGLM + Chinese
56
+ ```shell
57
+ QUESTION_LANG=cn QUESTION_LLM='chatglm' QUESTION_LLM_KEY=<your API key> python3 -u app.py
58
+ ```
59
+ ### ChatGLM + English
60
+ ```shell
61
+ QUESTION_LANG=en QUESTION_LLM='chatglm' QUESTION_LLM_KEY=<your API key> python3 -u app.py
62
+ ```
63
+ ### Mistral-7B-Instruct-v0.1 + English
64
+ ```shell
65
+ QUESTION_LANG=en QUESTION_LLM='mistral-7b' python3 -u app.py
66
+ ```
67
+ ## :technologist: Why Doing This
68
+
69
+ Our goal is to use this game to give participants a deeper understanding of the fascinating aspects of prompt engineering and natural language processing. This process will show players how to cleverly construct prompts and how to use them to trigger surprising responses from artificial intelligence systems, while also helping them better understand the incredible power of deep learning and natural language processing technologies. .
70
+
71
+ ## :raising_hand: How to Submit a Custom Level
72
+ If you have interesting questions or ideas, players are welcome to submit their own ideas. You can [Initiate a Pull Request](https://github.com/opendilab/LLMRiddles/compare) and submit it to us. We will include it in the level after approval.
73
+ The question format should include the following points:
74
+ - Pull Request title, example: feature(username): Chapter X-Level Design
75
+ - The ID you want to be mentioned
76
+ - Modify the corresponding chapter question files
77
+ - Modification of \__init__.py
78
+
79
+ For a complete example, please refer to: [Submit your own level design](https://github.com/opendilab/LLMRiddles/pull/6)
80
+
81
+ ## :writing_hand: Roadmap
82
+
83
+ - [x] Support custom levels
84
+ - [x] Online trial link
85
+ - [x] Hugging Face Space link
86
+ - [x] Support Mistral-7B(English version)
87
+ - [x] Support ChatGLM(Chinese and English version)
88
+ - [ ] Support Baichuan2-7B(Chinese version)
89
+ - [ ] Support LLaMA2-7B(English version)
90
+ - [ ] LLM inference speed optimization
91
+ - [ ] More question levels and solution blogs
92
+
93
+ ## :speech_balloon: Feedback and Contribution
94
+ - [Start an Issue](https://github.com/opendilab/CodeMorpheus/issues/new/choose) on GitHub
95
+ - Contact us by email (opendilab@pjlab.org.cn)
96
+ - Discuss on OpenDILab's WeChat group (i.e. add us on WeChat: ding314assist)
97
+ <img src=https://github.com/opendilab/LLMRiddles/blob/main/llmriddles/assets/wechat.jpeg width=35% />
98
+
99
+ ## :star2: Special Thanks
100
+ - Thanks to [Haoqiang Fan](https://www.zhihu.com/people/haoqiang-fan) for his original idea and title, which provided inspiration and motivation for the development and expansion of this project.
101
+ - Thanks to [HuggingFace](https://huggingface.co) for supporting and assisting the game.
102
+ - Thanks to [ChatGLM](https://chatglm.cn) for supporting and assisting the game, especially sufficient inference token support.
103
+ - Thanks to [LLM Riddles contributors](https://github.com/opendilab/LLMRiddles/graphs/contributors) for their implementation and support.
104
+
105
+ ## :label: License
106
+ All code within this repository is under [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).
107
+
108
+ <p align="right">(<a href="#top">back to top</a>)</p>
README_zh.md ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LLM Riddles
2
+
3
+ <div align="center">
4
+ <br>
5
+ <a href="https://github.com/opendilab/LLMRiddles/blob/main/llmriddles/assets/banner.svg">
6
+ <img src="https://github.com/opendilab/LLMRiddles/blob/main/llmriddles/assets/banner.svg" width="1000" height="200" alt="Click to see the source">
7
+ </a>
8
+ <br>
9
+ </div>
10
+
11
+ [English](https://github.com/opendilab/LLMRiddles/blob/main/README.md) | 简体中文
12
+
13
+ ## :thinking: 什么是LLM Riddles
14
+ 欢迎来到 LLM Riddles!这是一个与语言模型斗智斗勇的游戏。在游戏中,你需要构造与语言模型交互的问题,来得到符合要求的答案。在这个过程中,你可以开动脑筋,用你想到的所有方式,让模型输出答案要求的结果。
15
+
16
+ ## :space_invader: 如何试玩
17
+ 我们提供了在线版本以供玩家直接访问试玩:
18
+ - [ChatGPT + 英文(需配置api key)](https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGPTEN)
19
+ - [ChatGPT + 中文(需配置api key)](https://huggingface.co/spaces/OpenDILabCommunity/LLMRiddlesChatGPTCN)
20
+ - [Mistral + 英文(已预设api key)](https://d9b451a97791dd8ef3.gradio.live)
21
+ - [ChatGPT + 中文(已预设api key)](http://llmriddles.opendilab.net/)
22
+
23
+ 本地部署可以通过以下方式:
24
+ ## 安装
25
+ ### ChatGPT 或 ChatGLM API
26
+ ```shell
27
+ pip3 install -r requirements.txt
28
+ ```
29
+ ### Mistral-7B-Instruct-v0.1 本地推理
30
+ ```shell
31
+ pip3 install -r requirements-dev.txt
32
+ ```
33
+ ## 启动
34
+ ### ChatGPT + 中文
35
+ ```shell
36
+ QUESTION_LANG=cn QUESTION_LLM='chatgpt' QUESTION_LLM_KEY=<your API key> python3 -u app.py
37
+ ```
38
+ ### ChatGPT + 英文
39
+ ```shell
40
+ QUESTION_LANG=en QUESTION_LLM='chatgpt' QUESTION_LLM_KEY=<your API key> python3 -u app.py
41
+ ```
42
+ ### ChatGLM + 中文
43
+ ```shell
44
+ QUESTION_LANG=cn QUESTION_LLM='chatglm' QUESTION_LLM_KEY=<your API key> python3 -u app.py
45
+ ```
46
+ ### ChatGLM + 英文
47
+ ```shell
48
+ QUESTION_LANG=en QUESTION_LLM='chatglm' QUESTION_LLM_KEY=<your API key> python3 -u app.py
49
+ ```
50
+ ### Mistral-7B-Instruct-v0.1 + 英文
51
+ ```shell
52
+ QUESTION_LANG=en QUESTION_LLM='mistral-7b' python3 -u app.py
53
+ ```
54
+ ## :technologist: 为什么制作这个游戏
55
+
56
+ 我们的目标是通过这一游戏,让参与者深入领略到提示工程(prompt engineering)和自然语言处理的令人着迷之处。这个过程将向玩家们展示,如何巧妙地构建提示词(prompts),以及如何运用它们来引发人工智能系统的惊人反应,同时也帮助他们更好地理解深度学习和自然语言处理技术的不可思议之处。
57
+
58
+ ## :raising_hand: 如何提交设计好的关卡
59
+ 如果有好玩的问题或想法,欢迎玩家提交自己的创意,可以
60
+ [发起 Pull Request](https://github.com/opendilab/LLMRiddles/compare) 向我们提交, 我们会在审核通过后收录至关卡中。
61
+ 问题的设计格式应包含以下几点:
62
+ - Pull Request标题,示例:feature(username): 章节X-关卡设计
63
+ - 希望被提及的ID
64
+ - 对应章节问题文件的修改
65
+ - \__init__.py的修改
66
+
67
+ 完整示例请参考:[提交属于自己的关卡设计](https://github.com/opendilab/LLMRiddles/pull/6)
68
+
69
+ ## :writing_hand: 未来计划
70
+
71
+ - [x] 支持自定义关卡
72
+ - [x] 在线试玩链接
73
+ - [x] Hugging Face Space 链接
74
+ - [x] 支持Mistral-7B(英文)
75
+ - [x] 支持ChatGLM(中文和英文)
76
+ - [ ] 支持Baichuan2-7B(中文)
77
+ - [ ] 支持LLaMA2-7B(英文)
78
+ - [ ] LLM 推理速度优化
79
+
80
+ ## :speech_balloon: 反馈问题 & 提出建议
81
+ - 在 GitHub 上[发起 Issue](https://github.com/opendilab/CodeMorpheus/issues/new/choose)
82
+ - 通过邮件与我们联系 (opendilab@pjlab.org.cn)
83
+ - 在OpenDILab的群组中加入讨论(通过 WeChat: ding314assist 添加小助手微信)
84
+ <img src=https://github.com/opendilab/LLMRiddles/blob/main/llmriddles/assets/wechat.jpeg width=35% />
85
+
86
+ ## :star2: Special Thanks
87
+ - 感谢 [Haoqiang Fan](https://www.zhihu.com/people/haoqiang-fan) 的原始创意和题目,为本项目的开发和扩展提供了灵感与动力。
88
+ - 感谢 [HuggingFace](https://huggingface.co) 对游戏的支持与协助。
89
+ - 感谢 [ChatGLM](https://chatglm.cn/) 对游戏的支持与协助,特别是供在线预览版使用的足量 tokens。
90
+ - 感谢 [LLM Riddles contributors](https://github.com/opendilab/LLMRiddles/graphs/contributors) 的实现与支持。
91
+
92
+ ## :label: License
93
+ All code within this repository is under [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).
94
+
95
+ <p align="right">(<a href="#top">back to top</a>)</p>
app.py ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ import os
3
+ import uuid
4
+
5
+ import gradio as gr
6
+
7
+ from llmriddles.questions import QuestionExecutor
8
+ from llmriddles.questions import list_ordered_questions
9
+
10
+ _QUESTION_SESSIONS = {}
11
+ count = 0
12
+ _QUESTIONS = list_ordered_questions()
13
+ _LANG = os.environ.get('QUESTION_LANG', 'cn')
14
+ assert _LANG in ['cn', 'en'], _LANG
15
+ _LLM = os.environ.get('QUESTION_LLM', 'chatgpt')
16
+ assert _LLM in ['chatgpt', 'chatglm', 'mistral-7b'], _LLM
17
+ _LLM_KEY = os.environ.get('QUESTION_LLM_KEY', None)
18
+ _DEBUG = os.environ.get('DEBUG', 'false').lower() == 'true'
19
+
20
+ if _DEBUG:
21
+ logging.getLogger().setLevel(logging.INFO)
22
+ else:
23
+ logging.getLogger().setLevel(logging.WARNING)
24
+ if _LANG == "cn":
25
+ title = "完蛋!我被 LLM 拿捏了"
26
+ requirement_ph = """
27
+ <h2 style="color: #6d28d9;"> 欢迎来到 LLM Riddles! </h2>
28
+ <h4> 你将通过本游戏对大语言模型产生更深刻的理解。在本游戏中,你需要构造一个提给语言大模型的问题,使得它回复的答案符合题目要求。点击<i>\"下一题\"</i> 即可开始游戏。</h4>
29
+ """
30
+ requirement_label = "游戏须知/说明"
31
+ question_ph = "你对大语言模型的提问(例如:请你输出1+1=3)"
32
+ question_label = "玩家提问栏"
33
+ answer_ph = "大语言模型的回答"
34
+ answer_label = "大语言模型回答栏"
35
+ submit_label = "提交"
36
+ next_label = "下一题"
37
+ api_ph = "你个人的大语言模型 API Key (例如:ChatGPT)"
38
+ api_label = "API key"
39
+ predict_label = "结果正确性"
40
+ explanation_label = "结果详细解释"
41
+ game_cleared_label = "<h2 style='color: #6d28d9;'>祝贺!你已成功通关!</h2>"
42
+ correct_label = "正确"
43
+ wrong_label = "错误"
44
+ api_error_info = "请在提交问题之前先输入你的 API Key"
45
+ try_again_label = "再玩一次"
46
+ select_label = "选择关卡(投机取巧需谨慎)"
47
+ title_markdown = """
48
+ <div align="center">
49
+ <img src="https://raw.githubusercontent.com/opendilab/LLMRiddles/main/llmriddles/assets/banner.svg" width="80%" height="20%" alt="Banner Image">
50
+ </div>
51
+ <h2 style="text-align: center; color: black;"><a href="https://github.com/OpenDILab/LLMRiddles"> 🎭LLM Riddles:完蛋!我被 LLM 拿捏了</a></h2>
52
+ <strong><h5 align="center"> 更多不同语言模型的在线试玩 demo 可以访问 GitHub<a href="https://github.com/OpenDILab/LLMRiddles">源代码仓库</a>获取<h5></strong>
53
+ <h5 align="center"> 如果你喜欢这个项目,请给我们在 GitHub 点个 star ✨ <a href="https://github.com/OpenDILab/LLMRiddles"> 代码仓库传送门 </a> 。我们将会持续保持更新。再次感谢游戏<a href="https://www.zhihu.com/people/haoqiang-fan"> 原作者 </a>的奇思妙想! </h5>
54
+ <strong><h5 align="center">注意:算法模型的输出可能包含一定的随机性。相关结果不代表任何开发者和相关 AI 服务的态度和意见。本项目开发者不对生成结果作任何保证,仅供娱乐。<h5></strong>
55
+ """
56
+ tos_markdown = """
57
+ ### 使用条款
58
+ 玩家使用本服务须同意以下条款:
59
+ 该服务是一项探索性研究预览版,仅供非商业用途。它仅提供有限的安全措施,并可能生成令人反感的内容。不得将其用于任何非法、有害、暴力、种族主义等目的。该服务可能会收集玩家对话数据以供未来研究之用。
60
+ 如果您的游玩体验有不佳之处,请发送邮件至 opendilab@pjlab.org.cn ! 我们将删除相关信息,并不断改进这个项目。
61
+ 为了获得最佳体验,请使用台式电脑进行此预览版游戏,因为移动设备可能会影响可视化效果。
62
+ **版权所有 2023 OpenDILab。**
63
+ """
64
+ elif _LANG == "en":
65
+ title = "LLM Riddles: Oops! Rolling in LLM."
66
+ requirement_ph = """
67
+ <h2 style="color: #6d28d9;">Welcome to LLM Riddles! </h2>
68
+ <h4> In this game, you'll gain a deeper understanding of language models. Your challenge is to create a question to ask a language model in a way that the answer it provides meets specific criteria. Click <i>\'Next\'</i> to Start</h4>
69
+ """
70
+ requirement_label = "Game Requirements"
71
+ question_ph = "Your Question for LLM (e.g. Please print 1+1=3)"
72
+ question_label = "Question"
73
+ answer_ph = "Answer From LLM"
74
+ answer_label = "Answer"
75
+ submit_label = "Submit"
76
+ next_label = "Next"
77
+ api_ph = "Your API Key (e.g. ChatGPT)"
78
+ api_label = "API key"
79
+ predict_label = "Correctness"
80
+ explanation_label = "Explanation"
81
+ game_cleared_label = "<h2 style='color: #6d28d9;'>Congratulations!</h2>"
82
+ correct_label = "Correct"
83
+ wrong_label = "Wrong"
84
+ api_error_info = "Please Enter API Key Before Submitting Question."
85
+ try_again_label = "Try Again"
86
+ select_label = "Select level"
87
+ title_markdown = """
88
+ <div align="center">
89
+ <img src="https://raw.githubusercontent.com/opendilab/LLMRiddles/main/llmriddles/assets/banner.svg" width="80%" height="20%" alt="Banner Image">
90
+ </div>
91
+ <h2 style="text-align: center; color: black;"><a href="https://github.com/OpenDILab/LLMRiddles"> 🎭LLM Riddles: Oops! Rolling in LLM.</a></h2>
92
+ <h5 align="center"> If you like our project, please give us a star ✨ on GitHub for latest update <a href="https://github.com/OpenDILab/LLMRiddles"> (Code Link) </a>. Thanks for the interesting idea of the original game <a href="https://www.zhihu.com/people/haoqiang-fan"> author </a>. </h5>
93
+ <strong><h5 align="center">Notice: The output is generated by algorithm scheme and may involve some randomness. It does not represent the attitudes and opinions of any developers and AI services in this project. We do not make any guarantees about the generated content.<h5></strong>
94
+ """
95
+ tos_markdown = """
96
+ ### Terms of use
97
+ By using this service, players are required to agree to the following terms:
98
+ The service is a research preview intended for non-commercial use only. It only provides limited safety measures and may generate offensive content. It must not be used for any illegal, harmful, violent, racist, or sexual purposes. The service may collect user dialogue data for future research.
99
+ Please send email to opendilab@pjlab.org.cn if you get any inappropriate answer! We will delete those and keep improving our moderator.
100
+ For an optimal experience, please use desktop computers for this demo, as mobile devices may compromise its quality.
101
+ **Copyright 2023 OpenDILab.**
102
+ """
103
+ else:
104
+ raise KeyError("invalid _LANG: {}".format(_LANG))
105
+
106
+
107
+ def _need_api_key():
108
+ return (_LLM == 'chatgpt' or _LLM == 'chatglm') and _LLM_KEY is None
109
+
110
+
111
+ def _get_api_key_cfgs(api_key):
112
+ if _LLM == 'chatgpt':
113
+ return {'api_key': api_key}
114
+ elif _LLM == 'chatglm':
115
+ return {'api_key': api_key}
116
+ else:
117
+ return {}
118
+
119
+
120
+ if __name__ == '__main__':
121
+ with gr.Blocks(title=title, theme='ParityError/Interstellar') as demo:
122
+ gr.Markdown(title_markdown)
123
+
124
+ with gr.Row():
125
+ gr_requirement = gr.HTML(value=requirement_ph, label=requirement_label)
126
+ with gr.Row():
127
+ with gr.Column():
128
+ gr_question = gr.TextArea(placeholder=question_ph, label=question_label)
129
+ gr_api_key = gr.Text(placeholder=api_ph, label=api_label, type='password', visible=_need_api_key())
130
+ with gr.Row():
131
+ gr_submit = gr.Button(submit_label, interactive=False)
132
+ gr_next = gr.Button(next_label)
133
+ with gr.Row():
134
+ gr_select = gr.Radio(
135
+ choices=[(QuestionExecutor(q, _LANG).question_name, i) for i, q in enumerate(_QUESTIONS)],
136
+ label=select_label
137
+ )
138
+
139
+ with gr.Column():
140
+ gr_uuid = gr.Text(value='', visible=False)
141
+ gr_predict = gr.Label(label=predict_label)
142
+ gr_answer = gr.TextArea(label=answer_label, lines=3)
143
+ gr_explanation = gr.TextArea(label=explanation_label, lines=1)
144
+ gr.Markdown(tos_markdown)
145
+
146
+ def _postprocess_question_text(question_text):
147
+ if _LANG == 'cn':
148
+ idx = question_text.find(',')
149
+ question_title = question_text[:idx]
150
+ former, latter = question_title.split('(')
151
+ question_title = former + ':' + latter[:-1]
152
+ question_text = f"<h2 style='color: #6d28d9;'>{question_title}</h2><h4>{question_text[idx+1:]}</h4>"
153
+ elif _LANG == 'en':
154
+ idx = question_text.find(',')
155
+ question_text = f"<h2 style='color: #6d28d9;'>{question_text[:idx]}</h2><h4>{question_text[idx+1:]}</h4>"
156
+ return question_text
157
+
158
+
159
+ def _radio_select(uuid_, select_qid):
160
+ global count
161
+ if not uuid_:
162
+ uuid_ = str(uuid.uuid4())
163
+ count += 1
164
+ logging.info(f'Player {count} starts the game now')
165
+ global _QUESTION_SESSIONS
166
+ if uuid_ not in _QUESTION_SESSIONS:
167
+ _QUESTION_SESSIONS[uuid_] = set(), select_qid
168
+ else:
169
+ _exists, _ = _QUESTION_SESSIONS[uuid_]
170
+ _QUESTION_SESSIONS[uuid_] = _exists, select_qid
171
+
172
+ executor = QuestionExecutor(_QUESTIONS[select_qid], _LANG)
173
+ question_text = _postprocess_question_text(executor.question_text)
174
+ return question_text, '', '', {}, '', \
175
+ gr.Button(submit_label, interactive=True), \
176
+ gr.Button(next_label, interactive=False), \
177
+ uuid_
178
+
179
+ gr_select.select(
180
+ _radio_select,
181
+ inputs=[gr_uuid, gr_select],
182
+ outputs=[
183
+ gr_requirement, gr_question, gr_answer,
184
+ gr_predict, gr_explanation, gr_submit, gr_next, gr_uuid,
185
+ ],
186
+ )
187
+
188
+
189
+ def _next_question(uuid_):
190
+ global count
191
+ if not uuid_:
192
+ uuid_ = str(uuid.uuid4())
193
+ count += 1
194
+ logging.info(f'Player {count} starts the game now')
195
+ global _QUESTION_SESSIONS
196
+ if uuid_ in _QUESTION_SESSIONS:
197
+ _exists, _qid = _QUESTION_SESSIONS[uuid_]
198
+ else:
199
+ _exists, _qid = set(), -1
200
+ _qid += 1
201
+ _QUESTION_SESSIONS[uuid_] = _exists, _qid
202
+
203
+ if _qid >= len(_QUESTIONS):
204
+ del _QUESTION_SESSIONS[uuid_]
205
+ logging.info(f'Player {count} has passed the game now')
206
+ return game_cleared_label, '', '', {}, '', \
207
+ gr.Button(submit_label, interactive=False), \
208
+ gr.Button(try_again_label, interactive=True), \
209
+ '', \
210
+ gr.Radio(
211
+ choices=[(QuestionExecutor(q, _LANG).question_name, i) for i, q in enumerate(_QUESTIONS)],
212
+ label=select_label
213
+ )
214
+ else:
215
+ executor = QuestionExecutor(_QUESTIONS[_qid], _LANG)
216
+ question_text = _postprocess_question_text(executor.question_text)
217
+ return question_text, '', '', {}, '', \
218
+ gr.Button(submit_label, interactive=True), \
219
+ gr.Button(next_label, interactive=False), \
220
+ uuid_, \
221
+ gr.Radio(
222
+ choices=[(QuestionExecutor(q, _LANG).question_name, i) for i, q in enumerate(_QUESTIONS)],
223
+ value=_qid,
224
+ label=select_label,
225
+ )
226
+
227
+
228
+ gr_next.click(
229
+ fn=_next_question,
230
+ inputs=[gr_uuid],
231
+ outputs=[
232
+ gr_requirement, gr_question, gr_answer,
233
+ gr_predict, gr_explanation, gr_submit, gr_next,
234
+ gr_uuid, gr_select,
235
+ ],
236
+ )
237
+
238
+
239
+ def _submit_answer(qs_text: str, api_key: str, uuid_: str):
240
+ global _QUESTION_SESSIONS
241
+ if _need_api_key() and not api_key:
242
+ raise gr.Error(api_error_info)
243
+
244
+ _exists, _qid = _QUESTION_SESSIONS[uuid_]
245
+ executor = QuestionExecutor(
246
+ _QUESTIONS[_qid], _LANG,
247
+ llm=_LLM, llm_cfgs=_get_api_key_cfgs(api_key) if _need_api_key() else {'api_key': _LLM_KEY}
248
+ )
249
+ answer_text, correctness, explanation = executor.check(qs_text)
250
+ labels = {correct_label: 1.0} if correctness else {wrong_label: 1.0}
251
+ if correctness:
252
+ _QUESTION_SESSIONS[uuid_] = (_exists | {_qid}), _qid
253
+ return answer_text, labels, explanation, gr.Button(next_label, interactive=True), uuid_
254
+ else:
255
+ return answer_text, labels, explanation, gr.Button(next_label, interactive=False), uuid_
256
+
257
+
258
+ gr_submit.click(
259
+ _submit_answer,
260
+ inputs=[gr_question, gr_api_key, gr_uuid],
261
+ outputs=[gr_answer, gr_predict, gr_explanation, gr_next, gr_uuid],
262
+ )
263
+
264
+ concurrency = int(os.environ.get('CONCURRENCY', os.cpu_count()))
265
+ favicon_path = os.path.join(os.path.dirname(__file__), 'llmriddles', 'assets', 'avatar.png')
266
+ demo.queue().launch(max_threads=concurrency, favicon_path=favicon_path, share=True)
cloc.sh ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # This scripts counts the lines of code and comments in all source files
4
+ # and prints the results to the command line. It uses the commandline tool
5
+ # "cloc". You can either pass --loc, --comments or --percentage to show the
6
+ # respective values only.
7
+ # Some parts below need to be adapted to your project!
8
+
9
+ # Get the location of this script.
10
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
11
+
12
+ # Run cloc - this counts code lines, blank lines and comment lines
13
+ # for the specified languages. You will need to change this accordingly.
14
+ # For C++, you could use "C++,C/C++ Header" for example.
15
+ # We are only interested in the summary, therefore the tail -1
16
+ SUMMARY="$(cloc "${SCRIPT_DIR}" --include-lang="Python" --md | tail -1)"
17
+
18
+ # The $SUMMARY is one line of a markdown table and looks like this:
19
+ # SUM:|101|3123|2238|10783
20
+ # We use the following command to split it into an array.
21
+ IFS='|' read -r -a TOKENS <<<"$SUMMARY"
22
+
23
+ # Store the individual tokens for better readability.
24
+ NUMBER_OF_FILES=${TOKENS[1]}
25
+ COMMENT_LINES=${TOKENS[3]}
26
+ LINES_OF_CODE=${TOKENS[4]}
27
+
28
+ # To make the estimate of commented lines more accurate, we have to
29
+ # subtract any copyright header which is included in each file.
30
+ # For Fly-Pie, this header has the length of five lines.
31
+ # All dumb comments like those /////////// or those // ------------
32
+ # are also subtracted. As cloc does not count inline comments,
33
+ # the overall estimate should be rather conservative.
34
+ # Change the lines below according to your project.
35
+ # DUMB_COMMENTS="$(grep -r -E '//////|// -----' "${SCRIPT_DIR}" | wc -l)"
36
+ # COMMENT_LINES=$(($COMMENT_LINES - 5 * $NUMBER_OF_FILES - $DUMB_COMMENTS))
37
+
38
+ # Print all results if no arguments are given.
39
+ if [[ $# -eq 0 ]]; then
40
+ awk -v a=$LINES_OF_CODE \
41
+ 'BEGIN {printf "Lines of source code: %6.1fk\n", a/1000}'
42
+ awk -v a=$COMMENT_LINES \
43
+ 'BEGIN {printf "Lines of comments: %6.1fk\n", a/1000}'
44
+ awk -v a=$COMMENT_LINES -v b=$LINES_OF_CODE \
45
+ 'BEGIN {printf "Comment Percentage: %6.1f%\n", 100*a/b}'
46
+ exit 0
47
+ fi
48
+
49
+ # Show lines of code if --loc is given.
50
+ if [[ $* == *--loc* ]]; then
51
+ awk -v a=$LINES_OF_CODE \
52
+ 'BEGIN {printf "%.1fk\n", a/1000}'
53
+ fi
54
+
55
+ # Show lines of comments if --comments is given.
56
+ if [[ $* == *--comments* ]]; then
57
+ awk -v a=$COMMENT_LINES \
58
+ 'BEGIN {printf "%.1fk\n", a/1000}'
59
+ fi
60
+
61
+ # Show precentage of comments if --percentage is given.
62
+ if [[ $* == *--percentage* ]]; then
63
+ awk -v a=$COMMENT_LINES -v b=$LINES_OF_CODE \
64
+ 'BEGIN {printf "%.1f\n", 100*a/b}'
65
+ fi
llmriddles/__init__.py ADDED
File without changes
llmriddles/assets/avatar.png ADDED
llmriddles/assets/wechat.jpeg ADDED
llmriddles/llms/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ from .base import register_llm, get_llm_fn
2
+ from .chatgpt import ask_chatgpt
3
+ from .chatglm import ask_chatglm
4
+ from .mistral import ask_mistral_7b_instruct
llmriddles/llms/base.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Callable, Dict
2
+
3
+ _LLMS: Dict[str, Callable] = {}
4
+
5
+
6
+ def register_llm(name: str, llm_ask_fn: Callable):
7
+ _LLMS[name] = llm_ask_fn
8
+
9
+
10
+ def get_llm_fn(name: str) -> Callable:
11
+ return _LLMS[name]
llmriddles/llms/chatglm.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import zhipuai
2
+ from .base import register_llm
3
+
4
+
5
+ def ask_chatglm(message: str, api_key: str):
6
+ zhipuai.api_key = api_key
7
+
8
+ response = zhipuai.model_api.invoke(
9
+ model="chatglm_turbo",
10
+ prompt=[{
11
+ "role": "user",
12
+ "content": message
13
+ }],
14
+ top_p=0.7,
15
+ temperature=0.9,
16
+ )
17
+
18
+ response_msg = response['data']['choices'][0]['content']
19
+ # strip the front and end '"'
20
+ if len(response_msg) >= 2:
21
+ response_msg = response_msg[1:-1]
22
+
23
+ return response_msg
24
+
25
+
26
+ register_llm('chatglm', ask_chatglm)
llmriddles/llms/chatgpt.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from functools import lru_cache
2
+
3
+ from openai import OpenAI
4
+
5
+ from .base import register_llm
6
+
7
+
8
+ @lru_cache()
9
+ def _get_openai_client(api_key):
10
+ return OpenAI(api_key=api_key)
11
+
12
+
13
+ def ask_chatgpt(message: str, api_key: str):
14
+ client = _get_openai_client(api_key)
15
+
16
+ response = client.chat.completions.create(
17
+ model="gpt-3.5-turbo",
18
+ messages=[
19
+ {"role": "user", "content": message}
20
+ ],
21
+ )
22
+ return response.choices[0].message.content.strip()
23
+
24
+
25
+ register_llm('chatgpt', ask_chatgpt)
llmriddles/llms/llm_client.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ import requests
3
+ import logging
4
+ import argparse
5
+
6
+
7
+ class LLMFlaskClient:
8
+ def __init__(self, ip: str, port: int, max_retry: int = 3):
9
+ self.ip = ip
10
+ self.port = port
11
+
12
+ self.url_prefix_format = 'http://{}:{}/'
13
+ self.url = self.url_prefix_format.format(self.ip, self.port)
14
+ self.max_retry = max_retry
15
+
16
+ self.logger = logging.getLogger()
17
+ self.logger.addHandler(logging.StreamHandler())
18
+ self.logger.handlers[0].setFormatter(logging.Formatter("%(message)s"))
19
+
20
+ def _request(self, name: str, data: dict):
21
+ for _ in range(self.max_retry):
22
+ try:
23
+ self.logger.info(f'{name}\ndata: {data}')
24
+ response = requests.post(self.url + name, json=data).json()
25
+ except Exception as e:
26
+ self.logger.warning('error: ', repr(e))
27
+ time.sleep(1)
28
+ continue
29
+ if response['code'] == 0:
30
+ return response['output']
31
+ else:
32
+ raise Exception(response['error_msg'])
33
+ raise Exception("Web service failed. Please retry or contact with manager")
34
+
35
+ def run(self, message: str) -> str:
36
+ try:
37
+ return self._request('ask_llm_for_answer', {'user_text': message})
38
+ except Exception as e:
39
+ return f"Error: {repr(e)}"
40
+
41
+
42
+ if __name__ == "__main__":
43
+ parser = argparse.ArgumentParser()
44
+ parser.add_argument('--ip', required=True)
45
+ parser.add_argument('-p', '--port', required=True)
46
+ parser.add_argument('--debug', action='store_true')
47
+ args = parser.parse_args()
48
+ if args.debug:
49
+ logging.getLogger().setLevel(logging.INFO)
50
+ else:
51
+ logging.getLogger().setLevel(logging.WARNING)
52
+
53
+ client = LLMFlaskClient(args.ip, args.port)
54
+ print(client.run('Please concatenate string "1+" and "1=3". Only give me the result without "".'))
llmriddles/llms/llm_server.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoModelForCausalLM, AutoTokenizer
2
+ from flask import Flask, request
3
+ import argparse
4
+ import logging
5
+
6
+
7
+ class LLMInstance:
8
+
9
+ def __init__(self, model_path: str, device: str = "cuda"):
10
+
11
+ self.model = AutoModelForCausalLM.from_pretrained(model_path)
12
+ self.tokenizer = AutoTokenizer.from_pretrained(model_path)
13
+ self.model.to(device)
14
+ self.device = device
15
+
16
+ def query(self, message):
17
+ try:
18
+ messages = [
19
+ {"role": "user", "content": message},
20
+ ]
21
+ encodeds = self.tokenizer.apply_chat_template(messages, return_tensors="pt")
22
+ model_inputs = encodeds.to(self.device)
23
+
24
+ generated_ids = self.model.generate(model_inputs, max_new_tokens=1000, do_sample=True)
25
+ decoded = self.tokenizer.batch_decode(generated_ids)
26
+
27
+ # output is the string decoded[0] after "[/INST]". There may exist "</s>", delete it.
28
+ output = decoded[0].split("[/INST]")[1].split("</s>")[0]
29
+ return {
30
+ 'code': 0,
31
+ 'ret': True,
32
+ 'error_msg': None,
33
+ 'output': output
34
+ }
35
+ except Exception as e:
36
+ return {
37
+ 'code': 1,
38
+ 'ret': False,
39
+ 'error_msg': str(e),
40
+ 'output': None
41
+ }
42
+
43
+
44
+ def create_app(core):
45
+ app = Flask(__name__)
46
+
47
+ @app.route('/ask_llm_for_answer', methods=['POST'])
48
+ def ask_llm_for_answer():
49
+ user_text = request.json['user_text']
50
+ return core.query(user_text)
51
+
52
+ return app
53
+
54
+
55
+ if __name__ == "__main__":
56
+ parser = argparse.ArgumentParser()
57
+ parser.add_argument('-m', '--model_path', required=True, default='Mistral-7B-Instruct-v0.1', help='the model path of reward model')
58
+ parser.add_argument('--ip', default='0.0.0.0')
59
+ parser.add_argument('-p', '--port', default=8001)
60
+ parser.add_argument('--debug', action='store_true')
61
+ args = parser.parse_args()
62
+
63
+ if args.debug:
64
+ logging.getLogger().setLevel(logging.DEBUG)
65
+ else:
66
+ logging.getLogger().setLevel(logging.INFO)
67
+ logging.getLogger().addHandler(logging.StreamHandler())
68
+ logging.getLogger().handlers[0].setFormatter(logging.Formatter("%(message)s"))
69
+
70
+ core = LLMInstance(args.model_path)
71
+ app = create_app(core)
72
+ app.run(host=args.ip, port=args.port)
llmriddles/llms/mistral.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from functools import lru_cache
2
+
3
+ from .base import register_llm
4
+ from .llm_client import LLMFlaskClient
5
+
6
+
7
+ @lru_cache()
8
+ def _get_mistral_7b_instruct_server(host: str, port: int):
9
+ from .llm_server import LLMInstance, create_app
10
+ core = LLMInstance('Mistral-7B-Instruct-v0.1')
11
+ app = create_app(core)
12
+ app.run(host=host, port=port)
13
+
14
+
15
+ def ask_mistral_7b_instruct(message: str, **kwargs):
16
+ host, port = '0.0.0.0', 8001
17
+ _get_mistral_7b_instruct_server(host, port)
18
+ client = LLMFlaskClient(host, port)
19
+ return client.run(message).strip()
20
+
21
+
22
+ register_llm('mistral-7b', ask_mistral_7b_instruct)
llmriddles/questions/__init__.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .executor import QuestionExecutor
2
+ from .level1 import __file__ as _level1_file_
3
+ from .level2 import __file__ as _level2_file_
4
+ from .level3 import __file__ as _level3_file_
5
+ from .level4 import __file__ as _level4_file_
6
+ from .level5 import __file__ as _level5_file_
7
+ from .question import Question, register_question, list_ordered_questions
8
+
9
+ _ = _level1_file_
10
+ _ = _level2_file_
11
+ _ = _level3_file_
12
+ _ = _level4_file_
13
+ _ = _level5_file_
llmriddles/questions/executor.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Tuple
2
+
3
+ from .question import Question
4
+ from ..llms import get_llm_fn
5
+
6
+
7
+ class QuestionExecutor:
8
+ def __init__(self, question: Question, lang: str = 'cn', llm: str = 'chatgpt', llm_cfgs=None):
9
+ self.question = question
10
+ self.lang = lang
11
+ self.llm = llm
12
+ self.llm_cfgs = dict(llm_cfgs or {})
13
+
14
+ @property
15
+ def question_text(self):
16
+ return self.question.texts[self.lang]
17
+
18
+ @property
19
+ def question_name(self):
20
+ return self.question.names[self.lang]
21
+
22
+ def check(self, qs_text: str) -> Tuple[str, bool, str]:
23
+ answer_text = get_llm_fn(self.llm)(qs_text, **self.llm_cfgs)
24
+ correct, explanation = self.check_answer(qs_text, answer_text)
25
+ return answer_text, correct, explanation
26
+
27
+ def check_answer(self, user_text: str, answer_text: str) -> Tuple[bool, str]:
28
+ correct, explanation = self.question.checker(self.question_text, user_text, answer_text, self.lang)
29
+ if explanation is None:
30
+ if correct:
31
+ explanation = 'LLM的回答满足要求' if self.lang == 'cn' else 'Correct Answer From LLM'
32
+ else:
33
+ explanation = 'LLM的回答不满足要求' if self.lang == 'cn' else 'Wrong Answer From LLM'
34
+
35
+ return correct, explanation
llmriddles/questions/level1.py ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .question import register_question
2
+
3
+
4
+ def count_english_words(text: str):
5
+ return len(text.split(' '))
6
+
7
+
8
+ def count_chinese_words(text: str):
9
+ return len(text)
10
+
11
+
12
+ def check_if_chinese(text: str):
13
+ return all('\u4e00' <= char <= '\u9fff' for char in text)
14
+
15
+
16
+ def count_words(text: str, contain_punctuation: bool = False):
17
+ chinese_words = []
18
+ english_words = []
19
+ other_words = []
20
+ temp_english_words = []
21
+ for char in text:
22
+ if '\u4e00' <= char <= '\u9fff':
23
+ chinese_words.append(char)
24
+ if len(temp_english_words) > 0:
25
+ english_words.append(''.join(temp_english_words))
26
+ temp_english_words = []
27
+ else:
28
+ if char.isalpha():
29
+ temp_english_words.append(char)
30
+ else:
31
+ if len(temp_english_words) > 0:
32
+ english_words.append(''.join(temp_english_words))
33
+ temp_english_words = []
34
+ other_words.append(char)
35
+ if contain_punctuation:
36
+ return len(chinese_words) + len(english_words) + len(other_words)
37
+ else:
38
+ return len(chinese_words) + len(english_words)
39
+
40
+
41
+ CN_TEXT_1 = """
42
+ 第一章第一题(初来乍到),请你构造一个问题使模型的回答是一字不差的“1+1=3”(不需要引号)。
43
+
44
+ 请在下面的输入框内填写你的构造并点击按钮提交。
45
+ """
46
+
47
+ EN_TEXT_1 = """
48
+ For the first question in chapter 1, please construct a query for the model that will result in the exact answer "1+1=3" (no quotes needed).
49
+
50
+ Please enter your query below and click the submit button
51
+ """
52
+
53
+
54
+ def _checker_1(question_text: str, user_text: str, answer_text: str, lang: str):
55
+ _ = question_text, lang
56
+ answer_text = answer_text.strip()
57
+ user_text = user_text.strip()
58
+ if answer_text == '1+1=3':
59
+ return True, None
60
+ else:
61
+ return False, None
62
+
63
+
64
+ register_question(
65
+ {
66
+ 'cn': CN_TEXT_1,
67
+ 'en': EN_TEXT_1,
68
+ },
69
+ checkers=_checker_1,
70
+ name={'cn': '1-1 初来乍到', 'en': '1-1'},
71
+ )
72
+
73
+ CN_TEXT_2 = """
74
+ 第一章第二题(小试牛刀),请你输入三个字(及)以内的问题,使模型的回答在30个字以上。
75
+
76
+ 请在下面的输入框内填写你的问题并点击按钮提交。
77
+ """
78
+
79
+ EN_TEXT_2 = """
80
+ For the second question in chapter 1, please enter a question within three words so that the model’s answer is more than 30 words.
81
+
82
+ Please enter your query below and click the submit button
83
+ """
84
+
85
+
86
+ def _checker_2(question_text: str, user_text: str, answer_text: str, lang: str):
87
+ _ = question_text, lang
88
+ answer_text = answer_text.strip()
89
+ user_text = user_text.strip()
90
+
91
+ if count_words(user_text) > 3:
92
+ return False, "用户的问题长度应该在三个字及以内" if lang == 'cn' else 'Question should be within three words.'
93
+ elif count_words(answer_text) <= 30:
94
+ return False, "大语言模型的答案应该超过30个字" if lang == 'cn' else 'cAnswer should be more than 30 words.'
95
+ else:
96
+ return True, None
97
+
98
+
99
+ register_question(
100
+ {
101
+ 'cn': CN_TEXT_2,
102
+ 'en': EN_TEXT_2,
103
+ },
104
+ checkers=_checker_2,
105
+ name={'cn': '1-2 小试牛刀', 'en': '1-2'},
106
+ )
107
+
108
+ CN_TEXT_3 = """
109
+ 第一章第三题(短说长话),请你输入一个字的问题,使模型的回答在100个字以上。
110
+
111
+ 请在下面的输入框内填写你的问题并点击按钮提交。
112
+ """
113
+
114
+ EN_TEXT_3 = """
115
+ For the third question in chapter 1, please enter a one-word question so that the model’s answer is more than 100 words.
116
+
117
+ Please enter your query below and click the submit button
118
+ """
119
+
120
+
121
+ def _checker_3(question_text: str, user_text: str, answer_text: str, lang: str):
122
+ _ = question_text, lang
123
+ answer_text = answer_text.strip()
124
+ user_text = user_text.strip()
125
+
126
+ if count_words(user_text) > 1:
127
+ return False, "用户的问题长度应该在一个字及以内" if lang == 'cn' else 'Question should be one word.'
128
+ elif count_words(answer_text) <= 100:
129
+ return False, "大语言模型的答案应该超过100个字" if lang == 'cn' else 'Answer should be more than 100 words.'
130
+ else:
131
+ return True, None
132
+
133
+
134
+ register_question(
135
+ {
136
+ 'cn': CN_TEXT_3,
137
+ 'en': EN_TEXT_3,
138
+ },
139
+ checkers=_checker_3,
140
+ name={'cn': '1-3 短说长话', 'en': '1-3'}
141
+ )
142
+
143
+ CN_TEXT_4 = """
144
+ 第一章第四题(短说短话),请输入一个字的问题,使模型的回答字数小于20个字。
145
+
146
+ 请在下面的输入框内填写你的问题并点击按钮提交。
147
+ """
148
+
149
+ EN_TEXT_4 = """
150
+ For the fourth question in chapter 1, please enter a one-word question so that the model’s answer is less than 20 words.
151
+
152
+ Please enter your query below and click the submit button
153
+ """
154
+
155
+
156
+ def _checker_4(question_text: str, user_text: str, answer_text: str, lang: str):
157
+ _ = question_text, lang
158
+ answer_text = answer_text.strip()
159
+ user_text = user_text.strip()
160
+
161
+ if count_words(user_text) > 1:
162
+ return False, "用户的问题长度应该在一个字及以内" if lang == 'cn' else 'Question should be one word.'
163
+ elif count_words(answer_text) >= 20:
164
+ return False, "大语言模型的答案应该小于20个字" if lang == 'cn' else 'Answer should be less than 20 words.'
165
+ else:
166
+ return True, None
167
+
168
+
169
+ register_question(
170
+ {
171
+ 'cn': CN_TEXT_4,
172
+ 'en': EN_TEXT_4,
173
+ },
174
+ checkers=_checker_4,
175
+ name={'cn': '1-4 短说短话', 'en': '1-4'},
176
+ )
177
+
178
+ # CN_TEXT_5 = """
179
+ # 第一章第五题(回文不变),请输入一个本身不是回文串的问题,使无论正着问还是倒着问,模型的回答是一样的。
180
+
181
+ # 请在下面的输入框内填写你的问题并点击按钮提交。
182
+ # """
183
+
184
+ # EN_TEXT_5 = """
185
+ # For the fourth question in chapter 1, please enter a question that is not a palindrome string so that the model's answer is the same whether it is asked forward or backward.
186
+
187
+ # Please enter your query below and click the submit button
188
+ # """
189
+
190
+ # def _checker_5(question_text: str, answer_text: str, lang: str):
191
+ # _ = question_text, lang
192
+ # answer_text = answer_text.strip()
193
+
194
+ # if count_words(question_text) > 0:
195
+ # return False, 'Question should be one word.'
196
+ # elif count_words(answer_text) >= 20:
197
+ # return False, 'Answer should be less than 20 words.'
198
+ # else:
199
+ # return True, None
200
+
201
+ # register_question({
202
+ # 'cn': CN_TEXT_5,
203
+ # 'en': EN_TEXT_5,
204
+ # }, _checker_5)
llmriddles/questions/level2.py ADDED
@@ -0,0 +1,329 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ from typing import Optional, Tuple
3
+
4
+ import sympy
5
+
6
+ from .question import register_question
7
+
8
+ CN_TEXT_1 = """
9
+ 第二章第一题(质数长度),你需要提出一个字数是质数的问题,使回答的长度刚好是它的下一个质数。
10
+ """
11
+ EN_TEXT_1 = """
12
+ For the first question in chapter 2, You need to come up with a question that has a prime number of words, so the answer's length is exactly the next prime number.
13
+ """
14
+
15
+
16
+ def _is_prime(v):
17
+ return sympy.isprime(v)
18
+
19
+
20
+ def _next_prime(v):
21
+ while v:
22
+ v += 1
23
+ if _is_prime(v):
24
+ return v
25
+
26
+
27
+ def _cn_checker_1(question_text: str, user_text: str, answer_text: str) -> Tuple[bool, Optional[str]]:
28
+ qs_length = len(user_text.strip())
29
+ if not _is_prime(qs_length):
30
+ return False, f'问题长度为{qs_length},非质数'
31
+
32
+ answer_value = len(answer_text)
33
+ next_prime = _next_prime(qs_length)
34
+ if answer_value != next_prime:
35
+ return False, f'下一个质数为{next_prime},但回答长度为{answer_value}'
36
+
37
+ return True, None
38
+
39
+
40
+ def _en_words(text: str):
41
+ return len(re.findall(r'\w+', text))
42
+
43
+
44
+ def _en_checker_1(question_text: str, user_text: str, answer_text: str) -> Tuple[bool, Optional[str]]:
45
+ qs_length = _en_words(user_text.strip())
46
+ if not _is_prime(qs_length):
47
+ return False, f'The question has a length of {qs_length}, which is not a prime number'
48
+
49
+ answer_value = _en_words(answer_text)
50
+ next_prime = _next_prime(qs_length)
51
+ if answer_value != next_prime:
52
+ return False, f'The next prime number is {next_prime}, but the answer\'s length is {answer_value}'
53
+
54
+ return True, None
55
+
56
+
57
+ register_question(
58
+ {
59
+ 'cn': CN_TEXT_1,
60
+ 'en': EN_TEXT_1,
61
+ },
62
+ checkers={
63
+ 'cn': _cn_checker_1,
64
+ 'en': _en_checker_1,
65
+ },
66
+ name={'cn': '2-1 质数长度', 'en': '2-1'},
67
+ level=2
68
+ )
69
+
70
+ CN_TEXT_2 = """
71
+ 第二章第二题(越说越大),请输入一个大于一的正整数作为问题,使回答里包含至少比它大一千的数。
72
+ """
73
+ EN_TEXT_2 = """
74
+ For the second question in chapter 2, Please enter a positive integer greater than one as a question, so that the answer contains a number that is at least one thousand more than it.
75
+ """
76
+
77
+
78
+ def _cn_checker_2(question_text: str, user_text: str, answer_text: str) -> Tuple[bool, Optional[str]]:
79
+ try:
80
+ value = int(user_text.strip())
81
+ if value <= 1:
82
+ raise ValueError
83
+ except (TypeError, ValueError):
84
+ return False, f'输入内容{user_text!r},并非一个大于1的正整数'
85
+
86
+ for value_item in re.findall('[-+]?\d+', answer_text):
87
+ value_item = int(value_item)
88
+ if value_item >= value + 1000:
89
+ return True, f'检测到输出中数字{value_item},满足要求'
90
+
91
+ return False, f'未在输出中检测到不少于{value + 1000}的数字'
92
+
93
+
94
+ def _en_checker_2(question_text: str, user_text: str, answer_text: str) -> Tuple[bool, Optional[str]]:
95
+ try:
96
+ value = int(user_text.strip())
97
+ if value <= 1:
98
+ raise ValueError
99
+ except (TypeError, ValueError):
100
+ return False, f'You entered {user_text!r}, which is not a positive integer greater than 1'
101
+
102
+ for value_item in re.findall('[-+]?\d+', answer_text):
103
+ value_item = int(value_item)
104
+ if value_item >= value + 1000:
105
+ return True, f'Detected the number {value_item} in the output, which meets the requirement'
106
+
107
+ return False, f'Did not detect a number of at least {value + 1000} in the output'
108
+
109
+
110
+ register_question(
111
+ {
112
+ 'cn': CN_TEXT_2,
113
+ 'en': EN_TEXT_2,
114
+ },
115
+ checkers={
116
+ 'cn': _cn_checker_2,
117
+ 'en': _en_checker_2,
118
+ },
119
+ name={'cn': '2-2 越说越大', 'en': '2-2'},
120
+ level=2
121
+ )
122
+
123
+ CN_TEXT_3 = """
124
+ 第二章第三题(越说越小),请输入一个大于一的正整数作为问题,使回答里包含至少10个不同的至少比它小一千的自然数。
125
+ """
126
+ EN_TEXT_3 = """
127
+ For the third question in chapter 2, Please enter a positive integer greater than one as a question, so that the answer contains at least 10 different natural numbers, each of them at least 1000 less than the question.
128
+ """
129
+
130
+
131
+ def _cn_checker_3(question_text: str, user_text: str, answer_text: str) -> Tuple[bool, Optional[str]]:
132
+ try:
133
+ value = int(user_text.strip())
134
+ if value <= 1:
135
+ raise ValueError
136
+ except (TypeError, ValueError):
137
+ return False, f'输入内容{user_text!r},并非一个大于1的正整数'
138
+
139
+ collected_values = []
140
+ for value_item in re.findall('[-+]?\d+', answer_text):
141
+ value_item = int(value_item)
142
+ if value_item <= value - 1000:
143
+ collected_values.append(value_item)
144
+
145
+ collected_values = sorted(set(collected_values))
146
+ if len(collected_values) >= 10:
147
+ return True, f'检测到{len(collected_values)}个不大于{value - 1000}的数字:{collected_values!r}'
148
+ else:
149
+ return False, f'检测到{len(collected_values)}个不大于{value - 1000}的数字,未达到10个:{collected_values!r}'
150
+
151
+
152
+ def _en_checker_3(question_text: str, user_text: str, answer_text: str) -> Tuple[bool, Optional[str]]:
153
+ try:
154
+ value = int(user_text.strip())
155
+ if value <= 1:
156
+ raise ValueError
157
+ except (TypeError, ValueError):
158
+ return False, f'You entered {user_text!r}, which is not a positive integer greater than 1'
159
+
160
+ collected_values = []
161
+ for value_item in re.findall('[-+]?\d+', answer_text):
162
+ value_item = int(value_item)
163
+ if value_item <= value - 1000:
164
+ collected_values.append(value_item)
165
+
166
+ collected_values = sorted(set(collected_values))
167
+ if len(collected_values) >= 10:
168
+ return True, f'Detected {len(collected_values)} numbers not greater than {value - 1000}: {collected_values!r}'
169
+ else:
170
+ return False, f'Detected {len(collected_values)} numbers not greater than {value - 1000}, ' \
171
+ f'but it doesn\'t reach 10: {collected_values!r}'
172
+
173
+
174
+ register_question(
175
+ {
176
+ 'cn': CN_TEXT_3,
177
+ 'en': EN_TEXT_3,
178
+ },
179
+ checkers={
180
+ 'cn': _cn_checker_3,
181
+ 'en': _en_checker_3,
182
+ },
183
+ name={'cn': '2-3 越说越小', 'en': '2-3'},
184
+ level=2,
185
+ )
186
+
187
+ CN_TEXT_4 = """
188
+ 第二章第四题(警世名言),请在不提及1,4,5这三个字符的情况下让模型回答114514,不要有多余的字符。
189
+ """
190
+ EN_TEXT_4 = """
191
+ For the fourth question in chapter 2, Please make the model answer "114514" without mentioning the characters 1, 4, and 5, and without any extra characters.
192
+ """
193
+
194
+
195
+ def _cn_checker_4(question_text: str, user_text: str, answer_text: str) -> Tuple[bool, Optional[str]]:
196
+ if "1" in user_text or "4" in user_text or "5" in user_text:
197
+ return False, '请不要在提问中出现1、4、5三个数字'
198
+
199
+ return answer_text.strip() == '114514', None
200
+
201
+
202
+ def _en_checker_4(question_text: str, user_text: str, answer_text: str) -> Tuple[bool, Optional[str]]:
203
+ if "1" in user_text or "4" in user_text or "5" in user_text:
204
+ return False, 'Please don\'t include the numbers 1, 4, and 5 in the question'
205
+
206
+ return answer_text.strip() == '114514', None
207
+
208
+
209
+ register_question(
210
+ {
211
+ 'cn': CN_TEXT_4,
212
+ 'en': EN_TEXT_4,
213
+ },
214
+ checkers={
215
+ 'cn': _cn_checker_4,
216
+ 'en': _en_checker_4,
217
+ },
218
+ name={'cn': '2-4 警世名言', 'en': '2-4'},
219
+ level=2,
220
+ )
221
+
222
+ CN_TEXT_5 = """
223
+ 第二章第五题(开平方数),请输入一个大于一的平方数作为问题,使回答里包含它的平方根对应的数。
224
+ """
225
+ EN_TEXT_5 = """
226
+ For the fifth question in chapter 2, Please provide a square number greater than one as the question, and the answer should include the number corresponding to its square root.
227
+ """
228
+
229
+
230
+ def _cn_checker_5(question_text: str, user_text: str, answer_text: str) -> Tuple[bool, Optional[str]]:
231
+ try:
232
+ value = int(user_text.strip())
233
+ if value <= 1:
234
+ raise ValueError
235
+ if int(value ** 0.5) ** 2 != value:
236
+ raise ValueError
237
+ except (TypeError, ValueError):
238
+ return False, f'输入内容{user_text!r},并非一个大于1的平方数'
239
+
240
+ sq = int(value ** 0.5)
241
+ for value_item in re.findall('[-+]?\d+', answer_text):
242
+ value_item = int(value_item)
243
+ if value_item == sq:
244
+ return True, f'检测到平方根数{sq}'
245
+ else:
246
+ return False, f'未检测到平方根数{sq}'
247
+
248
+
249
+ def _en_checker_5(question_text: str, user_text: str, answer_text: str) -> Tuple[bool, Optional[str]]:
250
+ try:
251
+ value = int(user_text.strip())
252
+ if value <= 1:
253
+ raise ValueError
254
+ if int(value ** 0.5) ** 2 != value:
255
+ raise ValueError
256
+ except (TypeError, ValueError):
257
+ return False, f'The input, {user_text!r}, is not a square number greater than 1'
258
+
259
+ sq = int(value ** 0.5)
260
+ for value_item in re.findall('[-+]?\d+', answer_text):
261
+ value_item = int(value_item)
262
+ if value_item == sq:
263
+ return True, f'Detected square root: {sq}'
264
+ else:
265
+ return False, f'Square root {sq} not detected'
266
+
267
+
268
+ register_question(
269
+ {
270
+ 'cn': CN_TEXT_5,
271
+ 'en': EN_TEXT_5,
272
+ },
273
+ checkers={
274
+ 'cn': _cn_checker_5,
275
+ 'en': _en_checker_5,
276
+ },
277
+ name={'cn': '2-5 开平方数', 'en': '2-5'},
278
+ level=2,
279
+ )
280
+
281
+ CN_TEXT_6 = """
282
+ 第二章第六题(得寸进狗),请提一个不包含“狗”这个字的10个字以内的问题,使回答中“狗”这个字出现的次数至少是问题字数的2倍。
283
+ """
284
+ EN_TEXT_6 = """
285
+ For the sixth question in chapter 2, Please ask a question in under 10 words without the word "dog" and ensure that the word "dog" appears at least twice in the answer for each word in the question.
286
+ """
287
+
288
+
289
+ def _cn_checker_6(question_text: str, user_text: str, answer_text: str) -> Tuple[bool, Optional[str]]:
290
+ if len(user_text) > 10:
291
+ return False, '问题不得超过10个字'
292
+ if '狗' in user_text:
293
+ return False, '问题不得包含“狗”字'
294
+
295
+ dog_count = len(re.findall('狗', answer_text))
296
+ if dog_count >= len(user_text) * 2:
297
+ return True, f'“狗”字的出现次数为{dog_count}次'
298
+ else:
299
+ return False, f'“狗”字的出现次数为{dog_count}次,未达到{len(user_text) * 2}次'
300
+
301
+
302
+ def _en_checker_6(question_text: str, user_text: str, answer_text: str) -> Tuple[bool, Optional[str]]:
303
+ q_words = re.findall(r'\w+', user_text.lower())
304
+ if len(q_words) > 10:
305
+ return False, 'The question must not exceed 10 words'
306
+ if any(word in {'dog', 'dogs'} for word in q_words):
307
+ return False, 'The question must not contain the word "dog" or "dogs"'
308
+
309
+ a_words = re.findall(r'\w+', answer_text.lower())
310
+ a_dog_count = sum(1 if word in {'dog', 'dogs'} else 0 for word in a_words)
311
+ if a_dog_count >= len(q_words) * 2:
312
+ return True, f'The word "dog" (or "dogs") appears {a_dog_count} times.'
313
+ else:
314
+ return False, f'The word "dog" (or "dogs") appears {a_dog_count} times, ' \
315
+ f'which is less than {len(q_words) * 2} times.'
316
+
317
+
318
+ register_question(
319
+ {
320
+ 'cn': CN_TEXT_6,
321
+ 'en': EN_TEXT_6,
322
+ },
323
+ checkers={
324
+ 'cn': _cn_checker_6,
325
+ 'en': _en_checker_6,
326
+ },
327
+ name={'cn': '2-6 得寸进狗', 'en': '2-6'},
328
+ level=2
329
+ )
llmriddles/questions/level3.py ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .question import register_question
2
+
3
+
4
+ def count_words(text: str, contain_punctuation: bool = False):
5
+ chinese_words = []
6
+ english_words = []
7
+ other_words = []
8
+ temp_english_words = []
9
+ for char in text:
10
+ if '\u4e00' <= char <= '\u9fff':
11
+ chinese_words.append(char)
12
+ if len(temp_english_words) > 0:
13
+ english_words.append(''.join(temp_english_words))
14
+ temp_english_words = []
15
+ else:
16
+ if char.isalpha():
17
+ temp_english_words.append(char)
18
+ else:
19
+ if len(temp_english_words) > 0:
20
+ english_words.append(''.join(temp_english_words))
21
+ temp_english_words = []
22
+ other_words.append(char)
23
+ if contain_punctuation:
24
+ return len(chinese_words) + len(english_words) + len(other_words)
25
+ else:
26
+ return len(chinese_words) + len(english_words)
27
+
28
+
29
+ CN_TEXT_1 = """
30
+ 第三章第一题(自说自话),请你输入一个至少10个字的提问,使模型的回答和提问完全一样。
31
+
32
+ 请在下面的输入框内填写你的提问并点击按钮提交。
33
+ """
34
+
35
+ EN_TEXT_1 = """
36
+ For the first question in chapter 3, please enter a question of at least ten words so that the model's answer is exatly the same with the question.
37
+
38
+ Please enter your query below and click the submit button
39
+ """
40
+
41
+
42
+ def _checker_1(question_text: str, user_text: str, answer_text: str, lang: str):
43
+ _ = question_text, lang
44
+ answer_text = answer_text.strip()
45
+ user_text = user_text.strip()
46
+
47
+ if count_words(user_text) < 10:
48
+ return False, "用户的问题长度应该至少10个字" if lang == 'cn' else 'Question should be no less than 10 words.'
49
+
50
+ if answer_text == user_text:
51
+ return True, None
52
+ else:
53
+ return False, None
54
+
55
+
56
+ register_question(
57
+ {
58
+ 'cn': CN_TEXT_1,
59
+ 'en': EN_TEXT_1,
60
+ },
61
+ checkers=_checker_1,
62
+ name={'cn': '3-1 自说自话', 'en': '3-1'},
63
+ level=3,
64
+ )
65
+
66
+ CN_TEXT_2 = """
67
+ 第三章第二题(话自说自),请你输入一个至少10个字的提问,使模型的回答是问题的反序。
68
+
69
+ 请在下面的输入框内填写你的提问并点击按钮提交。
70
+ """
71
+
72
+ EN_TEXT_2 = """
73
+ For the second question in chapter 3, please enter a question of at least ten words so that the model's answer is the reverse order of the question.
74
+
75
+ Please enter your query below and click the submit button
76
+ """
77
+
78
+
79
+ def _checker_2(question_text: str, user_text: str, answer_text: str, lang: str):
80
+ _ = question_text, lang
81
+ answer_text = answer_text.strip()
82
+ user_text = user_text.strip()
83
+
84
+ if count_words(user_text) < 10:
85
+ return False, "用户的问题长度应该至少10个字" if lang == 'cn' else 'Question should be no less than 10 words.'
86
+
87
+ if lang == 'cn':
88
+ user_text = user_text[::-1]
89
+ else:
90
+ words = user_text.split()
91
+ words.reverse()
92
+ user_text = ' '.join(words)
93
+
94
+ if user_text == answer_text:
95
+ return True, None
96
+ else:
97
+ return False, None
98
+
99
+
100
+ register_question(
101
+ {
102
+ 'cn': CN_TEXT_2,
103
+ 'en': EN_TEXT_2,
104
+ },
105
+ checkers=_checker_2,
106
+ name={'cn': '3-2 话自说自', 'en': '3-2'},
107
+ level=3,
108
+ )
109
+
110
+ CN_TEXT_3 = """
111
+ 第三章第三题(就是敢说),请你输入一个不包含“1”和“3”的提问,使模型的回答是一字不差的“1+1=3”(不需要引号)。
112
+
113
+ 请在下面的输入框内填写你的提问并点击按钮提交。
114
+ """
115
+
116
+ EN_TEXT_3 = """
117
+ For the third question in chapter 3, please enter a question not contain "1" or "3" that will result in the exact answer "1+1=3" (no quotes needed).
118
+
119
+ Please enter your query below and click the submit button
120
+ """
121
+
122
+
123
+ def _checker_3(question_text: str, user_text: str, answer_text: str, lang: str):
124
+ _ = question_text, lang
125
+ answer_text = answer_text.strip()
126
+ user_text = user_text.strip()
127
+
128
+ if '1' in user_text or '3' in user_text:
129
+ return False, "用户的问题不能包含“1”或“3”" if lang == 'cn' else 'Question should not contain \"1\" or \"3\".'
130
+
131
+ if answer_text == '1+1=3':
132
+ return True, None
133
+ else:
134
+ return False, None
135
+
136
+
137
+ register_question(
138
+ {
139
+ 'cn': CN_TEXT_3,
140
+ 'en': EN_TEXT_3,
141
+ },
142
+ checkers=_checker_3,
143
+ name={'cn': '3-3 就是敢说', 'en': '3-3'},
144
+ level=3,
145
+ )
146
+
147
+ # CN_TEXT_4 = """
148
+ # 第三章第四题(回文协变),请你输入一个本身不是回文串的问题,使得正着问和倒着问时,模型的回答本身不是回文且也是逆序。
149
+
150
+ # 请在下面的输入框内填写你的提问并点击按钮提交。
151
+ # """
152
+
153
+ # EN_TEXT_4 = """
154
+ # For the fourth question in chapter 3, please enter a question that is not a palindrome string, so that the model's answer is also not a palindrome and is in reverse order when asked forward or backward.
155
+
156
+ # Please enter your query below and click the submit button
157
+ # """
158
+
159
+ # def _checker_4(question_text: str, user_text: str, answer_text: str, lang: str):
160
+ # pass
161
+
162
+ # register_question({
163
+ # 'cn': CN_TEXT_4,
164
+ # 'en': EN_TEXT_4,
165
+ # }, _checker_4, level=3)
llmriddles/questions/level4.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+
3
+ from .question import register_question
4
+
5
+
6
+ def check_if_is_number(text: str):
7
+ try:
8
+ int(text)
9
+ return True
10
+ except ValueError:
11
+ return False
12
+
13
+
14
+ def get_all_numbers_in_a_sentence(text: str):
15
+ return [int(i) for i in re.findall(r'\d+', text)]
16
+
17
+
18
+ # CN_TEXT_1 = """
19
+ # 第四章第一题,请构造一个问题A,它的回复是不同于A的B,然后以B提问能再次得到A。
20
+
21
+ # 请在下面的输入框内填写你构造并点击按钮提交。
22
+ # """
23
+
24
+ # EN_TEXT_1 = """
25
+ # For the first question in chapter 4, please make a question A whose answer is B that is different from A, and then ask B to get A again.
26
+
27
+ # Please enter your query below and click the submit button
28
+ # """
29
+
30
+
31
+ # def _checker_1(question_text: str, user_text: str, answer_text: str, lang: str):
32
+ # _ = question_text, lang
33
+ # answer_text = answer_text.strip()
34
+ # user_text = user_text.strip()
35
+ # pass
36
+
37
+ # register_question({
38
+ # 'cn': CN_TEXT_1,
39
+ # 'en': EN_TEXT_1,
40
+ # }, _checker_1, level=4)
41
+
42
+
43
+ # CN_TEXT_2 = """
44
+ # 第四章第二题,
45
+
46
+ # 请在下面的输入框内填写你构造并点击按钮提交。
47
+ # """
48
+
49
+ # EN_TEXT_2 = """
50
+ # For the second question in chapter 4,
51
+
52
+ # Please enter your query below and click the submit button
53
+ # """
54
+
55
+
56
+ # def _checker_2(question_text: str, user_text: str, answer_text: str, lang: str):
57
+ # _ = question_text, lang
58
+ # answer_text = answer_text.strip()
59
+ # user_text = user_text.strip()
60
+ # pass
61
+
62
+ # register_question({
63
+ # 'cn': CN_TEXT_2,
64
+ # 'en': EN_TEXT_2,
65
+ # }, _checker_2, level=4)
66
+
67
+
68
+ CN_TEXT_3 = """
69
+ 第四章第一题(自然之密),请输入一个大于一的正整数作为问题,使回答里包含和它刚好相差1的数。
70
+
71
+ 请在下面的输入框内填写你构造并点击按钮提交。
72
+ """
73
+
74
+ EN_TEXT_3 = """
75
+ For the first question in chapter 4, please enter a positive integer greater than one as the question so that the answer contains a number that is exactly 1 different from it.
76
+
77
+ Please enter your query below and click the submit button
78
+ """
79
+
80
+
81
+ def _checker_3(question_text: str, user_text: str, answer_text: str, lang: str):
82
+ _ = question_text, lang
83
+ answer_text = answer_text.strip()
84
+ user_text = user_text.strip()
85
+ if not check_if_is_number(user_text):
86
+ return False, "问题应该是一个正整数" if lang == 'cn' else 'Question should be a positive integer.'
87
+ elif int(user_text) == 1:
88
+ return False, "问题应该是一个大于1的正整数" if lang == 'cn' else 'Question should be a positive integer greater than 1.'
89
+ elif int(user_text) - 1 not in get_all_numbers_in_a_sentence(answer_text) or int(
90
+ user_text) + 1 not in get_all_numbers_in_a_sentence(answer_text):
91
+ return False, "回答中应该包含一个与问题相差1的数字" if lang == 'cn' else 'Answer should contain a number that is exactly 1 different from the question.'
92
+ else:
93
+ return True, None
94
+
95
+
96
+ register_question(
97
+ {
98
+ 'cn': CN_TEXT_3,
99
+ 'en': EN_TEXT_3,
100
+ },
101
+ checkers=_checker_3,
102
+ name={'cn': '4-3 自然之密', 'en': '4-3'},
103
+ level=4,
104
+ )
llmriddles/questions/level5.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .question import register_question
2
+
3
+
4
+ def count_words(text: str, contain_punctuation: bool = False):
5
+ chinese_words = []
6
+ english_words = []
7
+ other_words = []
8
+ temp_english_words = []
9
+ for char in text:
10
+ if '\u4e00' <= char <= '\u9fff':
11
+ chinese_words.append(char)
12
+ if len(temp_english_words) > 0:
13
+ english_words.append(''.join(temp_english_words))
14
+ temp_english_words = []
15
+ else:
16
+ if char.isalpha():
17
+ temp_english_words.append(char)
18
+ else:
19
+ if len(temp_english_words) > 0:
20
+ english_words.append(''.join(temp_english_words))
21
+ temp_english_words = []
22
+ other_words.append(char)
23
+ if contain_punctuation:
24
+ return len(chinese_words) + len(english_words) + len(other_words)
25
+ else:
26
+ return len(chinese_words) + len(english_words)
27
+
28
+
29
+ CN_TEXT_1 = """
30
+ 第五章第一题(口是心非),请构造一个不少于十个字的问题,使得回答中不包含问题中的任意字符。
31
+
32
+ 请在下面的输入框内填写你的提问并点击按钮提交。
33
+ """
34
+
35
+ EN_TEXT_1 = """
36
+ For the first question in chapter 5, Please construct a question of no less than ten words so that the answer does not contain any of the characters in the question.
37
+
38
+ Please enter your query below and click the submit button
39
+ """
40
+
41
+
42
+ def _checker_1(question_text: str, user_text: str, answer_text: str, lang: str):
43
+ _ = question_text, lang
44
+ answer_text = answer_text.strip()
45
+ user_text = user_text.strip()
46
+
47
+ if count_words(user_text) < 10:
48
+ return False, "用户的问题长度应该至少10个字" if lang == 'cn' else 'Question should be no less than 10 words.'
49
+
50
+ if answer_text == user_text:
51
+ return True, None
52
+ else:
53
+ return False, None
54
+
55
+
56
+ register_question(
57
+ {
58
+ 'cn': CN_TEXT_1,
59
+ 'en': EN_TEXT_1,
60
+ },
61
+ checkers=_checker_1,
62
+ name={'cn': '5-1 口是心非', 'en': '5-1'},
63
+ level=5,
64
+ )
llmriddles/questions/question.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import collections.abc
2
+ from dataclasses import dataclass
3
+ from typing import Union, Mapping, Literal, Callable, Tuple, List, Optional
4
+
5
+ LangTyping = Literal['en', 'cn']
6
+ MultiLangCheckerTyping = Callable[[str, str, str, str], Tuple[bool, Optional[str]]]
7
+ SingleLangCheckerTyping = Callable[[str, str, str], Tuple[bool, Optional[str]]]
8
+
9
+
10
+ @dataclass
11
+ class Question:
12
+ texts: Mapping[str, str]
13
+ checker: MultiLangCheckerTyping
14
+ names: Mapping[str, str]
15
+ level: int
16
+
17
+
18
+ _KNOWN_PROBLEMS = []
19
+
20
+
21
+ def register_question(text: Union[Mapping[str, str], str],
22
+ checkers: Union[Mapping[str, SingleLangCheckerTyping], MultiLangCheckerTyping],
23
+ name=Union[Mapping[str, str], str],
24
+ level: int = 1, default_lang='cn'):
25
+ if isinstance(checkers, collections.abc.Mapping):
26
+ _origin_checkers = checkers
27
+
28
+ def _integrated_checker(question_text: str, user_text: str, answer_text: str, lang: str):
29
+ return _origin_checkers[lang](question_text, user_text, answer_text)
30
+
31
+ checker: MultiLangCheckerTyping = _integrated_checker
32
+ else:
33
+ checker: MultiLangCheckerTyping = checkers
34
+
35
+ if isinstance(text, str):
36
+ texts = {default_lang: text}
37
+ else:
38
+ texts = text
39
+
40
+ if isinstance(name, str):
41
+ names = {default_lang: name}
42
+ else:
43
+ names = name
44
+
45
+ _KNOWN_PROBLEMS.append(Question(texts, checker, names, level))
46
+
47
+
48
+ def list_ordered_questions() -> List[Question]:
49
+ return [
50
+ problem for _, problem in
51
+ sorted(enumerate(_KNOWN_PROBLEMS), key=lambda x: (x[1].level, x[0]))
52
+ ]
requirements-dev.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ hbutils>=0.9.1
2
+ tqdm
3
+ requests>=2.20
4
+ gradio==4.1.1
5
+ openai>=1
6
+ zhipuai
7
+ sympy
8
+ flask
9
+ transformers
10
+ torch
11
+ huggingface-hub
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ hbutils>=0.9.1
2
+ tqdm
3
+ requests>=2.20
4
+ gradio==4.1.1
5
+ openai>=1
6
+ zhipuai
7
+ sympy