{"id":2774,"date":"2024-10-02T07:00:00","date_gmt":"2024-10-02T11:00:00","guid":{"rendered":"https:\/\/blogs.mathworks.com\/matlab\/?p=2774"},"modified":"2024-10-02T07:02:36","modified_gmt":"2024-10-02T11:02:36","slug":"4-ways-of-using-matlab-with-large-language-models-llms-such-as-chatgpt-and-ollama","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/matlab\/2024\/10\/02\/4-ways-of-using-matlab-with-large-language-models-llms-such-as-chatgpt-and-ollama\/","title":{"rendered":"4 ways of using MATLAB with Large Language Models (LLMs) such as ChatGPT and Ollama"},"content":{"rendered":"<div class = rtcContent><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Everyone's talking about<\/span><a href = \"https:\/\/en.wikipedia.org\/wiki\/Large_language_model\" target=\"_blank\"><span> Large Language Models (LLMs)<\/span><\/a><span> and a huge number of you are using them too. Here are 4 ways to make use of them in the MathWorks ecosystem right now, no matter what your skill level is.<\/span><\/div><h2  style = 'margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left; '><span>1. MATLAB AI Chat Playground<\/span><\/h2><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><a href = \"https:\/\/blogs.mathworks.com\/community\/2023\/11\/07\/the-matlab-ai-chat-playground-has-launched\/\"><span>First released in 2023<\/span><\/a><span> with Chat GPT 3.5 Turbo as the underlying model, the MATLAB AI Chat Playground has <\/span><a href = \"https:\/\/uk.mathworks.com\/matlabcentral\/discussions\/highlights\/875730\"><span>recently been upgraded to use GPT-4o mini<\/span><\/a><span>. As well as talking to the AI in the left hand side of the browser window, you can also run MATLAB code in the right hand-side using an engine that is based on the latest release of MATLAB, R2024b. AI and MATLAB together without needing to leave your web browser. This is probably the easiest way for MATLAB users to get started with experimenting with AI models.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><a href = \"https:\/\/uk.mathworks.com\/matlabcentral\/playground\/new\"><img class = \"imageNode\" src = \"http:\/\/blogs.mathworks.com\/matlab\/files\/2024\/10\/llm_1.png\" width = \"984\" height = \"767\" alt = \"\" style = \"vertical-align: baseline; width: 984px; height: 767px;\"><\/img><\/a><\/div><h2  style = 'margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left; '><span>2. Large Language Models (LLMS) with MATLAB<\/span><\/h2><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>As a programmer, I have more fun with LLMS when I can interact with them programmatically. That's where <\/span><a href = \"https:\/\/uk.mathworks.com\/matlabcentral\/fileexchange\/163796-large-language-models-llms-with-matlab\"><span>this MathWorks repository<\/span><\/a><span> comes in. It contains code to connect MATLAB to the<\/span><span> <\/span><a href = \"https:\/\/platform.openai.com\/docs\/guides\/text-generation\/chat-completions-api\" target=\"_blank\"><span>OpenAI\u00ae Chat Completions API<\/span><\/a><span> <\/span><span>(which powers ChatGPT\u2122), OpenAI Images API (which powers DALL\u00b7E\u2122),<\/span><span> <\/span><a href = \"https:\/\/learn.microsoft.com\/en-us\/azure\/ai-services\/openai\/\" target=\"_blank\"><span>Azure\u00ae OpenAI Service<\/span><\/a><span>, and both local and nonlocal<\/span><span> <\/span><a href = \"https:\/\/ollama.com\/\" target=\"_blank\"><span>Ollama\u2122<\/span><\/a><span> <\/span><span>models. This allows you to leverage the natural language processing capabilities of large language models directly within your MATLAB environment.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>The repo was <\/span><a href = \"https:\/\/blogs.mathworks.com\/deep-learning\/2024\/01\/22\/large-language-models-with-matlab\/\"><span>discussed in depth in January 2024<\/span><\/a><span> over at the MathWorks Artificial Intelligence blog, <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><a href = \"https:\/\/uk.mathworks.com\/matlabcentral\/fileexchange\/163796-large-language-models-llms-with-matlab\"><img class = \"imageNode\" src = \"http:\/\/blogs.mathworks.com\/matlab\/files\/2024\/10\/llm_2.png\" width = \"982\" height = \"791\" alt = \"\" style = \"vertical-align: baseline; width: 982px; height: 791px;\"><\/img><\/a><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>For a great example of what's possible with this repository, see T<\/span><a href = \"https:\/\/uk.mathworks.com\/matlabcentral\/fileexchange\/126665-matgpt\"><span>oshi Takeuchi's personal project MatGPT<\/span><\/a><span> which allows you to easily access OpenAI's API with an app.<\/span><\/div><h2  style = 'margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left; '><span>3. GitHub Co-pilot with the MATLAB extension for Visual Studio Code <\/span><\/h2><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>The <\/span><a href = \"https:\/\/marketplace.visualstudio.com\/items?itemName=MathWorks.language-matlab\" target=\"_blank\"><span>MATLAB extension for Visual Studio Code<\/span><\/a><span> has been extremely popular since its release in 2023 and I've covered it several times in The MATLAB Blog. Most recently in March of this year when I<\/span><a href = \"https:\/\/blogs.mathworks.com\/matlab\/2024\/03\/05\/matlab-extension-for-visual-studio-code-now-with-code-execution\/\"><span> described code execution<\/span><\/a><span> and the fact that <\/span><a href = \"https:\/\/blogs.mathworks.com\/matlab\/2024\/03\/12\/matlab-extension-for-visual-studio-code-yes-it-works-with-github-copilot\/\"><span>it works great with GitHub co-pilot<\/span><\/a><span>. <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"http:\/\/blogs.mathworks.com\/matlab\/files\/2024\/10\/llm_3.gif\" width = \"994\" height = \"620\" alt = \"CoPilot_1.gif\" style = \"vertical-align: baseline; width: 994px; height: 620px;\"><\/img><\/div><h2  style = 'margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left; '><span>4. Custom MATLAB GPT in the OpenAI GPT Store<\/span><\/h2><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>This one is for users of the ChatGPT site. The <\/span><a href = \"https:\/\/chatgpt.com\/g\/g-QFTjbeK3U-matlab\" target=\"_blank\"><span>custom MATLAB GPT<\/span><\/a><span> currently uses the GPT-4o model but has some additional customizations especially for MATLAB users. In particular, the AI uses <\/span><a href = \"https:\/\/en.wikipedia.org\/wiki\/Retrieval-augmented_generation\" target=\"_blank\"><span>Retrieval Augmented Generation (RAG)<\/span><\/a><span> to search the MathWorks website before formulating an answer<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><a href = \"https:\/\/chatgpt.com\/g\/g-QFTjbeK3U-matlab\" target=\"_blank\"><img class = \"imageNode\" src = \"http:\/\/blogs.mathworks.com\/matlab\/files\/2024\/10\/llm_4.png\" width = \"533\" height = \"603\" alt = \"\" style = \"vertical-align: baseline; width: 533px; height: 603px;\"><\/img><\/a><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><\/div>\n<\/div><script type=\"text\/javascript\">var css = ''; var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); head.appendChild(style); style.type = 'text\/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); }<\/script>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/matlab\/files\/2024\/10\/llm_2.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><p>Everyone's talking about Large Language Models (LLMs) and a huge number of you are using them too. Here are 4 ways to make use of them in the MathWorks ecosystem right now, no matter what your skill... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/matlab\/2024\/10\/02\/4-ways-of-using-matlab-with-large-language-models-llms-such-as-chatgpt-and-ollama\/\">read more >><\/a><\/p>","protected":false},"author":176,"featured_media":2762,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[78],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts\/2774"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/users\/176"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/comments?post=2774"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts\/2774\/revisions"}],"predecessor-version":[{"id":2777,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts\/2774\/revisions\/2777"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/media\/2762"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/media?parent=2774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/categories?post=2774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/tags?post=2774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}