【Java开发者必看】从零开始使用LangChain4j与Ollama实现大语言模型的本地化部署及SpringBoot集成测试

目录

一、关于Ollama

1、什么是Ollama

2、AI大模型为什么要本地部署

二、通过Ollama工具轻松部署DeepSeek-R1大模型

1、下载Ollama

2、安装Ollama

3、安装deepseek-r1大模型

4、Ollama常用指令

三、SpringBoot集成测试

1、引入Ollama依赖

2、配置模型参数

3、创建测试用例

四、Ollama 相关文档


一、关于Ollama

1、什么是Ollama

Ollama是一个模型框架,专为在本地机器上便捷部署模型而存在。国内AI模型秒问秒答,无需联网,本地运行数据更安全。

2、AI大模型为什么要本地部署

Ollama是一个本地部署大模型的工具。

使用 Ollama进行本地部署有以下多方面的原因:
1)、数据隐私与安全:对于金融、医疗、法律等涉及大量敏感数据的行业,数据安全至关重要。
2)、离

(三)LangChain4j模型分类和使用 该模型的API比较简单,接受字符串作为输入并返回字符串作为输出,这种模型已经被ChatLanguageModel取代,所以LangChain4j中也不在扩展对LanguageModel的支持,在此处也不过多描述。 阅读详情

相关推荐

【langchain4j系列教程-03】Ollama本地部署并调用本地模型

在人工智能飞速发展的今天,大型语言模型(LLM)已成为推动技术创新的核心引擎。然而,传统的云端大模型依赖网络、受限于隐私与延迟,难以满足个性化、高安全性的需求。Ollama 应运而生,它是一款轻量级、高性能的本地大模型运行框架,让开发者、研究者和企业能够轻松在本地部署和运行各类开源大模型,如Llama 3、Mistral、Gemma等,无需依赖云端服务,即可享受强大的AI能力。本地运行,隐私无忧:数据完全留在本地,避免敏感信息外泄。极简部署,开箱即用:一行命令即可下载并运行模型,无需复杂配置。

双非二本自学到互联网公司的成长经历,有故事,有干货。 1782

LangChain4j 从入门到放弃,java可以使用的 LLM 大模型 AI 框架(1)快速开始

随着人工智能(AI)技术的迅猛发展,越来越多的开发者开始关注 AI 应用的开发。然而,市场上主流的 AI 框架和工具(如 LangChain、PyTorch)大多仅支持 Python,这为 Java 开发者带来了工具不足和学习门槛较高的困扰。LangChain4j 是一个旨在简化将大型语言模型(LLM)集成到 Java 应用程序中的框架。统一的 API 接口。

TangBoBoa的博客 1万+

大模型应用开发-LangChain4j

大模型应用开发

m0_69695971的博客 1095

VCS 2018 环境下,手把手教你用 UVMC 搞定 SystemC 和 SystemVerilog 混合仿真(附完整代码)

本文详细介绍了在VCS 2018环境下使用UVMC实现SystemC和SystemVerilog混合仿真的完整指南。从环境配置、工具链设置到UVMC通信机制解析,提供了实战案例和高级调试技巧,帮助开发者高效搭建复杂验证环境。特别适合需要处理跨语言仿真的芯片验证工程师。

weixin_30952535的博客 285

vscode远程连接deepin出错:过程试图写入的管道不存在的解决方法

背景:昨天我用vscode使用ssh远程开发还处于正常状态,今天刚打开电脑,并启动deepin,再次使用vscode重新连接就出现异常。意思就是22号默认端口连接被拒绝,所以要先确定ssh是否连接。3.重新进入vscode里面,重新连接,如图成功连接。,查看port后面的端口号是不是22号。1.检查sshd是否启动。

qq_43573047的博客 2946

航空大数据——项目资源汇总及开源(四)

ADS-B项目开源大礼包

cyc头发还挺多的博客 4976

第七章 Wi-Fi连接过程

系列文章目录 第一章 国内下载AOSP最新源码的方法 第二章 下载AOSP WiFi相关的代码 第三章 将源码导入Android Studio(无需编译idegen) 文章目录系列文章目录前言一、Wi-Fi连接是什么?二、Wi-Fi连接的过程1. 手动连接总结 前言 Wi-Fi连接分为下面几种过程,每种的流程都有些许差异: 手动连接 自动连接 在BSS之间漫游 Passpoint热点连接 一、Wi-Fi连接是什么? Wi-Fi连接是指STA(手机)连接到AP(无线路由器)的过程,这个过程分为链路

Frank.Zhang的专栏 2526

手把手教你学基带SOC芯片(4.4.9)--基带芯片的电源管理实例:高通 Snapdragon 系列实例(十)

Snapdragon 888 通过支持多种深度睡眠模式,如 AOAC 模式、低功耗模式和深度睡眠模式,以及智能电源管理技术,实现了对功耗的精细管理。这些模式不仅延长了设备的电池寿命,还确保了用户在各种使用场景下的良好体验。无论是保持网络连接、限制后台活动,还是完全关闭不必要的功能,Snapdragon 888 都能够灵活应对,提供高效的功耗管理方案。

MHD0815的博客 740

数字孪生教程大全之 我们如何构建数字孪生?数字孪生的五个级别都是什么

文章摘要 什么是数字孪生? 我们如何构建数字孪生? 开发智能数字孪生系统的框架 什么是数字孪生? 数字孪生是一个不言自明的术语,用于识别物理系统的数字化版本。数字孪生的最早参考来自大卫·格伦特(David Gelernter )的小说作品。在他 1995 年的书中,Gelernter 博士为读者提供了未来有趣的可能性——万维网。前网络书籍谈到了计算机系统上的镜像数字世界。有些人可能会争辩说,我们的 Meta-verse 是新的数字世界——现实世界的数字孪生。但是,还有其他可能性,时间可能会讲述一个更好的

iCloudEnd的博客 3629

工业级实战:C#实现欧姆龙PLC FINS-TCP通信(协议解析+完整源码+避坑指南)

// FINS主命令码+子命令码枚举(工业级常用指令)ReadData = 0x0101, // 读取数据WriteData = 0x0102, // 写入数据ReadPlcStatus = 0x0601, // 读取PLC状态ResetPlc = 0x0605 // 复位PLC(慎用)/// 欧姆龙PLC数据区枚举(工业常用)CIO = 0x30, // CIO区(核心数据区)WR = 0x31, // 工作区HR = 0x32, // 保持区。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 656

车载以太网-ARP 动态 静态

车载以太网-ARP 动态 静态

天赐好车的博客 409

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

上一篇: 【AI 大模型开发者必看】Windows下AI交互界面Ollama Open WebUI 安装与配置详细教程
下一篇: error: subprocess-exited-with-error,This error originates from a subprocess, and is likely...的解决办法
TechBro华仔
TechBro华仔 优质创作者: Java技术领域 优质创作者: Java技术领域 领域专家: 后端开发技术领域 领域专家: 后端开发技术领域
博客等级 码龄11年 5万+粉丝 430原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

TechBro华仔

日拱一卒无有尽,功不唐捐终入海

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值