{"id":459,"date":"2023-04-20T17:44:56","date_gmt":"2023-04-20T17:44:56","guid":{"rendered":"https:\/\/kevingoedecke.com\/?p=459"},"modified":"2023-04-21T14:00:42","modified_gmt":"2023-04-21T14:00:42","slug":"fine-tuning-chatgpt-on-our-intercom-support-chat-history","status":"publish","type":"post","link":"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/","title":{"rendered":"Fine Tuning ChatGPT on our Intercom support chat history"},"content":{"rendered":"\n<p>Fine Tuning ChatGPT on your Intercom support chat history<\/p>\n\n\n\n<p>An experiment: Fine tuning a ChatGPT model on your customer support chat history to provide automatic replies or suggestions.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Introduction &amp; Goal<\/h1>\n\n\n\n<p>Fine tuning a model has gotten significantly easier in ChatGPT 3 compared to GPT 2. All it really takes nowadays is for you to prepare a data set of prompts and replies and ChatGPT will be able to fine tune a model for you. I wanted to dig into how to fine tune a model myself, so I decided to pick up a little side project.<\/p>\n\n\n\n<p>At Magicul.io we use Intercom for our support chat and we\u2019ve been doing so for the last 3 years. That means that all the replies that we\u2019ve manually sent out over the years are stored in our Intercom support chat history. Perfect material to train an AI model on, I was thinking\u2026 \ud83e\udd14<\/p>\n\n\n\n<p>Well apparently I\u2019m not the only one who had that idea. Intercom itself is working on their own AI chatbot called \u201cFin\u201d. Powered by ChatGPT 4 it looks very promising and I bet it will be. Apparently ChatGPT 3.5 had too many issues and wasn\u2019t reliable enough to give direct answers to customers (read more about it here: <a href=\"https:\/\/www.intercom.com\/blog\/announcing-intercoms-new-ai-chatbot\/\">https:\/\/www.intercom.com\/blog\/announcing-intercoms-new-ai-chatbot\/<\/a>). That being said, \u201cFin\u201d isn\u2019t currently even available to the public. It doesn\u2019t seem to be quite ready yet. You can sign up for a wait list, but even after the public release I bet Intercom is going to make this paid feature (duh) \ud83d\ude2a&nbsp;<\/p>\n\n\n\n<p>So my idea was the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Train my own model based on all the support chat answers we\u2019ve given manually over the last 3 years<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Don\u2019t reply automatically to customer automatically but rather give highly accurate suggestions<\/li>\n\n\n\n<li>Ideally this will reduce support workload and make it easier to onboard new support agents<\/li>\n<\/ul>\n\n\n\n<p>So I started to dig into it\u2026<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Requirements<\/h1>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Have a big chat history in Intercom: <\/strong>In order to fine tune a ChatGPT model you need data, a lot of data\u2026 the more the better. So if you\u2019re reading this article with the plan to implement this yourself you have to have a big data set.&nbsp;<\/li>\n\n\n\n<li><strong>A paid OpenAI account:<\/strong> Since we\u2019ll be using OpenAIs ChatGPT you\u2019ll need a paid account. A quick heads up: fine tuning a model isn\u2019t cheap, I\u2019ve spent about $6-10 per fine tuning job.<\/li>\n<\/ol>\n\n\n\n<h1 class=\"wp-block-heading\">Exporting your Intercom Chat History<\/h1>\n\n\n\n<p>Unfortunately there\u2019s no easy way to export and download your Intercom chat history. I was really hoping it would be as easy as signing into the admin panel and hitting a download button.&nbsp;<\/p>\n\n\n\n<p>After looking into this for a while I found a few GitHub repositories. Some of them came close to what I had in mind:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/github.com\/TheArtling\/intercom-conversations-export\">https:\/\/github.com\/TheArtling\/intercom-conversations-export<\/a>\n<ul class=\"wp-block-list\">\n<li>A Python script that exports your Intercom conversations as txt files<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/toch\/intercom-export\">https:\/\/github.com\/toch\/intercom-export<\/a>\n<ul class=\"wp-block-list\">\n<li>A Ruby script to export your Intercom data<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>I decided to give the Python script a try first. After fiddled around with it for a while I managed to export our existing conversations as txt files. Great!<\/p>\n\n\n\n<p>There was only a small problem: In order to fine tune the ChatGPT model later, we need to have the data as a JSONL file (yes, you read correctly, not JSON, but JSONL, see here: <a href=\"https:\/\/platform.openai.com\/docs\/guides\/fine-tuning\">https:\/\/platform.openai.com\/docs\/guides\/fine-tuning<\/a> and <a href=\"https:\/\/jsonlines.org\/\">https:\/\/jsonlines.org\/<\/a>). Additionally the data has to be in a prompt\/completion format. Meaning that we have to prepare the data further and potentially cut out subsequent conversations parts after the initial customer question was answered.<\/p>\n\n\n\n<p>Here\u2019s an example of the structure that we need to fine tune the model later:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\"prompt\": \"Do you offer a free trial?\", \"completion\": \"No, but we have a 30 day money back guarantee, so you can go ahead and purchase one of our plans and always get your money back afterwards if you\u2019re not happy.\"}\n\n{\"prompt\": \"Do you share any data with 3rd parties?\", \"completion\": \"No, we don\u2019t share any data with any 3rd party. Our terms and conditions state that by using our service you solely grant us the right to access the data for the purpose of the conversion and nothing else.\"}<\/code><\/pre>\n\n\n\n<p>Given that we need a different output format and also potentially have to clean the exported Intercom data, I decided to write my own JavaScript script to export all conversations from Intercom.<\/p>\n\n\n\n<p>I\u2019ve uploaded the Intercom export script here: <a href=\"https:\/\/github.com\/kgoedecke\/intercom-exporter-node\">https:\/\/github.com\/kgoedecke\/intercom-exporter-node<\/a><\/p>\n\n\n\n<p>Credit to @TheArtling, because my codebase is heavily influenced by their project.<\/p>\n\n\n\n<p><br>A few words about what this script does, this is important since the data we need is not directly what comes back from the API:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>It retrieves all conversations from your Intercom account<\/li>\n\n\n\n<li>It then filters for only conversations that are customer initiated<\/li>\n\n\n\n<li>It then removes all replies except for the VERY FIRST one, this is critical since we don\u2019t want the whole conversation<\/li>\n\n\n\n<li>It then filters out empty replies and only keeps replies which were written by an admin\/support agent<\/li>\n\n\n\n<li>Last step: It removes all HTML tags from the reply<\/li>\n<\/ol>\n\n\n\n<p>Let\u2019s go ahead and see what this nifty script can do for us in practice.<\/p>\n\n\n\n<p>In order to get started you need to get an Intercom API access token. Head over to the Intercom developer hub and get your token (see: <a href=\"https:\/\/developers.intercom.com\/building-apps\/docs\/authentication-types#access-tokens\">https:\/\/developers.intercom.com\/building-apps\/docs\/authentication-types#access-tokens<\/a>).<\/p>\n\n\n\n<p>Once you\u2019ve got it, simply clone the Intercom Conversation Export repository from GitHub:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/kgoedecke\/intercom-exporter-node<\/code><\/pre>\n\n\n\n<p>Afterwards copy the <code>.env.example<\/code> file to <code>.env<\/code> and change the values in it.<\/p>\n\n\n\n<p>For example your .env file should look like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>INTERCOM_TOKEN = 2LDJwyV9S7HsKxAxLx7b2Yv3H0nSeuh='\n\nOUTPUT_PATH = '\/Users\/kevin\/Downloads'<\/code><\/pre>\n\n\n\n<p>Install all dependencies with <code>yarn<\/code> and then you can go ahead and simply run `yarn start` to get the conversation export process started. This should print out something like the following<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yarn start &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \n\nyarn run v1.22.19\n\n$ node src\/index.js\n\nNext page URL: https:\/\/api.intercom.io\/conversations?starting_after=WzE2ODE5MjY5NjkwMDAsMTYyNTAzODAwMjMzMzg4LDJd\n\nRetrieving 2 of 485\n\nNext page URL: https:\/\/api.intercom.io\/conversations?starting_after=WzE2ODE4NDM3MjIwMDAsMTYyNTAzODAwMjMzNDc1LDNd\n\nRetrieving 3 of 485<\/code><\/pre>\n\n\n\n<p>Once it has finished you\u2019ll find a file called <code>output.jsonl<\/code> in the directory you\u2019ve specified in your <code>.env<\/code> file.<\/p>\n\n\n\n<p>Go ahead and open it to check what\u2019s in it.<\/p>\n\n\n\n<p>Here are a few lines of what our file looks like:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\"prompt\":\"Hey wondering if your program works for Keynote to Figma too?\",\"completion\":\"Hi there,\\n\\nThanks for reaching out. Unfortunately, we don't support Keynote to Figma conversion. Nonetheless, you can try our Powerpoint to Figma converter, since Keynote offers an option to export files as PowerPoint.\\n\\nI hope this information is helpful. Please don't hesitate to contact us if you have any further queries or concerns.\\n\\nBest regards,\\nLokman\"}\n\n{\"prompt\":\"Hi, the canva to figma converter appears to still be down. Could someone please convert this manually for me? Thanks\",\"completion\":\"Hi there,\\n\\nSorry for the trouble. Yes, unfortunately, our Canva to Figma production server is down. We will convert your file locally and send you the file as soon as possible.\\n\\nBest regards,\\nLokman\"}\n\n{\"prompt\":\"Hi Support,I recently purchased a subscription at Magicul and already have two issues. Maybe you can assist.1. How do I download the converted file?I took the following steps:I uploaded a Canva file, then paid for the subscription, and logged in.Clicked Files.I see the copy (Download your converted files here) and see the converted file below.I see the option to Convert (again) but not download.2. It seems as though the same file was converted twice, so now I have one less credit. Thanks for your help.\",\"completion\":\"Hi there,\\n\\nSorry for the inconvenience. Would you please send me the link to your Canva design? It seems the file did not convert due to a bug.\\n\\nLet me know if you have any questions.\\n\\nRegards,\\nLokman\"}\n\n{\"prompt\":\"can i get a trial of one file one artboard to see how well magicul converts from XD to Figma?\",\"completion\":\"Hi there, \\n\\nYour converted file is ready. Please click here to download your file.\\n\\nLet us know if there's any issue.\\n\\nRegards,\\nLokman\"}<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">Cleaning your Chat History Data<\/h1>\n\n\n\n<p>Just by looking at the data that we\u2019ve exported from Intercom it\u2019s already quite obvious that we\u2019ll have to do some cleaning here.&nbsp;<\/p>\n\n\n\n<p>Here are some of the issues with the raw data:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Data may contain sensitive information that should not be feed into ChatGPT<\/li>\n\n\n\n<li>Incomplete answers should be deleted<\/li>\n\n\n\n<li>For now our export only contains the very first reply, if the support agent just replied with \u201cHello, how can I help\u201d then it\u2019s not really helpful<\/li>\n<\/ul>\n\n\n\n<p><br>All those things&nbsp; can be potentially implemented in the Intercom conversation export script. To keep this tutorial short I\u2019ve manually cleaned our dataset by removing sensitive data and useless replies.&nbsp;<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Fine Tuning the ChatGPT model<\/h1>\n\n\n\n<p>So let\u2019s fine tune our ChatGPT model with the data we\u2019ve exported from Intercom.<\/p>\n\n\n\n<p>In order to do so we\u2019ll be using the OpenAI Command Line Interface (CLI).<\/p>\n\n\n\n<p>I would recommend you follow my tutorial on how to get the OpenAI CLI set up on your computer: <a href=\"https:\/\/kevingoedecke.com\/blog\/2023\/04\/14\/how-to-install-openai-cli-on-macos\/\">https:\/\/kevingoedecke.com\/blog\/2023\/04\/14\/how-to-install-openai-cli-on-macos\/<\/a><\/p>\n\n\n\n<p>To verify that you\u2019ve got it properly setup, simply run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>openai --help<\/code><\/pre>\n\n\n\n<p>This should give you back a set of available command from the OpenAI CLI.<\/p>\n\n\n\n<p>The first thing we\u2019ll have to do is prepare the JSONL data. The OpenAI CLI has a command that takes care of that.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>openai tools fine_tunes.prepare_data -f \/Users\/kevin\/Downloads\/output.jsonl<\/code><\/pre>\n\n\n\n<p>In my case this prompted me with the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>openai tools fine_tunes.prepare_data -f \/Users\/kevin\/Downloads\/output.jsonl&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\n\nAnalyzing...\n\n- Your file contains 1648 prompt-completion pairs\n\n- Your data does not contain a common separator at the end of your prompts. Having a separator string appended to the end of the prompt makes it clearer to the fine-tuned model where the completion should begin. See https:\/\/platform.openai.com\/docs\/guides\/fine-tuning\/preparing-your-dataset for more detail and examples. If you intend to do open-ended generation, then you should leave the prompts empty\n\n- Your data does not contain a common ending at the end of your completions. Having a common ending string appended to the end of the completion makes it clearer to the fine-tuned model where the completion should end. See https:\/\/platform.openai.com\/docs\/guides\/fine-tuning\/preparing-your-dataset for more detail and examples.\n\n- The completion should start with a whitespace character (` `). This tends to produce better results due to the tokenization we use. See https:\/\/platform.openai.com\/docs\/guides\/fine-tuning\/preparing-your-dataset for more details\n\nBased on the analysis we will perform the following actions:\n\n- &#91;Recommended] Add a suffix separator `\\n\\n###\\n\\n` to all prompts &#91;Y\/n]: Y\n\n- &#91;Recommended] Add a suffix ending ` END` to all completions &#91;Y\/n]: Y\n\n- &#91;Recommended] Add a whitespace character to the beginning of the completion &#91;Y\/n]: Y<\/code><\/pre>\n\n\n\n<p>Say yes (type \u201cY\u201d) for all optimization suggestions.<\/p>\n\n\n\n<p>Afterwards we\u2019re ready to properly train our model with our Intercom exported chat history.<\/p>\n\n\n\n<p>Execute the following (<strong>Note:<\/strong> make sure to use the cleaned jsonl file from the step before):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>openai api fine_tunes.create -t \"\/Users\/kevin\/Downloads\/output_prepared (1).jsonl\"<\/code><\/pre>\n\n\n\n<p>This might take a while depending on how big your data set is.<\/p>\n\n\n\n<p>After a bit of waiting around I got prompted with this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ openai api fine_tunes.create -t\n\n\/Users\/kevin\/Downloads\/output_prepared (1).jsonl -m davinci\n\nUpload progress: 100%\n\nUploaded file from \/tmp\/output. jsonl: file-XXX\n\nCreated fine-tune: ft-XXX\n\nStreaming events until fine-tuning is complete...\n\n(Ctrl-C will interrupt the stream, but not cancel the fine-tune)\n\n&#91;2023-04-18 14:58:17] Created fine-tune: ft-XXX\n\n&#91;2023-04-18 14:59:16] Fine-tune costs $6.94<\/code><\/pre>\n\n\n\n<p>As you can see it cost me $6.94 to fine tune my ChatGPT model with my existing Intercom records. This is obviously not cheap. The price highly depends on how many records you feed into the fine tuning and also which underlying model you use. I used `davinci`, but according to other posts out there you might be able to achieve similar results using a cheaper model like `ada`.<\/p>\n\n\n\n<p>Alright so now that we\u2019ve finally managed to fine tune our model let\u2019s give it a spin \ud83e\udd41<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Results &#8211; How well does it work?<\/h1>\n\n\n\n<p>You can now go ahead and try your fine tuned model out by shooting some prompts to the ChatGPT API via the CLI. To my surprise I was also able to see my fine tune model even in the ChatGPT playground (<a href=\"https:\/\/platform.openai.com\/playground\">https:\/\/platform.openai.com\/playground<\/a>).<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/lh5.googleusercontent.com\/lM58DFpH4nN1iCLqoA86WatEoFchN0djez9V4MfiKNS6EPubf72deKzNlp2TJVjEhGvK_fU0c8jdXUfd6ylzdI6ua_WwJNbbvSPvecXrlRX2wwHZ30373ijSKnHRJoYhbV-iOfML_U6KwOYM7jnXlg\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/lM58DFpH4nN1iCLqoA86WatEoFchN0djez9V4MfiKNS6EPubf72deKzNlp2TJVjEhGvK_fU0c8jdXUfd6ylzdI6ua_WwJNbbvSPvecXrlRX2wwHZ30373ijSKnHRJoYhbV-iOfML_U6KwOYM7jnXlg\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<p>Let\u2019s feed it some questions, shall we\u2026<\/p>\n\n\n\n<p>Most of our customer service requests are one of the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Someone wants to know if we offer a free trial<\/li>\n\n\n\n<li>Someone has questions about one of our plans<\/li>\n\n\n\n<li>Someone has a problem with a file conversion (we offer a design file converter)<\/li>\n<\/ul>\n\n\n\n<p><br>Here are some of the results are training ChatGPT.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/lh3.googleusercontent.com\/hcyd3d39hizVVqkMvllxd2JnOzTbQ0BzBRwNQaEnxufcZdLVk_oZsG_WilgNBc_y-LUv-vIXcjr3hbw5hKQ-6uymwW4RyXcijDHP1s-MTaeFNImLhNsBn2Ntxwi_8tI5aaJEg8R-z_ap_6MuS3k_Vw\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/hcyd3d39hizVVqkMvllxd2JnOzTbQ0BzBRwNQaEnxufcZdLVk_oZsG_WilgNBc_y-LUv-vIXcjr3hbw5hKQ-6uymwW4RyXcijDHP1s-MTaeFNImLhNsBn2Ntxwi_8tI5aaJEg8R-z_ap_6MuS3k_Vw\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<p>It was interesting to see that ChatGPT tried to become one of our customer support agents (Lokman) and it was even more funny to see it giving away a 50% discount on the first payment \ud83d\udcb8HAHA! Am I really ok with this \ud83d\ude02<\/p>\n\n\n\n<p>Here\u2019s another very impressive one:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/lh5.googleusercontent.com\/JfJs8-PQaXQGvu-iMwUzeCJfrPLpPzORwc28rWrwnX9kjDfkYSEKnt5_8ND5ariN_JfW-OcFavC1zuS7dChOHwIOpuUC3VFoA2W7DfwVhJdYhJAVu_0ZTsBBPfxW2XIH1atqk9EcUzFTqHvkDebnGg\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/JfJs8-PQaXQGvu-iMwUzeCJfrPLpPzORwc28rWrwnX9kjDfkYSEKnt5_8ND5ariN_JfW-OcFavC1zuS7dChOHwIOpuUC3VFoA2W7DfwVhJdYhJAVu_0ZTsBBPfxW2XIH1atqk9EcUzFTqHvkDebnGg\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<p>It seems to have managed to pick up which exact file formats our design file converter supports and in which plan it is included. Kudos ChatGPT, not bad at all!<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/lh4.googleusercontent.com\/79CTpEQNlXvzg1CDuYTbzvkhCeQSw6znoTkXa_OHSEnNxVxu--bFwJwitoqwzKC-8GJDAUan-RvU6_McraQ1EeUyCjgdSueQjq8aWvyMDqjTOxscSJWTRDmiQXQap_kSzXv1JHY9Lwa2QMREF_LLmA\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/79CTpEQNlXvzg1CDuYTbzvkhCeQSw6znoTkXa_OHSEnNxVxu--bFwJwitoqwzKC-8GJDAUan-RvU6_McraQ1EeUyCjgdSueQjq8aWvyMDqjTOxscSJWTRDmiQXQap_kSzXv1JHY9Lwa2QMREF_LLmA\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<p>This one is really impressive too, since it actually picked up very specific things about our business.&nbsp;<\/p>\n\n\n\n<p>Generally speaking I was very impressed with the results. That being said it also gave some very bad answers. I think this is partly because of the input data on which we fine tuned the model.&nbsp;<\/p>\n\n\n\n<p>Have a look at this one:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/lh4.googleusercontent.com\/xhHU8-D-KoF07nu9Q6Hqp6HwSrJzQSl8M3ou8ogvwhIRPDScsntQ0QzHYdL2X1fmwL2b_FehwSjTdbOlJHR70vTM0TZQm5vKhkgOk8UzoXoMKjGXTo_bS7KHJyILUWghh1KgHPBHD5pDwHrnVsK0yA\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/xhHU8-D-KoF07nu9Q6Hqp6HwSrJzQSl8M3ou8ogvwhIRPDScsntQ0QzHYdL2X1fmwL2b_FehwSjTdbOlJHR70vTM0TZQm5vKhkgOk8UzoXoMKjGXTo_bS7KHJyILUWghh1KgHPBHD5pDwHrnVsK0yA\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<p>Here it pretty much replied to the customer with another question. Very odd.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Cost<\/h1>\n\n\n\n<p>Obviously cost is a big factor in all this. I ended up spending about $7 to fine tune our model. This can get significantly more expensive if your data set is bigger.&nbsp;<\/p>\n\n\n\n<p>The requests afterwards follow the standard OpenAI ChatGPT pricing. As of writing this for ChatGPT 3.5 this is $0.002 \/ 1K tokens.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Where to take it from here?<\/h1>\n\n\n\n<p>There is so much room for improvement here. I think if taken more seriously it would easily be possible to improve the fine tuned model by cleaning up the input data further. It was very impressive to see how well ChatGPT can be trained on a data set that isn\u2019t gigantic.<\/p>\n\n\n\n<p>Additionally it\u2019s possible to filter out certain replies using sentiment checks or other techniques.<\/p>\n\n\n\n<p>Another interesting thing to look into would be to search through existing answers and rewriting them using ChatGPT. An approach here could be to turn all answers into embeddings, storing them in a vector storage and then upon a customer inquiry search over vectors storage similar answers. The results could then be passed into a ChatGPT prompt.<\/p>\n\n\n\n<p>I don\u2019t think a fine-tuned ChatGPT bot would be able directly serve as a customer support agent, but I definitely think it would make a lot of sense to give suggestions on how to reply to customers.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Open Source Code \/ Repos<\/h2>\n\n\n\n<p>You can find the code for the Intercom exporter here: <a href=\"https:\/\/github.com\/kgoedecke\/intercom-exporter-node\">https:\/\/github.com\/kgoedecke\/intercom-exporter-node<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Is it possible to replace support agents with ChatGPT? An experiment: Fine tuning a ChatGPT model on our Intercom support chat history to provide automatic replies or suggestions.<\/p>\n","protected":false},"author":1,"featured_media":470,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[15,1],"tags":[46,43,45,44],"class_list":["post-459","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming","category-uncategorized","tag-ai","tag-chatgpt","tag-intercom","tag-openai"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Fine Tuning ChatGPT on our Intercom support chat history - Kevin Goedecke<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fine Tuning ChatGPT on our Intercom support chat history - Kevin Goedecke\" \/>\n<meta property=\"og:description\" content=\"Is it possible to replace support agents with ChatGPT? An experiment: Fine tuning a ChatGPT model on our Intercom support chat history to provide automatic replies or suggestions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/\" \/>\n<meta property=\"og:site_name\" content=\"Kevin Goedecke\" \/>\n<meta property=\"article:published_time\" content=\"2023-04-20T17:44:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-21T14:00:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2023\/04\/intercom-chatgpt-bot-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1800\" \/>\n\t<meta property=\"og:image:height\" content=\"900\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Kevin Goedecke\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kevin Goedecke\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/\",\"url\":\"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/\",\"name\":\"Fine Tuning ChatGPT on our Intercom support chat history - Kevin Goedecke\",\"isPartOf\":{\"@id\":\"https:\/\/kevingoedecke.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2023\/04\/intercom-chatgpt-bot-1.jpg\",\"datePublished\":\"2023-04-20T17:44:56+00:00\",\"dateModified\":\"2023-04-21T14:00:42+00:00\",\"author\":{\"@id\":\"https:\/\/kevingoedecke.com\/#\/schema\/person\/4b156cd6453e1af4bab9076b0a663871\"},\"breadcrumb\":{\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/#primaryimage\",\"url\":\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2023\/04\/intercom-chatgpt-bot-1.jpg\",\"contentUrl\":\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2023\/04\/intercom-chatgpt-bot-1.jpg\",\"width\":1800,\"height\":900},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/kevingoedecke.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Fine Tuning ChatGPT on our Intercom support chat history\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/kevingoedecke.com\/#website\",\"url\":\"https:\/\/kevingoedecke.com\/\",\"name\":\"Kevin Goedecke\",\"description\":\"Founder. Entrepreneur.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/kevingoedecke.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/kevingoedecke.com\/#\/schema\/person\/4b156cd6453e1af4bab9076b0a663871\",\"name\":\"Kevin Goedecke\",\"url\":\"https:\/\/kevingoedecke.com\/blog\/author\/kgoedecke\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Fine Tuning ChatGPT on our Intercom support chat history - Kevin Goedecke","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/","og_locale":"en_US","og_type":"article","og_title":"Fine Tuning ChatGPT on our Intercom support chat history - Kevin Goedecke","og_description":"Is it possible to replace support agents with ChatGPT? An experiment: Fine tuning a ChatGPT model on our Intercom support chat history to provide automatic replies or suggestions.","og_url":"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/","og_site_name":"Kevin Goedecke","article_published_time":"2023-04-20T17:44:56+00:00","article_modified_time":"2023-04-21T14:00:42+00:00","og_image":[{"width":1800,"height":900,"url":"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2023\/04\/intercom-chatgpt-bot-1.jpg","type":"image\/jpeg"}],"author":"Kevin Goedecke","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kevin Goedecke","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/","url":"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/","name":"Fine Tuning ChatGPT on our Intercom support chat history - Kevin Goedecke","isPartOf":{"@id":"https:\/\/kevingoedecke.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/#primaryimage"},"image":{"@id":"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/#primaryimage"},"thumbnailUrl":"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2023\/04\/intercom-chatgpt-bot-1.jpg","datePublished":"2023-04-20T17:44:56+00:00","dateModified":"2023-04-21T14:00:42+00:00","author":{"@id":"https:\/\/kevingoedecke.com\/#\/schema\/person\/4b156cd6453e1af4bab9076b0a663871"},"breadcrumb":{"@id":"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/#primaryimage","url":"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2023\/04\/intercom-chatgpt-bot-1.jpg","contentUrl":"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2023\/04\/intercom-chatgpt-bot-1.jpg","width":1800,"height":900},{"@type":"BreadcrumbList","@id":"https:\/\/kevingoedecke.com\/blog\/2023\/04\/20\/fine-tuning-chatgpt-on-our-intercom-support-chat-history\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/kevingoedecke.com\/"},{"@type":"ListItem","position":2,"name":"Fine Tuning ChatGPT on our Intercom support chat history"}]},{"@type":"WebSite","@id":"https:\/\/kevingoedecke.com\/#website","url":"https:\/\/kevingoedecke.com\/","name":"Kevin Goedecke","description":"Founder. Entrepreneur.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kevingoedecke.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/kevingoedecke.com\/#\/schema\/person\/4b156cd6453e1af4bab9076b0a663871","name":"Kevin Goedecke","url":"https:\/\/kevingoedecke.com\/blog\/author\/kgoedecke\/"}]}},"jetpack_featured_media_url":"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2023\/04\/intercom-chatgpt-bot-1.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/posts\/459","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/comments?post=459"}],"version-history":[{"count":7,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/posts\/459\/revisions"}],"predecessor-version":[{"id":473,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/posts\/459\/revisions\/473"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/media\/470"}],"wp:attachment":[{"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/media?parent=459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/categories?post=459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/tags?post=459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}