使用LM Studio在本地运行LLM完整教程

GPT-4被普遍认为是最好的生成式AI聊天机器人,但开源模型一直在变得越来越好,并且通过微调在某些特定领域是可以超过GPT4的。在开源类别中出于以下的原因,你可能会考虑过在本地计算机上本地运行LLM :

  1. 脱机:不需要互联网连接。
  2. 模型访问:在本地运行模型,可以尝试开源模型(Llama 2、Vicuna、Mistral、OpenOrca等等)。
  3. 隐私:当在本地运行模型时,没有信息被传输到云。尽管在使用GPT-4、Bard和claude 2等基于云的模型时,隐私问题可能被夸大了,但在本地运行模型可以避免任何问题。
  4. 实验:如果你看到了生成人工智能的价值,可以通过测试了解模型的细节并知道还有什么可用。
  5. 成本:开源模型是免费的,其中一些可以不受限制地用于商业。

对许多人来说,运行本地LLM需要一点计算机知识,因为它通常需要在命令提示符中运行它们,或者使用更复杂的web工具,如Oobabooga。

LM Studio是一个免费的桌面软件工具,它使得安装和使用开源LLM模型非常容易。

但是请记住,LM Studio并不开源,只是免费使用

但是LM Studio是我目前见到最好用,也是最简单的本地测试工具,所以如果是本机测试使用的话还是推荐试一试他。

首先进入“lmstudio.ai”,下载并安装适合操作系统的版本:

LM Studio,选择要安装的LLM。

可以通过选择主窗口中列出的社区建议模型之一来实现进行,也可以使用HuggingFace上可用的任何模型的搜索栏查找关键字。

模型搜索列表中可以看到安装/下载文件的大小。请确保下载的大小没有问题。(国内需要魔法)

在屏幕左上角的发布日期栏,是“compatibility guess”。LM Studio已经检查了本地系统,并展示它认为可以在计算机上运行的那些模型。要查看所有模型,点击“compatibility guess”(#1)。点击左边的一个模型,右边就会显示可用的版本,并显示那些根据你的电脑规格应该可以工作的模型(#2)。见下图:

根据计算机的能力/速度,较大的模型将更准确,但速度较慢。并且这个鞋模型中的大多数都是量化的,包含了GGML和GGUF等格式。(具体这些格式可以参考我们以前的文章)

模型下载完成后,(1)在窗口顶部的下拉菜单中选择模型;(2)选择左侧栏中的聊天气泡;(3)打开右侧的“Context Overflow Policy”和“Chat Appearance”。

确保在“Context Overflow Policy”下选择“Maintain a rolling window and truncate past messages”,并在“Chat Appearance”下选择“Plaintext”。

打开“Model Configuration”,然后打开“Prompt Format”,向下滚动到“Pre-prompt / System prompt”,选择“>”符号打开。可以在这里输入系统“role”。也就是说可以设定希望机器人如何行动,以及在它的回答中应该提供什么“技能”或其他特定的品质。这与ChatGPT Plus帐户的“Custom instructions”相同。


继续向下滚动,找到“Hardware Settings”。默认设置是计算机的CPU完成所有工作,但如果安装了GPU,将在这里看到它。如果GPU显存不够,可以将GPU想要处理多少层(从10-20开始)这会将一部分层使用GPU处理,这与llama.cpp的参数是一样的。还可以选择增加LLM使用的CPU线程数。默认值是4。这个也是需要根据本地计算机进行设置。

完成这些更改后,就可以使用本地LLM了。只需在“USER”字段中输入查询,LLM将响应为“AI”。

可以看到LM Studio提供了极好的体验,为ChatGPT提供了一个很好的本地替代方案。LM Studio提供了一种使用OpenAI兼容接口来提供模型的方便方法,这简化了与使用OpenAI作为后端的客户端的集成。

如果你正在寻找一种快速简便的方法来设置和使用具有不同开源模型的聊天或服务器供个人使用,LM Studio是一个很好的起点。

https://avoid.overfit.cn/post/bc8b0a511ea94cad81b581ef5bd19d39

作者:Gene Bernardin

### LMSTUDIO SERVER SETUP AND CONFIGURATION #### Server Installation Prerequisites For the installation of an lmStudio server, ensuring that all prerequisites are met can prevent common issues such as those seen with failed installations or invalid configurations. The environment must support necessary services and dependencies required by the lmStudio application to function properly[^1]. #### Configuration Requirements An improperly configured system may lead to errors similar to messages indicating `Invalid configuration information`. This suggests that before running any setup programs for lmStudio, it's crucial to verify that all specified parameters match the actual hardware and software conditions on which lmStudio will operate[^2]. #### Detailed Setup Process To set up the lmStudio server correctly: Ensure the Jack server—a component possibly involved in audio processing within lmStudio—is both installed and operational. Failures like `Ensuring Jack server is installed and started FAILED` suggest potential problems either during this phase or due to missing components critical for its operation. ```bash # Example command to start a service (this should be adapted based on specific requirements) sudo systemctl start jackd.service ``` After confirming that all dependent systems including but not limited to the Jack server are functioning normally, proceed with configuring lmStudio according to official documentation guidelines provided by the developers or maintainers of lmStudio. During this process, pay close attention to setting correct paths, permissions, network settings, etc., which directly affect whether the server starts successfully after completion of the setup procedure. #### Verification Post-Setup Once the setup has been completed without encountering error messages related to configuration validity or dependency failures, perform tests using predefined scenarios to ensure everything operates as expected under normal circumstances.
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值