mirror of
https://github.com/rasbt/LLMs-from-scratch.git
synced 2026-04-10 12:33:42 +00:00
Add user interface to ch06 and ch07 (#366)
* Add user interface to ch06 and ch07 * pep8 * fix url
This commit is contained in:
committed by
GitHub
parent
0f395921d7
commit
7a9a17608d
39
ch06/04_user_interface/README.md
Normal file
39
ch06/04_user_interface/README.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# Building a User Interface to Interact With the GPT-based Spam Classifier
|
||||
|
||||
|
||||
|
||||
This bonus folder contains code for running a ChatGPT-like user interface to interact with the finetuned GPT-based spam classifier from chapter 6, as shown below.
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
To implement this user interface, we use the open-source [Chainlit Python package](https://github.com/Chainlit/chainlit).
|
||||
|
||||
|
||||
## Step 1: Install dependencies
|
||||
|
||||
First, we install the `chainlit` package via
|
||||
|
||||
```bash
|
||||
pip install chainlit
|
||||
```
|
||||
|
||||
(Alternatively, execute `pip install -r requirements-extra.txt`.)
|
||||
|
||||
|
||||
## Step 2: Run `app` code
|
||||
|
||||
The [`app.py`](app.py) file contains the UI code based. Open and inspect these files to learn more.
|
||||
|
||||
This file loads and uses the GPT-2 classifier weights we generated in chapter 6. This requires that you execute the [`../01_main-chapter-code/ch06.ipynb`](../01_main-chapter-code/ch06.ipynb) file first.
|
||||
|
||||
Excecute the following command from the terminal to start the UI server:
|
||||
|
||||
```bash
|
||||
chainlit run app.py
|
||||
```
|
||||
|
||||
Running 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`).
|
||||
Reference in New Issue
Block a user