This is a submission for the Cloudflare AI Challenge.
What I Built
We built a customizable chatbot using Cloudflare AI Workers that responds to custom questions with pre-defined answers, leveraging text vectorisation and AI text generation for natural conversational interaction.
In the age of AI, it's really important to think of it as an opportunity to grow your business, not a threat. Imagine having a virtual assistant that knows everything about you and your business, that can handle multiple customers at once, that can also speak in the customer's local language, that can give them accurate information and help them understand your product in a second - yes, we've done a demo of this with AI thanks to Cloudflare's AI workers.
Demo
Please go to: https://ai-chatbot-demo.pages.dev and ask the chatbot about me đ
â ď¸Currently the site has not login, so be responsible, don't abuse
My Code
ElvisAns / ai-chatbot-demo
A customizable chatbot using Cloudflare AI Workers that responds to custom questions with pre-defined answers, leveraging text vectorisation and AI text generation for natural conversational interaction.
AI Chat Bot
We built a customizable chatbot using Cloudflare AI Workers that responds to custom questions with pre-defined answers, leveraging text vectorisation and AI text generation for natural conversational interaction.
66e5b2a0-e9d5-4a24-bf24-c5f4a76d4b38.mp4
Please check the Demo at : https://ai-chatbot-demo.pages.dev
Technology used
We're using vector embedding to sort of train our AI to respond to users questions with predefined answers, all without having to train the AI in a formal way, which can be difficult and expensive.
On the AI backend side we are using 2 models :
- @cf/baai/bge-base-en-v1.5 : Cloudflare vectorize, https://developers.cloudflare.com/vectorize
- @cf/meta/llama-2-7b-chat-int8 : Text generation model, https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-int8
The entire frontend is built with NuxtJs
We also have a D1
https://developers.cloudflare.com/d1/ database that help us store our questions and answers
How does it work
We have a database that store questions and answers, when our frontend queryâŚ
Journey
We could have gone strictly by prompting the AI, of course it can work but scarify the accuracy. Thanks to #vectorize we were able to do the search from a pre-defined QA set, then pass the data to the right AI model for text generation.
After testing many models I stuck with @cf/meta/llama-2-7b-chat-int8
, it has accurate answers, it understands context well and provides more fun answers.
I also discovered that for the AI to give accurate answers, the prompt must also be accurate, a slightly unclear sentence in the prompt can lead to weird behaviour.
This can go a long way and use a translation model to talk to a user in their local language, which can be a great addition to a chatbot like this.
Multiple Models
On the AI backend side we are using 2 models :
-
@cf/baai/bge-base-en-v1.5
: Cloudflare vectorize, https://developers.cloudflare.com/vectorize -
@cf/meta/llama-2-7b-chat-int8
: Text generation model, https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-int8
Top comments (0)