Friday, August 25, 2023

Train Chat Bot With an Ebook in 5 mins

I see a lot of job openings about training a chatbot with the company's data so that it will be able to answer the questions of the company's employees, customers, or clients. I thought at first that training a chatbot would require a lot of computing power and a substantial amount of data. Then, I came across the Chainlet, Langchainin, and OpenAI libraries for Python purely by accident. A video appeared on my YouTube watch list, and I accidentally clicked on it. I was surprised to discover that such libraries exist. I've already forgotten the title of that video because upon learning about the capabilities of Chainlet, I immediately searched YouTube for tutorials, and yes, there are tons of them. I also browsed the Chainlet website. While the information there is very basic, one particular example caught my attention: Document QA. You can check it out here. All I did was copy the code, insert my OpenAI API, and run it. I obtained the ebook in TXT format from https://www.gutenberg.org.

To be honest, it didn't run immediately. I encountered several errors. One notable error I encountered was the version of SQLite3. I was using Python 3.8, and the built-in SQLite3 version is 3.14, which is not compatible with the version being used by Chainlet. I did some research and found out that SQLite3 is not upgradable on Windows 10. I would have to upgrade to version Python 3.10 because it uses SQLite3 version 3.10. However, I didn't want to upgrade to version 3.10 because my Machine Learning projects are only compatible with 3.8. I had to install 3.10 and run the program in a virtual environment. I used Pipenv, reinstalled all the libraries, and finally, it worked! Take a look at the screenshots below:

Inital Screen:



It answered several of m questions:




I noticed that it failed on one of my questions; it couldn't retrieve the ebook's title, which is weird. However, it was able to answer all the rest of my questions. This is cool. The tutorials and the source code can be found on Chainlet's website. Some of the tutorials on YouTube are already obsolete based on my experience, so I just followed Chainlet's example. However, I still find it a bit too basic; there's a lot to explore, like how to embed it in React, how to change the user name, and how to use user authentication, etc.

I also noticed that it lacks chat memory; perhaps that's another interesting topic to explore. But with all those huge topics to explore, I hope there will be tutorials, documentations and sample code snippets for developers to be able to learn how to use chainlet easily.



No comments:

Post a Comment