当前位置: 首页 > news >正文

LLM(5) | Encoder 和 Decoder 架构

LLM(5) | Encoder 和 Decoder 架构

文章目录

  • LLM(5) | Encoder 和 Decoder 架构
    • 0. 目的
    • 1. 概要
    • 2. encoder 和 decoder 风格的 transformer (Encoder- And Decoder-Style Transformers)
      • 原始的 transformer (The original transformer)
      • 编码器 (Encoders)
      • 解码器 (Decoders)
      • 编码器和解码器的混合 (encoder-decoder hybrids)
      • 术语、 黑话 (Terminology and jargon)
      • 结论
    • References

0. 目的

LLM 模型都是 transformer 结构的, 先前已经粗略翻阅了提出 transformer 模型的论文 “Attention Is All You Need”, 了解到了 transformer 结构是第一个完全基于 attention 的模型。

而在一些资料中, 看到有人对 LLM 进行分类, 分成 encoder-only, decoder-only, encode-decode 三类, 感觉很晕, 有必要了解下什么是 encoder 和 decoder。

本文主要是对 Understanding Encoder And Decoder LLMs 的翻译。

老规矩, 中文翻译后的括号里, 是个人粗浅的笔记和想法。

1. 概要

Several people asked me to dive a bit deeper into large language model (LLM) jargon and explain some of the more technical terms we nowadays take for granted. This includes references to “encoder-style” and “decoder-style” LLMs. What do these terms mean?

我被人问了好几次, 让我更深入的说说 LLM 术语, 并解释我们现在认为理所当然的一些更技术性的术语。 这包括对 encode-style 和 decoder-style 的 LLM。 这些术语是什么意思?
( LLM 火起来后, 经常发现一些缩写,术语, 让不了解它的人很晕。 有些老铁让作者讲讲。 作者 sebastianraschka 以前是 University of Wisconsin-Madison 的 Assistant Professor, 后来全职加入 lighting ai。)

To explain the difference between encoder- and decoder-style LLMs, I wanted to share an excerpt from my new book, Machine Learning Q and AI, that I completed last week.

为了解释 encoder-style 和 decoder-style LLM 的区别, 我想分享一段我上周完成的新书 “Machine Learning Q and AI” 的摘录。
(作者写了一本书, 看来在讲授 AI 方面有经验.)

This book is aimed at people who are already familiar with machine learning and deep learning (“AI”) and are interested in diving into more advanced topics. There are 30 chapters in total, covering various topics, including

这本书是针对那些已经熟悉机器学习和深度学习(AI), 并对深入更高级话题感兴趣的人, 总共有30章, 涵盖了各种主题,包括:

  • 多GPU训练范式的解释 (Explanations of multi-GPU training paradigms)
  • 微调 transformer (Finetuning transformers)
  • encoder 和 decoder 风格的 LLM 之前的区别 (Differences between encoder- and decoder-style LLMs)
  • 更多其他主题 (And many more!)

(看了下电子书需要购买,20+美元)

2. encoder 和 decoder 风格的 transformer (Encoder- And Decoder-Style Transformers)

Fundamentally, both encoder- and decoder-style architectures use the same self-attention layers to encode word tokens. However, the main difference is that encoders are designed to learn embeddings that can be used for various predictive modeling tasks such as classification. In contrast, decoders are designed to generate new texts, for example, answering user queries.

基本上, endoder- 和 decoder- 风格的架构, 都使用相同的 self-attention 层来编码单词标记 (word tokens). 然而, 主要区别在于 encoder 的设计,是为了学习可以用于各种预测建模任务的嵌入。 相反, decoder 的设计初衷是生成新的文本, 比如回答用户的查询。
(encoder 是为了学习一个 embedding, 这个 embedding 能用于预测性的任务比如分类; decoder 是为了生成新的文本, 比如回答问题.)

原始的 transformer (The original transformer)

The original transformer architecture (Attention Is All You Need, 2017), which was developed for English-to-French and English-to-German language translation, utilized both an encoder and a decoder, as illustrated in the figure below.

原始的 transformer 架构是在2017年的论文 “Attention Is All You Need” 里提出的, 左图是 encoder, 右图是 decoder:
在这里插入图片描述

In the figure above, the input text (that is, the sentences of the text that is to be translated) is first tokenized into individual word tokens, which are then encoded via an embedding layer before it enters the encoder part.

在上图中, 输入文本(即要翻译的文本的句子)首先被分词成单个词元(token), 然后通过 embedding 层进行编码, 然后进入编码器部分。

Then, after adding a positional encoding vector to each embedded word, the embeddings go through a multi-head self-attention layer.

然后, 在为每个嵌入的单词添加位置编码向量后, 嵌入 multi-head self-attention 层。

The multi-head attention layer is followed by an “Add & normalize” step, which performs a layer normalization and adds the original embeddings via a skip connection (also known as a residual or shortcut connection).

multi-head attention 层之后是 “Add & Normalize” 步骤, 它执行 layer normalization, 并通过 skip connection (也叫做残差 或 快捷连接)添加原始嵌入。

Finally, after entering a “fully connected layer,” which is a small multilayer perceptron consisting of two fully connected layers with a nonlinear activation function in between, the outputs are again added and normalized before they are passed to a multi-head self-attention layer of the decoder part.

最后, 经过进入全连接层后, 这是一个由两个全连接层组成的小型多层感知机, 在两者之间还有非线性激活函数, 输出再次被添加和归一化, 然后传递到 decoder 部分的 multi-head self-attention 层。

The decoder part in the figure above has a similar overall structure as the encoder part. The key difference is that the inputs and outputs are different.

上图中 decoder 部分和 encoder 部分具有相似的整体结构。 主要区别在于输入和输出是不同的。

The encoder receives the input text that is to be translated, and the decoder generates the translated text.

encoder 接收要翻译的输入文本, decoder 则是生成翻译后的文本。

以下是个人理解

encoder 和 decoder 没那么神秘。 提出 transformer 的那篇论文里的第一张图, 左图是 encoder, 右图是 decoder, 并且 encoder 和 decoder 在整体上是非常相似的。 为什么这么说呢? 你看:

  • 【红色】 encoder 和 decoder 的输入, 都是先经过 tokenize 后搞一个 embendding 和 positional encoding 的
  • 【绿色】 进入 encoder 和 decoder 里面, 都是先经过一个 MHA 的结构 (先忽略 mask 的问题)
  • 【橙色】 然后是 “Add & normalize” 和 “Fully connected” 层的组合
  • 【没标记颜色】 encoder 和 decoder 内部的最后一部分, 都是 “Add & normalize”

在这里插入图片描述

编码器 (Encoders)

The encoder part in the original transformer, illustrated in the preceding figure, is responsible for understanding and extracting the relevant information from the input text.

在原始 transformer 中,编码器部分负责理解和提取输入文本中的相关信息。

It then outputs a continuous representation (embedding) of the input text that is passed to the decoder.

然后,它输出输入文本的连续表示(embedding),这个表示被传递给 decoder。

Finally, the decoder generates the translated text (target language) based on the continuous representation received from the encoder.

最后, decoder 基于从 encoder 接收到的连续表示生成翻译文本(目标语言)。

Over the years, various encoder-only architectures have been developed based on the encoder module of the original transformer model outlined above.

多年来,基于上述原始 transformer 模型的 encoder 模块,已经开发了各种 encoder-only 的架构。

Notable examples include BERT (Pre-training of Deep Bidirectional Transformers for Language Understanding, 2018) and RoBERTa (A Robustly Optimized BERT Pretraining Approach, 2018).

值得注意的例子包括BERT(用于语言理解的深度双向变换器的预训练,2018年)和RoBERTa(一种鲁棒优化的BERT预训练方法,2018年)

BERT (Bidirectional Encoder Representations from Transformers) is an encoder-only architecture based on the Transformer’s encoder module.

BERT(来自 transformer 的双向 encoder 表示)是一种 encoder-only 的架构, 它里面的 encoder 模块是基于 transformer 的 encoder 模块。

The BERT model is pretrained on a large text corpus using masked language modeling (illustrated in the figure below) and next-sentence prediction tasks.

BERT模型使用遮蔽语言建模(完形填空)(如下图所示)和下一句预测任务在大型文本语料库上进行预训练.

在这里插入图片描述

The main idea behind masked language modeling is to mask (or replace) random word tokens in the input sequence and then train the model to predict the original masked tokens based on the surrounding context.

遮蔽语言建模背后的主要思想是在输入序列中遮蔽(或替换)随机词语标记,然后训练模型根据周围的上下文预测原始遮蔽的标记。

Next to the masked language modeling pretraining task illustrated in the figure above, the next-sentence prediction task asks the model to predict whether the original document’s sentence order of two randomly shuffled sentences is correct. For example, two sentences, in random order, are separated by the [SEP] token:

除了上图所示的遮蔽语言建模预训练任务之外,下一句预测任务要求模型预测两个随机打乱顺序的句子是否保持了原始文档的句子顺序。例如,两个随机顺序的句子由[SEP]标记分隔:

[CLS] Toast is a simple yet delicious food [SEP] It’s often served with butter, jam, or honey.

[CLS] 吐司是一种简单却美味的食物 [SEP] 它通常搭配黄油、果酱或蜂蜜食用。

[CLS] It’s often served with butter, jam, or honey. [SEP] Toast is a simple yet delicious food.

[CLS] 它通常搭配黄油、果酱或蜂蜜食用。[SEP] 吐司是一种简单却美味的食物。

The [CLS] token is a placeholder token for the model, prompting the model to return a True or False label indicating whether the sentences are in the correct order or not.

其中 [CLS] 标记是模型的占位符标记,提示模型返回一个真或假的标签,表明句子的顺序是否正确。

The masked language and next-sentence pretraining objectives (which are a form of self-supervised learning, as discussed in Chapter 2) allow BERT to learn rich contextual representations of the input texts, which can then be finetuned for various downstream tasks like sentiment analysis, question-answering, and named entity recognition.

遮蔽语言和下一句预训练目标(正如第二章所讨论的,这是一种自监督学习的形式)使得BERT能够学习输入文本的丰富上下文表示,然后可以针对各种下游任务进行微调,如情感分析、问答和命名实体识别。

RoBERTa (Robustly optimized BERT approach) is an optimized version of BERT. It maintains the same overall architecture as BERT but employs several training and optimization improvements, such as larger batch sizes, more training data, and eliminating the next-sentence prediction task. These changes resulted in RoBERTa achieving better performance on various natural language understanding tasks than BERT.

RoBERTa(鲁棒优化的BERT方法)是BERT的优化版本。它保持了与BERT相同的总体架构,但采用了多项训练和优化改进,如更大的批量大小、更多的训练数据,并且取消了下一句预测任务。这些变化使得RoBERTa在各种自然语言理解任务上的表现优于BERT。

解码器 (Decoders)

Coming back to the original transformer architecture outlined at the beginning of this section, the multi-head self-attention mechanism in the decoder is similar to the one in the encoder, but it is masked to prevent the model from attending to future positions, ensuring that the predictions for position i can depend only on the known outputs at positions less than i. As illustrated in the figure below, the decoder generates the output word by word.

回到本节开头概述的原始 transformer 架构, decoder 中的 multi-head self-attention 机制与 encoder 中的相似,但它被遮蔽以防止模型关注未来的位置,确保位置i的预测只能依赖于小于i的位置上已知的输出。如下图所示,decoder 逐字生成输出。

在这里插入图片描述

This masking (shown explicitly in the figure above, although it happens internally in the decoder’s multi-head self-attention mechanism) is essential to maintain the autoregressive property of the transformer model during training and inference.

这种遮蔽(如上图所示,尽管它在 encoder 的 MHA 中内部发生)对于在训练和推理过程中保持 transformer 的自回归特性是至关重要的。

The autoregressive property ensures that the model generates output tokens one at a time and uses previously generated tokens as context for generating the next word token.

自回归特性确保模型一次生成一个输出标记,并使用之前生成的标记作为生成下一个词标记的上下文。

Over the years, researchers have built upon the original encoder-decoder transformer architecture and developed several decoder-only models that have proven to be highly effective in various natural language processing tasks. The most notable models include the GPT family.

多年来,研究人员在原始的 encoder-decoder transformer 架构的基础上进行了发展,开发出了几种 decoder-only 模型,这些模型在各种自然语言处理任务中被证明是高度有效的。最值得注意的模型包括GPT系列。

The GPT (Generative Pre-trained Transformer) series are decoder-only models pretrained on large-scale unsupervised text data and finetuned for specific tasks such as text classification, sentiment analysis, question-answering, and summarization.

GPT(生成式预训练变换器)系列是 decoder-only 模型,它们在大规模无监督文本数据上进行预训练,并针对特定任务如文本分类、情感分析、问答和摘要生成进行微调。

The GPT models, including GPT-2, (GPT-3 Language Models are Few-Shot Learners, 2020), and the more recent GPT-4, have shown remarkable performance in various benchmarks and are currently the most popular architecture for natural language processing.

GPT模型,包括GPT-2、(GPT-3语言模型是少数次学习者,2020年)和更近期的GPT-4,在各种基准测试中展现了卓越的性能,目前是自然语言处理中最受欢迎的架构。

One of the most notable aspects of GPT models is their emergent properties.

GPT模型最引人注目的方面之一是它们的涌现属性 (emergent properties)。

Emergent properties refer to the abilities and skills that a model develops due to its next-word prediction pretraining. Even though these models were only taught to predict the next word, the pretrained models are capable of text summarization, translation, question answering, classification, and more. Furthermore, these models can perform new tasks without updating the model parameters via in-context learning, which is discussed in more detail in Chapter 18.

涌现属性指的是模型由于下一个词预测预训练而发展出的能力和技能。尽管这些模型只被教导预测下一个词,但预训练模型能够进行文本摘要、翻译、问答、分类等。此外,这些模型可以通过上下文学习在不更新模型参数的情况下执行新任务,第18章将更详细地讨论这一点。

编码器和解码器的混合 (encoder-decoder hybrids)

Next to the traditional encoder and decoder architectures, there have been advancements in the development of new encoder-decoder models that leverage the strengths of both components.

在传统的 encoder 和 decoder 架构之外,新型 encoder-decoder 模型的开发也取得了进展,这些模型利用了两个组件的优势。

These models often incorporate novel techniques, pre-training objectives, or architectural modifications to enhance their performance in various natural language processing tasks. Some notable examples of these new encoder-decoder models include

这些模型通常融入了新颖的技术、预训练目标或架构修改,以提高它们在各种自然语言处理任务中的表现。一些值得注意的新型编码器-解码器模型包括:

BART (Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension, 2019)

BART(自然语言生成、翻译和理解的序列到序列预训练的去噪,2019)

and T5 (Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer, 2019).

和T5(利用统一的文本到文本变换器探索迁移学习的极限,2019)。

Encoder-decoder models are typically used for natural language processing tasks that involve understanding input sequences and generating output sequences, often with different lengths and structures.

encoder-decoder 模型通常用于自然语言处理任务,这些任务涉及理解输入序列并生成输出序列,输出序列的长度和结构往往与输入不同。

They are particularly good at tasks where there is a complex mapping between the input and output sequences and where it is crucial to capture the relationships between the elements in both sequences. Some common use cases for encoder-decoder models include text translation and summarization.

它们在输入与输出序列之间存在复杂映射关系的任务中表现尤为出色,捕捉两个序列中元素之间的关系至关重要。 encoder-decoder 模型的一些常见用例包括文本翻译和摘要。

术语、 黑话 (Terminology and jargon)

All of these methods, encoder-only, decoder-only, and encoder-decoder models, are sequence-to-sequence models (often abbreviated as seq2seq).

所有这些方法,包括 encoder-only、 decoder-only 和 encoder-decoder 模型,都是序列到序列模型(通常缩写为seq2seq)。

Note that while we refer to BERT-style methods as encoder-only, the description encoder-only may be misleading since these methods also decode the embeddings into output tokens or text during pretraining.

请注意,虽然我们将BERT风格的方法称为 encoder-only,但“encoder-only”这一描述可能会引起误解,因为这些方法在预训练期间也会将嵌入decoding成输出 token 或文本。

In other words, both encoder-only and decoder-only architectures are “decoding.”

换句话说,encoder-only 和 decoder-only 架构都在进行“解码”。

However, the encoder-only architectures, in contrast to decoder-only and encoder-decoder architectures, are not decoding in an autoregressive fashion.

然而,与 decoder-only 和 encoder-decoder 架构不同的是,encoder-only 架构不是以自回归方式进行解码。

Autoregressive decoding refers to generating output sequences one token at a time, conditioning each token on the previously generated tokens.

自回归解码是指一次生成一个token的输出序列,每个token都依赖于之前生成的token。

Encoder-only models do not generate coherent output sequences in this manner. Instead, they focus on understanding the input text and producing task-specific outputs, such as labels or token predictions.

encoder-only 模型不以这种方式生成连贯的输出序列。相反,它们专注于理解输入文本并产生特定于任务的输出,如标签或 token 预测。

结论

In brief, encoder-style models are popular for learning embeddings used in classification tasks, encoder-decoder-style models are used in generative tasks where the output heavily relies on the input (for example, translation and summarization), and decoder-only models are used for other types of generative tasks including Q&A. Since the first transformer architecture emerged, hundreds of encoder-only, decoder-only, and encoder-decoder hybrids have been developed, as summarized in the figure below.

简而言之,encoder-style 的模型在用于分类任务的嵌入学习中很受欢迎, encoder-decoder-style 的模型被用于输出严重依赖于输入的生成性任务(例如,翻译和摘要),而 decoder-only 模型被用于包括问答在内的其他类型的生成性任务。自第一个 transformer 架构出现以来,已经开发了数百种 encoder-only, decoder-only, and encoder-decoder hybrids 的模型结构,如下图所示。

在这里插入图片描述

While encoder-only models gradually lost in popularity, decoder-only models like GPT exploded in popularity thanks to breakthrough in text generation via GPT-3, ChatGPT, and GPT-4. However, encoder-only models are still very useful for training predictive models based on text embeddings versus generating texts.

虽然 encoder-only 模型逐渐失去了人气,但像GPT这样的 decoder-only 模型因GPT-3、ChatGPT和GPT-4在文本生成方面的突破而爆炸性增长。然而,encoder-only 模型在基于文本嵌入的预测模型训练方面仍然非常有用,与生成文本相比。

References

  • Understanding Encoder And Decoder LLMs
  • LLM的3种架构:Encoder-only、Decoder-only、encode-decode

相关文章:

LLM(5) | Encoder 和 Decoder 架构

LLM(5) | Encoder 和 Decoder 架构 文章目录 LLM(5) | Encoder 和 Decoder 架构0. 目的1. 概要2. encoder 和 decoder 风格的 transformer (Encoder- And Decoder-Style Transformers)原始的 transformer (The original transformer)编码器 (Encoders)解码器 (Decoders)编码器和…...

CV | Medical-SAM-Adapter论文详解及项目实现

******************************* 👩‍⚕️ 医学影像相关直达👨‍⚕️******************************* CV | SAM在医学影像上的模型调研【20240207更新版】-CSDN博客 CV | Segment Anything论文详解及代码实现 本文主要讲解Medical-SAM-Adapter论文及项…...

C++初阶:容器(Containers)vector常用接口详解

介绍完了string类的相关内容后:C初阶:适合新手的手撕string类(模拟实现string类) 接下来进入新的篇章,容器vector介绍: 文章目录 1.vector的初步介绍2.vector的定义(constructor)3.v…...

flink写入es的参数解析

ElasticsearchSink内部使用BulkProcessor一次将一批动作(ActionRequest)发送到ES集群。在发送批量动作前,BulkProcessor先缓存,再刷新。缓存刷新的间隔,支持基于Action数量、基于Action大小、基于时间间隔3种策略。BulkProcessor支持在同一次…...

逆向工程:揭开科技神秘面纱的艺术

在当今这个科技飞速发展的时代,我们每天都在与各种电子产品、软件应用打交道。然而,你是否想过,这些看似复杂的高科技产品是如何被创造出来的?今天,我们就来探讨一下逆向工程这一神秘而又令人着迷的领域。 一、什么是…...

决策树的相关知识点

📕参考:ysu老师课件西瓜书 1.决策树的基本概念 【决策树】:决策树是一种描述对样本数据进行分类的树形结构模型,由节点和有向边组成。其中每个内部节点表示一个属性上的判断,每个分支代表一个判断结果的输出&#xff…...

【数据结构】单向链表实现 超详细

目录 一. 单链表的实现 1.准备工作及其注意事项 1.1 先创建三个文件 1.2 注意事项:帮助高效记忆和理解 2.链表的基本功能接口 2.0 创建一个 链表 2.1 链表的打印 3.链表的创建新节点接口 4.链表的节点插入功能接口 4.1 尾插接口 4.2 头插接口 4.3 指定位…...

Opencc4j 开源中文繁简体使用介绍

Opencc4j Opencc4j 支持中文繁简体转换,考虑到词组级别。 Features 特点 严格区分「一简对多繁」和「一简对多异」。 完全兼容异体字,可以实现动态替换。 严格审校一简对多繁词条,原则为「能分则不合」。 词库和函数库完全分离&#xff0c…...

vue 下载二进制文件

文章目录 概要技术细节 概要 vue 下载后端返回的二进制文件流 技术细节 import axios from "axios"; const baseUrl process.env.VUE_APP_BASE_API; //downLoadPdf("/pdf/download?pdfName" res .pdf, res); export function downLoadPdf(str, fil…...

数据结构之堆排序

对于几个元素的关键字序列{K1,K2,…,Kn},当且仅当满足下列关系时称其为堆,其中 2i 和2i1应不大于n。 { K i ≤ K 2 i 1 K i ≤ K 2 i 或 { K i ≥ K 2 i 1 K i ≥ K 2 i {\huge \{}^{K_i≤K_{2i}} _{K_i≤K_{2i1}} …...

鸿蒙(HarmonyOS)项目方舟框架(ArkUI)之ScrollBar组件

鸿蒙(HarmonyOS)项目方舟框架(ArkUI)之ScrollBar组件 一、操作环境 操作系统: Windows 10 专业版、IDE:DevEco Studio 3.1、SDK:HarmonyOS 3.1 二、ScrollBar组件 鸿蒙(HarmonyOS)滚动条组件ScrollBar&…...

读论文:DiffBIR: Towards Blind Image Restoration with Generative Diffusion Prior

DiffBIR 发表于2023年的ICCV,是一种基于生成扩散先验的盲图像恢复模型。它通过两个阶段的处理来去除图像的退化,并细化图像的细节。DiffBIR 的优势在于提供高质量的图像恢复结果,并且具有灵活的参数设置,可以在保真度和质量之间进…...

基于微信小程序的新生报到系统的研究与实现,附源码

博主介绍:✌程序员徐师兄、7年大厂程序员经历。全网粉丝12w、csdn博客专家、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ 🍅文末获取源码联系🍅 👇🏻 精彩专栏推荐订阅👇…...

分享一下 uniapp 打包安卓apk

首先需要安装 Java 环境,这里就不做解释了 第二步:打开 mac 终端 / cmd 命令行工具 使用keytool -genkey命令生成证书 keytool -genkey -alias testalias -keyalg RSA -keysize 2048 -validity 36500 -keystore test.keystore *testalias 是证书别名&am…...

DevOps落地笔记-21|业务价值:软件发布的最终目的

上一课时介绍如何度量软件的内部质量和外部质量。在外部质量中,我们提到用户满意度是衡量软件外部质量的关键因素。“敏捷宣言”的第一条原则规定:“我们最重要的目标,是通过持续不断的及早交付有价值的软件使用户满意”。从这一点也可以看出…...

【动态规划】【前缀和】【数学】2338. 统计理想数组的数目

作者推荐 【动态规划】【前缀和】【C算法】LCP 57. 打地鼠 本文涉及知识点 动态规划汇总 C算法:前缀和、前缀乘积、前缀异或的原理、源码及测试用例 包括课程视频 LeetCode:2338. 统计理想数组的数目 给你两个整数 n 和 maxValue ,用于描述一个 理想…...

【已解决】onnx转换为rknn置信度大于1,图像出现乱框问题解决

前言 环境介绍: 1.编译环境 Ubuntu 18.04.5 LTS 2.RKNN版本 py3.8-rknn2-1.4.0 3.单板 迅为itop-3568开发板 一、现象 采用yolov5训练并将pt转换为onnx,再将onnx采用py3.8-rknn2-1.4.0推理转换为rknn出现置信度大于1,并且图像乱框问题…...

多路服务器技术如何处理大量并发请求?

在当今的互联网时代,随着用户数量的爆炸性增长和业务规模的扩大,多路服务器技术已成为处理大量并发请求的关键手段。多路服务器技术是一种并行处理技术,它可以通过多个服务器同时处理来自不同用户的请求,从而显著提高系统的整体性…...

SpringBoot - 不加 @EnableCaching 标签也一样可以在 Redis 中存储缓存?

网上文章都是说需要在 Application 上加 EnableCaching 注解才能让缓存使用 Redis,但是测试发现不用 EnableCaching 也可以使用 Redis,是网上文章有问题吗? 现在 Application 上用了 EnableAsync,SpringBootApplication&#xff0…...

Linux------命令行参数

目录 前言 一、main函数的参数 二、命令行控制实现计算器 三、实现touch指令 前言 当我们在命令行输入 ls -al ,可以查看当前文件夹下所有文件的信息,还有其他的如rm,touch等指令,都可以帮我们完成相应的操作。 其实运行这些…...

LLM少样本示例的上下文学习在Text-to-SQL任务中的探索

导语 本文探索了如何通过各种提示设计策略,来增强大型语言模型(LLMs)在Few-shot In-context Learning中的文本到SQL转换能力。通过使用示例SQL查询的句法结构来检索演示示例,并选择同时追求多样性和相似性的示例可以提高性能&…...

双非本科准备秋招(19.2)—— 设计模式之保护式暂停

一、wait & notify wait能让线程进入waiting状态,这时候就需要比较一下和sleep的区别了。 sleep vs wait 1) sleep 是 Thread 方法,而 wait 是 Object 的方法 2) sleep 不需要强制和 synchronized 配合使用,但 wait 强制和 s…...

使用SpringMVC实现功能

目录 一、计算器 1、前端页面 2、服务器处理请求 3、效果 二、用户登陆系统 1、前端页面 (1)登陆页面 (2)欢迎页面 2、前端页面发送请求--服务器处理请求 3、效果 三、留言板 1、前端页面 2、前端页面发送请求 &…...

spring aop实现接口超时处理组件

文章目录 实现思路实现代码starter组件 实现思路 这里使用FutureTask,它通过get方法以阻塞的方式获取执行结果,并设定超时时间: public V get() throws InterruptedException, ExecutionException ;public V get(long timeout, TimeUnit un…...

c++设计模式之装饰器模式

作用 为现有类增加功能 案例说明 class Car { public:virtual void show()0; };class Bmw:public Car { public:void show(){cout<<"宝马汽车>>"<<endl;} };class Audi:public Car { public:void show(){cout<<"奥迪汽车>>&q…...

WordPress如何实现随机显示一句话经典语录?怎么添加到评论框中?

我们在一些WordPress网站的顶部或侧边栏或评论框中&#xff0c;经常看到会随机显示一句经典语录&#xff0c;他们是怎么实现的呢&#xff1f; 其实&#xff0c;boke112百科前面跟大家分享的『WordPress集成一言&#xff08;Hitokoto&#xff09;API经典语句功能』一文中就提供…...

【退役之重学前端】vite, vue3, vue-router, vuex, ES6学习日记

学习使用vitevue3的所遇问题总结&#xff08;2024年2月1日&#xff09; 组件中使用<script>标签忘记加 setup 这会导致Navbar 没有暴露出来&#xff0c;导致使用不了&#xff0c;出现以下报错 这是因为&#xff0c;如果不用setup&#xff0c;就得使用 export default…...

[linux]-总线,设备,驱动,dts

1. 总线BUS 在物理层面上&#xff0c;代表不同的工作时序和电平特性&#xff1a; 总线代表着同类设备需要共同遵守的工作时序&#xff0c;不同的总线对于物理电平的要求是不一样的&#xff0c;对于每个比特的电平维持宽度也是不一样&#xff0c;而总线上传递的命令也会有自己…...

python3实现gitlab备份文件上传腾讯云COS

gitlab备份文件上传腾讯云COS 脚本说明脚本名称&#xff1a;upload.py 假设gitlab备份文件目录&#xff1a;/opt/gitlab/backups gitlab备份文件格式&#xff1a;1706922037_2024_02_06_14.2.1_gitlab_backup.tar1.脚本需和gitlab备份文件同级目录 2.根据备份文件中的日期判断…...

292.Nim游戏

桌子上有一堆石头。 轮流进行自己的回合&#xff0c; 你作为先手 。 每一回合&#xff0c;轮到的人拿掉 1 - 3 块石头。 拿掉最后一块石头的人就是获胜者。 假设你们每一步都是最优解。请编写一个函数&#xff0c;来判断你是否可以在给定石头数量为 n 的情况下赢得游戏。如果可…...

Spring和Spring Boot的区别

Spring 是一个轻量级的 Java 开发框架&#xff0c;它提供了一系列的模块和功能&#xff0c;例如 IoC&#xff08;控制反转&#xff09;、AOP&#xff08;面向方面编程&#xff09;、数据库访问、Web 开发等。Spring 的目标是使 Java 开发更加简单、高效和可维护。 Spring Boot …...

备战蓝桥杯---动态规划(理论基础)

目录 动态规划的概念&#xff1a; 解决多阶段决策过程最优化的一种方法 阶段&#xff1a; 状态&#xff1a; 决策&#xff1a; 策略&#xff1a; 状态转移方程&#xff1a; 适用的基本条件 1.具有相同的子问题 2.满足最优子结构 3.满足无后效性 动态规划的实现方式…...

FPGA_ip_pll

常使用插件管理器进行ip核的配置&#xff0c;ip核分为计算&#xff0c;存储&#xff0c;输入输出&#xff0c;视频图像处理&#xff0c;接口&#xff0c;调试等。 一 pll ip核简介 pll 即锁相环&#xff0c;可以对输入到fpga的时钟信号&#xff0c;进行分频&#xff0c;倍频&…...

【实验3】统计某电商网站买家收藏商品数量

文章目录 一、实验目的和要求∶二、实验任务∶三、实验准备方案,包括以下内容:实验内容一、实验环境二、实验内容与步骤(过程及数据记录):三、实验结果分析、思考题解答∶四、感想、体会、建议∶一、实验目的和要求∶ 现有某电商网站用户对商品的收藏数据,记录了用户收藏…...

【Qt】Android上运行keeps stopping, Desktop上正常

文章目录 问题 & 背景背景问题 解决方案One More ThingTake Away 问题 & 背景 背景 在文章【Qt】最详细教程&#xff0c;如何从零配置Qt Android安卓环境中&#xff0c;我们在Qt中配置了安卓开发环境&#xff0c;并且能够正常运行。 但笔者在成功配置并完成上述文章…...

算法学习打卡day47|单调栈系列题目

单调栈题目思路 通常是一维数组&#xff0c;要寻找任一个元素的右边或者左边第一个比自己大或者小的元素的位置&#xff0c;此时我们就要想到可以用单调栈了。时间复杂度为O(n)。单调栈的本质是空间换时间&#xff0c;因为在遍历的过程中需要用一个栈来记录右边第一个比当前元…...

Maven构建OSGI+HttpServer应用

Maven构建OSGIHttpServer应用 官网&#xff08;https://eclipse.dev/equinox/server/http_in_equinox.php&#xff09;介绍有两种方式&#xff1a; 一种是基于”org.eclipse.equinox.http”包的轻量级实现&#xff0c;另一种是基于”org.eclipse.equinox.http.jetty”包&#…...

chrome扩展插件常用文件及作用

Chrome扩展通常包含以下常用文件及其作用&#xff1a; manifest.json&#xff1a; 描述了扩展的基本信息&#xff0c;如名称、版本、权限、图标等。定义了扩展的各种组件和功能&#xff0c;包括后台脚本、内容脚本、页面、浏览器动作按钮等。 background.js&#xff1a; 后台脚…...

PdfFactory Pro软件下载以及序列号注册码生成器

PdfFactory Pro注册机是一款针对同名虚拟打印机软件所推出的用户名和序列号生成器。PdfFactory Pro是一款非常专业的PDF虚拟打印软件&#xff0c;通过使用这款注册机&#xff0c;就能帮助用户免费获取注册码&#xff0c;一键激活&#xff0c;永久免费使用。 pdffactory7注册码如…...

jsp康养小镇管理系统Myeclipse开发mysql数据库web结构java编程计算机网页项目

一、源码特点 JSP康养小镇管理系统是一套完善的java web信息管理系统&#xff0c;对理解JSP java编程开发语言有帮助&#xff0c;系统具有完整的源代码和数据库&#xff0c;系统主要采用B/S模式开发。开发环境为TOMCAT7.0,Myeclipse8.5开发&#xff0c;数据库为Mysql5.0&a…...

Android 无操作之后定时退出

android定时器监用户听对页面无操作5分钟退出登录实现 - 简书 private long advertisingTime 600000;///定时结束退出登录10分(分钟)600000毫秒public CountDownTimer countDownTimer;Overrideprotected void onResume() {super.onResume();//启动定时if (isTimedExitApp()) …...

CMS 检测神器:CMSeek 保姆级教程(附链接)

一、介绍 CMSeek&#xff08;Content Management System Exploitation and Enumeration Toolkit&#xff09;是一款用于检测和利用网站上可能存在的内容管理系统&#xff08;CMS&#xff09;漏洞的开源工具。它旨在帮助安全研究人员和渗透测试人员识别目标网站所使用的CMS&…...

oracle 启动命令以及ORA-01033问题处理、删除归档日志

1 启动数据库:startup 2 关闭数据库&#xff1a;Shutdown immediate 3 查看监听状态&#xff1a;lsnrctl status 4 启动监听&#xff1a;lsnrctl start 5 停止监听&#xff1a;lsnrctl stop 常见问题 1、在服务器重启后会出现&#xff0c;Oracle ORA-01033: ORAC…...

【大模型上下文长度扩展】MedGPT:解决遗忘 + 永久记忆 + 无限上下文

MedGPT&#xff1a;解决遗忘 永久记忆 无限上下文 问题&#xff1a;如何提升语言模型在长对话中的记忆和处理能力&#xff1f;子问题1&#xff1a;有限上下文窗口的限制子问题2&#xff1a;复杂文档处理的挑战子问题3&#xff1a;长期记忆的维护子问题4&#xff1a;即时信息检…...

谷歌seo搜索引擎优化有什么思路?

正常做seo哪有那么多思路&#xff0c;其实就那么几种方法&#xff0c;无非就关键词&#xff0c;站内优化&#xff0c;外链&#xff0c;可以说万变不离其宗&#xff0c;但如果交给我们&#xff0c;你就可以实现其他的思路&#xff0c;或者说玩法 收录可以说是一个网站的基础&…...

腾讯云与IBM共同打造“高性能计算服务解决方案“

腾讯云与IBM共同打造"高性能计算服务解决方案" 腾讯云与IBM达成战略合作&#xff0c;对优势产品及服务进行深度集成&#xff0c;基于腾讯云产品及服务&#xff0c;共同打造"腾讯-IBM混合云与人工智能解决方案"。双方通过更为紧密的嵌入式解决方案的深度合…...

【SparkML实践7】特征选择器FeatureSelector

本节介绍了用于处理特征的算法&#xff0c;大致可以分为以下几组&#xff1a; 提取&#xff08;Extraction&#xff09;&#xff1a;从“原始”数据中提取特征。转换&#xff08;Transformation&#xff09;&#xff1a;缩放、转换或修改特征。选择&#xff08;Selection&…...

LeetCode983. Minimum Cost For Tickets——动态规划

文章目录 一、题目二、题解 一、题目 You have planned some train traveling one year in advance. The days of the year in which you will travel are given as an integer array days. Each day is an integer from 1 to 365. Train tickets are sold in three differen…...

百卓Smart管理平台 uploadfile.php 文件上传漏洞【CVE-2024-0939】

百卓Smart管理平台 uploadfile.php 文件上传漏洞【CVE-2024-0939】 一、 产品简介二、 漏洞概述三、 影响范围四、 复现环境五、 漏洞复现手动复现小龙验证Goby验证 免责声明&#xff1a;请勿利用文章内的相关技术从事非法测试&#xff0c;由于传播、利用此文所提供的信息或者工…...

项目中常用的一些数据库及缓存

1、常见的开发工具介绍 MySQL: MySQL是一种流行的开源关系型数据库管理系统&#xff08;RDBMS&#xff09;&#xff0c;由瑞典MySQL AB公司开发&#xff0c;并在后来被Sun Microsystems收购&#xff0c;最终成为Oracle公司的一部分。MySQL广泛用于各种Web应用程序和大型企业应…...