物流官网网站/公司推广方法有哪些
Prompts
语言模型的提示是用户提供的一组指令或输入,用于指导模型的响应,帮助模型理解上下文并生成相关且连贯的基于语言的输出,例如回答问题、完成句子或参与某项活动。对话。
关键问题
- 如何在LLMs中使用少量示例(few-shot examples)——How to use few-shot examples with LLMs
- 如何将少量示例(few-shot examples)与聊天模型结合使用——How to use few-shot examples with chat models
- 如何使用示例选择器(example selectors)——How to use example selectors
- 如何部分提示(partial prompts)——How to partial prompts
- 如何使用消息提示(message prompts)——How to work with message prompts
- How to compose prompts together
- 如何创建管道提示(pipeline prompt)——How to create a pipeline prompt
提示模板是用于生成语言模型提示的预定义配方。模板可以包括说明、少量示例以及适合给定任务的特定上下文和问题,LangChain提供了创建和使用提示模板的工具,LangChain致力于创建与模型无关的模板,以便能够轻松地跨不同语言模型重用现有模板。
通常,语言模型期望提示是字符串或聊天消息列表。
PromptTemplate
- 用于
PromptTemplate
创建字符串提示的模板 - 通常情况下,该模板使用python中的str.format语法进行模板化
- 该模板支持任意数量的变量,包括无变量
- 用于
ChatPromptTemplate
- Chat Model的提示是聊天消息列表,每条消息都有内容,以及
role
ChatPromptTemplate.from_messages
接受各种消息表示形式。- 还可以传入
MessagePromptTemplate
或者实例BaseMessage
。
- Chat Model的提示是聊天消息列表,每条消息都有内容,以及
- LCEL
PromptTemplate
和ChatPromptTemplate
都实现了Runnable接口,这意味着它们支持invoke
、ainvoke
、stream
、astream
、batch
、abatch
、astream_log
调用。PromptTemplate
接受一个字典(有提示变量的)并返回一个StringPromptValue
.ChatPromptTemplate
接受一个字典并返回一个ChatPromptValue
。
Composition
String prompt composition
使用字符串提示时,每个模板都会连接在一起,可以直接使用提示或字符串(列表中的第一个元素必须是提示)
prompt = (PromptTemplate.from_template("Tell me a joke about {topic}")+ ", make it funny"+ "\n\nand in {language}"
)
Chat prompt composition
聊天提示由消息列表组成。为了开发人员体验,我们添加了一种创建这些提示的便捷方法。在此管道中,每个新元素都是最终提示中的一条新消息。
首先,让我们使用系统消息初始化基本 ChatPromptTemplate。
prompt = SystemMessage(content="You are a nice pirate")
当没有要格式化的变量时使用 Message,当有要格式化的变量时使用 MessageTemplate,还可以仅使用一个字符串(注意:这将自动推断为 HumanMessagePromptTemplate。)
new_prompt = (prompt + HumanMessage(content="hi") + AIMessage(content="what?") + "{input}"
)
在底层,会创建 ChatPromptTemplate 类的一个实例,可以使用它
new_prompt.format_messages(input="i said hi")
[SystemMessage(content='You are a nice pirate', additional_kwargs={}),HumanMessage(content='hi', additional_kwargs={}, example=False),AIMessage(content='what?', additional_kwargs={}, example=False),HumanMessage(content='i said hi', additional_kwargs={}, example=False)]
Example Selector Types
- 选择器类型示例
Name | Description |
---|---|
Similarity | 使用输入和示例之间的语义相似性来决定选择哪些示例 |
MMR | 使用输入和示例之间的最大边际相关性来决定选择哪些示例 |
Length | 根据一定长度内可以容纳的数量来选择示例 |
Ngram | 使用输入和示例之间的 ngram 重叠来决定选择哪些示例 |
-
Select by similarity 语义相似性
通过查找与输入具有最大余弦相似度的嵌入示例
-
Select by maximal marginal relevance(MMR) 最大边际相关性
MaxMarginalRelevanceExampleSelector
根据与输入最相似的示例的组合来选择示例,同时还针对多样性进行优化。它通过查找与输入具有最大余弦相似度的嵌入示例来实现这一点,然后迭代地添加它们,同时惩罚它们与已选择示例的接近程度。 -
Select by length 长度
-
Select by n-gram overlap ngram重叠度
NGramOverlapExampleSelector
根据 ngram 重叠分数,根据与输入最相似的示例来选择示例并对其进行排序。ngram 重叠分数是 0.0 到 1.0 之间的浮点数(含 0.0 和 1.0)。选择器允许设置阈值分数。ngram 重叠分数小于或等于阈值的示例被排除。默认情况下,阈值设置为 -1.0,因此不会排除任何示例,只会对它们重新排序。将阈值设置为 0.0 将排除与输入没有 ngram 重叠的示例。
Example selectors
- 选择器示例
如果有大量示例,就可能需要选择要在提示中包含的示例。示例选择器就是负责执行此操作的类。
基本接口定义如下:
class BaseExampleSelector(ABC):"""Interface for selecting examples to include in prompts."""@abstractmethoddef select_examples(self, input_variables: Dict[str, str]) -> List[dict]:"""Select which examples to use based on the inputs."""@abstractmethoddef add_example(self, example: Dict[str, str]) -> Any:"""Add new example to store."""
唯一需要定义的方法是一个select_examples
方法,接受输入变量,然后返回示例列表。如何选择这些示例取决于每个具体的实现。
Examples
创建示例列表,包含输入和输出
examples = [{"input": "hi", "output": "ciao"},{"input": "bye", "output": "arrivaderci"},{"input": "soccer", "output": "calcio"},
]
Custom Example Selector
以下是根据单词的长度选择要选择的示例:
from langchain_core.example_selectors.base import BaseExampleSelectorclass CustomExampleSelector(BaseExampleSelector):def __init__(self, examples):self.examples = examplesdef add_example(self, example):self.examples.append(example)def select_examples(self, input_variables):# This assumes knowledge that part of the input will be a 'text' keynew_word = input_variables["input"]new_word_length = len(new_word)# 初始化变量来存储最佳匹配及其长度差best_match = Nonesmallest_diff = float("inf")# Iterate through each examplefor example in self.examples:current_diff = abs(len(example["input"]) - new_word_length)if current_diff < smallest_diff:smallest_diff = current_diffbest_match = examplereturn [best_match]
example_selector = CustomExampleSelector(examples)
Use in a Prompt
在提示中使用这个示例选择器
from langchain_core.prompts.few_shot import FewShotPromptTemplate
from langchain_core.prompts.prompt import PromptTemplateexample_prompt = PromptTemplate.from_template("Input: {input} -> Output: {output}")
prompt = FewShotPromptTemplate(example_selector=example_selector,example_prompt=example_prompt,suffix="Input: {input} -> Output:",prefix="Translate the following words from English to Italain:",input_variables=["input"],
)print(prompt.format(input="word"))
Few-shot prompt templates
- 少量提示模板
可以由一组示例或一个示例选择器对象构建少量提示模板。下面将配置一些用于自我询问和搜索的示例。
Using an example set
- 使用示例集
Create the example set
- 创建示例集
首先,创建一个少量示例的列表。每个示例都是一个字典,其中键是输入变量,值是这些输入变量的值。
from langchain.prompts.few_shot import FewShotPromptTemplate
from langchain.prompts.prompt import PromptTemplateexamples = [{"question": "Who lived longer, Muhammad Ali or Alan Turing?","answer": """
Are follow up questions needed here: Yes.
Follow up: How old was Muhammad Ali when he died?
Intermediate answer: Muhammad Ali was 74 years old when he died.
Follow up: How old was Alan Turing when he died?
Intermediate answer: Alan Turing was 41 years old when he died.
So the final answer is: Muhammad Ali
""",},{"question": "When was the founder of craigslist born?","answer": """
Are follow up questions needed here: Yes.
Follow up: Who was the founder of craigslist?
Intermediate answer: Craigslist was founded by Craig Newmark.
Follow up: When was Craig Newmark born?
Intermediate answer: Craig Newmark was born on December 6, 1952.
So the final answer is: December 6, 1952
""",},{"question": "Who was the maternal grandfather of George Washington?","answer": """
Are follow up questions needed here: Yes.
Follow up: Who was the mother of George Washington?
Intermediate answer: The mother of George Washington was Mary Ball Washington.
Follow up: Who was the father of Mary Ball Washington?
Intermediate answer: The father of Mary Ball Washington was Joseph Ball.
So the final answer is: Joseph Ball
""",},{"question": "Are both the directors of Jaws and Casino Royale from the same country?","answer": """
Are follow up questions needed here: Yes.
Follow up: Who is the director of Jaws?
Intermediate Answer: The director of Jaws is Steven Spielberg.
Follow up: Where is Steven Spielberg from?
Intermediate Answer: The United States.
Follow up: Who is the director of Casino Royale?
Intermediate Answer: The director of Casino Royale is Martin Campbell.
Follow up: Where is Martin Campbell from?
Intermediate Answer: New Zealand.
So the final answer is: No
""",},
]
Create a formatter for the few-shot examples
配置一个格式化程序,将少量示例格式化为字符串。此格式化程序应该是 PromptTemplate
对象。
example_prompt = PromptTemplate(input_variables=["question", "answer"], template="Question: {question}\n{answer}"
)print(example_prompt.format(**examples[0]))
Question: Who lived longer, Muhammad Ali or Alan Turing?Are follow up questions needed here: Yes.
Follow up: How old was Muhammad Ali when he died?
Intermediate answer: Muhammad Ali was 74 years old when he died.
Follow up: How old was Alan Turing when he died?
Intermediate answer: Alan Turing was 41 years old when he died.
So the final answer is: Muhammad Ali
Feed examples and formatter to FewShotPromptTemplate
- 将示例和格式化程序提供给
FewShotPromptTemplate
最后,创建一个 FewShotPromptTemplate
对象。该对象接受少数样本示例和少数样本示例的格式化程序。
prompt = FewShotPromptTemplate(examples=examples,example_prompt=example_prompt,suffix="Question: {input}",input_variables=["input"],
)print(prompt.format(input="Who was the father of Mary Ball Washington?"))
Using an example selector
- 使用示例选择器
Feed example into ExampleSelector
- 将少量示例提供给
Exampleselector
这里不会将示例直接输入到 FewShotPromptTemplate
中,而是将它们输入到Exampleselector
对象中。
本例中将使用 SemanticSimilarityExampleSelector
类。此类根据与输入的相似性来选择少数样本。
它使用嵌入模型来计算输入和少数样本之间的相似度,并使用向量存储来执行最近邻搜索。
from langchain.prompts.example_selector import SemanticSimilarityExampleSelector
from langchain_community.vectorstores import Chroma
from langchain_openai import OpenAIEmbeddingsexample_selector = SemanticSimilarityExampleSelector.from_examples(# 可供选择的示例列表examples,# 嵌入类,用于测量语义相似性OpenAIEmbeddings(),# VectorStore 类,用于存储嵌入并进行相似性搜索。Chroma,# 生成的示例数。k=1,
)# 选择与输入最相似的示例。
question = "Who was the father of Mary Ball Washington?"
selected_examples = example_selector.select_examples({"question": question})
print(f"Examples most similar to the input: {question}")
for example in selected_examples:print("\n")for k, v in example.items():print(f"{k}: {v}")
Feed example selector into FewShotPromptTemplate
最后,创建一个FewShotPromptTemplate
对象。该对象接受示例选择器和少数示例的格式化程序。
prompt = FewShotPromptTemplate(example_selector=example_selector,example_prompt=example_prompt,suffix="Question: {input}",input_variables=["input"],
)print(prompt.format(input="Who was the father of Mary Ball Washington?"))
Few-shot examples for chat models
- 聊天模型的少量示例
介绍如何在聊天模型中使用少量示例。对于如何最好地进行几次提示似乎没有达成一致的共识,并且最佳提示编译可能会因模型而异。因此,我们提供了少量提示模板(例如FewShotChatMessagePromptTemplate
) 作为灵活的起点,您可以根据需要修改或替换它们。
少量提示模板的目标是根据输入动态选择示例,然后在最终提示中格式化示例以提供给模型。
下面的代码样例是chat models,关于LLMs中的使用参考上节
Fixed Examples
- 固定示例
最基本(也是常见)的少量提示技术是使用固定提示示例。这样就可以选择一条链条,对其进行评估,并避免担心生产中的额外移动部件。
该模板的基本组件是:
examples
:包含在最终提示中的字典示例列表。example_prompt
:通过format_messages
方法将每个示例转换为一条或多条消息。一个常见的示例是将每个示例转换为一条human message和一条AI message response,或者一条human message后跟一条function call message
demonstration:
# import the modules for this example
from langchain.prompts import (ChatPromptTemplate,FewShotChatMessagePromptTemplate,
)
# define the examples you’d like to include
examples = [{"input": "2+2", "output": "4"},{"input": "2+3", "output": "5"},
]
# assemble them into the few-shot prompt template
# 一个用于格式化每个单独示例的提示模板
example_prompt = ChatPromptTemplate.from_messages([("human", "{input}"),("ai", "{output}"),]
)
few_shot_prompt = FewShotChatMessagePromptTemplate(example_prompt=example_prompt,examples=examples,
)print(few_shot_prompt.format())
# assemble your final prompt and use it with a model.
final_prompt = ChatPromptTemplate.from_messages([("system", "You are a wondrous wizard of math."),few_shot_prompt,("human", "{input}"),]
)
from langchain_community.chat_models import ChatAnthropicchain = final_prompt | ChatAnthropic(temperature=0.0)chain.invoke({"input": "What's the square of a triangle?"})
Dynamic few-shot prompting
- 动态少量提示
如果需要根据输入来限制显示哪些示例,可以使用example_selector
代替examples
动态少量提示模板如下所示:
example_selector
:负责为给定的输入选择少数样本(以及它们返回的顺序),实现了BaseExampleSelector
接口。一个常见的例子是向量存储支持的SemanticSimilarityExampleSelector
example_prompt
:通过format_messages
方法将每个示例转换为一个或多个消息。一个常见的示例是将每个示例转换为一条human message和一条AI message response,或者一条human message后跟一条function call message
可以再次与其他消息和聊天模板组合生成最终提示
from langchain.prompts import SemanticSimilarityExampleSelector
from langchain_community.vectorstores import Chroma
from langchain_openai import OpenAIEmbeddings
由于我们使用向量存储来根据语义相似性选择示例,因此我们需要首先填充存储。
examples = [{"input": "2+2", "output": "4"},{"input": "2+3", "output": "5"},{"input": "2+4", "output": "6"},{"input": "What did the cow say to the moon?", "output": "nothing at all"},{"input": "Write me a poem about the moon","output": "One for the moon, and one for me, who are we to talk about the moon?",},
]to_vectorize = [" ".join(example.values()) for example in examples]
embeddings = OpenAIEmbeddings()
vectorstore = Chroma.from_texts(to_vectorize, embeddings, metadatas=examples)
创建example_selector
创建矢量存储后,可以创建example_selector
.
# 仅获取前 2 个示例
example_selector = SemanticSimilarityExampleSelector(vectorstore=vectorstore,k=2,
)# 提示模板通过将输入传递给“select_examples”方法来加载示例
example_selector.select_examples({"input": "horse"})
创建prompt template
使用上面创建的 example_selector
组装提示模板
from langchain.prompts import (ChatPromptTemplate,FewShotChatMessagePromptTemplate,
)# Define the few-shot prompt.
few_shot_prompt = FewShotChatMessagePromptTemplate(# The input variables select the values to pass to the example_selectorinput_variables=["input"],example_selector=example_selector,# Define how each example will be formatted.# In this case, each example will become 2 messages:# 1 human, and 1 AIexample_prompt=ChatPromptTemplate.from_messages([("human", "{input}"), ("ai", "{output}")]),
)
print(few_shot_prompt.format(input="What's 3+3?"))
Human: 2+3
AI: 5
Human: 2+2
AI: 4
组装最终的提示模板:
final_prompt = ChatPromptTemplate.from_messages([("system", "You are a wondrous wizard of math."),few_shot_prompt,("human", "{input}"),]
)
print(few_shot_prompt.format(input="What's 3+3?"))
Human: 2+3
AI: 5
Human: 2+2
AI: 4
Use with an LLM
from langchain_community.chat_models import ChatAnthropicchain = final_prompt | ChatAnthropic(temperature=0.0)chain.invoke({"input": "What's 3+3?"})
AIMessage(content=' 3 + 3 = 6', additional_kwargs={}, example=False)
Types of MessagePromptTemplate
LangChain提供了不同种类的MessagePromptTemplate
,最常见的是 AIMessagePromptTemplate
, SystemMessagePromptTemplate
和 HumanMessagePromptTemplate
。
但是,如果聊天模型支持使用任意角色获取聊天消息,则可以使用 ChatMessagePromptTemplate
,它允许用户指定角色名称。
from langchain.prompts import ChatMessagePromptTemplateprompt = "May the {subject} be with you"chat_message_prompt = ChatMessagePromptTemplate.from_template(role="Jedi", template=prompt
)
chat_message_prompt.format(subject="force")
LangChain还提供了MessagesPlaceholder
,它可以让您完全控制格式化期间要呈现的消息。
如果不确定消息提示模板应使用什么角色或希望在格式化期间插入消息列表时,就使用它。
from langchain.prompts import (ChatPromptTemplate,HumanMessagePromptTemplate,MessagesPlaceholder,
)human_prompt = "Summarize our conversation so far in {word_count} words."
human_message_template = HumanMessagePromptTemplate.from_template(human_prompt)chat_prompt = ChatPromptTemplate.from_messages([MessagesPlaceholder(variable_name="conversation"), human_message_template]
)
from langchain_core.messages import AIMessage, HumanMessagehuman_message = HumanMessage(content="What is the best way to learn programming?")
ai_message = AIMessage(content="""\
1. Choose a programming language: Decide on a programming language that you want to learn.2. Start with the basics: Familiarize yourself with the basic programming concepts such as variables, data types and control structures.3. Practice, practice, practice: The best way to learn programming is through hands-on experience\
"""
)chat_prompt.format_prompt(conversation=[human_message, ai_message], word_count="10"
).to_messages()
Partial prompt templates
- 部分提示模板
“部分”提示模板是有意义的 - 例如传入所需值的子集,以创建一个新的提示模板,该模板仅需要剩余的值子集。
LangChain通过两种方式支持:
- 使用字符串值进行部分格式化
- 使用返回字符串值的函数进行部分格式化
Partial with strings
如果想要在其他元素之前得到一些变量,可以使用此方法。
例如,现在有一个提示模板需要两个变量foo
和baz
。如果很早的得到了foo
,但较晚得到baz
,那么等到两个变量处于同一位置时才将它们传入提示模板,就很不方便。但是,可以使用foo
部分化提示模板,然后传递部分提示模板并使用它。
from langchain.prompts import PromptTemplateprompt = PromptTemplate.from_template("{foo}{bar}")
partial_prompt = prompt.partial(foo="foo")
print(partial_prompt.format(bar="baz"))
也可以使用部分变量初始化提示。
prompt = PromptTemplate(template="{foo}{bar}", input_variables=["bar"], partial_variables={"foo": "foo"}
)
print(prompt.format(bar="baz"))
Partial with functions
对函数进行部分处理。这种情况是,当有一个变量,希望通过函数获取该变量。
一个典型例子是日期或时间。想象一下,您有一个提示,您总是希望获得当前日期。您无法在提示中对其进行硬编码,并且将其与其他输入变量一起传递有点烦人。在这种情况下,能够使用始终返回当前日期的函数来部分提示是非常方便的。
from datetime import datetimedef _get_datetime():now = datetime.now()return now.strftime("%m/%d/%Y, %H:%M:%S")
prompt = PromptTemplate(template="Tell me a {adjective} joke about the day {date}",input_variables=["adjective", "date"],
)
partial_prompt = prompt.partial(date=_get_datetime)
print(partial_prompt.format(adjective="funny"))
还可以使用部分变量初始化提示,这在此工作流程中通常更有意义。
prompt = PromptTemplate(template="Tell me a {adjective} joke about the day {date}",input_variables=["adjective"],partial_variables={"date": _get_datetime},
)
print(prompt.format(adjective="funny"))
Pipeline
本节中介绍了如何将多个提示组合在一起。这样就可以重复使用部分提示,PipelinePrompt 由两个主要部分组成:
- Final prompt(最后提示):最终要返回的提示
- Pipeline prompts(管道提示):元组列表,由字符串名称和提示模板组成。每个提示模板将被格式化,然后作为具有相同名称的变量传递到下一个提示模板。
from langchain.prompts.pipeline import PipelinePromptTemplate
from langchain.prompts.prompt import PromptTemplate
full_template = """{introduction}{example}{start}"""
full_prompt = PromptTemplate.from_template(full_template)
introduction_template = """You are impersonating {person}."""
introduction_prompt = PromptTemplate.from_template(introduction_template)
example_template = """Here's an example of an interaction:Q: {example_q}
A: {example_a}"""
example_prompt = PromptTemplate.from_template(example_template)
start_template = """Now, do this for real!Q: {input}
A:"""
start_prompt = PromptTemplate.from_template(start_template)
input_prompts = [("introduction", introduction_prompt),("example", example_prompt),("start", start_prompt),
]
pipeline_prompt = PipelinePromptTemplate(final_prompt=full_prompt, pipeline_prompts=input_prompts
)
pipeline_prompt.input_variables
['example_q', 'example_a', 'input', 'person']
print(pipeline_prompt.format(person="Elon Musk",example_q="What's your favorite car?",example_a="Tesla",input="What's your favorite social media site?",)
)
You are impersonating Elon Musk.Here's an example of an interaction:Q: What's your favorite car?
A: TeslaNow, do this for real!Q: What's your favorite social media site?
A:
相关文章:

LangChain核心模块 Model I/O——Prompts
Prompts 语言模型的提示是用户提供的一组指令或输入,用于指导模型的响应,帮助模型理解上下文并生成相关且连贯的基于语言的输出,例如回答问题、完成句子或参与某项活动。对话。 关键问题 如何在LLMs中使用少量示例(few-shot examples)—…...

关于Docker守护程序未运行导致的错误
01 在启动Docker之前,确保你已经安装了Docker并且Docker服务是运行的。以下是一些步骤可以帮助你解决这个问题: 首先,确保Docker已经正确安装在你的系统上。你可以通过运行以下命令来检查Docker是否已安装: docker --version如果…...

Unity中关于SendMessage方法
在Unity中,SendMessage 方法用于在游戏对象及其所有子对象上调用指定名称的方法。这种方法可以用于在不需要知道接收方的确切类型的情况下,向游戏对象发送消息。 基本语法如下: void SendMessage(string methodName, object value null, S…...

C++ 修饰符类型
C 允许在 char、int 和 double 数据类型前放置修饰符。修饰符用于改变基本类型的含义,所以它更能满足各种情境的需求。 下面列出了数据类型修饰符: signedunsignedlongshort 修饰符 signed、unsigned、long 和 short 可应用于整型,signed …...

生产计划数据模型,实现能源企业数字化高效管理
随着市场经济的快速发展,能源企业在经济发展中的地位也随之提高。但由于能源企业在生产计划经济管理上存在指标不平衡、市场观念落后和环保意识欠缺等问题,导致企业的经济效益降低。目前,提高企业的生产计划管理是改善能源企业现状最有利的途…...

【chemistry 2】蛋白质的共价结构
🌞欢迎来到生物化学的世界 🌈博客主页:卿云阁 💌欢迎关注🎉点赞👍收藏⭐️留言📝 🌟本文由卿云阁原创! 📆首发时间:🌹2024年3月26日&…...

什么是 UI ?设计师为你解答
用户界面(UI)它是人与机器互动的载体,也是用户体验(UX)一个组成部分。用户界面由视觉设计 (即传达产品的外观和感觉) 和交互设计 (即元素的功能和逻辑组织) 两部分组成。用户界面设计的目标是创建一个用户界面…...

pytest框架入门及环境配置
一、简介 pytest是python的专用测试框架,由于设计的巧妙性,使得pytest使用起来更加的灵活简单。pytest框架有着强大的功能,拥有很多的第三方插件,还具有良好的扩展性,可以与其他的框架进行结合使用。 pytest的优点: 1、可以与一些调度工具结合,实现持续集成 2、与allu…...

unity 2d范围检测:怪物检测范围
需求 实现怪物有一定范围的侦测能力,当目标进入侦测范围内后,自动追踪目标[使用unity navmash实现],当子弹进入时,销毁子弹,播放怪物死亡动画以及其他事件。 实现方案 实现怪物在主角靠近一定范围内时发动攻击的功能…...

外包干了10天,技术倒退明显
先说情况,大专毕业,18年通过校招进入湖南某软件公司,干了接近6年的功能测试,今年年初,感觉自己不能够在这样下去了,长时间呆在一个舒适的环境会让一个人堕落!而我已经在一个企业干了四年的功能测试…...

后端常问面经之Java基础
基本数据类型 Java中有8种基本数据类型: 6种数字类型: 4种整数型:byte、short、int、long 2种浮点型:float、double 1种字符类型:char 1种布尔类型:boolean 数据类型的默认值以及所占空间如下&#x…...

I.MX6ULL_Linux_驱动篇(58)linux IIO驱动
工业场合里面也有大量的模拟量和数字量之间的转换,也就是我们常说的 ADC 和 DAC。而且随着手机、物联网、工业物联网和可穿戴设备的爆发,传感器的需求只持续增强。比如手机或者手环里面的加速度计、光传感器、陀螺仪、气压计、磁力计等,这些传…...

两个包装类型变量的比较问题
问题: 由于受包装类的自动装箱和拆箱的影响,一直以为直接用直接比较两个包装类的大小是否相等就可以,惭愧。比如: Integer a11; Integer b11; System.out.println(ab); 运行结果是 true,似乎没啥问题,但…...

Qt/C++通用跨平台Onvif工具/支持海康大华宇视华为天地伟业等/云台控制/预置位管理/工程调试利器
一、前言 在安防视频监控行业,Onvif作为国际标准,几乎主要的厂商都支持,不仅包含了国内的厂商,也包括主要的国际厂商,由于有了这个标准的存在,使得不同设备不同安防平台之间,能够接入各个厂家的…...

js 在for循环中有setTimeout 时,不执行等待,解决方法
原因:由于setTimeout是异步的,for循环是同步的,所以你的循环会立即继续到下一个迭代,而不会等待setTimeout完成。这意味着所有setTimeout调用几乎会同时开始等待2秒,而不是一个接一个地等待,因此程序出错。…...

机械硬盘与固态硬盘的区别
硬盘中包含机械硬盘、固态硬盘和混合硬盘,那机械硬盘与固态硬盘之间有什么区别呢? 机械硬盘就是传统的普通硬盘,主要采取的存储方式是机械式存储,通过磁头在盘片上进行读写数据;固态硬盘采取的方式则是电子存储&#x…...

Springboot总结
新建项目后,我们一般都需要配置编码,这点非常重要,很多初学者都会忘记这一步,所以要养成良好的习惯。 IDEA 中,仍然是打开File->settings,搜索 encoding,配置一下本地的编码信息。如下&…...

P8623 [蓝桥杯 2015 省 B] 移动距离 Python
[蓝桥杯 2015 省 B] 移动距离 题目描述 X 星球居民小区的楼房全是一样的,并且按矩阵样式排列。其楼房的编号为 $1,2,3, \cdots $ 。 当排满一行时,从下一行相邻的楼往反方向排号。 比如:当小区排号宽度为 6 6 6 时,开始情形如…...

【Python】学习率调整策略详解和示例
学习率调整得当将有助于算法快速收敛和获取全局最优,以获得更好的性能。本文对学习率调度器进行示例介绍。 学习率调整的意义基础示例无学习率调整方法学习率调整方法一多因子调度器余弦调度器 结论 学习率调整的意义 首先,学习率的大小很重要。如果它…...

【Linux实践室】Linux用户管理实战指南:用户密码管理操作详解
🌈个人主页:聆风吟_ 🔥系列专栏:Linux实践室、网络奇遇记 🔖少年有梦不应止于心动,更要付诸行动。 文章目录 一. ⛳️任务描述二. ⛳️相关知识2.1 🔔用户密码存放地及方式2.2 🔔使用…...

UE5学习日记——蓝图节点前缀关键字整理
一、起因 节点如海,中英文翻译的时候还是有差别的,比如: 同一个中文,可能在英文里完全不同,连出现位置可能都不一样 附加 Attach Actor To Component(将Actor附加到组件)Append Array…...

浅析机器学习的常用方法
引言: 机器学习(Machine Learning,ML)是一种以计算机程序为基础,在不需要明确编程的情况下,对数据进行分析和处理的人工智能技术。与传统的计算机编程相比,机器学习的区别在于它通过数据建立模…...

大数据开发(日志离线分析项目)
大数据开发(日志离线分析项目) 一、项目需求1、使用jqueryecharts的方式调用程序后台提供的rest api接口,获取json数据,然后通过jquerycss的方式进行数据展示。工作流程如下:2、七大角度1、用户基本信息分析模块2、浏览…...

PostgreSQL技术大讲堂 - 第48讲:PG高可用实现keepalived
PostgreSQL从小白到专家,是从入门逐渐能力提升的一个系列教程,内容包括对PG基础的认知、包括安装使用、包括角色权限、包括维护管理、、等内容,希望对热爱PG、学习PG的同学们有帮助,欢迎持续关注CUUG PG技术大讲堂。 第48讲&#…...

【若依 SpringBoot 前后端分离版】修改加密传输后密码错误的解决方法(附排错过程)
目录 排错过程 报错信息 SysLoginController SysLoginService(问题核心) 太长不看版:解决方法 文章传送门:若依(RuoYi)SpringBoot框架密码加密传输(前后分离板)_若依密码加密方式-CSDN博客文章浏览阅读1.5w次,点赞…...

发送请求- header配置
请求头里是客户端的要求,把你的诉求告诉服务端,服务端按照你的要求返回数据 , 请求header需要严格全配置,把请求header全部传入,不能频繁访问,让后端知道它是正常请求 一般只配置User-Agent和Content Typ…...

C语言重难知识点
C语言重难知识点 if(a=1) 为真函数指针的调用(int)2.9 = 2逗号运算符,最右边表达式值作为整个逗号表达式的值。文件操作if(a=1) 为真 int a=0,b=0,c=0; if(a...

jMeter学习
一. JMeter介绍 1. 什么是JMeter? Apache JMeter™ 应用程序是开源软件,一个 100% 纯 Java 应用程序,旨在加载测试功能行为和测量性能 。它最初是为测试 Web 应用程序而设计的,但后来扩展到其他测试功能。 2. JMeter能做啥&#x…...

Nodejs运行vue项目时,报错:Error: error:0308010C:digital envelope routines::unsupported
前端项目使用( npm run dev ) 运行vue项目时,出现错误:Error: error:0308010C:digital envelope routines::unsupported 经过探索,发现问题所在,主要是nodeJs V17版本发布了OpenSSL3.0对算法和秘钥大小增加了更为严格的限制&#…...

华为汽车图谱
极狐 极狐(ARCFOX)是由北汽、华为、戴姆勒、麦格纳等联合打造。总部位于北京蓝谷。 问界 华为与赛力斯(东风小康)合作的成果。 阿维塔 阿维塔(AVATR)是由长安汽车、华为、宁德时代三方联合打造。公司总部位…...