Skip to main content

Customizing Book Bingo Challenges (Behind the Book Bingo Generator, Part II)

·996 words·5 mins
Book Bingo Generator was designed to make it easy to generate fun reading challenges with large language models (LLMs). The goal was that it should run locally in any Javascript-enabled browser with internet access, without needing a server, a fancy GPU or paid API access to hosted language models.

What is the Book Bingo Generator?

The previous blog post in this series explained the ins and outs of generating book bingo cards on the crowd sourced distributed cluster, AI Horde. Now, let’s go behind the scenes of the Book Bingo Card to examine how you can create your own unique implementation of the card with your own AI Horde API Key, custom prompts and CSS styling.

Book Bingo Generator is powered by client-side Javascript, which means that running it should be as easy as opening the main page (index.html) in a browser.

To get started:

  1. Download Book Bingo Generator
  2. Unzip to a directory
  3. Navigate to the directory you just unzipped the files to and open index.html in your favorite browser

Book Bingo Generator should load, connect to AI Horde and begin generating a new book bingo challenge. From here, you can start making changes to how the Book Bingo Generator works.

Add Your Own API Key #

If you don’t want lowest priority access to AI Horde, generate a personal API key. This will give you an account on AI Horde, with the ability to earn Kudos to increase your priority in the queue. Review the previous blog post to learn more about earning Kudos.

Once you’ve obtained your API Key and stored it securely to prevent loss, you’re ready to add it to the Book Bingo Generator. From the folder containing Book Bingo Generator files you downloaded earlier, open script.js in a text editor. At the top of script.js, you should see the following line:

let api_key = "0000000000"

Here “0000000000” is the key that lets you connect anonymously at a low priority. Replace “0000000000” with the unique API key that you generated on AI Horde. Save the file and open index.html in a browser to generate a new bingo card. You may need to clear your cache by holding the Ctrl key (⌘ on Mac) down while pressing the Refresh (↻) icon on the browser. This will ensure that the browser uses the new API key to connect to AI Horde.

Generate Book Challenges Around a Theme #

One way to customize the generated Bingo Cards is to edit the prompt that is being sent to models on AI Horde. The current prompt is designed to give a variety of fun book challenges that are accessible to all ages. Experiment with this to try to make Bingo Card Challenges around specific themes.

Near the top of script.js, find the block of code that looks like:

let prompt = `
### System:
Below is an instruction that describes how to generate book challenges as a JSON object. Follow the instructions as best you can.

### Instruction: 
Generate a JSON formatted object including 24 unique and family-friendly book challenges for a book bingo card, like: 
    {'1': 'Award Winner', 
     '2': 'Fiction', 
     '3': 'Bestseller', 
     ...
     '24': ...
    }
    Replace the named challenges above with your own unique challenge descriptions that are concise and brief, 3 words or less. 
    Challenges should be appropriate for middle-grade readers. Return a valid JSON Object.

### Response:`;

Note that this prompt has 3 sections, ### System:, ### Instruction:, and ### Response:. These sections are common inputs to a variety of large language models.

  • ### System: contains specific rules or instructions that your model should follow.

  • ### Instruction: contains the specifics about what you’re querying the language model to do.

  • ### Response: primes the model to give it’s reply.

The instructions block is where most of the magic happens. In our case, we want the language model to generate a JSON object with 24 unique book challenges. We use the instructions to provide the model an example of what the JSON object should look like, along with some sample challenges. To ensure that the Book Bingo Generator continues to generate valid generate, I recommend not changing this part of the prompt. However, you can modify the last few sentences of the instructions to change the type of book challenges that are generated. For example, you could ask the model to provide book challenges related to fantasy themes by adjusting the following:

Replace:

“Challenges should be appropriate for middle-grade readers. Return a valid JSON Object.”

with:

“Challenges should be appropriate for middle-grade readers and related to fantasy themes. Return a valid JSON Object.”

After editing the prompt, save script.js and open index.html in your Browser again. Hopefully the book bingo challenges will adjust to match any changes you make to your prompt.

Generation 1 Failed. Trying again.
Possible Error
If your prompt modifications result in repeated errors such as 'Generation 1 failed. Trying again,' this usually means the language model is not returning a valid JSON object. You might need to reset your prompt back to the default prompt above and systematically add or change things one at a time to see what helps you get you get closer to achieving the results you want, and what makes it worse or breaks it.

You may also occasionally get an error like 'Model not available right now. Please try again later.' This means that there are no models available on AI Horde that are compatible with the bingo card. Since AI Horde is run entirely by volunteers, there is no guaranteed uptime for any model.

Last but not least, once the generator is creating challenges around themes that you want, customize the look and feel by editing style.css. Experiment with new colors or a different font in .bingo-cell.

Themed Bingo Card with Customized CSS
Science Fiction Themed Bingo Card with Custom Style

That concludes the series on Generating Book Bingo Cards Did you customize your bingo card generator? Let me know! I’d love to see some of the bingo card challenges you produce.


Header image by StockSnap.