# Large Language Models (LLMs) with MATLAB®
This repository contains code to connect MATLAB to the [OpenAI™ Chat Completions API](https://platform.openai.com/docs/guides/text-generation/chat-completions-api) (which powers ChatGPT™), OpenAI Images API (which powers DALL·E™), [Azure® OpenAI Service](https://learn.microsoft.com/en-us/azure/ai-services/openai/), and both local and nonlocal [Ollama™](https://ollama.com/) models. This allows you to leverage the natural language processing capabilities of large language models directly within your MATLAB environment.
## Requirements
### MathWorks Products
- Requires MATLAB release R2024a or newer.
- Some examples require Text Analytics Toolbox™.
### 3rd Party Products:
- For OpenAI connections: An active OpenAI API subscription and API key.
- For Azure OpenAI Services: An active Azure subscription with OpenAI access, deployment, and API key.
- For Ollama: An Ollama installation.
## Setup
See these pages for instructions specific to the 3rd party product selected:
* [OpenAI](doc/OpenAI.md)
* [Azure](doc/Azure.md)
* [Ollama](doc/Ollama.md)
### MATLAB Online
To use this repository with MATLAB Online, click [![Open in MATLAB Online](https://www.mathworks.com/images/responsive/global/open-in-matlab-online.svg)](https://matlab.mathworks.com/open/github/v1?repo=matlab-deep-learning/llms-with-matlab)
### MATLAB Desktop
To use this repository with a local installation of MATLAB, first clone the repository.
1. In the system command prompt, run:
```bash
git clone https://github.com/matlab-deep-learning/llms-with-matlab.git
```
2. Open MATLAB and navigate to the directory where you cloned the repository.
3. Add the directory to the MATLAB path.
```matlab
addpath('path/to/llms-with-matlab');
```
## Examples
To learn how to use this in your workflows, see [Examples](/examples/).
- [ProcessGeneratedTextinRealTimebyUsingChatGPTinStreamingMode.mlx](/examples/ProcessGeneratedTextinRealTimebyUsingChatGPTinStreamingMode.mlx): Learn to implement a simple chat that stream the response.
- [SummarizeLargeDocumentsUsingChatGPTandMATLAB.mlx](/examples/SummarizeLargeDocumentsUsingChatGPTandMATLAB.mlx): Learn to create concise summaries of long texts with ChatGPT. (Requires Text Analytics Toolbox™)
- [CreateSimpleChatBot.mlx](/examples/CreateSimpleChatBot.mlx): Build a conversational chatbot capable of handling various dialogue scenarios using ChatGPT. (Requires Text Analytics Toolbox)
- [AnalyzeScientificPapersUsingFunctionCalls.mlx](/examples/AnalyzeScientificPapersUsingFunctionCalls.mlx): Learn how to create agents capable of executing MATLAB functions.
- [AnalyzeTextDataUsingParallelFunctionCallwithChatGPT.mlx](/examples/AnalyzeTextDataUsingParallelFunctionCallwithChatGPT.mlx): Learn how to take advantage of parallel function calling.
- [RetrievalAugmentedGenerationUsingChatGPTandMATLAB.mlx](/examples/RetrievalAugmentedGenerationUsingChatGPTandMATLAB.mlx): Learn about retrieval augmented generation with a simple use case. (Requires Text Analytics Toolbox™)
- [DescribeImagesUsingChatGPT.mlx](/examples/DescribeImagesUsingChatGPT.mlx): Learn how to use GPT-4 Turbo with Vision to understand the content of an image.
- [AnalyzeSentimentinTextUsingChatGPTinJSONMode.mlx](/examples/AnalyzeSentimentinTextUsingChatGPTinJSONMode.mlx): Learn how to use JSON mode in chat completions
- [UsingDALLEToEditImages.mlx](/examples/UsingDALLEToEditImages.mlx): Learn how to generate images
- [UsingDALLEToGenerateImages.mlx](/examples/UsingDALLEToGenerateImages.mlx): Create variations of images and editimages.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
使用MATLAB的大型语言模型(LLM) 将MATLAB连接到Ollama(用于本地LLM)、OpenAI聊天完成API(支持ChatGPT)和AzureOpenAI服务 使用MATLAB的大型语言模型(LLM) 在MATLAB中打开文件交换上的MATLAB在线查看大型语言模型(LLM) 此存储库包含将MATLAB连接到OpenAI聊天完成API(为ChatGPT提供动力)、OpenAI Images API(为DALL·E提供动力的)、AzureOpenAI Service以及本地和非本地Ollama模型的代码。这使您可以在MATLAB环境中直接利用大型语言模型的自然语言处理能力。
资源推荐
资源详情
资源评论
收起资源包目录
LLMs with MATLAB.zip (64个子文件)
SECURITY.md 389B
openAIMessages.m 293B
codecov.yml 51B
doc
OpenAI.md 11KB
Azure.md 10KB
Ollama.md 4KB
extractOpenAIEmbeddings.m 3KB
tests
tazureChat.m 20KB
tresponseStreamer.m 3KB
tollamaChat.m 13KB
topenAIChat.m 30KB
texampleTests.m 4KB
tmessageHistory.m 15KB
textractOpenAIEmbeddings.m 5KB
test_files
solar.png 65KB
topenAIMessages.m 295B
topenAIFunction.m 9KB
topenAIImages.m 12KB
examples
RetrievalAugmentedGenerationUsingOllamaAndMATLAB.mlx 6KB
InformationRetrievalUsingOpenAIDocumentEmbedding.mlx 5KB
DescribeImagesUsingChatGPT.mlx 546KB
AnalyzeSentimentinTextUsingChatGPTinJSONMode.mlx 5KB
ProcessGeneratedTextInRealTimeByUsingOllamaInStreamingMode.mlx 6KB
ProcessGeneratedTextinRealTimebyUsingChatGPTinStreamingMode.mlx 5KB
UsingDALLEToGenerateImages.mlx 1.98MB
CreateSimpleChatBot.mlx 5KB
CreateSimpleOllamaChatBot.mlx 6KB
RetrievalAugmentedGenerationUsingChatGPTandMATLAB.mlx 6KB
AnalyzeScientificPapersUsingFunctionCalls.mlx 6KB
AnalyzeTextDataUsingParallelFunctionCallwithChatGPT.mlx 6KB
images
bear.png 2.15MB
mask_bear.png 2.22MB
SummarizeLargeDocumentsUsingChatGPTandMATLAB.mlx 6KB
UsingDALLEToEditImages.mlx 4.21MB
messageHistory.m 13KB
openAIImages.m 15KB
ollamaChat.m 9KB
+llms
+openai
models.m 388B
validateMessageSupported.m 671B
validateResponseFormat.m 673B
+stream
responseStreamer.m 4KB
+utils
mustBeTextOrEmpty.m 272B
isUnique.m 237B
mustBeValidPenalty.m 242B
mustBeValidTopP.m 244B
mustBeNonzeroLengthTextScalar.m 339B
mustBeValidStop.m 480B
errorMessageCatalog.m 4KB
mustBeValidTemperature.m 251B
+azure
apiVersions.m 302B
+internal
callOllamaChatAPI.m 3KB
sendRequest.m 1KB
hasTools.m 379B
gptPenalties.m 483B
needsAPIKey.m 210B
getApiKeyFromNvpOrEnv.m 896B
callOpenAIChatAPI.m 4KB
callAzureChatAPI.m 4KB
textGenerator.m 869B
openAIChat.m 12KB
azureChat.m 14KB
openAIFunction.m 7KB
README.md 4KB
functionSignatures.json 6KB
共 64 条
- 1
资源评论
自不量力的A同学
- 粉丝: 772
- 资源: 2787
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功