Amazon Bedrock AI Karaoke is an interactive demo of prompting foundation models with a microphone and asking a human to pick their preferred response.
Firstly, this is meant to be fun! Getting people to interact through a microphone and big push-buttons makes this demo more suitable for summits and demo spaces and resonates with non-technical audiences.
Secondly, this introduces customers to several key ideas in generative AI system engineering including:
1) Text to image generation and visual Q/A 2) Importance of creating a data flywheel from human feedback 3) Mitigating challenges of hallucination and safety
1) 💭 First, think of a thing or a place in your minds eye you can describe in detail. For example, "A cute ginger cat wearing a suit and tie" 2) 🎤 Pickup the microphone and un-mute and describe that image! Speak clearly and close to the mic. 3) 🔴 🔵 Review the two images, and push the color button corresponding to the best image. 4) 🎑 🎤 Now ask a question about the selected best image. For example: "What's the color of the cat's tie?" 5) 🔴 🔵 Review the two responses, and push the color button corresponding to the best answer. 6) 🔁 Repeat!
The key AWS services used in this architecture are:
Get the code
git clone https://github.com/aws-samples/amazon-bedrock-ai-karaoke
Ensure you have AWS credentials configured
To interact with models from Amazon Bedrock, you need to request access to the base models in one of the regions where Amazon Bedrock is available. Make sure to read and accept models end-user license agreements or EULA.
cdk bootstrap aws://ACCOUNT-NUMBER/REGION
To get started with this project, it's recommended to first try it out locally on your laptop.
Firstly, we will install and run the front-end website locally:
cd ./lib/client/
npm install
npm start
Now, in another terminal - we will started the server application
cd ./lib/server/
pip install -r requirements.txt
python3 server.py
Once you have tried the application locally, you may choose to deploy it to a Raspberry Pi device with orchestration in the cloud so you can leave the demo running at an event. There are several benefits to this approach of using Amazon ECS Anywhere including:
The following commands show how to package and deploy the application as an AWS CDK application.
First, complete the following pre-requisites:
Now it's time to configure the infrastructure to deploy the software to the Raspberry Pi. Mkae sure you've completed the prerequisites above.
Deploy the cdk app
cdk deploy
When the deployment is paused on the ECS Service creation, login to the AWS Console to get the registration command: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-anywhere-registration.html
SSH onto the raspberry pi and paste the registration command
The deployment should now complete and the service should be running on the pi
Setup the kiosk service. You can find the kiosk.sh
and kiosk.service
files in the top level scripts
directory.
sudo apt install -y xdotool unclutter fonts-noto-color-emoji
sudo raspi-config > 1 System Options > S5 Boot / Auto Login >B4 Desktop Autologin — Desktop GUI, automatically logged in as ‘pi’ user
Create the following files and enable the kiosk service
vim /home/pi/kiosk.sh
sudo vim /lib/systemd/system/kiosk.service
sudo systemctl enable kiosk.service
sudo systemctl start kiosk.service
Either build the full hardware box following the Build Instructions or use the minimal pi setup and use a USB mouse instead of the buttons to select the best response:
If UI scaling is wrong then first try to correct it from the TV settings. If that fails, try the following:
Ctr +
to increase the zoom and Ctr -
to decrease the zoomYou can add more bad words to mask in the prompt by appending to the lib/server/profanity.txt
file. Please note the requirements and limits listed here when adding words to the list.
Total ~ £250
Work in progress
Flash SSD or SD card with Raspberry Pi OS (64 Bit) using Raspberry Pi Imager
Drill holes
Assemble buttons, fans, plugs and wires.
Wire | Pin Number | Pin Name |
---|---|---|
Red button COM1 | 36 | GPIO 16 |
Red button NO3 | 34 | Ground |
Blue button COM1 | 11 | GPIO 17 |
Blue button NO3 | 9 | Ground |
Fan 1 5V (Yellow) | 4 | 5V |
Fan 1 GND (Black) | 6 | Ground |
Fan 1 PWM (Blue) | 8 | GPIO 14 |
Fan 2 5V (Yellow) | 2 | 5V |
Fan 2 GND (Black) | 39 | Ground |
Fan 2 PWM (Blue) | 37 | GPIO 26 |
Optionally, you can also connect the LED connectors on the buttons to the two spare 3V3/GND pins.
Wire | Pin Number | Pin Name |
---|---|---|
Red button LED | 17 | 3V3 |
Red button GND | 25 | Ground |
Blue button LED | 1 | 3V3 |
Blue button GND | 20 | Ground |
This is useful if you need to re-register the raspberry pi to a different ECS cluster
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-anywhere-deregistration.html
sudo systemctl stop ecs amazon-ssm-agent
sudo apt remove -y amazon-ecs-init amazon-ssm-agent
sudo rm -rf /var/lib/ecs /etc/ecs /var/lib/amazon/ssm /var/log/ecs /var/log/amazon/ssm
https://github.com/aws/amazon-ecs-agent/blob/master/agent/app/agent.go#L783-L798
sudo vim /etc/rc.local
rm /var/lib/ecs/data/ecs_agent_data.json
sudo vim /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid=""
psk=""
}
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.