Screen Recording
May 24, 2024 ยท View on GitHub
We use screen recording to visually present how fast an algorithm generates text or to compare the text generation speed of two algorithms.

Inspired by this tutorial, we use asciinema to record the terminal content. asciinema outputs a file that is much smaller than a video file. We then use agg to convert the cast into a GIF file, or use svg-term-cli for a SVG file.
When recording a comparative screen cast, we use GNU screen to split the terminal into two panels. And run the script generate.py simultaneously in each panel. We configure the split and run using the configuration file ~/.screenrc, as follows:
split -v
screen 1 sh -c 'echo -e "Compose an engaging travel blog post about a recent trip to Hawaii, highlighting cultural experiences and must-see attractions.\nexit" | TRANSFORMERS_VERBOSITY=error python3 -m recurrent_drafting.cmd.generate --hf_tokenizer=lmsys/vicuna-7b-v1.3 --hf_llm=lmsys/vicuna-7b-v1.3 --hf_drafter=$HOME/m/redrafter/ --max_prompt_length=1000 --max_generation_length=2048 --batch_size=1 --dtype=bf16 --greedy_search=False --temperature=0.01 --autoregression=True --use_gpu=1'
focus
screen 2 sh -c 'echo -e "Compose an engaging travel blog post about a recent trip to Hawaii, highlighting cultural experiences and must-see attractions.\nexit" | TRANSFORMERS_VERBOSITY=error python3 -m recurrent_drafting.cmd.generate --hf_tokenizer=lmsys/vicuna-7b-v1.3 --hf_llm=lmsys/vicuna-7b-v1.3 --hf_drafter=$HOME/m/redrafter/ --max_prompt_length=1000 --max_generation_length=2048 --batch_size=1 --dtype=bf16 --greedy_search=False --temperature=0.01 --autoregression=False --beam_width=45 --beam_length=5 --use_gpu=2'
Please be aware that each run of the generate.py uses a unique GPU, so there must be at least two GPUs on the host.
We could now run the following command to run the programs and record the screen cast:
rm /tmp/a.cast; asciinema rec -c "screen -R devto" /tmp/a.cast
We could replay the cast:
asciinema play /tmp/a.cast
Or, we could convert it into a GIF file:
agg /tmp/a.cast /tmp/a.gif
Install Dependencies
We could use the standard package manager to install asciinema. On Ubuntu, we use apt:
apt-get update
apt-get install asciinema screen
Agg has to be installed from the Rust source code. To install Rust, run the following command:
curl https://sh.rustup.rs -sSf | sh
Then we need to update the shell and install agg
. ~/.bash_profile
cargo install --git https://github.com/asciinema/agg
To install svg-term-cli, we need npm:
apt-get install npm
Then, we could install svg-term-cli:
npm install -g svg-term-cli