{"id":10601,"date":"2024-02-06T14:30:02","date_gmt":"2024-02-06T05:30:02","guid":{"rendered":"https:\/\/blogs.mathworks.com\/japan-community\/?p=10601"},"modified":"2024-08-09T23:47:49","modified_gmt":"2024-08-09T14:47:49","slug":"large-language-models-with-matlab-jp","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/japan-community\/2024\/02\/06\/large-language-models-with-matlab-jp\/","title":{"rendered":"MATLAB \u3067\u5927\u898f\u6a21\u8a00\u8a9e\u30e2\u30c7\u30eb"},"content":{"rendered":"<p>\u203b\u3053\u306e\u6295\u7a3f\u306f 2024 \u5e74 1 \u6708 22 \u65e5\u306b<a href=\"https:\/\/blogs.mathworks.com\/deep-learning\/2024\/01\/22\/large-language-models-with-matlab\/\">Artificial Intelligence \u3078 \u6295\u7a3f<\/a>\u3055\u308c\u305f\u3082\u306e\u306e\u6284\u8a33\u3067\u3059\u3002<\/p>\n<hr \/>\n<p style=\"font-size: 16px;\"><strong>MATLAB \u3092 OpenAI\u2122 API \u306b\u63a5\u7d9a\u3057\u3066\u81ea\u7136\u8a00\u8a9e\u51e6\u7406\u3092\u884c\u3046\u65b9\u6cd5<\/strong><\/p>\n<p>ChatGPT\u2122\u3001Generative AI\u3001\u5927\u898f\u6a21\u8a00\u8a9e\u30e2\u30c7\u30eb\uff08LLM, Large Language Model\uff09\u3001\u3053\u308c\u3089\u306e\u9769\u65b0\u7684\u306a\u6280\u8853\u3092 MATLAB \u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3053\u3068\u3092\u3054\u5b58\u3058\u3067\u3057\u3087\u3046\u304b\uff1f\u30d6\u30e9\u30a6\u30b6\u3067\u6a5f\u80fd\u3059\u308b <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/playground\/new\">MATLAB AI Chat Playground<\/a>\uff08<a href=\"https:\/\/blogs.mathworks.com\/japan-community\/2023\/11\/08\/the-matlab-ai-chat-playground-has-launched-jp\/\">\u95a2\u9023\u30d6\u30ed\u30b0\u6295\u7a3f<\/a>\uff09\u306b\u52a0\u3048\u3066\u3001MATLAB \u3092 OpenAI\u2122 Chat Completions API \u306b\u3082\u63a5\u7d9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30d6\u30ed\u30b0\u3067\u306f\u3001LLM \u306e\u80cc\u5f8c\u306b\u3042\u308b\u6280\u8853\u3068\u3001MATLAB \u3092 OpenAI API \u306b\u63a5\u7d9a\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3059\u3002\u307e\u305f\u3001<a href=\"https:\/\/www.mathworks.com\/help\/textanalytics\/\">Text Analytics Toolbox<\/a> \u3092\u6d3b\u7528\u3057\u3066\u3001\u611f\u60c5\u5206\u6790\u3084\u30c1\u30e3\u30c3\u30c8\u30dc\u30c3\u30c8\u306e\u69cb\u7bc9\u306a\u3069\u306e<a href=\"https:\/\/www.mathworks.com\/discovery\/natural-language-processing.html\">\u81ea\u7136\u8a00\u8a9e\u51e6\u7406\uff08NLP\uff09\u30bf\u30b9\u30af<\/a>\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u3082\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h1>LLM \u3063\u3066\u306a\u306b?<\/h1>\n<p>\u5927\u898f\u6a21\u8a00\u8a9e\u30e2\u30c7\u30eb\uff08LLM\uff09\u306f\u3001\u30c8\u30e9\u30f3\u30b9\u30d5\u30a9\u30fc\u30de\u30fc\u30e2\u30c7\u30eb\uff08\u30c7\u30a3\u30fc\u30d7\u30e9\u30fc\u30cb\u30f3\u30b0\u30e2\u30c7\u30eb\u306e\u7279\u5225\u306a\u30b1\u30fc\u30b9\uff09\u306b\u57fa\u3065\u3044\u3066\u3044\u307e\u3059\u3002\u30c8\u30e9\u30f3\u30b9\u30d5\u30a9\u30fc\u30de\u30fc\u306f\u3001\u9023\u7d9a\u3057\u305f\u30c7\u30fc\u30bf\u5185\u306e\u95a2\u4fc2\u6027\u3092\u8ffd\u8de1\u3059\u308b\u3088\u3046\u306b\u8a2d\u8a08\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u305d\u308c\u3089\u306f\u81ea\u5df1\u6ce8\u610f\u30e1\u30ab\u30cb\u30ba\u30e0\u306b\u4f9d\u5b58\u3057\u3066\u3001\u5165\u529b\u3068\u51fa\u529b\u306e\u9593\u306e\u30b0\u30ed\u30fc\u30d0\u30eb\u306a\u4f9d\u5b58\u95a2\u4fc2\u3092\u6349\u3048\u307e\u3059\u3002LLM \u306f NLP \u306b\u9769\u547d\u3092\u3082\u305f\u3089\u3057\u307e\u3057\u305f\u3002\u306a\u305c\u306a\u3089\u3001\u4eba\u9593\u306e\u8a00\u8a9e\u306b\u5b58\u5728\u3059\u308b\u5358\u8a9e\u9593\u306e\u8907\u96d1\u306a\u95a2\u4fc2\u3084\u30cb\u30e5\u30a2\u30f3\u30b9\u3092\u6349\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>\u3088\u304f\u77e5\u3089\u308c\u3066\u3044\u308b\u30c8\u30e9\u30f3\u30b9\u30d5\u30a9\u30fc\u30de\u30fc\u30e2\u30c7\u30eb\u306b\u306f\u3001BERT \u3068 GPT \u306e\u30e2\u30c7\u30eb\u304c\u3042\u308a\u3001\u3069\u3061\u3089\u3082 MATLAB \u3067\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002MATLAB \u306b\u542b\u307e\u308c\u3066\u3044\u308b\u4e8b\u524d\u8a13\u7df4\u6e08\u307f\u306e BERT \u30e2\u30c7\u30eb\u3092\u4f7f\u7528\u3057\u305f\u3044\u5834\u5408\u306f\u3001<a href=\"https:\/\/www.mathworks.com\/help\/textanalytics\/ref\/bert.html\">bert<\/a> \u95a2\u6570\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u3053\u306e\u30d6\u30ed\u30b0\u3067\u306f\u3001GPT \u30e2\u30c7\u30eb\u306b\u7126\u70b9\u3092\u5f53\u3066\u307e\u3059\u3002<\/p>\n<h1>LLM\u30ea\u30dd\u30b8\u30c8\u30ea<\/h1>\n<p>MATLAB \u304b\u3089 LLM \u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a\u30b3\u30fc\u30c9\u306f GitHub \u306e <a href=\"https:\/\/github.com\/matlab-deep-learning\/llms-with-matlab\" class=\"external\" rel=\"nofollow\" target=\"_blank\">LLM \u30ea\u30dd\u30b8\u30c8\u30ea<\/a>\u306b\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u30b3\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u3066 MATLAB \u74b0\u5883\u304b\u3089ChatGPT API \u3092\u64cd\u4f5c\u3067\u304d\u307e\u3059\u3002gpt-3.5-turbo \u3084 gpt-4 \u3082\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-13679 size-full\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2024\/01\/LLMs_repo.png\" alt=\"GitHub repository for large language models with MATLAB\" width=\"1080\" height=\"870\" \/><\/p>\n<p style=\"font-size: 18px;\"><strong>\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7<\/strong><\/p>\n<p>ChatGPT API \u3092\u64cd\u4f5c\u3059\u308b\u305f\u3081\u306b\u306f\u3001OpenAI API \u30ad\u30fc\u3092\u53d6\u5f97\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002API \u30ad\u30fc\u306e\u53d6\u5f97\u65b9\u6cd5\u3068 OpenAI API \u306e\u4f7f\u7528\u6599\u91d1\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u306f\u3001<a href=\"https:\/\/openai.com\/blog\/openai-api\" class=\"external\" rel=\"nofollow\" target=\"_blank\">OpenAI API<\/a>\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u73fe\u5728\u306e\u30d5\u30a9\u30eb\u30c0\u306b API \u30ad\u30fc\u3092\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u4fdd\u5b58\u3057\u3066\u304a\u304f\u3068\u4fbf\u5229\u3067\u3059\u3002<\/p>\n<p><div id=\"attachment_13685\" style=\"width: 1460px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-13685\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-13685 size-full\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2024\/01\/save_api_key.gif\" alt=\"How to save OpenAI API key for reuse\" width=\"1450\" height=\"910\" \/><p id=\"caption-attachment-13685\" class=\"wp-caption-text\">Save the OpenAI API key in your current folder.<\/p><\/div><\/p>\n<p>&nbsp;<\/p>\n<p style=\"font-size: 18px;\"><strong>Getting Started<\/strong><\/p>\n<p>MATLAB \u3067 LLM \u3092\u4f7f\u7528\u3057\u59cb\u3081\u308b\u305f\u3081\u306b\u3001\u307e\u305a OpenAI Chat \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u521d\u671f\u5316\u3057\u307e\u3059\u3002<\/p>\n<pre>chat = openAIChat(systemPrompt,ApiKey=my_key);\r\n<\/pre>\n<p>\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3055\u307e\u3056\u307e\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u306b\u5bfe\u3057\u3066\u30b7\u30b9\u30c6\u30e0\u30d7\u30ed\u30f3\u30d7\u30c8\u3092\u3069\u306e\u3088\u3046\u306b\u6307\u5b9a\u3059\u308b\u304b\u3001\u304a\u3088\u3073\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u540d\u524d-\u5024\u5f15\u6570\u3092\u4f7f\u7528\u3057\u3066 OpenAI Chat \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u6a5f\u80fd\u3092\u5f37\u5316\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p style=\"font-size: 18px;\"><strong>MATLAB Online \u3067\u59cb\u3081\u308b<\/strong><\/p>\n<p>MATLAB Online \u3067 LLM \u3092\u4f7f\u3044\u305f\u3044\u5834\u5408\u3082\u3042\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002MATLAB \u30b3\u30fc\u30c9\u304c\u542b\u307e\u308c\u308b GitHub \u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u306f\u300cOpen in MATLAB Online\u300d\u30dc\u30bf\u30f3\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u30ea\u30dd\u30b8\u30c8\u30ea\u304c\u76f4\u63a5 MATLAB Online \u3067\u958b\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u30d3\u30c7\u30aa\u3092\u3054\u89a7\u306b\u306a\u3063\u3066\u300130\u79d2\u4ee5\u5185\u3067 LLM \u30ea\u30dd\u30b8\u30c8\u30ea\u3092 MATLAB Online \u3067\u958b\u304f\u65b9\u6cd5\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><div id=\"attachment_13682\" style=\"width: 1090px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-13682\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-13682 size-full\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2024\/01\/LLMs_recording.gif\" alt=\"Open large language models repository in MATLAB Online\" width=\"1080\" height=\"870\" \/><p id=\"caption-attachment-13682\" class=\"wp-caption-text\">Use LLMs in MATLAB Online.<\/p><\/div><\/p>\n<h1>\u4f7f\u7528\u4f8b<\/h1>\n<p>\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001MATLAB \u3067\u306e LLM \u306e\u4f7f\u7528\u4f8b\u3092\u7d39\u4ecb\u3057\u3001\u95a2\u9023\u30ea\u30f3\u30af\u3092\u8a18\u8f09\u3057\u307e\u3059\u3002\u4f7f\u7528\u4f8b\u306b\u306f\u611f\u60c5\u5206\u6790\u3001\u30c1\u30e3\u30c3\u30c8\u30dc\u30c3\u30c8\u306e\u69cb\u7bc9\u3001RAG (Retrieval Augmented Generation) \u306a\u3069\u304c\u3042\u308a\u307e\u3059\u3002Text Analytics Toolbox \u3092\u4f7f\u7528\u3057\u3066\u3001\u30c6\u30ad\u30b9\u30c8\u3092\u524d\u51e6\u7406\u3057\u3001\u5206\u6790\u3057\u3001\u305d\u3057\u3066\u300c\u610f\u5473\u306e\u3042\u308b\u300d\u5f62\u3067\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u3044\u304f\u3064\u304b\u306e\u95a2\u6570\u3092\u7d39\u4ecb\u3057\u307e\u3059\u304c\u3001\u8a73\u7d30\u306f\u30ea\u30f3\u30af\u5148\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p style=\"font-size: 18px;\"><strong>\u611f\u60c5\u5206\u6790<\/strong><\/p>\n<p>\u611f\u60c5\u5206\u6790\u3092\u884c\u3046\u7c21\u5358\u306a\u4f8b\u304b\u3089\u59cb\u3081\u307e\u3057\u3087\u3046\u3002\u611f\u60c5\u5206\u6790\u306f\u3001\u30c6\u30ad\u30b9\u30c8\u4e2d\u306e\u610f\u898b\u3084\u611f\u60c5\u306e\u5206\u985e\u306b\u53d6\u308a\u7d44\u3080\u3082\u306e\u3067\u3059\u3002\u30c6\u30ad\u30b9\u30c8\u306e\u611f\u60c5\u7684\u306a\u30c8\u30fc\u30f3\u306f\u3001\u30dd\u30b8\u30c6\u30a3\u30d6\u3001\u30cd\u30ac\u30c6\u30a3\u30d6\u3001\u307e\u305f\u306f\u30cb\u30e5\u30fc\u30c8\u30e9\u30eb\u3068\u3057\u3066\u5206\u985e\u3055\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><div id=\"attachment_13691\" style=\"width: 394px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-13691\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-13691\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2024\/01\/sentiment_analysis.png\" alt=\"Sentiment analysis with large language models\" width=\"384\" height=\"216\" \/><p id=\"caption-attachment-13691\" class=\"wp-caption-text\">Creating a sentiment analysis classifier.<\/p><\/div><\/p>\n<h6><\/h6>\n<p>\u307e\u305a\u30b7\u30b9\u30c6\u30e0\u30d7\u30ed\u30f3\u30d7\u30c8\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u30b7\u30b9\u30c6\u30e0\u30d7\u30ed\u30f3\u30d7\u30c8\u306f\u3001\u30a2\u30b7\u30b9\u30bf\u30f3\u30c8\u306b\u3069\u306e\u3088\u3046\u306b\u632f\u308b\u821e\u3046\u304b\u3092\u4f1d\u3048\u307e\u3059\u3002\u3053\u306e\u5834\u5408\u3001\u611f\u60c5\u5206\u6790\u5668\u3068\u3057\u3066\u632f\u308b\u821e\u3044\u307e\u3059\u3002\u307e\u305f\u3001\u30b7\u30b9\u30c6\u30e0\u306b\u611f\u60c5\u5206\u6790\u3092\u884c\u3046\u65b9\u6cd5\u306e\u7c21\u5358\u306a\u4f8b\u3082\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n<pre>systemPrompt = \"You are a sentiment analyser. You will look at a sentence and output\"+...\r\n    \" a single word that classifies that sentence as either 'positive' or 'negative'.\"+....\r\n    \"Examples: \\n\"+...\r\n    \"The project was a complete failure. \\n\"+...\r\n    \"negative \\n\\n\"+...  \r\n    \"The team successfully completed the project ahead of schedule.\"+...\r\n    \"positive \\n\\n\"+...\r\n    \"His attitude was terribly discouraging to the team. \\n\"+...\r\n    \"negative \\n\\n\";\r\n<\/pre>\n<h6><\/h6>\n<p>\u30b7\u30b9\u30c6\u30e0\u30d7\u30ed\u30f3\u30d7\u30c8\u3092\u6e21\u3057\u3066 OpenAI Chat \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u521d\u671f\u5316\u3057\u307e\u3059\u3002<\/p>\n<pre>chat = openAIChat(systemPrompt,ApiKey=my_key);<\/pre>\n<p>\u65b0\u3057\u3044\u6587\u3092\u6e21\u3057\u3066\u5206\u985e\u3055\u305b\u307e\u3059\u3002<\/p>\n<pre>text = generate(chat,\"The team is feeling very motivated.\")<\/pre>\n<p style=\"font-size: 14px;\"><span style=\"font-family: courier;\">\u00a0 text = &#8220;positive&#8221;<\/span><\/p>\n<p>\u6b63\u3057\u304f\u30dd\u30b8\u30c6\u30a3\u30d6\u306a\u611f\u60c5\u3068\u3057\u3066\u5206\u985e\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p style=\"font-size: 18px;\"><strong>\u30c1\u30e3\u30c3\u30c8\u30dc\u30c3\u30c8\u306e\u69cb\u7bc9<\/strong><\/p>\n<p>\u30c1\u30e3\u30c3\u30c8\u30dc\u30c3\u30c8\u306f\u4eba\u9593\u306e\u4f1a\u8a71\u3092\u30b7\u30df\u30e5\u30ec\u30fc\u30c8\u3057\u307e\u3059\u3002\u3064\u307e\u308a\u30e6\u30fc\u30b6\u30fc\u304c\u30af\u30a8\u30ea\u3092\u5165\u529b\u3057\u3001\u30c1\u30e3\u30c3\u30c8\u30dc\u30c3\u30c8\u304c\u81ea\u7136\u306a\u4eba\u9593\u306e\u8a00\u8a9e\u3067\u5fdc\u7b54\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/p>\n<h6><\/h6>\n<p><div id=\"attachment_13697\" style=\"width: 449px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-13697\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-13697\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2024\/01\/chatbot_flow.png\" alt=\"Building a chatbot with large language models\" width=\"439\" height=\"146\" \/><p id=\"caption-attachment-13697\" class=\"wp-caption-text\">Building a chatbot.<\/p><\/div><\/p>\n<p>LLM\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u300c<a href=\"https:\/\/github.com\/matlab-deep-learning\/llms-with-matlab\/blob\/main\/examples\/CreateSimpleChatBot.md\" class=\"external\" rel=\"nofollow\" target=\"_blank\">Example: Build ChatBot<\/a>\u300d\u3092\u53c2\u8003\u306b\u3001\u6570\u5206\u3067\u30c1\u30e3\u30c3\u30c8\u30dc\u30c3\u30c8\u3092\u69cb\u7bc9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30c1\u30e3\u30c3\u30c8\u30dc\u30c3\u30c8\u3092\u69cb\u7bc9\u3059\u308b\u6700\u521d\u306e2\u3064\u306e\u30b9\u30c6\u30c3\u30d7\u306f\u3001(1) \u30c1\u30e3\u30c3\u30c8\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b openAIChat \u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3068\u3001(2) \u4f1a\u8a71\u5c65\u6b74\u3092\u4fdd\u5b58\u3059\u308b\u305f\u3081\u306b openAIMessages \u95a2\u6570\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/p>\n<pre>chat = openAIChat(\"You are a helpful assistant. You reply in a very concise way, keeping answers \"+...\r\n    \"limited to short sentences.\",ModelName=modelName,ApiKey=my_key);\r\nmessages = openAIMessages;\r\n<\/pre>\n<p>\u3055\u3089\u306b\u6570\u884c\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u305f\u5f8c\u3001\u30e1\u30ad\u30b7\u30b3\u3067\u306e\u4f11\u6687\u8a08\u753b\u306b\u5f79\u7acb\u3064\u30c1\u30e3\u30c3\u30c8\u30dc\u30c3\u30c8\u3092\u69cb\u7bc9\u3057\u307e\u3057\u305f\u3002\u4ed6\u306e MATLAB \u95a2\u6570\uff08\u4f8b\u3048\u3070\u3001<a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/extractbetween.html\">extractBetween<\/a>\uff09\u3092\u4f7f\u7528\u3057\u3066\u30c1\u30e3\u30c3\u30c8\u30dc\u30c3\u30c8\u306e\u5fdc\u7b54\u3092\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3057\u307e\u3057\u305f\u3002\u4ee5\u4e0b\u306e\u56f3\u306f\u3001\u30c1\u30e3\u30c3\u30c8\u30dc\u30c3\u30c8\u3068\u306e\u7c21\u6f54\u3067\u3059\u304c\u5f79\u7acb\u3064\u30c1\u30e3\u30c3\u30c8\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002\u30c1\u30e3\u30c3\u30c8\u30dc\u30c3\u30c8\u306f\u4ee5\u524d\u306e\u30af\u30a8\u30ea\u304b\u3089\u306e\u60c5\u5831\u3092\u4fdd\u6301\u3057\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u79c1\u306f\u8cea\u554f\u3067\u300c\u30e6\u30ab\u30bf\u30f3\u534a\u5cf6\u300d\u3092\u7e70\u308a\u8fd4\u3059\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<h6><\/h6>\n<p><div id=\"attachment_13703\" style=\"width: 749px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-13703\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-13703\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2024\/01\/chat_screenshot.png\" alt=\"Conversation with chatbot built with large language model\" width=\"739\" height=\"391\" \/><p id=\"caption-attachment-13703\" class=\"wp-caption-text\">User queries and chatbot responses for planning a Mexico vacation.<\/p><\/div><\/p>\n<p>&nbsp;<\/p>\n<p style=\"font-size: 18px;\"><strong>Retrieval Augmented Generation<\/strong><\/p>\n<p>Retrieval-augmented generation (RAG\uff09\u306f\u3001LLM \u306b\u3088\u3063\u3066\u5f97\u3089\u308c\u305f\u7d50\u679c\u3092\u5411\u4e0a\u3055\u305b\u308b\u305f\u3081\u306e\u6280\u8853\u3067\u3059\u3002\u5916\u90e8\u30bd\u30fc\u30b9\u304b\u3089\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u3067\u3001\u6b63\u78ba\u6027\u3068\u4fe1\u983c\u6027\u306e\u4e21\u65b9\u3092\u5f37\u5316\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001LLM \u306b\u4f9b\u7d66\u3055\u308c\u308b\u30d7\u30ed\u30f3\u30d7\u30c8\u306f\u3001\u3088\u308a\u6700\u65b0\u306e\u60c5\u5831\u3084\u6280\u8853\u7684\u306a\u60c5\u5831\u3067\u5f37\u5316\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h6><\/h6>\n<p><div id=\"attachment_13706\" style=\"width: 728px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-13706\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-13706\" src=\"https:\/\/blogs.mathworks.com\/deep-learning\/files\/2024\/01\/rag.png\" alt=\"Workflow for retrieval augmented generation (RAG) with large language model\" width=\"718\" height=\"314\" \/><p id=\"caption-attachment-13706\" class=\"wp-caption-text\">Workflow for retrieval-augmented generation (RAG).<\/p><\/div><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/github.com\/matlab-deep-learning\/llms-with-matlab\/blob\/main\/examples\/RetrievalAugmentedGenerationUsingChatGPTandMATLAB.md\" class=\"external\" rel=\"nofollow\" target=\"_blank\">Example: Retrieval-Augmented Generation<\/a> \u3067\u306f\u3001\u96fb\u529b\u30b7\u30b9\u30c6\u30e0\u306b\u95a2\u3059\u308b\u6280\u8853\u5831\u544a\u66f8\u304b\u3089\u60c5\u5831\u3092\u53d6\u5f97\u3057\u3001\u6280\u8853\u7684\u306a\u554f\u3044\u5408\u308f\u305b\u306e\u305f\u3081\u306b ChatGPT \u3092\u5f37\u5316\u3059\u308b\u65b9\u6cd5\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u3059\u3079\u3066\u306e\u8a73\u7d30\u3092\u793a\u3057\u3066\u3044\u307e\u305b\u3093\u304c\u3001\u91cd\u8981\u306a\u30b9\u30c6\u30c3\u30d7\u3092\u3044\u304f\u3064\u304b\u5f37\u8abf\u3057\u307e\u3059\u3002<\/p>\n<ol>\n<li>MATLAB \u95a2\u6570 (e.g., <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/websave.html\">websave<\/a>\u00a0\u3084\u00a0<a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/matlab.io.datastore.filedatastore.html\">fileDatastore<\/a>) \u30aa\u30f3\u30e9\u30a4\u30f3\u6587\u66f8\u306e\u53d6\u5f97\u304a\u3088\u3073\u6574\u7406\u3057\u307e\u3059\u3002<\/li>\n<li>Text Analytics Toolbox \u306e\u95a2\u6570 (e.g., <a href=\"https:\/\/www.mathworks.com\/help\/textanalytics\/ref\/tokenizeddocument.splitparagraphs.html\">splitParagraphs<\/a>, <a href=\"https:\/\/www.mathworks.com\/help\/textanalytics\/ref\/tokenizeddocument.html\">tokenizedDocument<\/a>, \u3084\u00a0<a href=\"https:\/\/www.mathworks.com\/help\/textanalytics\/ref\/bm25similarity.html\">bm25Similarity<\/a>) \u53d6\u5f97\u3057\u305f\u6587\u66f8\u304b\u3089\u4f7f\u7528\u3059\u308b\u30c6\u30ad\u30b9\u30c8\u3092\u6e96\u5099\u3057\u307e\u3059\u3002<\/li>\n<li>\u30c6\u30ad\u30b9\u30c8\u306e\u6e96\u5099\u304c\u3067\u304d\u305f\u3089\u3001\u6307\u5b9a\u3055\u308c\u305f\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3068 API \u30ad\u30fc\u3067\u30c1\u30e3\u30c3\u30c8\u30dc\u30c3\u30c8\u3092\u521d\u671f\u5316\u3057\u307e\u3059\u3002\n<pre>chat = openAIChat(\"You are a helpful assistant. You will get a \" + ...\r\n    \"context for each question, but only use the information \" + ...\r\n    \"in the context if that makes sense to answer the question. \" + ...\r\n    \"Let's think step-by-step, explaining how you reached the answer.\",ApiKey=my_key);\r\n<\/pre>\n<\/li>\n<li>\u30af\u30a8\u30ea\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u6b21\u306b\u3001\u30af\u30a8\u30ea\u306b\u57fa\u3065\u3044\u3066\u95a2\u9023\u6587\u66f8\u3092\u53d6\u5f97\u304a\u3088\u3073\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u307e\u3059\u3002\n<pre>query = \"What technical criteria can be used to streamline new approvals for grid-friendly DPV?\";\r\nselectedDocs = retrieveAndFilterRelevantDocs(allDocs,query);\r\n<\/pre>\n<\/li>\n<li>\u30c1\u30e3\u30c3\u30c8\u30dc\u30c3\u30c8\u306e\u30d7\u30ed\u30f3\u30d7\u30c8\u3092\u5b9a\u7fa9\u3057\u3001\u5fdc\u7b54\u3092\u751f\u6210\u3057\u307e\u3059\u3002\n<pre>prompt = \"Context:\" ...\r\n    + join(selectedDocs, \" \") + newline +\"Answer the following question: \"+ query;\r\nresponse = generate(chat,prompt);\r\n<\/pre>\n<p>\u53ef\u8996\u5316\u3057\u3084\u3059\u3044\u3088\u3046\u306b\u30c6\u30ad\u30b9\u30c8\u3092\u6574\u5f62\u3057\u307e\u3059\u3002<\/p>\n<pre>wrapText(response)\r\n<\/pre>\n<p style=\"font-size: 14px;\"><span style=\"font-family: courier;\">ans =<\/span><\/p>\n<p style=\"font-size: 14px;\"><span style=\"font-family: courier;\"><br \/>\n&#8220;The technical criteria that can be used to streamline new approvals for grid-friendly DPV can include prudent screening criteria for systems that meet certain specifications.<br \/>\nThese criteria can be based on factors such as DPV capacity penetration relative to minimum feeder daytime load.<br \/>\nAdditionally, hosting capacity calculations can be used to estimate the point where DPV would induce technical impacts on system operations.<br \/>\nThese screening criteria are commonly used in countries like India and the United States.&#8221;<br \/>\n<\/span><\/p>\n<\/li>\n<\/ol>\n<h6><\/h6>\n<p style=\"font-size: 18px;\"><strong>\u4ed6\u306e\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9<\/strong><\/p>\n<p>\u4e0a\u8a18\u306b\u793a\u3057\u305f\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u306f\u3001LLM \u3092\u4f7f\u7528\u3057\u3066\u9054\u6210\u3067\u304d\u308b\u3053\u3068\u306e\u4e00\u4f8b\u306b\u904e\u304e\u307e\u305b\u3093\u3002\u4ed6\u306e\u6ce8\u76ee\u3059\u3079\u304d\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\uff08LLM\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u4f8b\u3092\u542b\u3080\uff09\u306b\u306f\u3001\u30c6\u30ad\u30b9\u30c8\u306e\u8981\u7d04\u3084\u95a2\u6570\u547c\u3073\u51fa\u3057\u304c\u3042\u308a\u307e\u3059\u3002\u307e\u305f\u3001LLM \u3092\u4f7f\u7528\u3057\u3066\u3001<a href=\"https:\/\/www.mathworks.com\/help\/textanalytics\/ug\/sequence-to-sequence-translation-using-attention.html\">\u6a5f\u68b0\u7ffb\u8a33<\/a>\u306e\u3088\u3046\u306a\u4ed6\u306e\u591a\u304f\u306e\u81ea\u7136\u8a00\u8a9e\u51e6\u7406\uff08NLP\uff09\u30bf\u30b9\u30af\u306b\u3082\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><em><a href=\"https:\/\/github.com\/matlab-deep-learning\/llms-with-matlab\" class=\"external\" rel=\"nofollow\" target=\"_blank\">MATLAB LLM\u30ea\u30dd\u30b8\u30c8\u30ea<\/a>\u3092\u4f55\u306b\u4f7f\u7528\u3057\u307e\u3059\u304b\uff1f\u4ee5\u4e0b\u306e\u30b3\u30e1\u30f3\u30c8\u6b04\u306b\u3054\u610f\u898b\u304f\u3060\u3055\u3044\u3002<\/em><\/p>\n<p><strong>\u30c6\u30ad\u30b9\u30c8\u8981\u7d04<\/strong>\u306f\u3001\u9577\u3044\u30c6\u30ad\u30b9\u30c8\u6587\u66f8\u304b\u3089\u77ed\u304f\u3001\u6b63\u78ba\u3067\u3001\u8aad\u307f\u3084\u3059\u3044\u8981\u7d04\u3092\u81ea\u52d5\u7684\u306b\u4f5c\u6210\u3059\u308b\u3053\u3068\u3067\u3059\u3002<a href=\"https:\/\/github.com\/matlab-deep-learning\/llms-with-matlab\/blob\/main\/examples\/SummarizeLargeDocumentsUsingChatGPTandMATLAB.md\" class=\"external\" rel=\"nofollow\" target=\"_blank\">Example: Text Summarization<\/a>\u3067\u306f\u3001\u5927\u304d\u306a\u30c6\u30ad\u30b9\u30c8\u3092\u5c0f\u3055\u306a\u30c1\u30e3\u30f3\u30af\u306b\u5206\u5272\u3057\u3001\u30b9\u30c6\u30c3\u30d7\u30d0\u30a4\u30b9\u30c6\u30c3\u30d7\u3067\u5404\u30c1\u30e3\u30f3\u30af\u3092\u8981\u7d04\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><strong>\u95a2\u6570\u547c\u3073\u51fa\u3057<\/strong>\u306f\u3001LLM \u306e NLP \u6a5f\u80fd\u3092\u5b9a\u7fa9\u3057\u305f\u95a2\u6570\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u5f37\u529b\u306a\u30c4\u30fc\u30eb\u3067\u3059\u3002\u3057\u304b\u3057\u3001ChatGPT \u306f\u95a2\u6570\u540d\u3092 &#8220;Hallucinate&#8221; \u3059\u308b\u3053\u3068\u304c\u3042\u308b\u306e\u3067\u3001\u4efb\u610f\u306b\u751f\u6210\u3055\u308c\u305f\u95a2\u6570\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u306f\u907f\u3051\u3001\u5b9a\u7fa9\u3057\u305f\u95a2\u6570\u306e\u5b9f\u884c\u306e\u307f\u3092\u8a31\u53ef\u3057\u3066\u304f\u3060\u3055\u3044\u3002arXiv API \u304b\u3089\u5b66\u8853\u8ad6\u6587\u3092\u81ea\u52d5\u7684\u306b\u5206\u6790\u3059\u308b\u305f\u3081\u306b\u95a2\u6570\u547c\u3073\u51fa\u3057\u3092\u4f7f\u7528\u3059\u308b\u4f8b\u306b\u3064\u3044\u3066\u306f\u3001<a href=\"https:\/\/github.com\/matlab-deep-learning\/llms-with-matlab\/blob\/main\/examples\/AnalyzeScientificPapersUsingFunctionCalls.md\" class=\"external\" rel=\"nofollow\" target=\"_blank\">LLM\u3092\u4f7f\u7528\u3057\u305f\u95a2\u6570\u547c\u3073\u51fa\u3057<\/a>\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h1>Key Takeaways<\/h1>\n<ol>\n<li>MATLAB \u3067\u81ea\u7136\u8a00\u8a9e\u51e6\u7406\u30bf\u30b9\u30af\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b GPT \u30e2\u30c7\u30eb\u3092\u4f7f\u7528\u3067\u304d\u308b\u65b0\u3057\u3044 <a href=\"https:\/\/github.com\/matlab-deep-learning\/llms-with-matlab\" class=\"external\" rel=\"nofollow\" target=\"_blank\">GitHub \u30ea\u30dd\u30b8\u30c8\u30ea<\/a>\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n<li>\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u306f\u3001\u611f\u60c5\u5206\u6790\u3084\u30c1\u30e3\u30c3\u30c8\u30dc\u30c3\u30c8\u306e\u69cb\u7bc9\u306a\u3069\u3001\u591a\u304f\u306e\u30bf\u30b9\u30af\u3092\u9054\u6210\u3059\u308b\u305f\u3081\u306e\u4f8b\u3068\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/li>\n<li>\u00a0MATLAB \u30c4\u30fc\u30eb\u3092\u6d3b\u7528\u3057\u3001<a href=\"https:\/\/www.mathworks.com\/products\/text-analytics.html\">Text Analytics Toolbox<\/a> \u306e\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u3001\u30c6\u30ad\u30b9\u30c8\u306e\u53d6\u5f97\u3001\u7ba1\u7406\u3001\u6e96\u5099\u306a\u3069\u306e LLM \u6a5f\u80fd\u3092\u5f37\u5316\u3057\u307e\u3059\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/japan-community\/files\/2024\/02\/LLMs_repo.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div>\n<p>\u203b\u3053\u306e\u6295\u7a3f\u306f 2024 \u5e74 1 \u6708 22 \u65e5\u306bArtificial Intelligence \u3078 \u6295\u7a3f\u3055\u308c\u305f\u3082\u306e\u306e\u6284\u8a33\u3067\u3059\u3002<\/p>\n<p>MATLAB \u3092 OpenAI\u2122 API \u306b\u63a5\u7d9a\u3057\u3066\u81ea\u7136\u8a00\u8a9e\u51e6\u7406\u3092\u884c\u3046\u65b9\u6cd5<br \/>\nChatGPT\u2122\u3001Generative AI\u3001\u5927\u898f\u6a21\u8a00\u8a9e\u30e2\u30c7\u30eb\uff08LLM, Large Language Model\uff09\u3001\u3053\u308c\u3089\u306e\u9769\u65b0\u7684\u306a\u6280\u8853\u3092 MATLAB&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/japan-community\/2024\/02\/06\/large-language-models-with-matlab-jp\/\">read more >><\/a><\/p>\n","protected":false},"author":159,"featured_media":10619,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[141,61],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/posts\/10601"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/users\/159"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/comments?post=10601"}],"version-history":[{"count":15,"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/posts\/10601\/revisions"}],"predecessor-version":[{"id":12052,"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/posts\/10601\/revisions\/12052"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/media\/10619"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/media?parent=10601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/categories?post=10601"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/tags?post=10601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}