CESAR TORTOLERO All projects

Companionship Chatbot

Listen for the tone, not just the words.

Category
CONVERSATIONAL AI
Project
03 / 06
Role
Team lead, backend LLM
Award
First Place, KSU C-Day, Spring 2024

In 30 seconds

Problem
Make an LLM companion listen for the tone of a message, not just its words.
My part
I led the four-person capstone team, handling the planning and direction, and designed the backend LLM: the DistilGPT-2 server and the sentiment module. One teammate designed the React Native app, and two others helped with it briefly.
Result
First Place, Undergraduate Capstone, at the KSU C-Day Computing Showcase, Spring 2024.
Proof
Original illustration of a companion chat conversation beside the eight emotions a sentiment module can name, with joy highlighted
The cover is an original illustration. The conversation shown is sample text.

The project in numbers

Code
1,360 lines of code in the final project.
Components
28 components.
Emotions
8 emotions the sentiment module can name.
Test prompts
10 labelled prompts in the report’s test.
From the team’s final report, April 2024.

Check the source Final report · PDF

How it works

The app is React Native, with login, chat and past conversations. Each message goes to a Python server, where a sentiment module names the emotion in it and a DistilGPT-2 model, using the QuAC dataset, writes the reply. Firebase Realtime Database handles logins and user information. The report also notes that storing chat history as context for the model was withheld from the final product.

The module names one of eight emotions: joy, sadness, anger, fear, surprise, disgust, trust or anticipation. Knowing the emotion lets the reply console or celebrate.

The module sits in the LLM pipeline on the Python server: it reads textual cues in each message to name the emotion, and the model adjusts its reply to fit; the public report does not name the classifier behind it.

Check the source Final report · PDF Code · GitHub

  1. Accounts Firebase Realtime Database
  2. React Native Mobile app
  3. First Sentiment module
  4. Then DistilGPT-2
  • Python server
  • The app signs people in and stores their information with Firebase Realtime Database.
  • The app sends each message to the Python server.
  • The sentiment module names the emotion before DistilGPT-2 writes the reply.
  • The reply goes back to the app, ready to console or celebrate.
One message through the app: Firebase handles the login, and the Python server names the emotion before the model replies.

Eight emotions

Prompts per emotion in the report’s test set
EmotionPrompts
Joy (two prompts)2
Sadness (two prompts)2
Anger1
Fear1
Surprise1
Disgust1
Trust1
Anticipation1
The report’s test set: 10 labelled prompts across the eight emotions, two each for joy and sadness (the green bars) and one for each of the others.

Two prompts from that set:

“I just got promoted at work and I'm ecstatic about the new opportunities!”

Joy

“I lost my favorite necklace today, and it's left me feeling really down.”

Sadness

The deployment plan

The C-Day abstract describes the Azure deployment as a plan. The report sized it two ways. For a fast-growing user base, two Azure NC6s_v3 GPU servers, one on the east coast and one on the west, each with a replicated Firebase database, so a regional outage would not take the app down. For an early, small user base, one server and one database in the east.

Planned capacity and monthly cost
SetupRequests per minuteUsersMonthly cost
One server, east (early stage)1,20010,000about half
Two servers, east and westabout 2,400about 22,000$5,070.56
The report’s two plans. Two servers: $5,070.56 a month ($4,870.56 for the servers and $200 for the databases) for about 2,400 requests a minute, or about 22,000 users. One server: about half the cost, for 1,200 requests a minute and 10,000 users. The report gives no exact one-server cost, so that grey bar is drawn at half.

Check the source Server architecture · PDF

One hard decision

Every message goes through the sentiment module before the reply. Without it, as the report puts it, the model was a basic conversationalist; with it, the reply can console a sad message or celebrate good news.

One limit

The report’s test fed the 10 labelled prompts to the backend and noted only the emotion it detected. It ignored the replies and reports no accuracy figure; the report’s reason is that testing an LLM widely is costly.

The evaluation lab shows how I evaluate a classifier instead, on open data: a held-out test set, bootstrap intervals, a threshold you can move, and failures picked by rule, not by hand.

Stack

  • DistilGPT-2
  • QuAC
  • Sentiment analysis
  • Python
  • React Native
  • Firebase