Sebastian Raschka 76e9a9ec02 Add user interface to ch06 and ch07 (#366) 1 year ago
..
README.md 76e9a9ec02 Add user interface to ch06 and ch07 (#366) 1 year ago
app_orig.py 76e9a9ec02 Add user interface to ch06 and ch07 (#366) 1 year ago
app_own.py 76e9a9ec02 Add user interface to ch06 and ch07 (#366) 1 year ago
previous_chapters.py 76e9a9ec02 Add user interface to ch06 and ch07 (#366) 1 year ago
requirements-extra.txt ea9b4e83a4 Add chatpgpt-like user interface (#360) 1 year ago

README.md

Building a User Interface to Interact With the Pretrained LLM

This bonus folder contains code for running a ChatGPT-like user interface to interact with the pretrained LLMs from chapter 5, as shown below.

Chainlit UI example

To implement this user interface, we use the open-source Chainlit Python package.

 

Step 1: Install dependencies

First, we install the chainlit package via

pip install chainlit

(Alternatively, execute pip install -r requirements-extra.txt.)

 

Step 2: Run app code

This folder contains 2 files:

  1. app_orig.py: This file loads and uses the original GPT-2 weights from OpenAI.
  2. app_own.py: This file loads and uses the GPT-2 weights we generated in chapter 5. This requires that you execute the ../01_main-chapter-code/ch05.ipynb file first.

(Open and inspect these files to learn more.)

Run one of the following commands from the terminal to start the UI server:

chainlit run app_orig.py

or

chainlit run app_own.py

Running one of the commands above should open a new browser tab where you can interact with the model. If the browser tab does not open automatically, inspect the terminal command and copy the local address into your browser address bar (usually, the address is http://localhost:8000).