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

深度学习:大模型Decoding+MindSpore NLP分布式推理详解

大模型推理流程

1. 用户输入提示词(Prompt)

假设用户输入为:“从前,有一只小猫,它喜欢……”

我们的目标是让模型生成一段完整的故事。

2. 模型处理用户输入

2.1 分词:输入提示被分词为模型可以理解的子词(subword)或单词(token)。

例如:

"从前,有一只小猫,它喜欢……" 可能被分词为:

["从前", ",", "有", "一只", "小猫", ",", "它", "喜欢", "……"]

这些 token 会被映射为模型词汇表中的索引(ID)。也就是Tokenizer分词器返回的input_ids

2.2 将IDs转为embeddings

每个 token 被转换为一个高维向量(embedding),这些向量包含了语义信息。模型通过嵌入层将 token 索引映射为向量。

用户输入的input_ids形状为:(1, 9),表示batch中有一个样本,样本序列长度为9。

嵌入层(Embedding Layer)将每个 token 索引映射为一个高维向量。这个向量的维度是 hidden_size,即模型的隐藏层维度。hidden_size为模型的超参数,由设计者决定。

经过嵌入层后,输入的形状会从 (batch_size, seq_length) 变为 (batch_size, seq_length, hidden_size)。例如,(1, 9) 会变为 (1, 9, hidden_size)

2.3 对张量加入位置编码

为了保留输入序列的顺序信息,模型会为每个 token 添加位置编码。这些编码与 token 嵌入相加,形成最终的输入表示。

位置编码(Positional Encoding) 的张量维度大小与 输入嵌入(Input Embedding) 的维度大小完全相同,并且它们会直接在最后一个维度上相加。

  • 输入嵌入的形状
    输入嵌入的输出形状是 (batch_size, seq_length, hidden_size),其中 hidden_size 是每个 token 的嵌入维度。

  • 位置编码的形状
    位置编码的形状也是 (batch_size, seq_length, hidden_size),与输入嵌入的形状完全一致。

位置编码可以保留语句的顺序信息,直接将位置信息注入语句中。

3. 前向传播

将处理过的用户输入张量输入模型进行前向计算。

4. 生成输出

在自回归生成任务中,模型会逐步生成 token,每次生成一个 token。因此,输出结果的形状会随着生成过程而变化。

  • 输入形状:(1, 9)

  • 模型输出的概率分布形状:(1, 9, vocab_size)

  • 生成下一个 token 的形状:(1, 1)

4.1 输出概率分布

最后一层 Transformer 的输出会通过一个线性层和 softmax 函数,生成每个可能 token 的概率分布。例如,模型可能会预测下一个 token 是“玩耍”的概率为 0.4,“睡觉”的概率为 0.3,等等。

4.2 解码策略(Decoding Strategy)

模型根据概率分布选择下一个 token。常见的解码策略包括:

  • 贪婪搜索(Greedy Search)
    选择概率最高的 token。例如,选择“玩耍”作为下一个 token。

  • 束搜索(Beam Search)
    保留多个候选序列,选择整体概率最高的序列。

  • 采样(Sampling)
    根据概率分布随机采样下一个 token。

输出的概率分布 和 随机采样的概率分布 之间有直接的联系!随机采样是基于模型输出的概率分布进行的,因此两者密切相关。

  • 随机采样的基础
    随机采样直接依赖于模型输出的概率分布。概率分布决定了每个 token 被采样的可能性。

  • 概率分布的作用
    概率分布反映了模型对每个 token 的“信心”或“偏好”。高概率的 token 更有可能被采样,而低概率的 token 也有可能被采样到(尤其是在多样性较高的场景中)。

  • 采样结果的不确定性
    由于采样是随机的,即使概率分布相同,每次采样的结果也可能不同。这与贪婪搜索(总是选择最高概率的 token)形成对比。

Top-K和Top-P策略可以与温度Temperature结合使用。

5. 迭代生成

5.1 递归生成

模型将生成的 token 重新作为输入,继续生成下一个 token。例如:

  1. 输入提示:“从前,有一只小猫,它喜欢……”

  2. 模型生成:“玩耍”

  3. 新输入:“从前,有一只小猫,它喜欢玩耍”

  4. 模型继续生成:“,每天……”

生成过程会持续,直到达到最大生成长度或生成特殊的终止 token(如 <EOS>)。

6. 最终输出

最终,模型生成的完整故事可能是:
“从前,有一只小猫,它喜欢玩耍,每天都会在花园里追逐蝴蝶。有一天,它遇到了一只小鸟……”

LLM模型不是直接使用贪心解码策略(选择概率最高的token作为输出),如果使用贪心解码册啰,对于相同输入序列LLM模型每次都会给出相同回复(推理模式下参数固定,不存在随机性)。所以, 

不同的大模型解码策略

假设模型正在预测“The cat”的下一个token,模型预测结果如下:

• sat  (0.5)

• jumped  (0.3)

• is  (0.1)

• slept  (0.05)

• runs  (0.05)

1. Top-k 采样

Top-k 采样将随机性引入解码过程,通过限制输出token的集合在Top-k个概率最高的token。下一个输出的token将在Top-k个token中随机采样生成。

在案例中,Top-k 采样会选出概率最高的sat(0.5)和jumped(0.3),随后从这两个token中随机采样出下一个预测的token作为模型的输出。

2. Top-p 采样

Top-p 采样首先通过设置一个限制值P,随后按照概率大小选取n个token,直至token累计的概率达到P。随后对n个token进行随机采样。

在案例中,Top-p 采样回选出sat(0.5),jumped(0.3)和is(0.1),随后对这三个token进行随机采样出下一个token。

3. 温度采样

温度Temperature,作为一个超参数,可以控制选择token的概率分布。预测的概率分布会被因子 1/T进行缩放,T则是温度。

  • 当T = 1时,概率分布不发生变化。
  • 当T > 1时,模型输出变得更为随机,小概率的token更容易出现。
  • 当T < 1时,模型输出变得更有确定性,高概率的token更容易得到选择。

温度高时,模型会变得“更有创造性”;温度较低时,模型变得“更加精准”。

4. 束搜索

束搜索是更加精密的贪心搜索策略,它会保留top-k个序列同时进行扩展。

  • 在每一步,模型生成 top-k 个最可能的词汇,并继续解码每一个 k 个序列。
  • 参数 beam width(k)决定了每一步保留多少个候选序列。
  • 在每一步之后,模型根据累积概率对 k 个序列进行排序,并保留概率最高的 k 个序列用于进一步扩展。

在案例中,假设beam的数量为2。那么我们将会选出概率最高的2个token用于后续生成。

“The cat sat”(累计概率:0.5)

“The cat jumped”(累计概率:0.3)

模型继续扩充两个序列,如:

“The cat sat on the mat”

“The cat jumped over the fence”

Beam-Search后续发展有Diverse Beam-Search

不同解码策略的使用场景

  • 贪婪解码(Greedy Decoding
  • 当需要快速生成文本且对生成质量要求不是特别高时,贪婪解码是一个简单且计算效率高的选择。它选择 具有最大logit值的token作为下一个输出,适用于需要快速响应的场景,如聊天机器人的初步响应生成。
  • 束搜索(Beam Search):
  • 适用于需要精确控制输出质量的场景,如机器翻译或问答系统。束搜索通过考虑多个候选序列来生成文本, 可以提高翻译的准确性和流畅性。
  • 抽样解码(Sampling Decoding
  • 适用于需要多样性输出的场景,如创意写作或开放性问题的回答。抽样解码从词汇表中根据概率分布选择 token,可以通过调整参数如温度(Temperature)来控制随机性。
  • Top-KTop-P
  • 适用于需要控制输出长度和提高生成质量的场景。Top-KTop-P通过限制候选token的数量来提高生 成的连贯性和减少重复,适用于需要高质量输出的任务。
  • 温度采样(Temperature Sampling
  • 适用于需要在生成过程中增加随机性的场景,如创意写作或探索性任务。温度参数可以调整输出的随 机度,较低的温度值会使采样更接近确定性解码,而较高的温度值则增加随机性。

MindSpore进行解码推理

创建Notebook

mindspore==2.3.0, cann==8.0

更新mindspore

pip install --upgrade mindspore

克隆mindnlp

git clone https://github.com/mindspore-lab/mindnlp.git

 更新mindnlp

cd mindnlp
bash scripts/build_and_reinstall.sh

卸载mindformers

pip uninstall mindformers

加载模型与转换输入

import mindspore
from mindnlp.transformers import AutoTokenizer, AutoModelForCausalLMmodel_id = "LLM-Research/Meta-Llama-3-8B-Instruct"
# 下载Llama 3的分词器
tokenizer = AutoTokenizer.from_pretrained(model_id, mirror="modelscope")# 下载Llama 3模型
model = AutoModelForCausalLM.from_pretrained(model_id,ms_dtype=mindspore.float16,mirror="modelscope"
)# 输入信息
messages = [{"role": "system", "content": "You are a psychological counsellor, who is good at emotional comfort"},{"role": "user", "content": "I don't sleep well for a long time."}
]
# 将输入信息转为input_ids
input_ids = tokenizer.apply_chat_template(messages,add_generation_prompt=True,return_tensors="ms"
)
# 声明预测的终止token
terminators = [tokenizer.eos_token_id,tokenizer.convert_tokens_to_ids("<|eot_id|>")
]
# 模型生产结果
outputs = model.generate(input_ids, # 输入tokenmax_new_tokens=50, # 限制输出长度eos_token_id=terminators, # 声明终止符do_sample=True, # 是否对输出进行概率分布采样top_p=1.0 # 声明top-p值
)

贪心策略

# 贪心策略
# 模型生产结果
outputs = model.generate(input_ids, # 输入tokenmax_new_tokens=1000, # 限制输出长度eos_token_id=terminators, # 声明终止符do_sample=False, # 是否对输出进行概率分布采样
)response = outputs[0][input_ids.shape[-1]:]
tokenizer.decode(response, skip_special_tokens=True)

模型输出:

"I'm so sorry to hear that you're struggling with sleep. It can be really frustrating and affect many aspects of your daily life. Can you tell me a bit more about what's been going on? What's been keeping you awake at night? Is it stress, anxiety, or something else?\n\nAlso, have you noticed any patterns or triggers that might be contributing to your insomnia? For example, do you find yourself lying awake for hours, or do you wake up multiple times during the night?\n\nRemember, I'm here to listen and support you, and I want you to feel comfortable sharing as much or as little as you'd like."

重复多次模型输出结果未发生变化 

Temperature参数

temperature控制文本生成的随机性和多样性,控制输出张量的概率分布。

import mindspore
from mindspore import Tensor
import numpy as np
import mindspore.ops as opslogits = Tensor(np.array([[0.5, 1.2, -1.0, 0.1]]), mindspore.float32)probs = ops.softmax(logits, axis=-1)
# low temp = 0.5
# 分布更为集中(陡峭)
probs_low = ops.softmax(logits / 0.5, axis=-1)
# high temp = 2
# 分布更为分散(平缓)
probs_high = ops.softmax(logits / 2, axis=-1)probs, probs_low, probs_high
(Tensor(shape=[1, 4], dtype=Float32, value=[[ 2.55937576e-01,  5.15394986e-01,  5.71073927e-02,  1.71560094e-01]]),Tensor(shape=[1, 4], dtype=Float32, value=[[ 1.80040166e-01,  7.30098903e-01,  8.96367151e-03,  8.08972642e-02]]),Tensor(shape=[1, 4], dtype=Float32, value=[[ 2.69529819e-01,  3.82481009e-01,  1.27316862e-01,  2.20672339e-01]]))

可以看出温度越高,分布越平缓,温度越低,分布越集中

temerature=1

# 模型生产结果
outputs = model.generate(input_ids, # 输入tokenmax_new_tokens=1000, # 限制输出长度eos_token_id=terminators, # 声明终止符do_sample=True, # 是否对输出进行概率分布采样temperature=1
)
# 标准温度输出
response = outputs[0][input_ids.shape[-1]:]
tokenizer.decode(response, skip_special_tokens=True)

输出1:

"I'm so sorry to hear that you're struggling with sleep. It can be really tough to deal with insomnia or disrupted sleep patterns. Can you tell me a bit more about what's been going on? What's been on your mind lately that might be keeping you awake? Has anything changed in your life that could be contributing to this difficulty?"

输出2:

"I'm so sorry to hear that you're struggling with sleep. It can be such a frustrating and debilitating experience. Can you tell me a bit more about what's been going on for you? What's been making it hard for you to fall asleep or stay asleep? Is it racing thoughts, stress, anxiety, or something else?\n\nAlso, how long have you been experiencing this sleep difficulty? Has it been a recent development or has it been going on for a while?"

temperature=0.1

输出1:

"I'm so sorry to hear that you're struggling with sleep. It can be really frustrating and affect many aspects of your daily life. Can you tell me a bit more about what's been going on? What are some of the things that make it hard for you to fall asleep or stay asleep? Is it stress, anxiety, physical discomfort, or something else?\n\nAlso, have you noticed any patterns or triggers that seem to make it worse? For example, do you tend to have trouble sleeping on certain nights of the week, or after certain events or activities?\n\nRemember, I'm here to listen and support you, and I want you to feel comfortable sharing as much or as little as you'd like."

输出2:

"I'm so sorry to hear that you're struggling with sleep. It can be really frustrating and affect many aspects of your daily life. Can you tell me a bit more about what's been going on? What's been on your mind lately, and how have you been feeling when you wake up in the morning?"

输出3:

"I'm so sorry to hear that you're struggling with sleep. It can be really frustrating and affect many aspects of your daily life. Can you tell me a bit more about what's been going on? What's been on your mind lately that might be making it hard for you to fall asleep or stay asleep?"

temperature=2

# 模型生产结果
outputs = model.generate(input_ids, # 输入tokenmax_new_tokens=1000, # 限制输出长度eos_token_id=terminators, # 声明终止符do_sample=True, # 是否对输出进行概率分布采样temperature=2.0
)
# 高温度输出->概率分布更为分散
response = outputs[0][input_ids.shape[-1]:]
tokenizer.decode(response, skip_special_tokens=True)

输出1:

"I'm so sorry to hear that. Not getting proper sleep can be really wearing on your emotional and physical well-being. Can you tell me a little bit more about how this lack of sleep is affecting you? Are you feeling constantly exhausted, irritable, or struggling to concentrate? Have you noticed any changes in your relationships or daily routine because of it?\n\nMost importantly, I'm here for you, and I believe that by exploring this together, we can find ways to improve your sleep and improve your overall well-being.\n\nIt might be helpful for me to share that sometimes, lack of sleep can be a sign of underlying anxiety, stress, or even unprocessed emotions. If we can identify the root cause, I may have some suggestions on how to ease your path to better sleep.\n\nWould you like me to offer you some coping strategies to help you relax and unwind before bedtime? Sometimes, a simple change in routine or relaxation techniques can make a world of difference."

 输出2:

"It can be really frustrating and worrying when sleep evade you, making it hard to wake up feeling refreshed and energized. I'm listening, and I want you to know that I'm here to support you. It's important to recognize that this is a tough and normal experience, even if it can be tough to bear right now.\n\nWould you like to talk more about what's going on when you have trouble sleeping? Is there anything in particular that bothers you or stress you out?"

输出3:

"It can be really distressing to deal with chronic sleep issues, not getting the rest you need and feeling tired and exhausted all the time. Can you tell me a little bit more about how you've been feeling? Have you noticed any patterns or triggers that might be contributing to the issue? And how has it been affecting other aspects of your life?\n\nAlso, I want you to know that as your listener, my main goal right now is just to support and provide comfort. Whatever you share, I'm here for you. No judgments, no critiques, just a gentle and compassionate space for you to express yourself.\n\nRemember, it takes a lot of courage to share vulnerable thoughts and feelings with someone like me, and I want to assure you that your feelings are completely normal and valid. Okay?"

 束搜索(Beam Search)

# Beam Search 束搜索
beam_outputs = model.generate(input_ids, # 输入tokenmax_new_tokens=100, # 限制输出长度eos_token_id=terminators, # 声明终止符num_return_sequences=5,early_stopping=True,
)for i, beam_output in enumerate(beam_outputs):print("{}: {}".format(i, tokenizer.decode(beam_output, skip_special_tokens=True)))
输出1:
0: systemYou are a psychological counsellor, who is good at emotional comfortuserI don't sleep well for a long time.assistantI'm so sorry to hear that you're struggling with sleep. It can be really frustrating and affect so many areas of your life. Can you tell me a bit more about what's been going on? When did you start having trouble sleeping, and what do you usually do when you try to go to bed? Do you find yourself lying awake for hours, or do you fall asleep but then wake up multiple times throughout the night?输出2:
1: systemYou are a psychological counsellor, who is good at emotional comfortuserI don't sleep well for a long time.assistantI'm so sorry to hear that you're struggling with sleep. It can be such a frustrating and unsettling experience, affecting not just your physical health but also your emotional well-being.First of all, please know that you're not alone in this struggle. Many people face difficulties with sleep from time to time, and it's not uncommon for it to be a persistent issue for some. It's okay to acknowledge that you're struggling, and it takes a lot of courage to reach out and talk about输出3:
2: systemYou are a psychological counsellor, who is good at emotional comfortuserI don't sleep well for a long time.assistantI'm so sorry to hear that you're struggling with sleep. It can be such a frustrating and isolating experience. It's like your body is refusing to cooperate with your mind, and it can leave you feeling exhausted, irritable, and just plain miserable.First of all, let me just acknowledge that it's okay to not be okay. It's okay to struggle with sleep, and it's okay to feel overwhelmed and stuck. I'm here to listen, and I want you to know输出4:
3: systemYou are a psychological counsellor, who is good at emotional comfortuserI don't sleep well for a long time.assistantI'm so sorry to hear that you're struggling with sleep. It can be really frustrating and affect many aspects of your daily life. Can you tell me a bit more about what's been going on? What are some common things that happen when you try to fall asleep, and what do you usually do when you wake up during the night?输出5:
4: systemYou are a psychological counsellor, who is good at emotional comfortuserI don't sleep well for a long time.assistantI'm so sorry to hear that you're struggling with sleep. It can be such a frustrating and exhausting experience. Can you tell me a bit more about what's been going on for you? When did you first start noticing that your sleep was affected, and what do you think might be contributing to it? Is it stress, anxiety, or something else entirely?Remember, everything we discuss is completely confidential and a safe space for you to express yourself. I'm here to listen and support you,
​​​​​
# Beam Search 束搜索
beam_outputs = model.generate(input_ids, # 输入tokenmax_new_tokens=100, # 限制输出长度eos_token_id=terminators, # 声明终止符num_return_sequences=5,early_stopping=True,no_repeat_ngram_size=2 # 设置此参数可以避免多句之间存在重复词组
)for i, beam_output in enumerate(beam_outputs):print("{}: {}".format(i, tokenizer.decode(beam_output, skip_special_tokens=True)))
输出1:
0: systemYou are a psychological counsellor, who is good at emotional comfortuserI don't sleep well for a long time.assistantIt can be really tough to deal with sleepless nights, and it's completely normal to feel frustrated, anxious, or even a bit hopeless. Can you tell me a little bit more about what's been going on? What's making it hard for you to fall asleep, do you think? Is it stress, worries, physical discomfort, something else, a combination of things?Also, how have you been coping with the lack of sleep? Have you noticed any changes in your daily life, mood输出2:
1: systemYou are a psychological counsellor, who is good at emotional comfortuserI don't sleep well for a long time.assistantSweetheart, I'm so sorry to hear that you're struggling with sleep. It can be really tough to deal with, both physically and emotionally. Can you tell me a bit more about what's been going on for you? What's making it hard foryou to fall asleep or stay asleep? Is it stress, anxiety, or something else entirely?Remember, everything we discuss is completely confidential and a safe space for us to explore your feelings. I want you to know that I believe in your输出3:
2: systemYou are a psychological counsellor, who is good at emotional comfortuserI don't sleep well for a long time.assistantSweetheart, I'm so sorry to hear that you're struggling with sleep. It can be such a frustrating and exhausting experience. Can you tell me a bit more about what's been going on? When did you start noticing that your sleep was affected, and what are some of the things that make it hard for you to fall asleep or stay asleep?输出4:
3: systemYou are a psychological counsellor, who is good at emotional comfortuserI don't sleep well for a long time.assistantIt sounds like you're struggling with insomnia or difficulty sleeping, and that's really tough. Not getting enough sleep can affect so many aspects of our lives, from our mood to our energy levels to even our physical health.First of all, I want you to know that you don’t have to go through this alone. I'm here to listen and support you. Can you tell me a bit more about what's been going on? When did you start noticing trouble sleeping? Is it a sudden change输出5:
4: systemYou are a psychological counsellor, who is good at emotional comfortuserI don't sleep well for a long time.assistantSweetheart, I'm so sorry to hear that you're struggling with sleep. It can be such a frustrating and debilitating experience, feeling like you can't get a good night's rest. Can you tell me a bit more about what's been going on for you? When did you first start noticing that your sleep was affected, and what are some of the things that keep you awake at night?

Top-K 采样

# top-k采样
outputs = model.generate(input_ids, # 输入tokenmax_new_tokens=100, # 限制输出长度eos_token_id=terminators, # 声明终止符do_sample=True,top_k=5,num_return_sequences=3
)for i, output in enumerate(outputs):# response = output[0][input_ids.shape[-1]:]print("{}: {}".format(i+1, tokenizer.decode(response, skip_special_tokens=True)))

k=5,只选取前5个概率最高的值进行采样,结果会缺乏创意性。

输出1:
"I'm so sorry to hear that you're struggling with sleep. It can be really frustrating and affect many aspects of your daily life. Can you tell me a bit more about what's been going on? When did you start having trouble sleeping, and what's been making it hard for you to fall asleep or stay asleep? Is it stress, anxiety, physical discomfort, or something else entirely?\n\nAlso, how have you been feeling during the day? Are you feeling tired, irritable, or just"

  输出2:

"I'm so sorry to hear that you're struggling with sleep. It can be really frustrating and affect so many aspects of your daily life. Can you tell me a bit more about what's been going on? What are some of the things that are making it hard for you to fall asleep or stay asleep? Is it stress, anxiety, or something else entirely?\n\nAlso, have you noticed any patterns or triggers that seem to make it worse? For example, do you tend to have trouble sleeping during"

 输出3:

"I'm so sorry to hear that you're struggling with sleep. It can be really frustrating and affect so many areas of your life. Can you tell me a bit more about what's been going on? Have you noticed any patterns or triggers that might be contributing to your insomnia? And how have you been feeling during the day when you're not getting a good night's sleep?"

k = 1000,采样具有随机性

# top-k采样
outputs = model.generate(input_ids, # 输入tokenmax_new_tokens=100, # 限制输出长度eos_token_id=terminators, # 声明终止符do_sample=True,top_k=1000
)response = outputs[0][input_ids.shape[-1]:]
tokenizer.decode(response, skip_special_tokens=True)

输出1:

"I'm so sorry to hear that you're struggling with sleep. It can be really frustrating and affect many areas of your life. Can you tell me a bit more about what's been going on? What's been keeping you awake at night? Is it stress, anxiety, or something else entirely?\n\nRemember, I'm here to listen and offer support. I'm not here to judge or try to fix the problem right away. Just talking about it can sometimes help you feel a bit better.\n\nAlso"

输出2:

"I'm so sorry to hear that you're struggling with sleep. It can be really frustrating and affect many aspects of your daily life. Can you tell me a bit more about what's been going on? Is it just difficulty falling asleep, or are you having trouble staying asleep or experiencing restless nights? And have you noticed any patterns or triggers that might be contributing to your sleep issues?\n\nAlso, I want you to know that it's completely normal to struggle with sleep from time to time, and it"

输出3:

"I'm so sorry to hear that you're struggling with sleep. It can be such a frustrating and exhausting experience. Can you tell me a bit more about what's been going on? What's been keeping you awake at night? Is it stress, anxiety, or something else entirely?\n\nRemember, everything we discuss is confidential and a safe space for you to share your feelings. I'm here to listen and offer support.\n\nAlso, I want you to know that you're not alone in this struggle."

Top-P 采样 

# top-p采样
outputs = model.generate(input_ids, # 输入tokenmax_new_tokens=100, # 限制输出长度eos_token_id=terminators, # 声明终止符do_sample=True,top_p=0.5
)response = outputs[0][input_ids.shape[-1]:]
tokenizer.decode(response, skip_special_tokens=True)

p = 0.5 

输出1:

"I'm so sorry to hear that you're struggling with sleep. It can be really frustrating and affect many aspects of your daily life. Can you tell me a bit more about what's been going on? What are some of the things that make it hard for you to fall asleep or stay asleep? Is it stress, anxiety, physical discomfort, or something else?\n\nAlso, have you noticed any patterns or triggers that seem to make it worse? For example, do you tend to have trouble sleeping on"

输出2:

"I'm so sorry to hear that you're struggling with sleep. It can be really frustrating and affect many aspects of your daily life. Can you tell me a bit more about what's been going on? What are some of the things that are making it hard for you to fall asleep or stay asleep? Is it stress, anxiety, physical discomfort, or something else?\n\nAlso, have you noticed any patterns or triggers that seem to make it worse? For example, do you tend to have trouble sleeping"

输出3:

"I'm so sorry to hear that you're struggling with sleep. It can be really frustrating and affect many aspects of your daily life. Can you tell me a bit more about what's been going on? What are some of the things that make it hard for you to fall asleep or stay asleep? Is it stress, anxiety, physical discomfort, or something else?\n\nAlso, have you noticed any patterns or triggers that seem to make it worse? For example, do you tend to have trouble sleeping on"

p = 0.95

输出1:

"I'm so sorry to hear that you're struggling with sleep. It can be such a frustrating and exhausting experience. Can you tell me a bit more about what's been going on? When did you first start noticing that you weren't sleeping well, and what are some of the things that you've tried to help you get a good night's rest?\n\nIt's also important to acknowledge that it's okay to not be okay. It takes a lot of courage to admit when we're struggling, and"

输出2:

"I'm so sorry to hear that you're struggling with sleep. It can be really frustrating and affect many aspects of your daily life. Can you tell me a bit more about what's been going on? Have you noticed any patterns or triggers that might be contributing to your insomnia?"

输出3:

"I'm so sorry to hear that you're struggling with sleep. It can be really frustrating and affect so many aspects of your daily life. Can you tell me a bit more about what's been going on? What are some of the things that are making it hard for you to fall asleep or stay asleep? Is it stress, anxiety, or something else?"

MindNLP并行推理——多进程多卡

示例代码地址:

https://github.com/mindspore-lab/mindnlp/tree/master/llm/inference/llama3

仓库中的 readme 文件说明了多卡推理的使用方法

注意:选择modelarts中贵阳区域的镜像:mindspore==2.3.0 cann==8.0.0 启动后不需要升级mindspore版本,否则hccl通信算子库将无法兼容。

推荐:使用msrun命令

msrun是mindspore定义的一个多进程并行命令,使用该命令可以获得最佳性能。

msrun --worker_num=2 --local_worker_num=2 --master_port=8118 --join=True run_llama3_distributed.py
# 具体数量根据你有多少张卡进行执行
  1. --worker_num=2:

    指定总共有 2 个工作节点(worker)参与任务。这些工作节点可以是不同的机器或不同的进程。
  2. --local_worker_num=2:

    指定在当前机器上启动 2 个工作节点。这意味着在当前机器上会有 2 个进程参与任务。
  3. --master_port=8118:

    指定主节点(master)的端口号为 8118。主节点负责协调各个工作节点的通信和任务分配。
  4. --join=True:

    表示工作节点在启动后会加入主节点的任务。通常用于确保所有工作节点都连接到主节点并准备好执行任务。

run_llama3_distributed.py文件具体如下:

# 导入 MindSpore 框架,用于深度学习任务
import mindspore# 从 MindSpore 的通信模块中导入 init 函数,用于初始化分布式训练环境
from mindspore.communication import init# 从 MindNLp 库中导入 AutoTokenizer 和 AutoModelForCausalLM 类,用于加载预训练模型和分词器
from mindnlp.transformers import AutoTokenizer, AutoModelForCausalLM# 定义模型 ID,这里使用的是 Meta-Llama-3-8B-Instruct 模型
model_id = "LLM-Research/Meta-Llama-3-8B-Instruct"# 初始化分布式训练环境,确保多机多卡之间的通信正常
init()# 使用 AutoTokenizer 从预训练模型加载分词器
# mirror='modelscope' 指定从 ModelScope 平台下载模型
tokenizer = AutoTokenizer.from_pretrained(model_id, mirror='modelscope')# 使用 AutoModelForCausalLM 从预训练模型加载语言模型
# ms_dtype=mindspore.float16 指定模型使用半精度浮点数(float16)进行计算
# mirror='modelscope' 指定从 ModelScope 平台下载模型
# device_map="auto" 自动分配模型到可用设备(如 GPU 或 CPU)
model = AutoModelForCausalLM.from_pretrained(model_id,ms_dtype=mindspore.float16,mirror='modelscope',device_map="auto"
)# 定义对话消息列表,包含系统提示和用户输入
messages = [{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},{"role": "user", "content": "Who are you?"},
]# 使用分词器将对话消息转换为模型输入的张量
# add_generation_prompt=True 添加生成提示,确保模型知道需要生成回复
# return_tensors="ms" 返回 MindSpore 格式的张量
input_ids = tokenizer.apply_chat_template(messages,add_generation_prompt=True,return_tensors="ms"
)# 定义终止符列表,用于告诉模型何时停止生成文本
# 包括结束符(eos_token_id)和自定义的终止符(<|eot_id|>)
terminators = [tokenizer.eos_token_id,tokenizer.convert_tokens_to_ids("<|eot_id|>")
]# 使用模型生成文本
# input_ids 是输入的张量
# max_new_tokens=100 限制生成的最大 token 数量为 100
# eos_token_id=terminators 指定终止符列表
# do_sample=True 启用采样策略,而不是贪婪解码
# temperature=0.6 控制生成文本的随机性,值越低越确定
# top_p=0.9 使用核采样(nucleus sampling),保留概率质量最高的 90% 的 token
outputs = model.generate(input_ids,max_new_tokens=100,eos_token_id=terminators,do_sample=True,temperature=0.6,top_p=0.9,
)# 从生成的输出中提取模型生成的文本部分
# outputs[0] 是生成的完整序列,input_ids.shape[-1] 是输入的长度
# 通过切片操作获取生成的部分
response = outputs[0][input_ids.shape[-1]:]# 使用分词器将生成的 token 解码为可读的文本
# skip_special_tokens=True 跳过特殊 token(如终止符)
print(tokenizer.decode(response, skip_special_tokens=True))

同时,也可以使用mpirun命令

mpirun -n 2 python run_llama3_distributed.py

关于mindspore的组网方式具体可以参考:

分布式并行启动方式 — MindSpore master 文档

相关文章:

深度学习:大模型Decoding+MindSpore NLP分布式推理详解

大模型推理流程 1. 用户输入提示词&#xff08;Prompt&#xff09; 假设用户输入为&#xff1a;“从前&#xff0c;有一只小猫&#xff0c;它喜欢……” 我们的目标是让模型生成一段完整的故事。 2. 模型处理用户输入 2.1 分词&#xff1a;输入提示被分词为模型可以理解的…...

GESP6级语法知识(二):动态规划算法(二)

最小路径和; //最小路径和 #include<iostream> using namespace std; const int N100; int dp[N][N],value[N][N]; int n,m; int main() {cin>>n>>m;for(int i1;i<n;i) //录入初始数字矩阵 for(int j1;j<m;j)cin>>value[i][j];for(int i1;i…...

数据结构与算法之递归: LeetCode 79. 单词搜索 (Ts 版)

单词搜索 https://leetcode.cn/problems/word-search/description/ 描述 给定一个 m x n 二维字符网格 board 和一个字符串单词 word 。如果 word 存在于网格中&#xff0c;返回 true &#xff1b;否则&#xff0c;返回 false 单词必须按照字母顺序&#xff0c;通过相邻的单…...

智能系统的感知和决策

智能系统在感知和决策过程中具备的关键能力表现在智能感知/自主判定上&#xff0c;下面可以从感知的本质、自主判断的含义及其在智能系统中的作用进行深入分析。 1、智能感知&#xff1a;信息获取与理解 智能感知是指智能系统通过传感器或其他数据采集手段获取环境中的信息&…...

多线程之旅:线程安全问题

之前说到了多线程的创建和一些属性等等&#xff0c;接下来&#xff0c;就来讲讲多线程安全问题。 小编引入这段代码讲解下&#xff1a; public class Demo13 {public static int count0;public static void main(String[] args) throws InterruptedException {Thread t1new…...

用java配合redis 在springboot上实现令牌桶算法

令牌桶算法配合 Redis 在 Java 中的应用令牌桶算法是一种常用的限流算法&#xff0c;适用于控制请求的频率&#xff0c;防止系统过载。结合 Redis 使用可以实现高效的分布式限流。 一.、引入依赖首先&#xff0c;需要在 pom.xml 文件中引入 spring-boot-starter-data-re…...

科学计算库NumPy

NumPy是高性能科学计算和数据分析的基础包。 认识NumPy数据对象 n维数组对象ndarray(array) 数组是编程语言中重要且复杂的数据结构&#xff0c;它是由相同类型元素按照一定的顺序排列的集合。ndarray具有矢量算术能力和复杂的广播能力。 - 维度又称为维数&#xff0c;在数学…...

【大数据】机器学习----------强化学习机器学习阶段尾声

一、强化学习的基本概念 注&#xff1a; 圈图与折线图引用知乎博主斜杠青年 1. 任务与奖赏 任务&#xff1a;强化学习的目标是让智能体&#xff08;agent&#xff09;在一个环境&#xff08;environment&#xff09;中采取一系列行动&#xff08;actions&#xff09;以完成一个…...

Unicode不可见字符

场景复现 在访问 https://dotnet.microsoft.com/zh-cn/apps/aspnet地址时 突然出现 https://dotnet.microsoft.com/zh-cn/apps/aspnet%E2%80%8C%E2%80%8C 但是正常来看&#xff0c;这个地址后面是没有%E2%80%8C%E2%80%8C的&#xff0c;粘贴到idea里发现了url地址后面还拼接了2…...

w172二手车交易系统的设计与实现

&#x1f64a;作者简介&#xff1a;多年一线开发工作经验&#xff0c;原创团队&#xff0c;分享技术代码帮助学生学习&#xff0c;独立完成自己的网站项目。 代码可以查看文章末尾⬇️联系方式获取&#xff0c;记得注明来意哦~&#x1f339;赠送计算机毕业设计600个选题excel文…...

TRELLIS微软的图生3D

TRELLIS 教程目录&#xff1a; Youtube&#xff1a;https://www.youtube.com/watch?vJqFHZ-dRMhI 官网地址&#xff1a;https://trellis3d.github.io/ GitHub&#xff1a;https://github.com/Microsoft/TRELLIS 部署目录&#xff1a; 克隆项目 git clone --recurse-submodul…...

【力扣:新动计划,编程入门 —— 题解 ①】

向前看&#xff0c;总会有新的故事值得期盼 —— 25.1.21 2235. 两整数相加 给你两个整数 num1 和 num2&#xff0c;返回这两个整数的和。 示例 1&#xff1a; 输入&#xff1a;num1 12, num2 5 输出&#xff1a;17 解释&#xff1a;num1 是 12&#xff0c;num2 是 5 &#x…...

如何使用 Pytest -k 选项轻松筛选测试用例

关注开源优测不迷路 大数据测试过程、策略及挑战 测试框架原理&#xff0c;构建成功的基石 在自动化测试工作之前&#xff0c;你应该知道的10条建议 在自动化测试中&#xff0c;重要的不是工具 你是否曾不得不从成百上千个测试中费力筛选&#xff0c;只为运行几个特定的测试&am…...

C语言之小型成绩管理系统

&#x1f31f; 嗨&#xff0c;我是LucianaiB&#xff01; &#x1f30d; 总有人间一两风&#xff0c;填我十万八千梦。 &#x1f680; 路漫漫其修远兮&#xff0c;吾将上下而求索。 C语言之小型成绩管理系统 目录 设计题目设计目的设计任务描述设计要求输入和输出要求验收要…...

C++ ——— 模拟实现 vector 类

目录 vector 类的框架 无参数的构造函数 析构函数 获取有效数据个数 获取容量 重载 [] 运算符 可读可写版本 只可读版本 扩容 尾插 实现迭代器 可读可写版本 只可读版本 自定义设置size长度和内容 在任意位置插入 删除任意位置的数据 赋值重载 vector 类的框…...

SpringBoot实现轻量级动态定时任务管控及组件化

1关于动态定时任务 关于在SpringBoot中使用定时任务&#xff0c;大部分都是直接使用SpringBoot的Scheduled注解&#xff0c;如下&#xff1a; Component public class TestTask {Scheduled(cron"0/5 * * * * ? ") //每5秒执行一次public void execute(){SimpleDa…...

STM32 FreeRTOS 任务挂起和恢复---实验

实验目标 学会vTaskSuspend( )、vTaskResume( ) 任务挂起与恢复相关API函数使用&#xff1a; start_task:用来创建其他的三个任务。 task1&#xff1a;实现LED1每500ms闪烁一次。 task2&#xff1a;实现LED2每500ms闪烁一次。 task3&#xff1a;判断按键按下逻辑&#xff0c;KE…...

#漏洞挖掘# 一文了解什么是Jenkins未授权访问!!!

免责声明 本教程仅为合法的教学目的而准备&#xff0c;严禁用于任何形式的违法犯罪活动及其他商业行为&#xff0c;在使用本教程前&#xff0c;您应确保该行为符合当地的法律法规&#xff0c;继续阅读即表示您需自行承担所有操作的后果&#xff0c;如有异议&#xff0c;请立即停…...

1.21学习记录

misc 2023isctf 你说爱我尊嘟假嘟 这题有点脑洞&#xff0c;需要把你说爱我换成Ook.将尊嘟换为Ook&#xff01;假嘟换成Ook&#xff1f;&#xff08;根据语气进行猜测吧&#xff09;用在线工具解密最后用base64解密即可 2023isctf 杰伦可是流量明星 解压后是一个MP3文件&am…...

【Pandas】pandas Series groupby

Pandas2.2 Series Function application, GroupBy & window 方法描述Series.apply()用于将一个函数应用到 Series 的每个元素或整个 SeriesSeries.agg()用于对 Series 数据进行聚合操作Series.aggregate()用于对 Series 数据进行聚合操作Series.transform()用于对 Series…...

Text2SQL 智能报表方案介绍

0 背景 Text2SQL智能报表方案旨在通过自然语言处理&#xff08;NLP&#xff09;技术&#xff0c;使用户能够以自然语言的形式提出问题&#xff0c;并自动生成相应的SQL查询&#xff0c;从而获取所需的数据报表&#xff0c;用户可根据得到结果展示分析从而为结论提供支撑&#…...

51c~SLAM~合集1

我自己的原文哦~ https://blog.51cto.com/whaosoft/12327374 #GSLAM 自动驾驶相关~~~ 一个通用的SLAM架构和基准 GSLAM&#xff1a;A General SLAM Framework and Benchmark 开源代码&#xff1a;https://github.com/zdzhaoyong/GSLAM SLAM技术最近取得了许多成功&am…...

服务器安装ESXI7.0系统及通过离线包方式升级到ESXI8.0

新到了一台物理服务器需要安装系统&#xff0c;项目不急用&#xff0c;先拿来做些实验。 本次实验目标&#xff1a; 1、在物理服务器上安装ESXI7.0系统&#xff1b; 2、通过离线包升级方式将ESXI7.0升级为ESXI8.0。 实验环境准备&#xff1a; 物理服务器1台&#xff0c;型号…...

计算机网络 (52)秘钥分配

一、重要性 在计算机网络中&#xff0c;密钥分配是密钥管理中的一个核心问题。由于密码算法通常是公开的&#xff0c;因此网络的安全性主要依赖于密钥的安全保护。密钥分配的目的是确保密钥在传输过程中不被窃取或篡改&#xff0c;同时确保只有合法的用户才能获得密钥。 二、方…...

xctf-comment(Intruder,git恢复,SQL注入,Hex解码)

这题是2018年网鼎杯真题&#xff0c;考察 Burp Suite 的 Intruder 模块去找用户密码&#xff0c;使用 githacker 恢复代码&#xff08;githack不行&#xff09;&#xff0c;代码审计发现SQL二次注入&#xff0c;尝试SQL注入读取文件内容&#xff0c;读取的是/home/www/.bash_hi…...

Docker Compose创建镜像服务

什么是Docker Compose 使用Docker Compose&#xff0c;可以使用YAML配置文件&#xff08;称为Compose文件&#xff09;来配置应用程序的服务&#xff0c;然后使用Compose CLI从配置中创建并启动所有服务 。 Compose文件的默认路径是compose.yaml&#xff08;首选&#xff09;…...

kafka学习笔记5 PLAIN认证——筑梦之路

在Kafka中&#xff0c;SASL&#xff08;Simple Authentication and Security Layer&#xff09;机制包括三种常见的身份验证方式&#xff1a; SASL/PLAIN认证&#xff1a;含义是简单身份验证和授权层应用程序接口&#xff0c;PLAIN认证是其中一种最简单的用户名、密码认证方式&…...

Walrus Learn to Earn计划正式启动!探索去中心化存储的无限可能

本期 Learn to Earn 活动将带领开发者和区块链爱好者深入探索 Walrus 的技术核心与实际应用&#xff0c;解锁分布式存储的无限可能。参与者不仅能提升技能&#xff0c;还能通过完成任务赢取丰厚奖励&#xff01;&#x1f30a; 什么是 Walrus&#xff1f; 数据主权如今正成为越…...

Linux学习笔记

1、什么是Linux Linux,一般指GNU/Linux&#xff08;单独的Linux内核并不可直接使用&#xff0c;一般搭配GUN套件&#xff0c;故得此称呼&#xff09;&#xff0c;是一种免费使用和自由传播的类UNIX操作系统。它主要受到Minix和Unix思想的启发&#xff0c;是一个基于POSIX的多用…...

解锁电商设计新速度:StartAI插件制作产品图实操教程

在电商设计这片竞争激烈的战场上&#xff0c;每一位设计师都在追求高效与创意的完美融合。繁琐的背景抠图、单一的设计模板、紧迫的时间周期&#xff0c;常常让我们力不从心。但现在&#xff0c;StartAI插件的问世&#xff0c;为我们的设计之路带来了革命性的改变。下面&#x…...

AutoPrompt框架和实操:如何用AutoPrompt完成电影评论和聊天审核任务?

1. AutoPrompt框架概述 1.1 框架定义与目标 AutoPrompt是一个旨在提升和完善用户提示以适应现实世界用例的提示优化框架。该框架通过迭代生成具有挑战性的边缘案例数据集,并相应地优化提示,从而自动生成针对用户意图量身定制的高质量、详细的提示。其核心目标是利用大型语言…...

修复 Kubernetes Deployment 修改后未生效的问题

在 Kubernetes 集群中&#xff0c;当尝试修改某些 Deployment 资源&#xff08;如 calico-kube-controllers&#xff09;的 image 配置时&#xff0c;发现修改总是未生效&#xff0c;并恢复到原样。这种问题通常是因为 Deployment 资源受到其他控制器&#xff08;如 Operator&a…...

Excel 技巧17 - 如何计算倒计时,并添加该倒计时的数据条(★)

本文讲如何计算倒计时&#xff0c;并添加该倒计时的数据条。 1&#xff0c;如何计算倒计时 这里也要用公式 D3 - TODAY() 显示为下面这个样子的 然后右键该单元格&#xff0c;选 设置单元格格式 然后点 常规 这样就能显示出还书倒计时的日数了。 下拉适用到其他单元格。 2&a…...

Golang Gin系列-5:数据模型和数据库

在这篇Gin教程的博客中&#xff0c;我们将探索如何将模型和数据库与Gin框架无缝集成&#xff0c;使你能够构建健壮且可扩展的web应用程序。通过利用流行的库并遵循最佳实践&#xff0c;你将学习如何定义模型、建立数据库连接、执行CRUD操作以及确保基于gin的项目中的数据完整性…...

Android系统开发(十九):无缝拉伸的艺术——9-Patch 可绘制对象详解

引言 在移动开发中&#xff0c;背景、标题以及其他界面元素的设计质量直接影响用户体验。然而&#xff0c;如何让图片适应不同分辨率设备&#xff0c;成为开发者常常头疼的问题。这时&#xff0c;9-Patch 闪亮登场&#xff01;它不仅可以无缝拉伸&#xff0c;还能保持视觉效果…...

物联网网关Web服务器--CGI开发实例BMI计算

本例子通一个计算体重指数的程序来演示Web服务器CGI开发。 硬件环境&#xff1a;飞腾派开发板&#xff08;国产E2000处理器&#xff09; 软件环境&#xff1a;飞腾派OS&#xff08;Phytium Pi OS&#xff09; 硬件平台参考另一篇博客&#xff1a;国产化ARM平台-飞腾派开发板…...

计算机网络 (51)鉴别

前言 计算机网络鉴别是信息安全领域中的一项关键技术&#xff0c;主要用于验证用户或信息的真实性&#xff0c;以及确保信息的完整性和来源的可靠性。 一、目的与重要性 鉴别的目的是验明用户或信息的正身&#xff0c;对实体声称的身份进行唯一识别&#xff0c;以便验证其访问请…...

Mellanox ConnectX 系列网卡的双驱动架构:以太网与 InfiniBand 的协同设计

在现代数据中心和高性能计算(HPC)环境中,网络硬件的性能和功能至关重要。Mellanox ConnectX 系列网卡以其卓越的性能和多功能性而闻名,支持从传统的以太网到高性能的 InfiniBand 网络协议。这种多功能性使得 Mellanox 网卡能够满足不同应用场景的需求,从常规的数据中心网络…...

【Java】阿里环球Antom支付对接

阿里环球Antom支付对接 线上文档地址&#xff1a; GitHub&#xff1a;https://github.com/alipay/global-open-sdk-java 文档&#xff1a;https://global.alipay.com/docs/ac/ams_zh-cn/session_cashier maven&#xff1a; <!--阿里国际支付--><dependency><g…...

【vim】vim编辑器如何设置行号

vim编辑器如何设置行号 一、**临时设置行号**二、永久设置行号2.1. **用户配置文件方式&#xff08;针对当前用户&#xff09;**2.2. **全局配置文件方式&#xff08;谨慎使用&#xff0c;会影响所有用户&#xff09;** 在Vim中设置行号有以下两种常见的方法&#xff1a; 一、…...

爬虫基础之爬取某站视频

目标网址:为了1/4螺口买小米SU7&#xff0c;开了一个月&#xff0c;它值吗&#xff1f;_哔哩哔哩_bilibili 本案例所使用到的模块 requests (发送HTTP请求)subprocess(执行系统命令)re (正则表达式操作)json (处理JSON数据) 需求分析: 视频的名称 F12 打开开发者工具 or 右击…...

2024嵌入式系统的未来发展与技术洞察分享

时间如白驹过隙&#xff0c;不知不觉又是一年&#xff0c;这一年收获满满。接下来&#xff0c;将本年度对技术的感悟和洞察分析如下&#xff0c;希望对大家有所帮助。 在过去几十年里&#xff0c;嵌入式系统技术迅速发展&#xff0c;成为现代电子设备和智能硬件的核心组成部分。…...

[微服务]注册中心优化

环境隔离 企业实际开发中&#xff0c;往往会搭建多个运行环境&#xff0c;例如&#xff1a; 开发环境测试环境预发布环境生产环境 这些不同环境之间的服务和数据之间需要隔离。 还有的企业中&#xff0c;会开发多个项目&#xff0c;共享nacos集群。此时&#xff0c;这些项目…...

Leetcode 3426. Manhattan Distances of All Arrangements of Pieces

Leetcode 3426. Manhattan Distances of All Arrangements of Pieces 1. 解题思路2. 代码实现 题目链接&#xff1a;3426. Manhattan Distances of All Arrangements of Pieces 1. 解题思路 这道题很惭愧&#xff0c;一开始没有搞定&#xff0c;后来看了答案想了想&#xff…...

【重庆市乡镇界】面图层shp格式arcgis数据乡镇名称和编码wgs84坐标无偏移内容测评

标题中的“最新重庆市乡镇界面图层shp格式arcgis数据乡镇名称和编码wgs84坐标无偏移最新”指的是一个地理信息系统&#xff08;GIS&#xff09;的数据集&#xff0c;特别设计用于ArcGIS软件。这个数据集包含了重庆市所有乡镇的边界信息&#xff0c;以Shapefile&#xff08;.shp…...

基于ChatGPT的论文写作辅助工具研究

**基于ChatGPT的论文写作辅助工具研究** **摘要**&#xff1a; 随着人工智能技术的飞速发展&#xff0c;自然语言处理&#xff08;NLP&#xff09;领域取得了显著进步。ChatGPT作为OpenAI最新推出的生成式预训练Transformer模型&#xff0c;在文本生成、对话系统等方面展现出…...

定时器setTimeout和setInterval

setTimeOut()异步 setInterval()异步...

PCL 部分点云视点问题【2025最新版】

目录 一、问题概述二、解决方案1、软件实现2、代码实现三、调整之后博客长期更新,本文最近更新时间为:2025年1月18日。 一、问题概述 针对CloudCompare软件处理过的pcd格式点云,在使用PCL进行特征点提取、配准等实验中最终显示结果出现点云位置偏差较大的问题,本博客给出解…...

Cursor 与常见集成开发环境(IDE)的优势对比

Cursor与常见集成开发环境&#xff08;IDE&#xff09;的优势对比 一、AI 辅助编程能力 强大的代码生成功能&#xff1a; Cursor&#xff1a; 以其内置的强大 AI 辅助编程功能为核心优势。用户可以通过输入自然语言描述&#xff0c;快速生成各种编程语言的代码。例如&#xf…...

TDengine 做为 FLINK 数据源技术参考手册

Apache Flink 是一款由 Apache 软件基金会支持的开源分布式流批一体化处理框架&#xff0c;可用于流处理、批处理、复杂事件处理、实时数据仓库构建及为机器学习提供实时数据支持等诸多大数据处理场景。与此同时&#xff0c;Flink 拥有丰富的连接器与各类工具&#xff0c;可对接…...