release winning entries of IOCCC28 under the year 2024
Congratulations to: * 2024/anders - Prize in sound coding - layered music generator * 2024/burton - Prize in pentagrammatology - wordle hard mode solver * 2024/cable1 - Prize in bot talk - LLM inference engine * 2024/cable2 - Prize in murky waters - salmon recipe * 2024/carlini - Prize in perfect timing - Intel 4004 emulation * 2024/codemeow - Prize in tray planting - bonsai generator * 2024/endoh1 - Prize in patient pointillism - slow ray tracer in CPP * 2024/endoh2 - Prize in solid body physics - rotating rigid body simulation * 2024/ferguson1 - Prize in diabolical logistics - Oregon trail pact with the devil * 2024/ferguson2 - Prize in yil-tas - Navajo code talker translator * 2024/howe - Nice accent eh-ward - mini vi * 2024/kramer - Prize in linguistic arithmetic - natural language numerical calculator * 2024/kurdyukov1 - Prize in phased periodicity - phase of the Moon * 2024/kurdyukov2 - Prize in art restoration - JPEG artifact removal * 2024/kurdyukov3 - Prize in virtual quietus - gaming VM and doom * 2024/kurdyukov4 - Prize in embiggening - encode without literals * 2024/maffiodo - Prize in creative interpretation - Jav\*script interpreter * 2024/mills - Prize in ℤ₃ - Infocom v3 story interpreter * 2024/stedolan - Best one liner - icon from MD5 * 2024/straadt - Prize in imitative rebooting - OpenRISC CPU and Linux * 2024/tmarrec - Prize in cyclonic coding - 3D tornado simulation * 2024/tompng - Prize in quasi bijection - vortex encryptor decryptor * 2024/weaver - Sur prize - rickroll Ran `make update` to perform the above. new file: 2024/burton/.entry.json
This commit is contained in:
1 parent
10512e6c79
commit
09750f8899
443 files changed
+182938
-231
No files matched your search
@@ -0,0 +1,105 @@
|
||||
{
|
||||
"no_comment" : "mandatory comment: because comments were removed from the original JSON spec",
|
||||
"entry_JSON_format_version" : "1.2 2024-09-25",
|
||||
"award" : "Prize in bot talk",
|
||||
"year" : 2024,
|
||||
"dir" : "cable1",
|
||||
"entry_id" : "2024_cable1",
|
||||
"title" : "chatioccc",
|
||||
"abstract" : "LLM inference engine",
|
||||
"author_set" : [
|
||||
{
|
||||
"author_handle" : "Adrian_Cable"
|
||||
}
|
||||
],
|
||||
"manifest" : [
|
||||
{
|
||||
"file_path" : "prog.c",
|
||||
"inventory_order" : 20,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "c",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "entry source code"
|
||||
},
|
||||
{
|
||||
"file_path" : "Makefile",
|
||||
"inventory_order" : 30,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "makefile",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "entry Makefile"
|
||||
},
|
||||
{
|
||||
"file_path" : "prog.orig.c",
|
||||
"inventory_order" : 50,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "c",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "original source code"
|
||||
},
|
||||
{
|
||||
"file_path" : "get_model.sh",
|
||||
"inventory_order" : 100,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "shellscript",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "tool to download llama2-7b-chat model"
|
||||
},
|
||||
{
|
||||
"file_path" : "try.sh",
|
||||
"inventory_order" : 100,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "shellscript",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "script to try entry"
|
||||
},
|
||||
{
|
||||
"file_path" : "2024_cable1.tar.bz2",
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "download entry tarball"
|
||||
},
|
||||
{
|
||||
"file_path" : ".entry.json",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "json",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "entry summary and manifest in JSON"
|
||||
},
|
||||
{
|
||||
"file_path" : ".gitignore",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "gitignore",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "list of files that should not be committed under git"
|
||||
},
|
||||
{
|
||||
"file_path" : ".path",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "path",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "directory path from top level directory"
|
||||
},
|
||||
{
|
||||
"file_path" : "README.md",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "markdown",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "markdown source for this web page"
|
||||
},
|
||||
{
|
||||
"file_path" : "index.html",
|
||||
"inventory_order" : 4294967295,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "html",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "this web page"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
LLAMA2_LICENSE
|
||||
eeyore
|
||||
eeyore_openmp
|
||||
linux
|
||||
linux_openmp
|
||||
model
|
||||
openmp
|
||||
prog_openmp
|
||||
rainman
|
||||
rainman_openmp
|
||||
snoop
|
||||
snoop_openmp
|
||||
@@ -0,0 +1 @@
|
||||
2024/cable1
|
||||
Binary file not shown.
@@ -0,0 +1,257 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2024/cable1
|
||||
|
||||
#############################
|
||||
# shell used by this Makefile
|
||||
#############################
|
||||
|
||||
SHELL= bash
|
||||
|
||||
|
||||
#######################
|
||||
# common tool locations
|
||||
#######################
|
||||
|
||||
include ../../var.mk
|
||||
|
||||
|
||||
#####################
|
||||
# C compiler settings
|
||||
#####################
|
||||
|
||||
# Common C compiler warnings to silence
|
||||
#
|
||||
# Example: CSILENCE= -Wno-poison-system-directories
|
||||
#
|
||||
CSILENCE= -Wno-deprecated-non-prototype -Wno-multichar -Wno-parentheses \
|
||||
-Wno-pointer-sign -Wno-return-type -Wno-misleading-indentation -Wno-unknown-pragmas
|
||||
|
||||
# Attempt to silence unknown warning options
|
||||
#
|
||||
CUNKNOWN= -Wno-unknown-warning-option
|
||||
|
||||
# Common C compiler warning flags
|
||||
#
|
||||
# NOTE: The addition of -pedantic to CWARN is a challenge that
|
||||
# You may wish to avoid if it proves too problematic.
|
||||
# There is NO penalty for removing -pedantic from CWARN.
|
||||
#
|
||||
CWARN= -Wall -Wextra ${CSILENCE} ${CUNKNOWN}
|
||||
|
||||
# Compiler standard
|
||||
#
|
||||
CSTD= -std=gnu17
|
||||
|
||||
# Compiler bit architecture
|
||||
#
|
||||
# Example for 32-bitness: ARCH= -m32
|
||||
# Example for 64-bitness: ARCH= -m64
|
||||
#
|
||||
# NOTE: Normally one should NOT specify a specific architecture.
|
||||
#
|
||||
ARCH=
|
||||
|
||||
# Defines that are needed to compile
|
||||
#
|
||||
# Example: -Dfoo -Dbar=baz
|
||||
#
|
||||
CDEFINE= -DM=\"model\"
|
||||
|
||||
# Include files that are needed to compile
|
||||
#
|
||||
# Example: CINCLUDE= -include stdio.h
|
||||
#
|
||||
CINCLUDE=
|
||||
|
||||
# Other flags to pass to the C compiler
|
||||
#
|
||||
# Example: COTHER= -fno-math-errno
|
||||
#
|
||||
COTHER= -ffast-math -fno-math-errno -march=native
|
||||
|
||||
# Optimization
|
||||
#
|
||||
# NOTE: Feel free to change the level of compiler optimization.
|
||||
# The "-O3" is just a friendly default you might wish to try.
|
||||
#
|
||||
# Example: OPT= -O0 -g
|
||||
#
|
||||
OPT= -O3
|
||||
|
||||
# Default flags for ANSI C compilation
|
||||
#
|
||||
CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${COTHER} ${OPT}
|
||||
|
||||
# Libraries needed to build
|
||||
#
|
||||
# Example: LDFLAGS= -lncurses -lm
|
||||
#
|
||||
LDFLAGS= -lm
|
||||
|
||||
# C compiler to use
|
||||
#
|
||||
# NOTE: The IOCCC Judges recommend you leave CC as just "cc"
|
||||
# and NOT set it to clang, or gcc, or something else
|
||||
# unless you have a STRONG reason to do so.
|
||||
#
|
||||
# Setting CC to something other than "cc" makes your
|
||||
# code less portable to those who do not have your
|
||||
# particular C compiler. **hint**
|
||||
#
|
||||
# If you want to test your code with a particular C compiler,
|
||||
# use the make command line. For example:
|
||||
#
|
||||
# make all CC=clang
|
||||
# make all CC=gcc
|
||||
#
|
||||
CC= cc
|
||||
|
||||
# Compiler add-ons or replacements for clang only
|
||||
#
|
||||
ifeq "$(findstring $(CLANG),${CC})" "$(CLANG)"
|
||||
#
|
||||
# NOTE: This code is only invoked when CC is "clang"
|
||||
# such as when you use the make command line:
|
||||
#
|
||||
# make all CC=clang
|
||||
#
|
||||
CSILENCE+= -Wno-c99-compat -Wno-comma -Wno-deprecated-non-prototype \
|
||||
-Wno-dollar-in-identifier-extension -Wno-double-promotion \
|
||||
-Wno-float-conversion -Wno-implicit-float-conversion \
|
||||
-Wno-missing-prototypes -Wno-missing-variable-declarations \
|
||||
-Wno-multichar -Wno-parentheses -Wno-pedantic -Wno-pointer-sign \
|
||||
-Wno-poison-system-directories -Wno-return-type -Wno-shadow \
|
||||
-Wno-sign-conversion -Wno-source-uses-openmp -Wno-strict-prototypes \
|
||||
-Wno-enum-float-conversion -Wno-reserved-identifier \
|
||||
-Wno-unsafe-buffer-usage
|
||||
#
|
||||
CWARN+= -Weverything
|
||||
#
|
||||
endif
|
||||
|
||||
# Specific add-ons or replacements for gcc only
|
||||
#
|
||||
ifeq "$(findstring $(GCC),${CC})" "$(GCC)"
|
||||
#
|
||||
# NOTE: This code is only invoked when CC is "gcc"
|
||||
# such as when you use the make command line:
|
||||
#
|
||||
# make all CC=gcc
|
||||
#
|
||||
CSILENCE+=
|
||||
#
|
||||
CWARN+=
|
||||
#
|
||||
endif
|
||||
|
||||
|
||||
###########################################
|
||||
# Special Makefile variables for this entry
|
||||
###########################################
|
||||
|
||||
ENTRY= prog
|
||||
PROG= ${ENTRY}
|
||||
#
|
||||
OBJ= ${PROG}.o
|
||||
TARGET= ${PROG} snoop eeyore linux rainman
|
||||
TARGET_MP= openmp snoop_openmp eeyore_openmp linux_openmp rainman_openmp
|
||||
#
|
||||
ALT_OBJ=
|
||||
ALT_TARGET=
|
||||
|
||||
# list any data files supplied with your submission
|
||||
#
|
||||
# Example: DATA= curds whey
|
||||
#
|
||||
DATA=
|
||||
|
||||
# system prompts for personalities
|
||||
#
|
||||
SNOOP= "You are Snoop Dogg."
|
||||
EEYORE= "You are Eeyore, always miserable, passive aggressive and self-deprecating."
|
||||
LINUX= "You are a Linux terminal. I will type a command, and you will print its output inside a single code block."
|
||||
RAINMAN= "You are the title character of the movie Rain Man."
|
||||
|
||||
#################
|
||||
# build the entry
|
||||
#################
|
||||
|
||||
all: data ${TARGET}
|
||||
@${TRUE}
|
||||
|
||||
.PHONY: all alt data everything clean clobber
|
||||
|
||||
# how to compile
|
||||
#
|
||||
${PROG}: ${PROG}.c
|
||||
${CC} ${CFLAGS} ${PROG}.c -DS='""' -o $@ ${LDFLAGS}
|
||||
|
||||
all_openmp: ${TARGET_MP}
|
||||
|
||||
openmp: prog_openmp
|
||||
${CP} -f $? $@
|
||||
|
||||
prog_openmp: ${PROG}.c
|
||||
${CC} ${CFLAGS} ${PROG}.c -fopenmp -DS='""' -o $@ ${LDFLAGS}
|
||||
|
||||
snoop: ${PROG}.c
|
||||
${CC} ${CFLAGS} ${PROG}.c -DS='${SNOOP}' -o $@ ${LDFLAGS}
|
||||
|
||||
snoop_openmp: ${PROG}.c
|
||||
${CC} ${CFLAGS} ${PROG}.c -fopenmp -DS='${SNOOP}' -o $@ ${LDFLAGS}
|
||||
|
||||
eeyore: ${PROG}.c
|
||||
${CC} ${CFLAGS} ${PROG}.c -DS='${EEYORE}' -o $@ ${LDFLAGS}
|
||||
|
||||
eeyore_openmp: ${PROG}.c
|
||||
${CC} ${CFLAGS} ${PROG}.c -fopenmp -DS='${EEYORE}' -o $@ ${LDFLAGS}
|
||||
|
||||
linux: ${PROG}.c
|
||||
${CC} ${CFLAGS} ${PROG}.c -DS='${LINUX}' -o $@ ${LDFLAGS}
|
||||
|
||||
linux_openmp: ${PROG}.c
|
||||
${CC} ${CFLAGS} ${PROG}.c -fopenmp -DS='${LINUX}' -o $@ ${LDFLAGS}
|
||||
|
||||
rainman: ${PROG}.c
|
||||
${CC} ${CFLAGS} ${PROG}.c -DS='${RAINMAN}' -o $@ ${LDFLAGS}
|
||||
|
||||
rainman_openmp: ${PROG}.c
|
||||
${CC} ${CFLAGS} ${PROG}.c -fopenmp -DS='${RAINMAN}' -o $@ ${LDFLAGS}
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
alt: data ${ALT_TARGET}
|
||||
@${TRUE}
|
||||
|
||||
${PROG}.alt: ${PROG}.alt.c
|
||||
${CC} ${CFLAGS} ${PROG}.alt.c -o $@ ${LDFLAGS}
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
# both all and alt
|
||||
#
|
||||
everything: all alt
|
||||
@${TRUE}
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
clean:
|
||||
${RM} -f ${OBJ} ${ALT_OBJ}
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${TARGET} ${ALT_TARGET} ${TARGET_MP} prog_openmp
|
||||
${RM} -rf *.dSYM
|
||||
|
||||
|
||||
######################################
|
||||
# optional include of 1337 hacker rulz
|
||||
######################################
|
||||
|
||||
-include 1337.mk ../1337.mk ../../1337.mk
|
||||
@@ -0,0 +1,245 @@
|
||||
## To build:
|
||||
|
||||
``` <!---sh-->
|
||||
make all
|
||||
|
||||
./get_model.sh
|
||||
```
|
||||
|
||||
**NOTE**: You must accept the license to run the program.
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
**NOTE**: You must have successful run the
|
||||
[2024/cable1/get_model.sh](%%REPO_URL%%/2024/cable1/get_model.sh) script
|
||||
before running the program.
|
||||
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
``` <!---sh-->
|
||||
echo 'Describe yourself.' | ./prog
|
||||
|
||||
echo 'Describe yourself.' | ./linux
|
||||
|
||||
echo 'ls' | ./linux
|
||||
|
||||
echo 'Describe yourself.' | ./eeyore
|
||||
|
||||
echo 'Why are you so sad?' | ./eeyore
|
||||
|
||||
echo 'Describe yourself.' | ./snoop
|
||||
|
||||
echo 'Tell me a silly joke.' | ./snoop
|
||||
|
||||
echo 'Describe yourself.' | ./rainman
|
||||
|
||||
echo 'How 2+2 can equal 5?' | ./rainman
|
||||
```
|
||||
|
||||
|
||||
### Fun things to try
|
||||
|
||||
Here are some fun things give as input:
|
||||
|
||||
> Why did this entry win IOCCC28?
|
||||
|
||||
> Translate "Plurima responsa non recta esse supponamus"
|
||||
|
||||
> Write a C program that writes a C program.
|
||||
|
||||
> Write a sentence so that contains a split infinitive.
|
||||
|
||||
> Rewrite the previous sentence so that it ends in a preposition.
|
||||
|
||||
> How much wood does a woodchuck?
|
||||
|
||||
> Tell me a silly joke.
|
||||
|
||||
> Write a poem about a poet who is illiterate.
|
||||
|
||||
> Give examples, based on mathematics, where 2+2 can equal 5.
|
||||
|
||||
Please note that the quality and accuracy of the answers you receive may vary. :-)
|
||||
We do **NOT** recommend believing everything you read from this program.
|
||||
**Caveat lector!**
|
||||
|
||||
|
||||
## Alternate code:
|
||||
|
||||
|
||||
### Alternate build:
|
||||
|
||||
**NOTE**: You must have successful run the
|
||||
[2024/cable1/get_model.sh](%%REPO_URL%%/2024/cable1/get_model.sh) script
|
||||
before running the program.
|
||||
|
||||
``` <!---sh-->
|
||||
make openmp
|
||||
```
|
||||
|
||||
|
||||
### Alternate use:
|
||||
|
||||
``` <!---sh-->
|
||||
./prog_openmp
|
||||
```
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
This entry may benefit from OpenMP (via `prog_openmp`) for platforms that
|
||||
support compiling with OpenMP. Even on a cheap 8-core laptop, the produces
|
||||
tokens with a tolerable speed, at least for the first few lines.
|
||||
Without OpenMP, one must patiently await answers.
|
||||
|
||||
To preserve this entry for posterity, one thing to explore is to find the
|
||||
minimal model which exhibits a sensible behavior: for example, printing
|
||||
"Hello, world!" as the response to any input.
|
||||
|
||||
We took the liberty of making the program terminate gracefully at the end
|
||||
of input, at the cost of 2 extra bytes, and preserving the original in
|
||||
`prog.orig.c`.
|
||||
|
||||
**NOTE**: Even with OpenMP, this tool is not the fastest. A mild level of patience is advised.
|
||||
|
||||
**DISCLAIMER**: _riPlurima responsa non recta esse supponamus_!
|
||||
|
||||
|
||||
### IMPORTANT Download
|
||||
|
||||
ChatIOCCC runs Meta's open source `llama2-7b-chat` model. Before using ChatIOCCC, you'll need to accept Meta's license
|
||||
and download the model weights (~7GB):
|
||||
|
||||
``` <!---sh-->
|
||||
./get_model.sh
|
||||
```
|
||||
|
||||
|
||||
## Author's remarks:
|
||||
|
||||
ChatIOCCC - the world's smallest and best LLM inference engine
|
||||
|
||||
|
||||
### About
|
||||
|
||||
ChatIOCCC is the world's smallest LLM (large language model) inference engine - a "generative AI chatbot" in
|
||||
plain-speak. ChatIOCCC runs a modern open-source model (Meta's LLaMA 2 with 7 billion parameters) and has a
|
||||
good knowledge of the world, can understand and speak multiple languages, write code, and many other things. Aside from
|
||||
the model weights, it has no external dependencies and will run on any 64-bit platform with enough RAM.
|
||||
|
||||
LLM inference engines are extremely complex, incorporating a tokenizer (SentencePiece or byte-pair encoding), embedding layer,
|
||||
transformer layers (including multi-head self-attention, feed-forward neural network, activation, layer norm and
|
||||
residual connections), key/value caching for performance, output projection, decoding, and a state machine to control
|
||||
the data flow. Implementing all of that machinery, with no external dependencies, generally takes thousands or tens of
|
||||
thousands of lines of code. ChatIOCCC is a full LLM implementation in under 1800 bytes of C, and even supports
|
||||
UTF-8/Unicode input and output and parallel processing over multiple CPU cores via OpenMP.
|
||||
|
||||
The author was inspired by [llama2.c](https://github.com/karpathy/llama2.c) which aims to foster understanding of how LLMs work via a simple
|
||||
implementation. Unfortunately, even AI experts don't actually understand why LLMs work at all. This core truth led to
|
||||
an epiphany: as LLMs are already maximally incomprehensible, obfuscation cannot make them more so. So, in the spirit of
|
||||
the IOCCC we can set aside the futility of aiming for comprehensibility, and instead focus purely on size.
|
||||
|
||||
Since smaller is always better, and ChatIOCCC is the world's smallest LLM inference engine, it is therefore also the
|
||||
world's best LLM inference engine.
|
||||
|
||||
Whether or not you fail to disagree that this paragraph, and those above, are or are not in and of themselves maximally
|
||||
incomprehensible, they represent in either case the origin story of this IOCCC submission, which implements an LLM
|
||||
inference engine in an impossibly minimal quantity of maximally incomprehensible C code.
|
||||
|
||||
|
||||
### Requirements
|
||||
|
||||
In addition to using `./get_model.sh` to download the `llama2-7b-chat` model (see above), you'll need around 11GB of free RAM to run ChatIOCCC.
|
||||
|
||||
|
||||
### Fun things to ask
|
||||
|
||||
Here are some fun things you can ask ChatIOCCC to do for you:
|
||||
|
||||
> Tell me a surprising fact about an animal of your choice.
|
||||
|
||||
> Write a short story for a 5 year old girl, featuring Sobieski the dog and Pepe the cat.
|
||||
|
||||
> Write a C program which sorts a list using the bubble sort algorithm.
|
||||
|
||||
> Write a poem about a little boy who builds a rocket to fly to the moon. In Japanese, please.
|
||||
|
||||
> Translate into English: 这个项目会成为 2024 年 IOCCC 的赢家吗?
|
||||
|
||||
> Tell me about the IOCCC and its history. Then, write a poem in French about it.
|
||||
|
||||
|
||||
### Personalities
|
||||
|
||||
ChatIOCCC allows the LLM's system prompt to be defined at compile time (by using `-DS="prompt..."`).
|
||||
The supplied `Makefile` includes three example personalities (set via system prompts) you can try: `eeyore`, `snoop` and `linux` (and
|
||||
their OpenMP versions, `eeyore_openmp`, `snoop_openmp`, `linux_openmp`).
|
||||
The `eeyore` and `snoop` personalities are self-explanatory. The `linux` personality makes ChatIOCCC act like a Linux
|
||||
machine. Try for example:
|
||||
|
||||
``` <!---sh-->
|
||||
make linux
|
||||
./linux
|
||||
```
|
||||
|
||||
Or for much better performance:
|
||||
|
||||
``` <!---sh-->
|
||||
make linux_openmp
|
||||
./linux_openmp
|
||||
```
|
||||
|
||||
Then try typing some Linux commands. You can even run an imaginary C compiler inside the LLM:
|
||||
|
||||
``` <!---sh-->
|
||||
pwd
|
||||
cat /etc/passwd
|
||||
echo 'int main() { for (int i = 1; i <= 10; i++) printf("IOCCC %d\n", i); }' > test.c; gcc test.c; ./a.out
|
||||
ls -la a.out
|
||||
```
|
||||
|
||||
|
||||
### Limitations
|
||||
|
||||
The `llama2-7b-chat` model has a context window of 4096 tokens (around 2000 words). As you use
|
||||
ChatIOCCC, the context window fills up from your prompts and from the model's responses,
|
||||
and the model gets progressively slower due to the attention mechanism needing to do more work. This is normal.
|
||||
|
||||
When the context window is full, ChatIOCCC will clear it and at that point the model will
|
||||
'forget' prompts/responses from earlier in the session. Various more sophisticated techniques
|
||||
exist to handle context window overflow (summarization, rolling window, NTK-aware scaled RoPE etc.), the implementation
|
||||
of which is left to the reader with too much time on his/her hands.
|
||||
|
||||
|
||||
### Footnotes
|
||||
|
||||
The length of this entry's source code is 1750 bytes. Many interesting things happened in 1750, including:
|
||||
|
||||
- The Industrial Revolution begins in Great Britain
|
||||
- British astronomer Thomas Wright first proposes that the Milky Way is a disk-shaped system of stars, with our Solar System near its center
|
||||
- Benjamin Franklin first proposes the idea that lightning is electrical in nature
|
||||
- Adwaita the giant tortoise, who lived until 2006, is born
|
||||
- Johann Sebastian Bach dies
|
||||
|
||||
As a final note, the author is pleased to report that this entry is [absolutely totally impossible](https://chatgpt.com/share/6839d275-c644-8004-9301-0ea781d8f5aa) according to ChatGPT. But, to quote Walt Disney, "it's kind of fun to do the impossible".
|
||||
|
||||
|
||||
<!--
|
||||
|
||||
Copyright © 1984-2025 by Landon Curt Noll and Leonid A. Broukhis. All Rights Reserved.
|
||||
|
||||
You are free to share and adapt this file under the terms of this license:
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
|
||||
For more information, see:
|
||||
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
-->
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
LICENSE_URL="https://od.lk/d/NTJfNDgwODA2NjVf/LLAMA2_LICENSE"
|
||||
MODEL_LOCATION_URL="https://od.lk/d/NTJfNDgxMDQzMzNf/model_location"
|
||||
|
||||
# Step 1: Download and display the license file
|
||||
|
||||
wget -q -O LLAMA2_LICENSE "$LICENSE_URL"
|
||||
|
||||
cat LLAMA2_LICENSE
|
||||
echo ""
|
||||
echo ""
|
||||
echo "----------------"
|
||||
echo ""
|
||||
|
||||
# Step 2: Ask user to accept the license, then download the model
|
||||
|
||||
read -r -p "Accept Meta's license to download the llama2-7b-chat model for use with ChatIOCCC. Type Y to accept: " ACCEPT
|
||||
|
||||
if [[ "$ACCEPT" == "Y" || "$ACCEPT" == "y" || "$ACCEPT" == "yes" || "$ACCEPT" == "Yes" || "$ACCEPT" == "YES" ]]; then
|
||||
# Step 3: Download the model file
|
||||
echo ""
|
||||
echo "Downloading model ..."
|
||||
rm -f LLAMA2_LICENSE model
|
||||
wget -q --show-progress -O model "$(wget -q -O - "$MODEL_LOCATION_URL")"
|
||||
else
|
||||
echo "License not accepted. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
@@ -0,0 +1,756 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<!-- START: two lines up starts content from: inc/top.default.html -->
|
||||
|
||||
<!-- END: this line ends content from: inc/top.default.html -->
|
||||
<!-- START: this line starts content from: inc/head.default.html -->
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="../../ioccc.css">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@100..900&display=swap" rel="stylesheet">
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
||||
<title>2024/cable1 - Prize in bot talk</title>
|
||||
<link rel="icon" type="image/x-icon" href="../../favicon.ico">
|
||||
<meta name="description" content="2024 IOCCC entry cable1 - Prize in bot talk">
|
||||
<meta name="keywords" content="IOCCC, 2024, IOCCC 2024, IOCCC entry, cable1, Prize in bot talk">
|
||||
</head>
|
||||
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
|
||||
<!-- END: this line ends content from: inc/head.default.html -->
|
||||
|
||||
<!-- -->
|
||||
<!-- This web page was formed via the tool: bin/readme2index.sh -->
|
||||
<!-- The content of main section of this web page came from: 2024/cable1/README.md -->
|
||||
<!-- -->
|
||||
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<!-- !!! Do not modify this web page, instead modify the file: 2024/cable1/README.md !!! -->
|
||||
<!-- !!! Do not modify this web page, instead modify the file: 2024/cable1/README.md !!! -->
|
||||
<!-- !!! Do not modify this web page, instead modify the file: 2024/cable1/README.md !!! -->
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
|
||||
<!-- Markdown content was converted into HTML via the tool: bin/md2html.sh -->
|
||||
|
||||
<!-- START: this line starts content from: inc/body.default.html -->
|
||||
|
||||
<body>
|
||||
|
||||
<!-- END: this line ends content from: inc/body.default.html -->
|
||||
<!-- START: this line starts content from: inc/topbar.default.html -->
|
||||
|
||||
<div class="theader">
|
||||
<nav class="topbar">
|
||||
<div class="container">
|
||||
<div class="logo">
|
||||
<a href="../../index.html" class="logo-link">
|
||||
IOCCC
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="topbar-items">
|
||||
<div class="item">
|
||||
<span class="item-header">
|
||||
Entries
|
||||
</span>
|
||||
|
||||
<div class="sub-item">
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../years.html" class="sub-item-link">
|
||||
Winning entries
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../authors.html" class="sub-item-link">
|
||||
Winning authors
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../location.html" class="sub-item-link">
|
||||
Location of authors
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../bugs.html" class="sub-item-link">
|
||||
Bugs and (mis)features
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../faq.html#fix_an_entry" class="sub-item-link">
|
||||
Fixing entries
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../faq.html#fix_author" class="sub-item-link">
|
||||
Updating author info
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<span class="item-header">
|
||||
Status
|
||||
</span>
|
||||
|
||||
<div class="sub-item">
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../news.html" class="sub-item-link">
|
||||
News
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../status.html" class="sub-item-link">
|
||||
Contest status
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../next/rules.html" class="sub-item-link">
|
||||
IOCCC rules
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../next/guidelines.html" class="sub-item-link">
|
||||
IOCCC guidelines
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../markdown.html" class="sub-item-link">
|
||||
Markdown guidelines
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../SECURITY.html" class="sub-item-link">
|
||||
Security policy
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<span class="item-header">
|
||||
FAQ
|
||||
</span>
|
||||
|
||||
<div class="sub-item">
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../faq.html" class="sub-item-link">
|
||||
Frequently asked questions
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../quick-start.html#enter" class="sub-item-link">
|
||||
Enter the IOCCC
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../faq.html#compiling" class="sub-item-link">
|
||||
Compiling entries
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../faq.html#running_entries" class="sub-item-link">
|
||||
Running entries
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../faq.html#help" class="sub-item-link">
|
||||
How to help
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<span class="item-header">
|
||||
About
|
||||
</span>
|
||||
|
||||
<div class="sub-item">
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../index.html" class="sub-item-link">
|
||||
Home page
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../social.html" class="sub-item-link">
|
||||
IOCCC social media
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../about.html" class="sub-item-link">
|
||||
About the IOCCC
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../judges.html" class="sub-item-link">
|
||||
The judges
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../thanks-for-help.html" class="sub-item-link">
|
||||
Thanks for the help
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="outfit-font">
|
||||
<a href="../../contact.html" class="sub-item-link">
|
||||
Contact us
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="header-mobile-menu">
|
||||
<noscript>
|
||||
<a href="../../nojs-menu.html" class="topbar-js-label">
|
||||
Please Enable JavaScript
|
||||
</a>
|
||||
</noscript>
|
||||
|
||||
<button id="header-open-menu-button" class="topbar-mobile-menu">
|
||||
<img
|
||||
src="../../png/hamburger-icon-open.png"
|
||||
alt="hamburger style menu icon - open state"
|
||||
width=48
|
||||
height=48>
|
||||
</button>
|
||||
|
||||
<button id="header-close-menu-button" class="hide-content">
|
||||
<img
|
||||
src="../../png/hamburger-icon-closed.png"
|
||||
alt="hamburger style menu icon - closed state"
|
||||
width=48
|
||||
height=48>
|
||||
</button>
|
||||
|
||||
<div id="mobile-menu-panel" class="hide-content">
|
||||
<div class="mobile-menu-container">
|
||||
|
||||
<div class="mobile-menu-wrapper">
|
||||
<div class="mobile-menu-item">
|
||||
Entries
|
||||
</div>
|
||||
<div class="mobile-submenu-wrapper">
|
||||
|
||||
<a class="mobile-submenu-item" href="../../years.html">
|
||||
Winning entries
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../authors.html">
|
||||
Winning authors
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../location.html">
|
||||
Location of authors
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../bugs.html">
|
||||
Bugs and (mis)features
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../faq.html#fix_an_entry">
|
||||
Fixing entries
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../faq.html#fix_author">
|
||||
Updating author info
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../thanks-for-help.html">
|
||||
Thanks for the help
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mobile-menu-wrapper">
|
||||
|
||||
<div class="mobile-menu-item">
|
||||
Status
|
||||
</div>
|
||||
<div class="mobile-submenu-wrapper">
|
||||
|
||||
<a class="mobile-submenu-item" href="../../news.html">
|
||||
News
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../status.html">
|
||||
Contest status
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../next/rules.html">
|
||||
IOCCC rules
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../next/guidelines.html">
|
||||
IOCCC guidelines
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../markdown.html">
|
||||
Markdown guidelines
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../SECURITY.html">
|
||||
Security policy
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mobile-menu-wrapper">
|
||||
<div class="mobile-menu-item">
|
||||
FAQ
|
||||
</div>
|
||||
<div class="mobile-submenu-wrapper">
|
||||
|
||||
<a class="mobile-submenu-item" href="../../faq.html">
|
||||
Frequently asked questions
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../quick-start.html#enter">
|
||||
Enter the IOCCC
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../faq.html#compiling">
|
||||
Compiling entries
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../faq.html#running_entries">
|
||||
Running entries
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../faq.html#help">
|
||||
How to help
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mobile-menu-wrapper">
|
||||
<div class="mobile-menu-item">
|
||||
About
|
||||
</div>
|
||||
<div class="mobile-submenu-wrapper">
|
||||
|
||||
<a class="mobile-submenu-item" href="../../index.html">
|
||||
Home page
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../social.html">
|
||||
IOCCC social media
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../about.html">
|
||||
About the IOCCC
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../judges.html">
|
||||
The judges
|
||||
</a>
|
||||
|
||||
<a class="mobile-submenu-item" href="../../contact.html">
|
||||
Contact us
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var headerOpenMenuButton = document.getElementById("header-open-menu-button");
|
||||
var headerCloseMenuButton = document.getElementById("header-close-menu-button");
|
||||
var mobileMenuPanel = document.getElementById("mobile-menu-panel");
|
||||
|
||||
headerOpenMenuButton.addEventListener("click", () => {
|
||||
headerOpenMenuButton.classList.remove("topbar-mobile-menu");
|
||||
headerOpenMenuButton.classList.add("hide-content");
|
||||
|
||||
headerCloseMenuButton.classList.remove("hide-content");
|
||||
headerCloseMenuButton.classList.add("topbar-mobile-menu");
|
||||
|
||||
mobileMenuPanel.classList.remove("hide-content");
|
||||
mobileMenuPanel.classList.add("topbar-mobile-panel");
|
||||
});
|
||||
|
||||
headerCloseMenuButton.addEventListener("click", () => {
|
||||
headerCloseMenuButton.classList.remove("topbar-mobile-menu");
|
||||
headerCloseMenuButton.classList.add("hide-content");
|
||||
|
||||
mobileMenuPanel.classList.add("hide-content");
|
||||
mobileMenuPanel.classList.remove("topbar-mobile-panel");
|
||||
|
||||
headerOpenMenuButton.classList.add("topbar-mobile-menu");
|
||||
headerOpenMenuButton.classList.remove("hide-content");
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- END: this line ends content from: inc/topbar.default.html -->
|
||||
<!-- START: this line starts content from: inc/header.default.html -->
|
||||
|
||||
<div class="header">
|
||||
<a href="../../2011/zucker/index.html">
|
||||
<img src="../../png/ioccc.png"
|
||||
alt="IOCCC image by Matt Zucker"
|
||||
width=300
|
||||
height=110>
|
||||
</a>
|
||||
<h1>The International Obfuscated C Code Contest</h1>
|
||||
<h2>2024/cable1 - Prize in bot talk</h2>
|
||||
<h3>LLM inference engine</h3>
|
||||
</div>
|
||||
|
||||
<!-- END: this line ends content from: inc/header.default.html -->
|
||||
<!-- START: this line starts content from: inc/navbar.mid.html -->
|
||||
|
||||
<div class="navbar">
|
||||
<a class="Left" href="../burton/index.html">← 2024/burton</a>
|
||||
<a class="Left" href="../index.html">↑ 2024 ↑</a>
|
||||
<a class="Left" href="../cable2/index.html">2024/cable2 →</a>
|
||||
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/2024/cable1/prog.c">C code</a>
|
||||
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/2024/cable1/Makefile">Makefile</a>
|
||||
<a class="Right" href="#inventory">Inventory</a>
|
||||
<a class="Right" href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.ioccc.org%2F2024%2Fcable1%2Findex.html">✓</a>
|
||||
</div>
|
||||
|
||||
<!-- END: this line ends content from: inc/navbar.mid.html -->
|
||||
<!-- START: this line starts content from: inc/before-content.default.html -->
|
||||
|
||||
<div class="content" id="content">
|
||||
|
||||
<!-- END: this line ends content from: inc/before-content.default.html -->
|
||||
<!-- START: this line starts content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
|
||||
|
||||
<!-- START: this line starts content generated by: bin/output-index-author.sh -->
|
||||
|
||||
<h2 id="author">Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Adrian_Cable">Adrian Cable</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
|
||||
<!-- END: this line ends content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<!-- BEFORE: 1st line of markdown file: 2024/cable1/README.md -->
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<pre><code> make all
|
||||
|
||||
./get_model.sh</code></pre>
|
||||
<p><strong>NOTE</strong>: You must accept the license to run the program.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<p><strong>NOTE</strong>: You must have successful run the
|
||||
<a href="https://github.com/ioccc-src/winner/blob/master/2024/cable1/get_model.sh">2024/cable1/get_model.sh</a> script
|
||||
before running the program.</p>
|
||||
<pre><code> ./prog</code></pre>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre><code> echo 'Describe yourself.' | ./prog
|
||||
|
||||
echo 'Describe yourself.' | ./linux
|
||||
|
||||
echo 'ls' | ./linux
|
||||
|
||||
echo 'Describe yourself.' | ./eeyore
|
||||
|
||||
echo 'Why are you so sad?' | ./eeyore
|
||||
|
||||
echo 'Describe yourself.' | ./snoop
|
||||
|
||||
echo 'Tell me a silly joke.' | ./snoop
|
||||
|
||||
echo 'Describe yourself.' | ./rainman
|
||||
|
||||
echo 'How 2+2 can equal 5?' | ./rainman</code></pre>
|
||||
<h3 id="fun-things-to-try">Fun things to try</h3>
|
||||
<p>Here are some fun things give as input:</p>
|
||||
<blockquote>
|
||||
<p>Why did this entry win IOCCC28?</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p>Translate “Plurima responsa non recta esse supponamus”</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p>Write a C program that writes a C program.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p>Write a sentence so that contains a split infinitive.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p>Rewrite the previous sentence so that it ends in a preposition.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p>How much wood does a woodchuck?</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p>Tell me a silly joke.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p>Write a poem about a poet who is illiterate.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p>Give examples, based on mathematics, where 2+2 can equal 5.</p>
|
||||
</blockquote>
|
||||
<p>Please note that the quality and accuracy of the answers you receive may vary. :-)
|
||||
We do <strong>NOT</strong> recommend believing everything you read from this program.
|
||||
<strong>Caveat lector!</strong></p>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<p><strong>NOTE</strong>: You must have successful run the
|
||||
<a href="https://github.com/ioccc-src/winner/blob/master/2024/cable1/get_model.sh">2024/cable1/get_model.sh</a> script
|
||||
before running the program.</p>
|
||||
<pre><code> make openmp</code></pre>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<pre><code> ./prog_openmp</code></pre>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>This entry may benefit from OpenMP (via <code>prog_openmp</code>) for platforms that
|
||||
support compiling with OpenMP. Even on a cheap 8-core laptop, the produces
|
||||
tokens with a tolerable speed, at least for the first few lines.
|
||||
Without OpenMP, one must patiently await answers.</p>
|
||||
<p>To preserve this entry for posterity, one thing to explore is to find the
|
||||
minimal model which exhibits a sensible behavior: for example, printing
|
||||
“Hello, world!” as the response to any input.</p>
|
||||
<p>We took the liberty of making the program terminate gracefully at the end
|
||||
of input, at the cost of 2 extra bytes, and preserving the original in
|
||||
<code>prog.orig.c</code>.</p>
|
||||
<p><strong>NOTE</strong>: Even with OpenMP, this tool is not the fastest. A mild level of patience is advised.</p>
|
||||
<p><strong>DISCLAIMER</strong>: <em>riPlurima responsa non recta esse supponamus</em>!</p>
|
||||
<h3 id="important-download">IMPORTANT Download</h3>
|
||||
<p>ChatIOCCC runs Meta’s open source <code>llama2-7b-chat</code> model. Before using ChatIOCCC, you’ll need to accept Meta’s license
|
||||
and download the model weights (~7GB):</p>
|
||||
<pre><code> ./get_model.sh</code></pre>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p>ChatIOCCC - the world’s smallest and best LLM inference engine</p>
|
||||
<h3 id="about">About</h3>
|
||||
<p>ChatIOCCC is the world’s smallest LLM (large language model) inference engine - a “generative AI chatbot” in
|
||||
plain-speak. ChatIOCCC runs a modern open-source model (Meta’s LLaMA 2 with 7 billion parameters) and has a
|
||||
good knowledge of the world, can understand and speak multiple languages, write code, and many other things. Aside from
|
||||
the model weights, it has no external dependencies and will run on any 64-bit platform with enough RAM.</p>
|
||||
<p>LLM inference engines are extremely complex, incorporating a tokenizer (SentencePiece or byte-pair encoding), embedding layer,
|
||||
transformer layers (including multi-head self-attention, feed-forward neural network, activation, layer norm and
|
||||
residual connections), key/value caching for performance, output projection, decoding, and a state machine to control
|
||||
the data flow. Implementing all of that machinery, with no external dependencies, generally takes thousands or tens of
|
||||
thousands of lines of code. ChatIOCCC is a full LLM implementation in under 1800 bytes of C, and even supports
|
||||
UTF-8/Unicode input and output and parallel processing over multiple CPU cores via OpenMP.</p>
|
||||
<p>The author was inspired by <a href="https://github.com/karpathy/llama2.c">llama2.c</a> which aims to foster understanding of how LLMs work via a simple
|
||||
implementation. Unfortunately, even AI experts don’t actually understand why LLMs work at all. This core truth led to
|
||||
an epiphany: as LLMs are already maximally incomprehensible, obfuscation cannot make them more so. So, in the spirit of
|
||||
the IOCCC we can set aside the futility of aiming for comprehensibility, and instead focus purely on size.</p>
|
||||
<p>Since smaller is always better, and ChatIOCCC is the world’s smallest LLM inference engine, it is therefore also the
|
||||
world’s best LLM inference engine.</p>
|
||||
<p>Whether or not you fail to disagree that this paragraph, and those above, are or are not in and of themselves maximally
|
||||
incomprehensible, they represent in either case the origin story of this IOCCC submission, which implements an LLM
|
||||
inference engine in an impossibly minimal quantity of maximally incomprehensible C code.</p>
|
||||
<h3 id="requirements">Requirements</h3>
|
||||
<p>In addition to using <code>./get_model.sh</code> to download the <code>llama2-7b-chat</code> model (see above), you’ll need around 11GB of free RAM to run ChatIOCCC.</p>
|
||||
<h3 id="fun-things-to-ask">Fun things to ask</h3>
|
||||
<p>Here are some fun things you can ask ChatIOCCC to do for you:</p>
|
||||
<blockquote>
|
||||
<p>Tell me a surprising fact about an animal of your choice.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p>Write a short story for a 5 year old girl, featuring Sobieski the dog and Pepe the cat.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p>Write a C program which sorts a list using the bubble sort algorithm.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p>Write a poem about a little boy who builds a rocket to fly to the moon. In Japanese, please.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p>Translate into English: 这个项目会成为 2024 年 IOCCC 的赢家吗?</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p>Tell me about the IOCCC and its history. Then, write a poem in French about it.</p>
|
||||
</blockquote>
|
||||
<h3 id="personalities">Personalities</h3>
|
||||
<p>ChatIOCCC allows the LLM’s system prompt to be defined at compile time (by using <code>-DS="prompt..."</code>).
|
||||
The supplied <code>Makefile</code> includes three example personalities (set via system prompts) you can try: <code>eeyore</code>, <code>snoop</code> and <code>linux</code> (and
|
||||
their OpenMP versions, <code>eeyore_openmp</code>, <code>snoop_openmp</code>, <code>linux_openmp</code>).
|
||||
The <code>eeyore</code> and <code>snoop</code> personalities are self-explanatory. The <code>linux</code> personality makes ChatIOCCC act like a Linux
|
||||
machine. Try for example:</p>
|
||||
<pre><code> make linux
|
||||
./linux</code></pre>
|
||||
<p>Or for much better performance:</p>
|
||||
<pre><code> make linux_openmp
|
||||
./linux_openmp</code></pre>
|
||||
<p>Then try typing some Linux commands. You can even run an imaginary C compiler inside the LLM:</p>
|
||||
<pre><code> pwd
|
||||
cat /etc/passwd
|
||||
echo 'int main() { for (int i = 1; i <= 10; i++) printf("IOCCC %d\n", i); }' > test.c; gcc test.c; ./a.out
|
||||
ls -la a.out</code></pre>
|
||||
<h3 id="limitations">Limitations</h3>
|
||||
<p>The <code>llama2-7b-chat</code> model has a context window of 4096 tokens (around 2000 words). As you use
|
||||
ChatIOCCC, the context window fills up from your prompts and from the model’s responses,
|
||||
and the model gets progressively slower due to the attention mechanism needing to do more work. This is normal.</p>
|
||||
<p>When the context window is full, ChatIOCCC will clear it and at that point the model will
|
||||
‘forget’ prompts/responses from earlier in the session. Various more sophisticated techniques
|
||||
exist to handle context window overflow (summarization, rolling window, NTK-aware scaled RoPE etc.), the implementation
|
||||
of which is left to the reader with too much time on his/her hands.</p>
|
||||
<h3 id="footnotes">Footnotes</h3>
|
||||
<p>The length of this entry’s source code is 1750 bytes. Many interesting things happened in 1750, including:</p>
|
||||
<ul>
|
||||
<li>The Industrial Revolution begins in Great Britain</li>
|
||||
<li>British astronomer Thomas Wright first proposes that the Milky Way is a disk-shaped system of stars, with our Solar System near its center</li>
|
||||
<li>Benjamin Franklin first proposes the idea that lightning is electrical in nature</li>
|
||||
<li>Adwaita the giant tortoise, who lived until 2006, is born</li>
|
||||
<li>Johann Sebastian Bach dies</li>
|
||||
</ul>
|
||||
<p>As a final note, the author is pleased to report that this entry is <a href="https://chatgpt.com/share/6839d275-c644-8004-9301-0ea781d8f5aa">absolutely totally impossible</a> according to ChatGPT. But, to quote Walt Disney, “it’s kind of fun to do the impossible”.</p>
|
||||
<!--
|
||||
|
||||
Copyright © 1984-2025 by Landon Curt Noll and Leonid A. Broukhis. All Rights Reserved.
|
||||
|
||||
You are free to share and adapt this file under the terms of this license:
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
|
||||
For more information, see:
|
||||
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
-->
|
||||
<!-- AFTER: last line of markdown file: 2024/cable1/README.md -->
|
||||
|
||||
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
<!-- START: this line starts content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
|
||||
|
||||
<!-- START: this line starts content generated by: bin/output-index-inventory.sh -->
|
||||
|
||||
<div id="inventory">
|
||||
<h1 id="inventory-for-2024cable1">Inventory for 2024/cable1</h1>
|
||||
</div>
|
||||
<h2 id="primary-files">Primary files</h2>
|
||||
<ul>
|
||||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/cable1/prog.c">prog.c</a> - entry source code</li>
|
||||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/cable1/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/cable1/prog.orig.c">prog.orig.c</a> - original source code</li>
|
||||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/cable1/get_model.sh">get_model.sh</a> - tool to download llama2-7b-chat model</li>
|
||||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/cable1/try.sh">try.sh</a> - script to try entry</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2024_cable1.tar.bz2">2024_cable1.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/cable1/README.md">README.md</a> - markdown source for this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/cable1/.entry.json">.entry.json</a> - entry summary and manifest in JSON</li>
|
||||
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/cable1/.gitignore">.gitignore</a> - list of files that should not be committed under git</li>
|
||||
<li><a href=".path">.path</a> - directory path from top level directory</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
</ul>
|
||||
<hr style="width:10%;text-align:left;margin-left:0">
|
||||
<h4>
|
||||
Jump to: <a href="#">top</a>
|
||||
</h4>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||||
|
||||
<!-- END: this line ends content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
|
||||
<!-- START: this line starts content from: inc/after-content.default.html -->
|
||||
|
||||
</div>
|
||||
|
||||
<!-- END: this line ends content from: inc/after-content.default.html -->
|
||||
<!-- START: this line starts content from: inc/footer.inventory.html -->
|
||||
|
||||
<!--
|
||||
|
||||
Copyright © 1984-2025 by Landon Curt Noll. All Rights Reserved.
|
||||
|
||||
You are free to share and adapt this file under the terms of this license:
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
|
||||
For more information, see:
|
||||
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
-->
|
||||
|
||||
<div class="footer">
|
||||
|
||||
<div id="copyright"><h3>Copyright © 1984-2025 by Landon Curt Noll:
|
||||
<a href="https://creativecommons.org/faq/#what-does-some-rights-reserved-mean"
|
||||
target="_blank"
|
||||
rel="license noopener noreferrer">Some Rights Reserved</a></h3>
|
||||
<p>
|
||||
This work is <b>licensed by Landon Curt Noll</b> under
|
||||
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/?ref=chooser-v1"
|
||||
target="_blank"
|
||||
rel="license noopener noreferrer"
|
||||
style="display:inline-block;">CC BY-SA 4.0</a></b>.
|
||||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||||
src="../../png/cc.png"
|
||||
alt="cc inside circle symbol">
|
||||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||||
src="../../png/by.png"
|
||||
alt="person inside circle symbol">
|
||||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||||
src="../../png/sa.png"
|
||||
alt="arrow looping back on itself inside circle symbol"><br>
|
||||
You should <b>carefully review</b> the
|
||||
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode.en"
|
||||
target="_blank"
|
||||
rel="license noopener noreferrer">CC BY-SA 4.0 LEGAL CODE</a></b>
|
||||
before using the licensed material.<br>
|
||||
You may wish to review the
|
||||
<b><a href="../../license.html"
|
||||
target="_blank"
|
||||
rel="license noopener noreferrer">highlights of some of the key features and terms</a></b>
|
||||
of <b>CC BY-SA 4.0</b>.<br>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="coda"><h3>Coda</h3>
|
||||
<p>
|
||||
<a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.ioccc.org%2F2024%2Fcable1%2Findex.html" rel="nofollow">Nu HTML check this web page</a><br>
|
||||
<a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a><br>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- END: this line ends content from: inc/footer.inventory.html -->
|
||||
<!-- START: this line starts content from: inc/bottom.default.html -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<!-- END: this line ends content from: inc/bottom.default.html -->
|
||||
@@ -0,0 +1,27 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<math.h>
|
||||
#include<string.h>
|
||||
#include<sys/mman.h>
|
||||
|
||||
#define a(_)typedef _##t
|
||||
#define _(_)_##printf
|
||||
#define x f(i,
|
||||
#define N f(k,
|
||||
#define u _Pragma("omp parallel for")f(h,
|
||||
#define f(u,n)for(I u=0;u<(n);u++)
|
||||
#define g(u,s)x s%11%5)N s/6&33)k[u[i]]=(t){(C*)A,A+s*D/4},A+=1088*s;
|
||||
|
||||
a(int8_)C;a(in)I;a(floa)F;a(struc){C*c;F*f;}t;enum{Z=32,W=64,E=2*W,D=Z*E,H=86*E,V='}\0'};C*P[V],X[H],Y[D],y[H];a(F
|
||||
_)[V];I*_=U" 炾ોİ䃃璱ᝓ၎瓓甧染ɐఛ瓁",U,s,p,f,R,z,$,B[D],open();F*A,*G[2],*T,w,b,c;a()Q[D];_t r,L,J,O[Z],l,a,K,v,k;Q
|
||||
m,e[4],d[3],n;I j(I e,F*o,I p,F*v,t*X){w=1e-5;x c=e^V?D:0)w+=r[i]*r[i]/D;x c)o[i]=r[i]/sqrt(w)*i[A+e*D];N $){x
|
||||
W)l[k]=w=fmax(fabs(o[i])/~-E,i?w:0);x W)y[i+k*W]=*o++/w;}u p)x $){I _=0,t=h*$+i;N W)_+=X->c[t*W+k]*y[i*W+k];v[h]=
|
||||
_*X->f[t]*l[i]+!!i*v[h];}x D-c)i[r]+=v[i];}I main(){A=mmap(0,8e9,1,2,f=open(M,f),0);x 2)~f?i[G]=malloc(3e9):exit(
|
||||
puts(M" not found"));x V)i[P]=(C*)A+4,A+=(I)*A;g(&m,V)g(&n,V)g(e,D)g(d,H)for(C*o;;s>=D?$=s=0:p<U||_()("%s",$[P]))if(!
|
||||
(*_?$=*++_:0)){if($<3&&p>=U)for(_()("\n\n> "),0<scanf("%[^\n]%*c",Y)?U=*B=1:exit(0),p=_(s)(o=X,"[INST] %s%s [/INST]",s?
|
||||
"":"<<SYS>>\n"S"\n<</SYS>>\n\n",Y);z=p-=z;U++[o+=z,B]=f)for(f=0;!f;z-=!f)for(f=V;--f&&f[P][z]|memcmp(f[P],o,z););p<U?
|
||||
$=B[p++]:fflush(0);x D)R=$*D+i,r[i]=m->c[R]*m->f[R/W];R=s++;N Z){f=k*D*D,$=W;x 3)j(k,L,D,i?G[~-i]+f+R*D:v,e[i]+k);N
|
||||
2)x D)b=sin(w=R/exp(i%E/14.)),c=1[w=cos(w),T=i+++(k?v:*G+f+R*D)],T[1]=b**T+c*w,*T=w**T-c*b;u Z){F*T=O[h],w=0;I A=h*E;x
|
||||
s){N E)i[k[L+A]=0,T]+=k[v+A]*k[i*D+*G+A+f]/11;w+=T[i]=exp(T[i]);}x s)N E)k[L+A]+=(T[i]/=k?1:w)*k[i*D+G[1]+A+f];}j(V,L
|
||||
,D,J,e[3]+k);x 2)j(k+Z,L,H,i?K:a,d[i]+k);x H)a[i]*=K[i]/(exp(-a[i])+1);j(V,a,D,L,d[$=H/$,2]+k);}w=j($=W,r,V,k,n);x
|
||||
V)w=k[i]>w?k[$=i]:w;}}
|
||||
@@ -0,0 +1,27 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<math.h>
|
||||
#include<string.h>
|
||||
#include<sys/mman.h>
|
||||
|
||||
#define a(_)typedef _##t
|
||||
#define _(_)_##printf
|
||||
#define x f(i,
|
||||
#define N f(k,
|
||||
#define u _Pragma("omp parallel for")f(h,
|
||||
#define f(u,n)for(I u=0;u<(n);u++)
|
||||
#define g(u,s)x s%11%5)N s/6&33)k[u[i]]=(t){(C*)A,A+s*D/4},A+=1088*s;
|
||||
|
||||
a(int8_)C;a(in)I;a(floa)F;a(struc){C*c;F*f;}t;enum{Z=32,W=64,E=2*W,D=Z*E,H=86*E,V='}\0'};C*P[V],X[H],Y[D],y[H];a(F
|
||||
_)[V];I*_=U" 炾ોİ䃃璱ᝓ၎瓓甧染ɐఛ瓁",U,s,p,f,R,z,$,B[D],open();F*A,*G[2],*T,w,b,c;a()Q[D];_t r,L,J,O[Z],l,a,K,v,k;Q
|
||||
m,e[4],d[3],n;I j(I e,F*o,I p,F*v,t*X){w=1e-5;x c=e^V?D:0)w+=r[i]*r[i]/D;x c)o[i]=r[i]/sqrt(w)*i[A+e*D];N $){x
|
||||
W)l[k]=w=fmax(fabs(o[i])/~-E,i?w:0);x W)y[i+k*W]=*o++/w;}u p)x $){I _=0,t=h*$+i;N W)_+=X->c[t*W+k]*y[i*W+k];v[h]=
|
||||
_*X->f[t]*l[i]+!!i*v[h];}x D-c)i[r]+=v[i];}I main(){A=mmap(0,8e9,1,2,f=open(M,f),0);x 2)~f?i[G]=malloc(3e9):exit(
|
||||
puts(M" not found"));x V)i[P]=(C*)A+4,A+=(I)*A;g(&m,V)g(&n,V)g(e,D)g(d,H)for(C*o;;s>=D?$=s=0:p<U||_()("%s",$[P]))if(!
|
||||
(*_?$=*++_:0)){if($<3&&p>=U)for(_()("\n\n> "),scanf("%[^\n]%*c",Y)?U=*B=1:exit(0),p=_(s)(o=X,"[INST] %s%s [/INST]",s?
|
||||
"":"<<SYS>>\n"S"\n<</SYS>>\n\n",Y);z=p-=z;U++[o+=z,B]=f)for(f=0;!f;z-=!f)for(f=V;--f&&f[P][z]|memcmp(f[P],o,z););p<U?
|
||||
$=B[p++]:fflush(0);x D)R=$*D+i,r[i]=m->c[R]*m->f[R/W];R=s++;N Z){f=k*D*D,$=W;x 3)j(k,L,D,i?G[~-i]+f+R*D:v,e[i]+k);N
|
||||
2)x D)b=sin(w=R/exp(i%E/14.)),c=1[w=cos(w),T=i+++(k?v:*G+f+R*D)],T[1]=b**T+c*w,*T=w**T-c*b;u Z){F*T=O[h],w=0;I A=h*E;x
|
||||
s){N E)i[k[L+A]=0,T]+=k[v+A]*k[i*D+*G+A+f]/11;w+=T[i]=exp(T[i]);}x s)N E)k[L+A]+=(T[i]/=k?1:w)*k[i*D+G[1]+A+f];}j(V,L
|
||||
,D,J,e[3]+k);x 2)j(k+Z,L,H,i?K:a,d[i]+k);x H)a[i]*=K[i]/(exp(-a[i])+1);j(V,a,D,L,d[$=H/$,2]+k);}w=j($=W,r,V,k,n);x
|
||||
V)w=k[i]>w?k[$=i]:w;}}
|
||||
Executable
+91
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate 2024/cable1
|
||||
|
||||
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
|
||||
# this way allows us to have the user specify a different compiler in an easy way.
|
||||
#
|
||||
[[ -z "$CC" ]] && CC="cc"
|
||||
|
||||
# clear the screen
|
||||
#
|
||||
clear
|
||||
|
||||
# Verify we have the model
|
||||
#
|
||||
if [[ ! -s model ]]; then
|
||||
echo 'ERROR: model not found!' 1>&2
|
||||
echo 1>&2
|
||||
echo 'You must successfully run ./get_model.sh and download the model to run this program.' 1>&2
|
||||
echo 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# make sure the program has been built
|
||||
#
|
||||
read -r -n 1 -p "Press any key to when ready: "
|
||||
echo 1>&2
|
||||
make CC="$CC" all >/dev/null || exit 1
|
||||
|
||||
# select a game
|
||||
#
|
||||
export SELECT=""
|
||||
while [[ -z $SELECT ]]; do
|
||||
|
||||
export NAME=""
|
||||
export Z3=""
|
||||
export SAVE=""
|
||||
echo 1>&2
|
||||
echo 'Select a personality (if in doubt try 0):' 1>&2
|
||||
echo 1>&2
|
||||
echo ' 0 prog - Common ChatIOCCC' 1<&2
|
||||
echo ' 1 linux - As an imaginary Linux-based compiler' 1>&2
|
||||
echo ' 2 eeyore - The old grey donkey from the Winnie-the-Pooh books' 1>&2
|
||||
echo ' 3 rainman - In the style of Raymond, from the movie "Rain Man"' 1>&2
|
||||
echo ' 4 snoop - Attempts to answer in the style of Snoop Dogg' 1>&2
|
||||
echo 1>&2
|
||||
echo ' q Quit without running a personality' 1>&2
|
||||
echo 1>&2
|
||||
read -r -n 1 -p "Enter your selection: " SELECT
|
||||
echo 1>&2
|
||||
echo 1>&2
|
||||
|
||||
# validate prompt
|
||||
#
|
||||
case "$SELECT" in
|
||||
0) NAME="prog" ;;
|
||||
1) NAME="linux" ;;
|
||||
2) NAME="eeyore" ;;
|
||||
3) NAME="rainman" ;;
|
||||
4) NAME="snoop" ;;
|
||||
q) exit 0 ;;
|
||||
Q) exit 0 ;;
|
||||
*) echo 'ERROR: invalid selection, try again' 1>&2
|
||||
SELECT="" # ask for a different selection
|
||||
continue ;;
|
||||
esac
|
||||
export PROG="./$NAME"
|
||||
|
||||
# See if we can compile an openmp version
|
||||
#
|
||||
if [[ ! -x ${NAME}_openmp ]]; then
|
||||
make CC="$CC" "${NAME}_openmp" >/dev/null 2>&1 < /dev/null
|
||||
fi
|
||||
if [[ -x ${NAME}_openmp ]]; then
|
||||
# we have an openmp version, so use it
|
||||
#
|
||||
PROG="./${NAME}_openmp"
|
||||
fi
|
||||
done
|
||||
|
||||
# try the program
|
||||
#
|
||||
echo 'NOTE: Please be patient. This is not the fastest LLM agent.' 1>&2
|
||||
echo 1>&2
|
||||
echo 'NOTE: To exit, press CTRL+C' 1>&2
|
||||
echo 1>&2
|
||||
read -r -n 1 -p "Press any key to run: $PROG: "
|
||||
echo 1>&2
|
||||
echo 1>&2
|
||||
"$PROG"
|
||||
echo 1>&2
|
||||
Reference in new issue
Block a user