Goal-guided Generative Prompt Injection Attack on Large Language Models

本文是LLM系列文章,针对《Goal-guided Generative Prompt Injection Attack on Large Language Models》的翻译。

大型语言模型的目标引导生成式提示注入攻击

摘要

当前的大型语言模型(LLM)为大规模面向用户的自然语言任务提供了坚实的基础。大量用户可以通过用户界面轻松注入对抗性文本或指令,从而导致LLM模型安全挑战。尽管目前有大量关于提示注入攻击的研究,但这些黑盒攻击大多使用启发式策略。目前尚不清楚这些启发式策略如何与攻击的成功率相关,从而有效地提高模型的鲁棒性。为了解决这个问题,我们重新定义了攻击的目标:最大化干净文本和对抗文本的条件概率之间的KL分歧。此外,我们证明了最大化KL散度等价于最大化嵌入表示x和x′之间的马氏距离。当条件概率为高斯分布时,干净文本和对抗文本的概率分布,并给出了x和x′的定量关系。然后,我们设计了一种简单有效的目标引导生成提示注入策略(G2PIA),以找到满足特定约束的注入文本,从而近似达到最佳攻击效果。特别值得注意的是,我们的攻击方法是一种计算成本低的无查询黑盒攻击方法。在七个LLM模型和四个数据集上的实验结果表明了我们的攻击方法的有效性。

1 引言

2 相关工作

3 方法

4 实验

5 消融研究

6 结论

在我们的工作中,我们提出了一种新的面向目标的生成提示注入攻击(G2PIA)方法。为了使注入的文本尽可能地误导大模型,我们定义了一个新的目标函数来最大化,即注入前(干净文本)和注入后(攻击文本)两个后验条件概率之间的KL散度值。此外,我们证明了在条件概率服从多元高斯分布的条件下,最大

Agent 开发面试题--Day010【如何防御 Prompt 注入】 防御 Prompt 注入,核心思路是。因为大语言模型在架构上无法从根本上区分“指令”与“数据”,单点防御很容易被绕过。你需要假设攻击总会发生,并通过多层机制来降低风险与影响。 阅读详情

相关推荐

从规则到模型:Rerank 精排与 LLM 的结构化 Prompt 设计

本文介绍如何通过Rerank模型与精心设计的Prompt,提升代码知识图谱中候选方案的精准度。采用BAAI/bge-reranker-v2-m3进行语义重排,结合Cross-Encoder实现细粒度排序;并通过结构化Prompt约束LLM输出可落地的JSON格式修改方案,避免幻觉与冗余。同时提出应对Token溢出、函数越界、历史经验忽略等三大坑点的解决方案。最终输出仅包含Top 4高相关代码片段,为下阶段“人在回路”的安全代码修改奠定基础。

xianyinsuifeng的博客 19

DC/DC开关电源EMC仿真红宝书

本红宝书系统性介绍开关电源EMC仿真方法,包括仿真原理、仿真思路、仿真工具以及仿真效率提升与仿测一致性的实战经验。从理论到仿真,从仿真到应用,真正帮你实现一文掌握开关电源EMC仿真!全文约14000字,适读人群:开关电源设计、电磁兼容EMC相关从业者,电磁相关专业研究生及CST仿真爱好者等。

电磁学社 2503

RFSoC应用XCZU47DR八发八收FPGA设计方案

本文介绍了基于Xilinx XCZU47DR RFSoC芯片的八发八收FPGA设计方案。该方案采用集成射频数据转换器的SoC架构,支持8路14bit ADC(5GSPS)和8路14bit DAC(9.85GSPS),可直接处理5GHz以下射频信号。硬件设计包含高性能输入缓冲器、QMC校正和复杂混频器,适用于5G/6G通信、雷达、卫星通信等领域。文章详细阐述了ADC/DAC子系统参数,包括通道配置、采样率、带宽等特性,并提供了FPGA顶层模块的硬件接口设计,展示了多通道数据收发处理能力。该方案无需外置混频器,

toonyhe的博客 1795

浅谈Android MVI架构---大自然的搬运工~~~

浅谈 Android MVI架构

hong_world的博客 2158

阿里开源最强数字人工具 EchoMimicV2,本地部署(一)

EchoMimicV2是阿里推出的半身人体AI数字人项目,基于参考图片、音频剪辑和手部姿势序列生成高质量动画视频,确保音频内容与半身动作的一致性。现在本地部署,安装体验一下。

缘分天空的专栏 4620

AI驱动的数据完整性:ECC到S/4HANA迁移

在SAP ECC到S/4HANA的迁移过程中,数据完整性验证是最复杂且关键的挑战之一。本文介绍了一个全面的AI驱动的端到端数据完整性框架,用于对账事务数据并验证数百万条主数据记录和事务记录的完整性。该框架结合了模式映射、自然语言提示到SQL生成、基于LLM的解决方案、大规模数据对账的数据完整性工具、基于云的测试数据管理以及实时Power BI仪表板,为开发者提供了一个可重复、可扩展的工作流程,确保ERP迁移过程中的数据质量。

简简单单Onlinezuozuo 1177

Visual Studio Code + MCP Server + Claude Code 三件套进行 ABAP 开发

本文介绍了如何在Visual Studio Code中利用Claude Code和SAP官方提供的MCP Server进行ABAP开发。作者分享了19年ABAP开发经验,从手动编码到如今通过自然语言生成高质量代码的技术演进。详细说明了配置步骤:启用ADT MCP Server、安装Claude Code扩展、配置.claude.json文件,并验证MCP Server的14个功能。通过实例演示了如何用自然语言指令让Claude Code创建包含冒泡排序实现和单元测试的ABAP类,展示了MCP Server在

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1301

CXSMILES细则-用于在 SMILES 字符串后存储分子的特殊特征

Chemaxon 扩展 SMILES/SMARTS 用于在 SMILES 字符串后存储分子的特殊特征。任何信息都可以存储在 SMILES 字符串后,只要它们由空格或制表符字符分隔,因为 SMILES 解析器会忽略这些信息,或者将它们作为注释使用。扩展特征以以下格式存储:Chemaxon 的扩展 SMILES/SMARTS 不包含非 ASCII 字符,它们通常以字符代码 n 的形式被转义为 &#n;。在 S-group 中,ASCII 字符“,”、“;”、“|”、“{”、“}”也以这种方式转义。此外,符号“$

ASKCOS博客 403

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

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'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('DeepLearnToolbox'));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('state',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'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',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 = 'sigm';%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, 'Too big error');```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('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';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)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';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, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% 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'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 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, 'Too big error');```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('state',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, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',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, 'Too big error');%% ex3 neural net with dropoutrand('state',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, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % 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, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % 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, 'Too big error');%% 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('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % 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, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

上一篇: RiskLabs: Predicting Financial Risk Using Large Language Model Based on Multi-Sources Data
下一篇: DYNAMIC GENERATION OF PERSONALITIES WITH LARGE LANGUAGE MODELS
UnknownBody
博客等级 码龄16年 5601粉丝 4749原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

打赏作者

UnknownBody

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值