{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "Chua Chin Hon",
  "title_listed": "Beginner's Guide To Building A Singlish AI Chatbot",
  "keywords": "",
  "domain": "文本处理",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://towardsdatascience.com/beginners-guide-to-building-a-singlish-ai-chatbot-7ecff8255ee/",
  "publish_date": "2020-08-05",
  "corpus_stage": "",
  "notes": "",
  "id": "d30f39c8c450",
  "collected_at": "2026-10-02T09:39:39",
  "title": "Beginner's Guide To Building A Singlish AI Chatbot | Towards Data Science",
  "body_markdown": "![Revisit consent button](../images/body-df29beacd7496220cc94.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](../images/body-2159bb67f3de8ad870eb.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Data Science](https://towardsdatascience.com/category/data-science/)\n# Beginner's Guide To Building A Singlish AI Chatbot\nAI text generation is one of the most exciting fields in NLP, but also a daunting one for beginners. This post aims to speed up the...\n[Chua Chin Hon](https://towardsdatascience.com/author/chuachinhon/)\nAugust 5, 20208 min read\n![Singlish phrases such as &quot;blur as a sotong&quot; can be bewildering for non-Singaporeans. Can a transformer model make sense of it? Photo: Chua Chin Hon](../images/000.jpeg)\nSinglish phrases such as \"blur as a sotong\" can be bewildering for non-Singaporeans. Can a transformer model make sense of it? Photo: Chua Chin Hon\n### AI text generation is one of the most exciting fields in NLP, but also a daunting one for beginners. This post aims to speed up the learning process for newcomers by combining and adapting several existing tutorials into a practical end-to-end walkthrough with notebooks and sample data for a conversational chatbot that can be used in an interactive app.\nAuto-text generation is undoubtedly one of the most exciting fields in NLP in recent years. But it's also an area that's relatively difficult for newcomers to navigate, due to the high bar for technical knowledge and resource requirements.\nWhile there's no shortage of [helpful notebooks](https://huggingface.co/transformers/notebooks.html) and tutorials out there, pulling the various threads together can be time consuming. To help speed up the learning process for fellow newcomers, I've put together a simple [end-to-end project](https://github.com/chuachinhon/practical_nlp) to create a simple AI conversational chatbot that you can run in an interactive app.\nI chose to frame the text generation project around a chatbot as we react more intuitively to conversations, and can easily tell whether the auto-generated text is any good. Chatbots are also ubiquitous enough that most of us would have a good sense of the expected baseline performance without having to consult a manual or an expert. If it's bad, you'll know right away without having to check a score or metric.\nThe workflow in the project is structured with the practical questions of a beginner in mind: How to get started with data extraction and preparation, what's needed to fine tune a pre-trained transformer model, and finally how to test/use the bot in an app.\nLearn this step by step with the interactive [AI and Data Scientist](https://roadmap.sh/ai-data-scientist) roadmap.\nThe end product is not what one might call \"polished\", as the screen-grab below of one of the test-runs shows. But as a first experiment, the results are good enough (in my view) for highlighting both the possibilities and limits of AI text generation via [transfer learning](https://www.analyticsvidhya.com/blog/2020/07/transfer-learning-for-nlp-fine-tuning-bert-for-text-classification/).\n![Screen-grab of test run of Singlish Chatbot on Colab.](../images/001.png)\nScreen-grab of test run of Singlish Chatbot on Colab.\n* * *\n## DATA, REPO AND REQUIREMENTS\nIf the sample conversation above looks bewildering to you, well, you've likely not been to Singapore and/or heard of \"Singlish\", or colloquial Singaporean English. It's a mish-mash of several languages and local slang, and can be confusing for non-Singaporeans. In other words, not a bad way to test the limits of the DialoGPT model.\nThe data for fine tuning the model is taken from a collection of [SMS messages by Singaporean students at a local university](https://scholarbank.nus.edu.sg/handle/10635/137343). While the written and spoken forms of \"Singlish\" can differ significantly, we'll set that aside for practical reasons.\nThe [dataset](https://github.com/chuachinhon/practical_nlp/blob/master/data/singlish.json) (raw and cleaned versions for training) and four related notebooks are available in my [repo](https://github.com/chuachinhon/practical_nlp). The notebooks are split according to the following tasks:\n  * notebook [3.0](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.0_data_prep_cch.ipynb): Data preparation\n  * notebook [3.1](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.1_finetune_bot_cch.ipynb): Fine tuning a pretrained DialoGPT-medium model on Colab (Pro)\n  * notebook [3.2](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.2_dash_chat_app_cch.ipynb): Testing the model's performance on an interactive Dash app\n  * notebook [3.3](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.3_\\[aitextgen\\]\\(https://github.com/minimaxir/aitextgen\\)_cpu_cch.ipynb): CPU alternative to text generation using aitextgen\n\n\nAs far as resource requirements go, you can run this project on a free Google/Colab account if you fine tune a DialoGPT-small model instead of the larger versions. If you are using a more robust dataset, perhaps fine tuning a DialoGPT-small model would be sufficient.\nBut I found that my results from fine tuning the smaller model weren't as good, and the constant housekeeping to avoid busting the 15Gb storage limit on a free Google account was a drain on productivity.\nIf you foresee yourself experimenting with more/larger transformer models in future, I'd recommend an upgrade to [Colab Pro](https://colab.research.google.com/signup) as well as increasing the amount of storage space on your Google account. This allowed me to iterate quickly, without having to wrestle with a physical eGPU set up at home.\nFor brevity, I won't go into the technical details in this post. I'm still learning as I go, and there are [far better articles](http://jalammar.github.io/illustrated-gpt2/) on [this topic](https://medium.com/huggingface/how-to-build-a-state-of-the-art-conversational-ai-with-transfer-learning-2d818ac26313) out there. Most of the code are lifted or adapted from the work of previous authors, and they are acknowledged as such in the notebooks.\n* * *\n## STEP 1: DATA PREPARATION\nThe first and biggest question for the project is whether you can find an appropriate dataset for your use case. The more specific the use case (say, a Trevor Noah chatbot), the harder it will be to find the appropriate training data. Ethical questions should be considered at the outset: Is it appropriate to model the chatbot after a real person, even if you have access to transcripts, and what is the likelihood of potential misuse?\nThe anonymised SMS dataset used in this project is among the few \"Singlish\" corpuses in the public space, and is the only one I've found that's large enough for this purpose. The first half of [notebook3.0](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.0_data_prep_cch.ipynb) involves the steps needed to extract the SMSes from a deeply nested json file. Skip this if you are using a different dataset.\nThe second half deals with the very specific way that the training and validation data sets have to be prepared for use in the DialoGPT model. Essentially, for every SMS you have to create x-number of previous SMSes as \"context\":\n![Click here to see another example of how data is prepared in building a Rick Sanchez bot.](../images/002.png)\nClick here to see [another example](https://colab.research.google.com/drive/15wa925dj7jvdvrz8_z3vU7btqAFQLVlG) of how data is prepared in building a Rick Sanchez bot.\nI settled on seven previous responses, but you can change it up or down to see what impact this may or may not have on the chatbot's performance. If this is more than an experiment for you, I suspect this is where you'll be spending a lot of time tweaking the dataset to clean up the response/context. Unfortunately, I've not come across a good tutorial on how best to structure or tweak custom datasets for fine tuning a DialoGPT model.\nAfter splitting the response-context dataset into training and validation sets, you are pretty much set for the fine tuning.\n## STEP 2: FINE TUNING DIALOGPT\nThere's a tonne of code involved in the fine tuning process, but thanks to the earlier work by folks like [Nathan Cooper](https://github.com/ncoop57/i-am-a-nerd/blob/master/_notebooks/2020-05-12-chatbot-part-1.ipynb) and [Rostyslav Neskorozhenyi](https://colab.research.google.com/drive/15wa925dj7jvdvrz8_z3vU7btqAFQLVlG), the training loops can be used as is without new users having to make major changes. You can study the code in greater detail when you have more time. The key cell to note in [notebook3.1](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.1_finetune_bot_cch.ipynb) is the one below:\n![](../images/body-77f21de74442a3cca642.png)\nThis is where you'd need to make changes depending on your dataset and the set-up at your disposal. For example, you can stick with the [medium-sized DialoGPT model](https://huggingface.co/microsoft/DialoGPT-medium) or dial down to the [small one](https://huggingface.co/microsoft/DialoGPT-small).\nIf you encounter GPU-out-of-memory issues, you'll have to reduce the batch size (as I did in cell above by reducing to 1). If you don't have much storage space left in your Google Drive, you'll have to adjust the logging_steps and save_steps intervals accordingly (files saved at various checkpoints can chew up storage space in a hurry).\nThe fine tuning process can take anything from 40 minutes to about 2 hours, depending on the parameters you set. Do note that there are usage limits even on Colab Pro. For instance, I wasn't able to fine tune a DialoGPT-large model due to GPU memory limits. Colab Pro notebooks can run up to 24 hours, but I have yet to test that out with more epochs.\nThe one metric to take note of at the end of the fine tuning process is the [perplexity score](https://huggingface.co/transformers/perplexity.html) - a measure of how certain the model is in picking the next token. The lower the score, the better as it means the model is less uncertain.\nI got a perplexity score of 1.6134 from fine tuning the DialoGPT-medium model, a significant improvement from the scores in the ranges of 6.3 to 5.7 when using the DialoGPT-small model. It'll take several runs for you to figure out what's an acceptable score.\nYou can start chatting with the bot at the end of the [notebook](https://colab.research.google.com/github/plotly/dash-sample-apps/blob/master/apps/dash-chatbot/ColabDemo.ipynb) (assuming everything ran correctly), but I much prefer to load the fine tuned model into an app. Thanks to [Lu Xing Han](https://github.com/xhlulu) @ [Plotly](https://community.plotly.com/t/show-tell-dash-transformers-apps-auto-summarization-translator-and-chatbot-are-now-runnable-on-colab/42762), there's a notebook for that.\n## STEP 3: TEST YOUR FINE TUNED MODEL IN A DASH APP\nThe Plotly repo contains code for running [the chatbot app on a local machine](https://github.com/plotly/dash-sample-apps/blob/master/apps/dash-chatbot/app.py) if you wish to do that, but I opted to run [notebook3.2](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.2_dash_chat_app_cch.ipynb) on Colab for practical reasons (the fine tuned model is already there). The code is lifted straight from Lu Xing Han's demo, with minor changes towards the end for folks who might want to experiment further with the output from the bot:\n![](../images/body-c4a06c48447782f86aac.png)\n\"Temperature\" allows you to control the level of creativity (or craziness/brazenness) of the responses. You can reduce the length of the chatbot's \"utterances\" by lowering the max_length (max number of token: 1,024; default: 256 tokens). A full list of the arguments you can tweak for the chatbot conversation can be found [here, under the section \"Using the interaction script\"](https://github.com/huggingface/transfer-learning-conv-ai).\nHere's a screen-grab of slightly more successful conversation I managed to have with the chatbot. Highlighted cells are my entries:\n![](../images/body-c5d8e888e72763816784.png)\nThe fine tuned pytorch model is too big (1.44Gb) to be deployed on any free hosting account, so there's no way (for now) for you to try this particular Singlish chatbot on a web app.\nMy take: The \"Singlish\" chatbot is not ready for prime-time. It can give surprisingly good responses at times, but can't sustain the effort beyond a few exchanges. As you can see in the screen-grab above, things go sideways towards the end. With a richer dataset and perhaps enough compute to train on a DialoGPT-large model, the responses might get better.\nBut as an experiment, I'd have to say the performance is not half bad at all.\n## BONUS STEP: CPU ALTERATIVE TO AUTO-TEXT GENERATION\nThere are a number of alternatives out there if you'd rather not use Colab and/or confine the data and the fine-tuning to a local machine. I'll just highlight one Python library that I've been experimenting with - [aitextgen](https://github.com/minimaxir/aitextgen) - that provides an option for CPU-only training.\n[Notebook3.3 ](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.3_aitextgen_cpu_cch.ipynb)outlines a simple example using the same SMS dataset in this project. I had previously tried aitextgen with other datasets involving YouTube transcripts of political speeches in Singapore. Unfortunately, I've not been able to get very satisfactory results so far.\nI'm probably not using it right. You might have better luck. A[itextgen can run on Colab](https://colab.research.google.com/drive/15qBZx5y9rdaQSyWpsreMDnTiZ5IlN0zD?usp=sharing) too.\n* * *\nHopefully this post and the accompanying notebooks will help you get started quickly on experiments with your own AI chatbot. What's far harder to do is figuring out how to improve its performance, or ensure that it's [safe for public use](https://www.theverge.com/2016/3/24/11297050/tay-microsoft-chatbot-racist).\nThere are also related technical issues to explore, such as slimming the model down for deployment or more advanced interactive app designs that can bring out additional functionalities in the chatbot. If you have recommendations for any of the above topics, or spot mistakes in this post, ping me at:\nTwitter: [Chua Chin Hon](https://medium.com/u/b3d8090c0aee?source=post_page-----aad7f2e1d0a0----------------------)\nLinkedIn: [www.linkedin.com/in/chuachinhon](http://www.linkedin.com/in/chuachinhon)\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](../images/body-d56b810b4697a0fbf983.png)\nWritten By\n## [Chua Chin Hon](https://towardsdatascience.com/author/chuachinhon/)\n[See all from Chua Chin Hon](https://towardsdatascience.com/author/chuachinhon/)\n[AI](https://towardsdatascience.com/tag/ai/)[Chatbots](https://towardsdatascience.com/tag/chatbots/)[Data Science](https://towardsdatascience.com/tag/data-science/)[Singapore](https://towardsdatascience.com/tag/singapore/)[Transfer Learning](https://towardsdatascience.com/tag/transfer-learning/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fbeginners-guide-to-building-a-singlish-ai-chatbot-7ecff8255ee%2F&title=Beginner's%20Guide%20To%20Building%20A%20Singlish%20AI%20Chatbot)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fbeginners-guide-to-building-a-singlish-ai-chatbot-7ecff8255ee%2F&title=Beginner's%20Guide%20To%20Building%20A%20Singlish%20AI%20Chatbot)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fbeginners-guide-to-building-a-singlish-ai-chatbot-7ecff8255ee%2F&text=Beginner's%20Guide%20To%20Building%20A%20Singlish%20AI%20Chatbot)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](../images/003.jpg)](https://towardsdatascience.com/analysing-pharmaceutical-sales-data-in-python-6ce74da818ab/)\n## [Analysing Pharmaceutical Sales Data in Python](https://towardsdatascience.com/analysing-pharmaceutical-sales-data-in-python-6ce74da818ab/)\n[Programming](https://towardsdatascience.com/category/programming/)\nHow to analyse pharmaceutical sales data using Python, Pandas, Matplotlib and regression models\n[Przemyslaw Jarzynski](https://towardsdatascience.com/author/pjwebdev/)\nSeptember 6, 20209 min read\n  * [![](../images/004.jpg)](https://towardsdatascience.com/building-a-command-line-quiz-application-in-r/)\n## [Building a Command-Line Quiz Application in R](https://towardsdatascience.com/building-a-command-line-quiz-application-in-r/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nPractice control flow, input handling, and functions in R by creating an interactive quiz game.\n[Benjamin Nweke](https://towardsdatascience.com/author/benjaminnweke/)\nOctober 5, 20256 min read\n  * [![](../images/005.jpg)](https://towardsdatascience.com/modelling-the-number-of-sunspots-with-time-series-analysis-39ce7d88cff3/)\n## [Can LSTM be used to Forecast the Number of Sunspots?](https://towardsdatascience.com/modelling-the-number-of-sunspots-with-time-series-analysis-39ce7d88cff3/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nI will be predicting the number of monthly Sunspots using time series analysis. The models that will be explored in-depth are the ARMA and...\n[Ethan Johnson-Skinner, MSc](https://towardsdatascience.com/author/ethanskinner94/)\nSeptember 9, 202110 min read\n  * [![](../images/006.jpeg)](https://towardsdatascience.com/p-value-explained-c7f5547c0562/)\n## [P value - Explained](https://towardsdatascience.com/p-value-explained-c7f5547c0562/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nWhat it means and how it is used. Explained with a use case.\n[Soner Yıldırım](https://towardsdatascience.com/author/sonery/)\nJuly 8, 20207 min read\n  * [![](../images/007.jpeg)](https://towardsdatascience.com/end-to-end-shiny-app-tutorial-using-nyc-mortality-data-d29ad99506b9/)\n## [End to end Shiny app tutorial using NYC mortality data](https://towardsdatascience.com/end-to-end-shiny-app-tutorial-using-nyc-mortality-data-d29ad99506b9/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nConceptual overview and step by step guide for beginners\n[Emily A. Halford](https://towardsdatascience.com/author/emilyahalford/)\nJanuary 10, 202117 min read\n  * [![](../images/008.png)](https://towardsdatascience.com/a-journey-through-xgboost-milestone-1-ff1be2970d39/)\n## [A Journey through XGBoost: Milestone 1](https://towardsdatascience.com/a-journey-through-xgboost-milestone-1-ff1be2970d39/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nSetting up the background\n[Rukshan Pramoditha](https://towardsdatascience.com/author/rukshanpramoditha/)\nMarch 2, 20216 min read\n  * [![](../images/009.png)](https://towardsdatascience.com/the-intuitive-basics-of-optimization-730e5b52180a/)\n## [The Intuitive Basics of Optimization](https://towardsdatascience.com/the-intuitive-basics-of-optimization-730e5b52180a/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nA gentle introduction to the amazing field of optimization\n[Jarom Hulet](https://towardsdatascience.com/author/jarom.hulet/)\nJune 26, 202412 min read\n  * [![](../images/010.png)](https://towardsdatascience.com/in-defense-of-statistical-modeling-e73d889b475d/)\n## [In defense of statistical modeling](https://towardsdatascience.com/in-defense-of-statistical-modeling-e73d889b475d/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nA persistent thread of commentary says data science is overhyped. Don't believe it.\n[Brian Kent](https://towardsdatascience.com/author/ctk-brian/)\nJune 10, 20218 min read\n  * [![](../images/011.png)](https://towardsdatascience.com/how-to-combine-the-forecasts-of-an-ensemble-11022e5cac25/)\n## [How to Combine the Forecasts of an Ensemble](https://towardsdatascience.com/how-to-combine-the-forecasts-of-an-ensemble-11022e5cac25/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nUsing dynamic forecasting ensembles to cope with changes in the time series\n[Vitor Cerqueira](https://towardsdatascience.com/author/vcerq/)\nJanuary 19, 20235 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/4970/image?etag=1780565225463&width=500&height=500) Productivity Tips, Data Career Insights, and Other Recent Must-Reads ](https://towardsdatascience.com/productivity-tips-data-career-insights-and-other-recent-must-reads-5c47eb7a2fe0/ \"Productivity Tips, Data Career Insights, and Other Recent Must-Reads\")\n\n\n",
  "metadata": {
    "title": "Beginner's Guide To Building A Singlish AI Chatbot | Towards Data Science",
    "description": "AI text generation is one of the most exciting fields in NLP, but also a daunting one for beginners. This post aims to speed up the...",
    "keywords": null,
    "author": "Chua Chin Hon",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "Beginner's Guide To Building A Singlish AI Chatbot",
    "og:description": "AI text generation is one of the most exciting fields in NLP, but also a daunting one for beginners. This post aims to speed up the...",
    "og:url": "https://towardsdatascience.com/beginners-guide-to-building-a-singlish-ai-chatbot-7ecff8255ee/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1dStowlpqDyRipF3JIvVV0Q-scaled.jpeg",
    "og:image:width": "2560",
    "og:image:height": "1707",
    "og:image:type": "image/jpeg",
    "twitter:card": "summary_large_image",
    "twitter:site": "@TDataScience",
    "twitter:creator": "@TDataScience",
    "twitter:label1": "Written by",
    "twitter:data1": "Chua Chin Hon",
    "twitter:label2": "Est. reading time",
    "twitter:data2": "8 min read",
    "article:published_time": "2020-08-05T07:29:49.000Z",
    "article:modified_time": "2020-08-05T07:29:49.000Z",
    "article:author": "https://towardsdatascience.com/author/chuachinhon/"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": ""
  },
  "code_blocks": [],
  "images": [
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:56:53Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:56:53Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:56:53Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/4970/image?etag=1780565225463&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/4970/image?etag=1780565225463&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:56:54Z"
    }
  ],
  "audio": [],
  "videos": [
    {
      "url": "https://www.youtube.com/c/TowardsDataScience",
      "kind": "channel_reference",
      "status": "reference_only"
    }
  ],
  "links": [
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/latest/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/editors-pick/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/the-variable/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/shipai/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/submissions/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/chuachinhon/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/ai/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/chatbots/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/singapore/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/transfer-learning/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/analysing-pharmaceutical-sales-data-in-python-6ce74da818ab/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/programming/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/pjwebdev/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/building-a-command-line-quiz-application-in-r/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/benjaminnweke/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/modelling-the-number-of-sunspots-with-time-series-analysis-39ce7d88cff3/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/machine-learning/"
    },
    {
      "type": "external",
      "href": "https://write.insightmediagroup.io"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/company/towards-data-science/"
    },
    {
      "type": "external",
      "href": "https://x.com/TDataScience"
    },
    {
      "type": "external",
      "href": "https://huggingface.co/transformers/notebooks.html"
    },
    {
      "type": "external",
      "href": "https://github.com/chuachinhon/practical_nlp"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/ai-data-scientist"
    },
    {
      "type": "external",
      "href": "https://www.analyticsvidhya.com/blog/2020/07/transfer-learning-for-nlp-fine-tuning-bert-for-text-classification/"
    },
    {
      "type": "external",
      "href": "https://scholarbank.nus.edu.sg/handle/10635/137343"
    },
    {
      "type": "external",
      "href": "https://github.com/chuachinhon/practical_nlp/blob/master/data/singlish.json"
    },
    {
      "type": "external",
      "href": "https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.0_data_prep_cch.ipynb"
    },
    {
      "type": "external",
      "href": "https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.1_finetune_bot_cch.ipynb"
    },
    {
      "type": "external",
      "href": "https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.2_dash_chat_app_cch.ipynb"
    },
    {
      "type": "external",
      "href": "https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.3_[aitextgen](https://github.com/minimaxir/aitextgen)_cpu_cch.ipynb"
    },
    {
      "type": "external",
      "href": "https://colab.research.google.com/signup"
    },
    {
      "type": "external",
      "href": "http://jalammar.github.io/illustrated-gpt2/"
    },
    {
      "type": "external",
      "href": "https://medium.com/huggingface/how-to-build-a-state-of-the-art-conversational-ai-with-transfer-learning-2d818ac26313"
    },
    {
      "type": "external",
      "href": "https://colab.research.google.com/drive/15wa925dj7jvdvrz8_z3vU7btqAFQLVlG"
    },
    {
      "type": "external",
      "href": "https://github.com/ncoop57/i-am-a-nerd/blob/master/_notebooks/2020-05-12-chatbot-part-1.ipynb"
    },
    {
      "type": "external",
      "href": "https://huggingface.co/microsoft/DialoGPT-medium"
    },
    {
      "type": "external",
      "href": "https://huggingface.co/microsoft/DialoGPT-small"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-20T17:29:27Z",
  "source_url": "https://towardsdatascience.com/beginners-guide-to-building-a-singlish-ai-chatbot-7ecff8255ee/",
  "delivery_status": "unverified",
  "discovery_status": "http_403",
  "missing_reason": "源页面未重新核验:http_403；已按保留正文补采图片",
  "repair_error": "",
  "actual_video_files": [],
  "expected_saved_body_images": 4,
  "image_discovery": "saved_markdown",
  "source_body_markdown": "![Revisit consent button](https://cdn-cookieyes.com/assets/images/revisit.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](https://cdn-cookieyes.com/assets/images/close.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Data Science](https://towardsdatascience.com/category/data-science/)\n# Beginner's Guide To Building A Singlish AI Chatbot\nAI text generation is one of the most exciting fields in NLP, but also a daunting one for beginners. This post aims to speed up the...\n[Chua Chin Hon](https://towardsdatascience.com/author/chuachinhon/)\nAugust 5, 20208 min read\n![Singlish phrases such as &quot;blur as a sotong&quot; can be bewildering for non-Singaporeans. Can a transformer model make sense of it? Photo: Chua Chin Hon](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1dStowlpqDyRipF3JIvVV0Q-scaled.jpeg)\nSinglish phrases such as \"blur as a sotong\" can be bewildering for non-Singaporeans. Can a transformer model make sense of it? Photo: Chua Chin Hon\n### AI text generation is one of the most exciting fields in NLP, but also a daunting one for beginners. This post aims to speed up the learning process for newcomers by combining and adapting several existing tutorials into a practical end-to-end walkthrough with notebooks and sample data for a conversational chatbot that can be used in an interactive app.\nAuto-text generation is undoubtedly one of the most exciting fields in NLP in recent years. But it's also an area that's relatively difficult for newcomers to navigate, due to the high bar for technical knowledge and resource requirements.\nWhile there's no shortage of [helpful notebooks](https://huggingface.co/transformers/notebooks.html) and tutorials out there, pulling the various threads together can be time consuming. To help speed up the learning process for fellow newcomers, I've put together a simple [end-to-end project](https://github.com/chuachinhon/practical_nlp) to create a simple AI conversational chatbot that you can run in an interactive app.\nI chose to frame the text generation project around a chatbot as we react more intuitively to conversations, and can easily tell whether the auto-generated text is any good. Chatbots are also ubiquitous enough that most of us would have a good sense of the expected baseline performance without having to consult a manual or an expert. If it's bad, you'll know right away without having to check a score or metric.\nThe workflow in the project is structured with the practical questions of a beginner in mind: How to get started with data extraction and preparation, what's needed to fine tune a pre-trained transformer model, and finally how to test/use the bot in an app.\nLearn this step by step with the interactive [AI and Data Scientist](https://roadmap.sh/ai-data-scientist) roadmap.\nThe end product is not what one might call \"polished\", as the screen-grab below of one of the test-runs shows. But as a first experiment, the results are good enough (in my view) for highlighting both the possibilities and limits of AI text generation via [transfer learning](https://www.analyticsvidhya.com/blog/2020/07/transfer-learning-for-nlp-fine-tuning-bert-for-text-classification/).\n![Screen-grab of test run of Singlish Chatbot on Colab.](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1kICGp1qA54EZYZCSt4mA8A.png)\nScreen-grab of test run of Singlish Chatbot on Colab.\n* * *\n## DATA, REPO AND REQUIREMENTS\nIf the sample conversation above looks bewildering to you, well, you've likely not been to Singapore and/or heard of \"Singlish\", or colloquial Singaporean English. It's a mish-mash of several languages and local slang, and can be confusing for non-Singaporeans. In other words, not a bad way to test the limits of the DialoGPT model.\nThe data for fine tuning the model is taken from a collection of [SMS messages by Singaporean students at a local university](https://scholarbank.nus.edu.sg/handle/10635/137343). While the written and spoken forms of \"Singlish\" can differ significantly, we'll set that aside for practical reasons.\nThe [dataset](https://github.com/chuachinhon/practical_nlp/blob/master/data/singlish.json) (raw and cleaned versions for training) and four related notebooks are available in my [repo](https://github.com/chuachinhon/practical_nlp). The notebooks are split according to the following tasks:\n  * notebook [3.0](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.0_data_prep_cch.ipynb): Data preparation\n  * notebook [3.1](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.1_finetune_bot_cch.ipynb): Fine tuning a pretrained DialoGPT-medium model on Colab (Pro)\n  * notebook [3.2](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.2_dash_chat_app_cch.ipynb): Testing the model's performance on an interactive Dash app\n  * notebook [3.3](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.3_\\[aitextgen\\]\\(https://github.com/minimaxir/aitextgen\\)_cpu_cch.ipynb): CPU alternative to text generation using aitextgen\n\n\nAs far as resource requirements go, you can run this project on a free Google/Colab account if you fine tune a DialoGPT-small model instead of the larger versions. If you are using a more robust dataset, perhaps fine tuning a DialoGPT-small model would be sufficient.\nBut I found that my results from fine tuning the smaller model weren't as good, and the constant housekeeping to avoid busting the 15Gb storage limit on a free Google account was a drain on productivity.\nIf you foresee yourself experimenting with more/larger transformer models in future, I'd recommend an upgrade to [Colab Pro](https://colab.research.google.com/signup) as well as increasing the amount of storage space on your Google account. This allowed me to iterate quickly, without having to wrestle with a physical eGPU set up at home.\nFor brevity, I won't go into the technical details in this post. I'm still learning as I go, and there are [far better articles](http://jalammar.github.io/illustrated-gpt2/) on [this topic](https://medium.com/huggingface/how-to-build-a-state-of-the-art-conversational-ai-with-transfer-learning-2d818ac26313) out there. Most of the code are lifted or adapted from the work of previous authors, and they are acknowledged as such in the notebooks.\n* * *\n## STEP 1: DATA PREPARATION\nThe first and biggest question for the project is whether you can find an appropriate dataset for your use case. The more specific the use case (say, a Trevor Noah chatbot), the harder it will be to find the appropriate training data. Ethical questions should be considered at the outset: Is it appropriate to model the chatbot after a real person, even if you have access to transcripts, and what is the likelihood of potential misuse?\nThe anonymised SMS dataset used in this project is among the few \"Singlish\" corpuses in the public space, and is the only one I've found that's large enough for this purpose. The first half of [notebook3.0](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.0_data_prep_cch.ipynb) involves the steps needed to extract the SMSes from a deeply nested json file. Skip this if you are using a different dataset.\nThe second half deals with the very specific way that the training and validation data sets have to be prepared for use in the DialoGPT model. Essentially, for every SMS you have to create x-number of previous SMSes as \"context\":\n![Click here to see another example of how data is prepared in building a Rick Sanchez bot.](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1UdXapp-bU4yFFmcU8pByjQ.png)\nClick here to see [another example](https://colab.research.google.com/drive/15wa925dj7jvdvrz8_z3vU7btqAFQLVlG) of how data is prepared in building a Rick Sanchez bot.\nI settled on seven previous responses, but you can change it up or down to see what impact this may or may not have on the chatbot's performance. If this is more than an experiment for you, I suspect this is where you'll be spending a lot of time tweaking the dataset to clean up the response/context. Unfortunately, I've not come across a good tutorial on how best to structure or tweak custom datasets for fine tuning a DialoGPT model.\nAfter splitting the response-context dataset into training and validation sets, you are pretty much set for the fine tuning.\n## STEP 2: FINE TUNING DIALOGPT\nThere's a tonne of code involved in the fine tuning process, but thanks to the earlier work by folks like [Nathan Cooper](https://github.com/ncoop57/i-am-a-nerd/blob/master/_notebooks/2020-05-12-chatbot-part-1.ipynb) and [Rostyslav Neskorozhenyi](https://colab.research.google.com/drive/15wa925dj7jvdvrz8_z3vU7btqAFQLVlG), the training loops can be used as is without new users having to make major changes. You can study the code in greater detail when you have more time. The key cell to note in [notebook3.1](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.1_finetune_bot_cch.ipynb) is the one below:\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1mMnVSNPFPO5BzssqhdgwtQ.png)\nThis is where you'd need to make changes depending on your dataset and the set-up at your disposal. For example, you can stick with the [medium-sized DialoGPT model](https://huggingface.co/microsoft/DialoGPT-medium) or dial down to the [small one](https://huggingface.co/microsoft/DialoGPT-small).\nIf you encounter GPU-out-of-memory issues, you'll have to reduce the batch size (as I did in cell above by reducing to 1). If you don't have much storage space left in your Google Drive, you'll have to adjust the logging_steps and save_steps intervals accordingly (files saved at various checkpoints can chew up storage space in a hurry).\nThe fine tuning process can take anything from 40 minutes to about 2 hours, depending on the parameters you set. Do note that there are usage limits even on Colab Pro. For instance, I wasn't able to fine tune a DialoGPT-large model due to GPU memory limits. Colab Pro notebooks can run up to 24 hours, but I have yet to test that out with more epochs.\nThe one metric to take note of at the end of the fine tuning process is the [perplexity score](https://huggingface.co/transformers/perplexity.html) - a measure of how certain the model is in picking the next token. The lower the score, the better as it means the model is less uncertain.\nI got a perplexity score of 1.6134 from fine tuning the DialoGPT-medium model, a significant improvement from the scores in the ranges of 6.3 to 5.7 when using the DialoGPT-small model. It'll take several runs for you to figure out what's an acceptable score.\nYou can start chatting with the bot at the end of the [notebook](https://colab.research.google.com/github/plotly/dash-sample-apps/blob/master/apps/dash-chatbot/ColabDemo.ipynb) (assuming everything ran correctly), but I much prefer to load the fine tuned model into an app. Thanks to [Lu Xing Han](https://github.com/xhlulu) @ [Plotly](https://community.plotly.com/t/show-tell-dash-transformers-apps-auto-summarization-translator-and-chatbot-are-now-runnable-on-colab/42762), there's a notebook for that.\n## STEP 3: TEST YOUR FINE TUNED MODEL IN A DASH APP\nThe Plotly repo contains code for running [the chatbot app on a local machine](https://github.com/plotly/dash-sample-apps/blob/master/apps/dash-chatbot/app.py) if you wish to do that, but I opted to run [notebook3.2](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.2_dash_chat_app_cch.ipynb) on Colab for practical reasons (the fine tuned model is already there). The code is lifted straight from Lu Xing Han's demo, with minor changes towards the end for folks who might want to experiment further with the output from the bot:\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/1G2ZdqPUKALkp-y9VcOPVfQ.png)\n\"Temperature\" allows you to control the level of creativity (or craziness/brazenness) of the responses. You can reduce the length of the chatbot's \"utterances\" by lowering the max_length (max number of token: 1,024; default: 256 tokens). A full list of the arguments you can tweak for the chatbot conversation can be found [here, under the section \"Using the interaction script\"](https://github.com/huggingface/transfer-learning-conv-ai).\nHere's a screen-grab of slightly more successful conversation I managed to have with the chatbot. Highlighted cells are my entries:\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/13lpKu7-FkslIkH4K9nKDRQ.png)\nThe fine tuned pytorch model is too big (1.44Gb) to be deployed on any free hosting account, so there's no way (for now) for you to try this particular Singlish chatbot on a web app.\nMy take: The \"Singlish\" chatbot is not ready for prime-time. It can give surprisingly good responses at times, but can't sustain the effort beyond a few exchanges. As you can see in the screen-grab above, things go sideways towards the end. With a richer dataset and perhaps enough compute to train on a DialoGPT-large model, the responses might get better.\nBut as an experiment, I'd have to say the performance is not half bad at all.\n## BONUS STEP: CPU ALTERATIVE TO AUTO-TEXT GENERATION\nThere are a number of alternatives out there if you'd rather not use Colab and/or confine the data and the fine-tuning to a local machine. I'll just highlight one Python library that I've been experimenting with - [aitextgen](https://github.com/minimaxir/aitextgen) - that provides an option for CPU-only training.\n[Notebook3.3 ](https://github.com/chuachinhon/practical_nlp/blob/master/notebooks/3.3_aitextgen_cpu_cch.ipynb)outlines a simple example using the same SMS dataset in this project. I had previously tried aitextgen with other datasets involving YouTube transcripts of political speeches in Singapore. Unfortunately, I've not been able to get very satisfactory results so far.\nI'm probably not using it right. You might have better luck. A[itextgen can run on Colab](https://colab.research.google.com/drive/15qBZx5y9rdaQSyWpsreMDnTiZ5IlN0zD?usp=sharing) too.\n* * *\nHopefully this post and the accompanying notebooks will help you get started quickly on experiments with your own AI chatbot. What's far harder to do is figuring out how to improve its performance, or ensure that it's [safe for public use](https://www.theverge.com/2016/3/24/11297050/tay-microsoft-chatbot-racist).\nThere are also related technical issues to explore, such as slimming the model down for deployment or more advanced interactive app designs that can bring out additional functionalities in the chatbot. If you have recommendations for any of the above topics, or spot mistakes in this post, ping me at:\nTwitter: [Chua Chin Hon](https://medium.com/u/b3d8090c0aee?source=post_page-----aad7f2e1d0a0----------------------)\nLinkedIn: [www.linkedin.com/in/chuachinhon](http://www.linkedin.com/in/chuachinhon)\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](https://assets.insightmediagroup.io/media/1787657280763_838i2j.png)\nWritten By\n## [Chua Chin Hon](https://towardsdatascience.com/author/chuachinhon/)\n[See all from Chua Chin Hon](https://towardsdatascience.com/author/chuachinhon/)\n[AI](https://towardsdatascience.com/tag/ai/)[Chatbots](https://towardsdatascience.com/tag/chatbots/)[Data Science](https://towardsdatascience.com/tag/data-science/)[Singapore](https://towardsdatascience.com/tag/singapore/)[Transfer Learning](https://towardsdatascience.com/tag/transfer-learning/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fbeginners-guide-to-building-a-singlish-ai-chatbot-7ecff8255ee%2F&title=Beginner's%20Guide%20To%20Building%20A%20Singlish%20AI%20Chatbot)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fbeginners-guide-to-building-a-singlish-ai-chatbot-7ecff8255ee%2F&title=Beginner's%20Guide%20To%20Building%20A%20Singlish%20AI%20Chatbot)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fbeginners-guide-to-building-a-singlish-ai-chatbot-7ecff8255ee%2F&text=Beginner's%20Guide%20To%20Building%20A%20Singlish%20AI%20Chatbot)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/09/0X8QgupiDcyZWNUzp-scaled.jpg)](https://towardsdatascience.com/analysing-pharmaceutical-sales-data-in-python-6ce74da818ab/)\n## [Analysing Pharmaceutical Sales Data in Python](https://towardsdatascience.com/analysing-pharmaceutical-sales-data-in-python-6ce74da818ab/)\n[Programming](https://towardsdatascience.com/category/programming/)\nHow to analyse pharmaceutical sales data using Python, Pandas, Matplotlib and regression models\n[Przemyslaw Jarzynski](https://towardsdatascience.com/author/pjwebdev/)\nSeptember 6, 20209 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/10/mohammad-rahmani-8qEB0fTe9Vw-unsplash-1.jpg)](https://towardsdatascience.com/building-a-command-line-quiz-application-in-r/)\n## [Building a Command-Line Quiz Application in R](https://towardsdatascience.com/building-a-command-line-quiz-application-in-r/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nPractice control flow, input handling, and functions in R by creating an interactive quiz game.\n[Benjamin Nweke](https://towardsdatascience.com/author/benjaminnweke/)\nOctober 5, 20256 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/09/0ed_P3s6Y5sk7cGum-scaled.jpg)](https://towardsdatascience.com/modelling-the-number-of-sunspots-with-time-series-analysis-39ce7d88cff3/)\n## [Can LSTM be used to Forecast the Number of Sunspots?](https://towardsdatascience.com/modelling-the-number-of-sunspots-with-time-series-analysis-39ce7d88cff3/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nI will be predicting the number of monthly Sunspots using time series analysis. The models that will be explored in-depth are the ARMA and...\n[Ethan Johnson-Skinner, MSc](https://towardsdatascience.com/author/ethanskinner94/)\nSeptember 9, 202110 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/07/1w6LTOSIRvpGp0CfJqFAnyQ-scaled.jpeg)](https://towardsdatascience.com/p-value-explained-c7f5547c0562/)\n## [P value - Explained](https://towardsdatascience.com/p-value-explained-c7f5547c0562/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nWhat it means and how it is used. Explained with a use case.\n[Soner Yıldırım](https://towardsdatascience.com/author/sonery/)\nJuly 8, 20207 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/01/19YYYmmF6pNauJHzVMQFzDw-scaled.jpeg)](https://towardsdatascience.com/end-to-end-shiny-app-tutorial-using-nyc-mortality-data-d29ad99506b9/)\n## [End to end Shiny app tutorial using NYC mortality data](https://towardsdatascience.com/end-to-end-shiny-app-tutorial-using-nyc-mortality-data-d29ad99506b9/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nConceptual overview and step by step guide for beginners\n[Emily A. Halford](https://towardsdatascience.com/author/emilyahalford/)\nJanuary 10, 202117 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/03/12RhTry5pAjpSaScT5sGk0g.png)](https://towardsdatascience.com/a-journey-through-xgboost-milestone-1-ff1be2970d39/)\n## [A Journey through XGBoost: Milestone 1](https://towardsdatascience.com/a-journey-through-xgboost-milestone-1-ff1be2970d39/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nSetting up the background\n[Rukshan Pramoditha](https://towardsdatascience.com/author/rukshanpramoditha/)\nMarch 2, 20216 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/06/1ljCHgdd8vYLzsXI3wwPeFQ.png)](https://towardsdatascience.com/the-intuitive-basics-of-optimization-730e5b52180a/)\n## [The Intuitive Basics of Optimization](https://towardsdatascience.com/the-intuitive-basics-of-optimization-730e5b52180a/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nA gentle introduction to the amazing field of optimization\n[Jarom Hulet](https://towardsdatascience.com/author/jarom.hulet/)\nJune 26, 202412 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/06/0wFAKSptAwJbWrE3d.png)](https://towardsdatascience.com/in-defense-of-statistical-modeling-e73d889b475d/)\n## [In defense of statistical modeling](https://towardsdatascience.com/in-defense-of-statistical-modeling-e73d889b475d/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nA persistent thread of commentary says data science is overhyped. Don't believe it.\n[Brian Kent](https://towardsdatascience.com/author/ctk-brian/)\nJune 10, 20218 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1Ko8iXVYg-JKDyH_tpz1ILQ.png)](https://towardsdatascience.com/how-to-combine-the-forecasts-of-an-ensemble-11022e5cac25/)\n## [How to Combine the Forecasts of an Ensemble](https://towardsdatascience.com/how-to-combine-the-forecasts-of-an-ensemble-11022e5cac25/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nUsing dynamic forecasting ensembles to cope with changes in the time series\n[Vitor Cerqueira](https://towardsdatascience.com/author/vcerq/)\nJanuary 19, 20235 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/4970/image?etag=1780565225463&width=500&height=500) Productivity Tips, Data Career Insights, and Other Recent Must-Reads ](https://towardsdatascience.com/productivity-tips-data-career-insights-and-other-recent-must-reads-5c47eb7a2fe0/ \"Productivity Tips, Data Career Insights, and Other Recent Must-Reads\")\n\n\n",
  "body_base_path": "attachments/d30f39c8c450/pages/",
  "body_markdown_path": "attachments/d30f39c8c450/pages/archived-body.md",
  "local_html": "attachments/d30f39c8c450/pages/archived-body.html",
  "body_source": "prior_capture"
}