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

Elasticsearch:使用 Ollama 和 Go 开发 RAG 应用程序

作者:来自 Elastic Gustavo Llermaly

使用 Ollama 通过 Go 创建 RAG 应用程序来利用本地模型。

关于各种开放模型,有很多话要说。其中一些被称为 Mixtral 系列,各种规模都有,而一种可能不太为人所知的是 openbiollm,这是 Llama 3 针对医疗领域的改编版。通过实现它们的 API 来测试所有这些模型需要大量工作。但是,Ollama 允许我们使用友好的界面和简单的命令行来测试它们。

在本文中,我们将在 Golang 中构建一个 RAG 应用程序,使用 Ollama 作为 LLM 服务器,使用 Elasticsearch 作为向量数据库。

步骤

  • 安装 Ollama
  • 提取数据
  • Go 中的 RAG 应用程序

安装 Ollama

什么是 Ollama?

Ollama 是一个框架,允许你使用 CLI 在本地下载和访问模型。使用简单的命令,我们可以下载、聊天和设置一个服务器,其中包含我们想要从我们的应用程序中使用的模型。

在此处下载 Ollama 安装程序:

https://ollama.com/

包含可用模型的库在此处:

https://ollama.com/library

安装 Ollama 后,我们可以通过运行其中一个可用模型来测试一切是否正常。让我们使用 3B 参数安装 llama3.2。该库包含下载和运行模型所需的命令:

我们将运行 3B 版本的命令:

ollama run llama3.2:latest

第一次,它会下载模型,然后在终端中打开聊天:

现在我们可以输入 /exit 退出并使用在此位置设置的服务器:http://localhost:11434。让我们测试端点以确保一切按预期运行。

Ollama 提供两种答案模式:generate 以提供单一答案,chat 以与模型进行对话:

生成 - generate

当我们只希望对单个问题得到单个答案而不需要其他答案时,我们会使用生成。

curl http://localhost:11434/api/chat -d '{"model": "llama3.2","stream": false,"messages": [{ "role": "user", "content": "Why Elastic is so cool?" }]
}' 

默认情况下,答案以 stream: true 的形式生成,但我们将使用 stream: false,这样答案就只在一条消息中生成,并且更易于阅读。stream: true 在 UI 应用程序中很有用,因为 tokens 在生成时就会发送,而不是阻塞直到整个响应完成。

让我们继续讨论数据。

提取数据

让我们将一些医学文档作为文本和向量在 Elasticsearch 中编入索引。我们将使用这些来测试面向医学的模型(如 openbiollm)与一般模型相比的答案质量。

在开始之前,请确保我们已经创建了推理端点以使用 ELSER 作为我们的嵌入模型:

PUT _inference/sparse_embedding/my-elser-model 
{"service": "elser", "service_settings": {"num_allocations": 1,"num_threads": 1}
}

现在,让我们继续使用 semantic_text 字段类型创建索引,该类型允许我们控制分块大小以及向量配置。这使我们的索引能够支持全文、语义和混合搜索。

PUT rag-ollama 
{"mappings": {"properties": {"semantic_field": {"type": "semantic_text","inference_id": "my-elser-model"},"content": {"type": "text","copy_to": "semantic_field"}}}
}

现在,让我们索引这些文档:

POST _bulk
{"index":{"_index":"rag-ollama"}}
{"title":"JAK Inhibitors vs. Monoclonal Antibodies in Rheumatoid Arthritis Treatment","content":"This article compares the mechanisms of action, efficacy, and safety profiles of JAK inhibitors and monoclonal antibodies in rheumatoid arthritis treatment, including recent clinical trial data and real-world evidence. It discusses the intracellular signaling pathways targeted by JAK inhibitors, their rapid onset of action, and oral administration advantages. The article also covers the specific targets of various monoclonal antibodies, their long-term safety profiles, and the criteria for choosing between these two classes of drugs based on patient characteristics and disease severity."}
{"index":{"_index":"rag-ollama"}}
{"title":"Diagnostic Approach to Resistant Hypertension: Focus on Primary Aldosteronism","content":"This guide outlines the step-by-step diagnostic process for resistant hypertension, with a particular emphasis on screening and confirming primary aldosteronism. It details the use of aldosterone-renin ratio (ARR) testing as an initial screening tool, explaining proper patient preparation and interpretation of results. The guide also covers confirmatory tests such as the saline infusion test and captopril challenge test, their protocols, and diagnostic criteria. Additionally, it discusses the role of imaging studies in localizing aldosterone-producing adenomas and the importance of adrenal vein sampling in subtype classification of primary aldosteronism."}
{"index":{"_index":"rag-ollama"}}
{"title":"Gut Microbiota Diversity and Inflammatory Cytokine Production in IBD","content":"This study examines the relationship between gut microbiota diversity and the production of pro-inflammatory cytokines in inflammatory bowel diseases (IBD). It explores how reduced microbial diversity correlates with increased levels of cytokines such as TNF-α, IL-1β, and IL-6 in both Crohn's disease and ulcerative colitis. The research discusses specific bacterial species associated with anti-inflammatory effects and their mechanisms of action. Furthermore, it delves into potential therapeutic implications, including the use of prebiotics, probiotics, and fecal microbiota transplantation to modulate the gut microbiome and influence cytokine production. The study also touches on emerging microbiome-based interventions and their potential to complement existing IBD treatments."}
{"index":{"_index":"rag-ollama"}}
{"title":"Biological Therapy Selection in Rheumatoid Arthritis After csDMARD Failure","content":"This article provides a comprehensive framework for selecting appropriate biological therapy in rheumatoid arthritis patients who have not responded adequately to conventional synthetic Disease-Modifying Antirheumatic Drugs (csDMARDs). It discusses the various classes of biologics available, including TNF inhibitors, IL-6 inhibitors, B-cell depleting agents, and T-cell costimulation modulators. The article outlines key factors to consider in the decision-making process, such as disease activity scores, extra-articular manifestations, comorbidities, and patient preferences. It also addresses the importance of biomarkers and predictors of treatment response in guiding therapy selection. The piece concludes with a discussion on cycling versus switching mechanisms of action when faced with inadequate response to an initial biologic agent."}
{"index":{"_index":"rag-ollama"}}
{"title":"Hypertension Management in Chronic Kidney Disease: Special Considerations","content":"This review discusses the unique challenges in managing hypertension in patients with chronic kidney disease (CKD). It outlines the current recommendations for blood pressure targets in CKD patients, explaining how these differ based on the presence and degree of albuminuria. The article explores the preferred classes of antihypertensive medications in CKD, with a focus on renin-angiotensin system blockers and their renoprotective effects. It addresses the complexities of managing volume status in CKD and the role of diuretics. The review also covers the impact of proteinuria on treatment decisions and the need for more aggressive blood pressure control in heavily proteinuric patients. Finally, it discusses considerations for patients on dialysis and the phenomenon of reverse epidemiology in end-stage renal disease."}

完成了!现在我们已经准备好了模型和数据,我们可以将所有内容与我们的 Go 应用程序整合在一起。

Go 中的 RAG 应用程序

对于我们的 Go 应用程序,我们可以直接调用 Ollama 服务器,但我决定改用 parakeet。Parakeet 是一个基于 Go 文本创建 GenAI 应用程序的库。它提供了 Go 接口来抽象 HTTP 通信,此外还提供了用于嵌入、分块和内存等的帮助程序,因此创建应用程序变得非常容易。

我们将首先创建工作文件夹并设置依赖项:

mkdir ollama-rag
cd ollama-rag
go mod init ollama-rag
go get github.com/parakeet-nest/parakeet
go get github.com/elastic/go-elasticsearch/v8@latest

现在,创建一个 main.go 文件,其中包含测试一切是否配置正确的最少内容:

main.go

package mainimport ("github.com/parakeet-nest/parakeet/completion""github.com/parakeet-nest/parakeet/enums/option""github.com/parakeet-nest/parakeet/llm""fmt"
)func main() {ollamaUrl := "http://localhost:11434"model := "llama3.2:latest"options := llm.SetOptions(map[string]interface{}{option.Temperature: 0.5,})question := llm.GenQuery{Model:   model,Prompt:  "Why Elastic is so cool?, answer in one sentence",Options: options,}// We use generate because we are going to run this script to ask a single questionanswer, err := completion.Generate(ollamaUrl, question)if err != nil {log.Fatal("😡:", err)}fmt.Println(answer.Response)
}

运行它:

go run main.go

在终端中,你应该看到类似这样的答案:

Elastic, a company known for its innovative and user-friendly software solutions, has disrupted the traditional IT industry by empowering businesses to create, deploy, and manage applications quickly and reliably.

这个答案是基于 LLM 的训练数据,这不是我们可以提供或控制的,并且存在一些缺点:

  • 信息可能是错误的
  • 信息可能已过时
  • 无法获取来源的引用

现在,让我们创建一个名为 elasticsearch/elasticsearch.go 的文件,使用 Go 的官方客户端连接 Elasticsearch,并能够使用我们文档中的信息根据我们的数据生成有根据的答案。

:更多有关如何连接到 Elasticsearch,摄取数据,并进行搜索,请参阅文章 “Elasticsearch:运用 Go 语言实现 Elasticsearch 搜索 - 8.x”。

elasticsearch/elasticsearch.go 

package elasticsearchimport ("context""encoding/json""fmt""strings""github.com/elastic/go-elasticsearch/v8""github.com/elastic/go-elasticsearch/v8/typedapi/types"
)// Initializing elasticsearch clientfunc EsClient() (*elasticsearch.TypedClient, error) {var cloudID = "" // your Elastic Cloud ID Herevar apiKey = "" // your Elastic ApiKey Herees, err := elasticsearch.NewTypedClient(elasticsearch.Config{CloudID: cloudID,APIKey:  apiKey,})if err != nil {return nil, fmt.Errorf("unable to connect: %w", err)}return es, nil
}// Searching for documents and building the context
func SemanticRetriever(client *elasticsearch.TypedClient, query string, size int) (string, error) {// Perform the semantic searchres, err := client.Search().Index("rag-ollama").Query(&types.Query{Semantic: &types.SemanticQuery{Field: "semantic_field",Query: query,},}).Size(size).Do(context.Background())if err != nil {return "", fmt.Errorf("semantic search failed: %w", err)}// Prepare to format the resultsvar output strings.Builderoutput.WriteString("Documents found\n\n")// Iterate through the search hitsfor i, hit := range res.Hits.Hits {// Define a struct to unmarshal each documentvar doc struct {Title   string `json:"title"`Content string `json:"content"`}// Unmarshal the document source into our structif err := json.Unmarshal(hit.Source_, &doc); err != nil {return "", fmt.Errorf("failed to unmarshal document %d: %w", i, err)}// Append the formatted document to our outputoutput.WriteString(fmt.Sprintf("Title\n%s\n\nContent\n%s\n", doc.Title, doc.Content))// Add a separator between documents, except for the last oneif i < len(res.Hits.Hits)-1 {output.WriteString("\n-----\n\n")}}// Return the formatted output as a stringreturn output.String(), nil
}

EsClient 函数使用提供的云凭据初始化 Elasticsearch 客户端,SemanticRetriever 执行语义查询以构建 LLM 回答问题所需的上下文。

要查找你的云 ID 和 API 密钥,请转到此链接。

让我们回到我们的 main.go 文件并使用上述功能进行更新以调用 Elasticsearch 并运行语义查询:这将构建 LLM 上下文:

main.go

package mainimport ("fmt""log""ollama-rag/elasticsearch""github.com/parakeet-nest/parakeet/completion""github.com/parakeet-nest/parakeet/enums/option""github.com/parakeet-nest/parakeet/llm"
)func main() {ollamaUrl := "http://localhost:11434"chatModel := "llama3.2:latest"question := `Summarize document: JAK Inhibitors vs. Monoclonal Antibodies in Rheumatoid Arthritis Treatment`size := 3esClient, err := elasticsearch.EsClient()if err != nil {log.Fatalln("😡:", err)}// Retrieve documents from semantic query to build contextdocumentsContent, nil := elasticsearch.SemanticRetriever(esClient, question, size)systemContent := `You are a helpful medical assistant. Only answer the questions based on found documents.Add references to the base document titles and be succint in your answers.`options := llm.SetOptions(map[string]interface{}{option.Temperature: 0.0,})queryChat := llm.Query{Model: chatModel,Messages: []llm.Message{{Role: "system", Content: systemContent},{Role: "system", Content: documentsContent},{Role: "user", Content: question},},Options: options,}fmt.Println()fmt.Println("🤖 answer:")// Answer the question_, err = completion.ChatStream(ollamaUrl, queryChat,func(answer llm.Answer) error {fmt.Print(answer.Message.Content)return nil})if err != nil {log.Fatal("😡:", err)}fmt.Println()
}

如你所见,我们将用户的问题连同与之相关的所有文档一起发送。这就是我们如何根据 Elasticsearch 中的文档获得答案。

我们可以通过运行代码进行测试:

go run .

你应该看到类似这样的内容:

According to the article "JAK Inhibitors vs. Monoclonal Antibodies in Rheumatoid Arthritis Treatment", JAK inhibitors and monoclonal antibodies are two classes of drugs used to treat rheumatoid arthritis (RA). The main difference between them lies in their mechanisms of action:

        JAK inhibitors target intracellular signaling pathways, specifically the Janus kinase (JAK) pathway, which is involved in inflammation and immune response. They have a rapid onset of action and are administered orally.

  • Monoclonal antibodies target specific proteins involved in the inflammatory process, such as tumor necrosis factor-alpha (TNF-α), interleukin-6 (IL-6), and interleukin-17 (IL-17).

The article highlights that JAK inhibitors have a more favorable safety profile compared to monoclonal antibodies, with fewer gastrointestinal side effects. However, the choice between these two classes of drugs depends on patient characteristics and disease severity.

"References:"

        "JAK Inhibitors vs. Monoclonal Antibodies in Rheumatoid Arthritis Treatment" (document title)

Parakeet 将为我们处理 Ollama 交互,包括 token 流!从现在开始,我们可以非常轻松地测试不同的模型,而无需更改代码。

除了主库中的模型外,我们还可以访问社区成员上传的模型。

要使用其中一个,我们只需确保先下载到 Ollama 中。例如,让我们测试 openbiollm:

ollama run taozhiyuai/openbiollm-llama-3:8b_q8_0

安装后,我们可以将它与我们的 Go 代码一起使用:

chatModel := "taozhiyuai/openbiollm-llama-3:8b_q8_0"

让我们用同样的问题再运行一次。你注意到有什么不同吗?

In rheumatoid arthritis treatment, JAK inhibitors and monoclonal antibodies are commonly used. This article discusses the benefits and drawbacks of both therapies. JAK inhibitors work by targeting intracellular signaling pathways involved in the immune response. They have a rapid onset of action and can be administered orally, making them convenient for patients. Recent clinical trial data has shown that JAK inhibitors are effective at reducing inflammation and slowing joint damage progression in rheumatoid arthritis. However, there is still ongoing research to fully understand their long-term safety profile. Monoclonal antibodies, on the other hand, specifically target molecules involved in the immune system. These drugs have been found to be highly effective in managing symptoms of rheumatoid arthritis and improving joint function. They can provide prolonged symptom control and are often used as first-line treatment options. However, due to their complexity and unique administration requirements, monoclonal antibodies may not be suitable for all patients. In conclusion, both J AK inhibitors and monoclonal antibodies have their own advantages and disadvantages in treating rheumatoid arthritis. The choice of therapy depends on individual patient characteristics and disease severity. Ongoing research will contribute to a deeper understanding of the efficacy and safety profiles of these treatments, ultimately leading to improved care for patients with rheumatoid arthritis.

openbiollm 模型似乎提供了更多有关技术术语的细节,但它没有遵循有关引用上下文中提供的文档和给出简短答案的说明。相比之下,Llama3.2 更好地遵循了说明。

你可以在此处找到完整的工作示例

结论

Ollama 提供了一种非常直接和简单的方法来下载和测试不同的开放模型,从知名的模型到社区成员微调的模型。将它与 Parakeet 和官方 Elasticsearch Go 客户端配对,可以非常轻松地创建 RAG 应用程序。此外,通过使用 semantic_text 字段类型,你可以创建一个使用 ELSER(Elastic Sparse 嵌入模型)的语义查询就绪索引,而无需任何其他配置,从而简化了分块、索引和向量查询过程。

Elasticsearch 与行业领先的 Gen AI 工具和提供商进行了原生集成。查看我们的网络研讨会,了解如何超越 RAG 基础知识,或构建可用于生产的应用程序 Elastic Vector Database。

要为你的用例构建最佳搜索解决方案,请立即开始免费云试用或在你的本地机器上试用 Elastic。

原文:Using Ollama and Go for RAG applications - Elasticsearch Labs

相关文章:

Elasticsearch:使用 Ollama 和 Go 开发 RAG 应用程序

作者&#xff1a;来自 Elastic Gustavo Llermaly 使用 Ollama 通过 Go 创建 RAG 应用程序来利用本地模型。 关于各种开放模型&#xff0c;有很多话要说。其中一些被称为 Mixtral 系列&#xff0c;各种规模都有&#xff0c;而一种可能不太为人所知的是 openbiollm&#xff0c;这…...

Linux 下 Mamba 环境安装踩坑问题汇总(重置版)

导航 安装教程导航 Mamba 及 Vim 安装问题参看本人博客&#xff1a;Mamba 环境安装踩坑问题汇总及解决方法&#xff08;初版&#xff09;Linux 下Mamba 及 Vim 安装问题参看本人博客&#xff1a;Mamba 环境安装踩坑问题汇总及解决方法&#xff08;重置版&#xff09;Windows …...

(免费送源码)计算机毕业设计原创定制:Java+springboot+MySQL springboot 线上线下一体化的宠物交易

摘 要 网络发布信息有其突出的优点&#xff0c;即信息量大&#xff0c;资源丰富&#xff0c;更新速度快等&#xff0c;很符合人们希望以捷、便利的方式获得最多最有效信息的要求。本系统就是一个线上线下一体化的宠物交易&#xff0c;为商家提供一个信息发布的平台&#xff0…...

【Rust自学】7.4. use关键字 Pt.2 :重导入与换国内镜像源教程

喜欢的话别忘了点赞、收藏加关注哦&#xff0c;对接下来的教程有兴趣的可以关注专栏。谢谢喵&#xff01;(&#xff65;ω&#xff65;) 7.4.1. 使用pub use重新导入名称 使用use将路径导入作用域内后。该名称在词作用域内是私有的。 以上一篇文章的代码为例&#xff1a; m…...

自动生成关于软件程序开发的100个文件并可提供下载入口

创建一个包含100个关于软件程序开发的文件并提供下载入口是一个庞大的任务&#xff0c;因为这需要编写大量的代码、文档和示例。不过&#xff0c;我可以提供一个大致的框架和指导&#xff0c;帮助你生成这些文件&#xff0c;并说明如何设置下载入口。 文件生成思路 编程语言文…...

Linux下基本指令

一、什么是指令 指令本质是可执行程序&#xff0c;在执行指令前&#xff0c;先在系统中查找对应的指令。在Linux系统中指令存在于/usr/bin/路径下 二、ls 指令 1、语法 ls [选项][目录或文件] 2、功能 对于目录&#xff0c;该命令列出该目录下的所有子目录与文件。 对于文…...

2024-12-25-sklearn学习(20)无监督学习-双聚类 料峭春风吹酒醒,微冷,山头斜照却相迎。

文章目录 sklearn学习(20) 无监督学习-双聚类1 Spectral Co-Clustering1.1 数学公式 2 Spectral Biclustering2.1 数学表示 3 Biclustering 评价 sklearn学习(20) 无监督学习-双聚类 文章参考网站&#xff1a; https://sklearn.apachecn.org/ 和 https://scikit-learn.org/sta…...

编程考古-传奇的开始Delphi(下)含所有版本.iso

概览 Delphi 的最新版本&#xff0c;即 Delphi 12&#xff0c;勾勒出了自公司创立以来的一条进化之路。该平台不断通过提升开发者生产力、扩展其支持的平台范围以及引入前沿技术来实现自我完善。作为 Embarcadero 提供的主要快速应用开发&#xff08;RAD&#xff09;环境&…...

集合stream

1.Collection集合 1.1数组和集合的区别【理解】 相同点 都是容器,可以存储多个数据 不同点 数组的长度是不可变的,集合的长度是可变的 数组可以存基本数据类型和引用数据类型 集合只能存引用数据类型,如果要存基本数据类型,需要存对应的包装类 1.2集合类体系结构【理解】…...

Xshell 和 Xftp 更新提示问题的解决方法及分析

Xshell 和 Xftp 更新提示问题的解决方法及分析 在个人使用 Xshell 和 Xftp 的过程中&#xff0c;通过官网注册使用一段时间后&#xff0c;往往会遇到这样的问题&#xff1a;软件提示“要继续使用此程序&#xff0c;你必须应用最新的更新或使用新版本”。对于那些觉得更新比较麻…...

Docker安装MongoDB

Docker安装MongoDB 1、拉取镜像2、创建容器3、启动容器4、进入容器内部5、进入admin数据库6、添加管理员&#xff0c;其拥有管理用户和角色的权限7、进行认证8、通过admin添加普通用户 1、拉取镜像 docker pull mongo:4.0.32、创建容器 docker create --name mongodb-server …...

解锁自动化新高度,zTasker v2.0全方位提升效率

zTasker 是一款集强大功能与高效操作于一体的自动化任务管理软件&#xff0c;以其简单直观的设计和一键完成操作的特性深受用户喜爱。软件体积小巧&#xff0c;运行速度极快&#xff0c;支持超过 100 种不同的任务类型&#xff0c;并提供 30 多种定时或条件触发方式&#xff0c…...

Windows Server 安装 MySQL 8.0 详细指南

文章目录 Windows Server 安装 MySQL 8.0 详细指南准备工作安装步骤1. 解压安装包2. 初始化数据目录3. 安装 MySQL 服务4. 启动 MySQL 服务 MySQL 配置文件 (my.ini)5. 设置 root 密码6. 配置远程访问 安全建议常见问题排查性能优化提示结语 &#x1f449;洛秋资源小站 Windows…...

uniapp小程序使用webview 嵌套 vue 项目

uniapp小程序使用webview 嵌套 vue 项目 小程序中发送 <web-view :src"urlSrc" message"handleMessage"></web-view>export default {data() {return {urlSrc: "",};},onLoad(options) {// 我需要的参数比较多 所以比较臃肿// 获取…...

高效搭建Nacos:实现微服务的服务注册与配置中心

一、关于Nacos 1.1 简介 Nacos&#xff08;Dynamic Naming and Configuration Service&#xff09;是阿里巴巴开源的一款动态服务发现、配置管理和服务管理平台。它旨在帮助开发者更轻松地构建、部署和管理分布式系统&#xff0c;特别是在微服务架构中。Nacos 提供了简单易用…...

JavaScript 实现动态产品展示网页

JavaScript 实现动态产品展示网页 1. HTML 页面结构2. CSS 样式设计3. JavaScript 实现功能功能总结 本文设计了一个基于 JavaScript 的动态产品展示网页案例&#xff0c;核心功能包括&#xff1a; 动态产品分类过滤&#xff1a;通过点击分类按钮&#xff0c;仅显示属于该分类…...

小程序配置文件 —— 13 全局配置 - window配置

全局配置 - window配置 这里讲解根目录 app.json 中的 window 字段&#xff0c;window 字段用于设置小程序的状态栏、导航条、标题、窗口背景色&#xff1b; 状态栏&#xff1a;顶部位置&#xff0c;有网络信号、时间信息、电池信息等&#xff1b;导航条&#xff1a;有一个当…...

【小程序】wxss与rpx单位以及全局样式和局部样式

目录 WXSS 1. 什么是 WXSS 2. WXSS 和 CSS 的关系 rpx 1. 什么是 rpx 尺寸单位 2. rpx 的实现原理 3. rpx 与 px 之间的单位换算* 样式导入 1. 什么是样式导入 2. import 的语法格式 全局样式和局部样式 1. 全局样式 2. 局部样式 WXSS 1. 什么是 WXSS WXSS (We…...

矩阵的因子分解1-奇异值分解

文章目录 矩阵的因子分解1-奇异值分解求法归纳例1. 对矩阵 A ( 0 1 − 1 0 0 2 1 0 ) A \begin{pmatrix} 0 & 1 \\ -1 & 0 \\ 0 & 2 \\ 1 & 0 \end{pmatrix} A ​0−101​1020​ ​ 进行奇异值分解1. 计算 A H A A^H A AHA 的特征值和特征向量2. 将奇异值按…...

Hive其十,优化和数据倾斜

目录 Hive优化 1、开启本地模式 2、explain分析SQL语句 3、修改Fetch操作 4、开启hive的严格模式【提高了安全性】 5、JVM重用 6、分区、分桶以及压缩 7、合理设置map和reduce的数量 合理设置map数量&#xff1a; 设置合理的reducer的个数 8、设置并行执行 9、CBO优…...

云原生后端开发(一)

云原生后端开发 云原生&#xff08;Cloud-Native&#xff09;是指一种构建和运行应用程序的方式&#xff0c;它充分利用了云计算的特点&#xff0c;比如弹性伸缩、自动化部署、容器化等。在云原生的架构下&#xff0c;后端应用通常具备高度可扩展、可维护、易于自动化管理的特…...

Python常用模块详解:从操作系统接口到日志记录

Python常用模块详解&#xff1a;从操作系统接口到日志记录 1. os模块&#xff1a;操作系统接口主要功能示例 2. io模块&#xff1a;流操作主要功能示例 3. time模块&#xff1a;时间操作主要功能示例 4. argparse模块&#xff1a;命令行参数解析主要功能示例 5. logging模块&am…...

修改成清华镜像源解决Anaconda报The channel is not accessible源通道不可用问题

修改成清华镜像源解决Anaconda报The channel is not accessible源通道不可用问题 最近在通过pycharm开发python程序&#xff0c;引用anaconda环境建立虚拟环境时报错&#xff0c;报UnavailableInvalidChannel: The channel is not accessible or is invalid.应该是镜像源访问通…...

Python之Web开发

一、基本概念 Web开发是指创建和维护网站或Web应用的过程。一个典型的Web应用包括前端&#xff08;客户端&#xff09;和后端&#xff08;服务器端&#xff09;。前端负责用户界面的设计和交互&#xff0c;而后端则处理业务逻辑、数据存储和与数据库的通信。Python作为一门功能…...

CDN如何抵御DDoS攻击

一、DDoS攻击的定义 DDoS&#xff08;Distributed Denial of Service&#xff0c;分布式拒绝服务&#xff09;攻击是一种常见且破坏性较大的网络攻击方式。攻击者通过控制大量分布在全球各地的受感染设备&#xff08;称为“僵尸网络”&#xff09;&#xff0c;同时向目标服务器…...

基于进程信号量的多线程同步机制研究与实现

1 信号量 1.1 原理与概念 信号量机制本质是对于资源的预订操作&#xff0c;线程或者进程预订了之后&#xff0c;确保未来有一段时间&#xff0c;资源是属于我的。 对于预订资源&#xff0c;会有一个最小单位&#xff0c;资源都是以这个最小单位为整体被使用的。 信号量需要做…...

七、队列————相关概念详解

队列————相关概念详解 前言一、队列1.1 队列是什么?1.2 队列的类比 二、队列的常用操作三、队列的实现3.1 基于数组实现队列3.1.1 基于环形数组实现的队列3.1.2 基于动态数组实现的队列 3.2 基于链表实现队列 四、队列的典型应用总结 前言 本篇文章&#xff0c;我们一起来…...

钉钉h5微应用鉴权配置客户端 API 鉴权步骤

这里记录一下使用的钉钉h5微应用 配置客户端 API 鉴权的内容 注意不是所有的都功能都需要鉴权。 先要引入钉钉环境 见下链接 https://blog.csdn.net/KLS_CSDN/article/details/144794982?spm1001.2014.3001.5501 引入鉴权代码到前端页面并配置以下参数&#xff1a; dd.con…...

04.HTTPS的实现原理-HTTPS的混合加密流程

04.HTTPS的实现原理-HTTPS的混合加密流程 简介1. 非对称加密与对称加密2. 非对称加密的工作流程3. 对称加密的工作流程4. HTTPS的加密流程总结 简介 主要讲述了HTTPS的加密流程&#xff0c;包括非对称加密和对称加密两个阶段。首先&#xff0c;客户端向服务器发送请求&#xf…...

Python中构建终端应用界面利器——Blessed模块

在现代开发中&#xff0c;命令行应用已经不再仅仅是一个简单的文本输入输出工具。随着需求的复杂化和用户体验的重视&#xff0c;终端界面也逐渐成为一个不可忽视的设计环节。 如果你曾经尝试过开发终端UI&#xff0c;可能对传统的 print() 或者 input() 函数感到不满足&#…...

【Python】 基于Python实现日志聚合与分析工具:利用Logstash与Fluentd构建高效分布式日志系统

《Python OpenCV从菜鸟到高手》带你进入图像处理与计算机视觉的大门! 解锁Python编程的无限可能:《奇妙的Python》带你漫游代码世界 在分布式系统中,日志数据的生成速度和数量呈指数级增长,传统的日志管理方式已无法满足现代企业对实时性、可扩展性和高效性的需求。本文深…...

汽车网络安全基线安全研究报告

一、引言 随着汽车行业朝着智能网联方向飞速发展&#xff0c;汽车网络安全已成为保障用户安全和行业健康发展的关键要素。本报告将深入探讨汽车网络安全相关内容&#xff0c;以及国际、国内重要的汽车网络安全标准基线和相应防护措施等内容。 二、汽车网络安全的重要性 &…...

[pdf、epub]260道《软件方法》强化自测题业务建模需求分析共216页(202412更新)

DDD领域驱动设计批评文集 做强化自测题获得“软件方法建模师”称号 《软件方法》各章合集 260道《软件方法》强化自测题业务建模需求分析共216页&#xff08;202412更新&#xff09; 已上传到本CSDN账号的资源 如果下载不到&#xff0c;也可以访问以下链接&#xff1a; ht…...

工业4.0和MES(制造执行系统)方案(附实践资料)

工业4.0和MES&#xff08;制造执行系统&#xff09;方案是智能制造领域中的关键组成部分&#xff0c;它们共同推动着制造业的数字化转型。以下是工业4.0和MES方案的一些核心要点&#xff1a; 智能制造背景&#xff1a; 工业4.0是第四次工业革命&#xff0c;它结合了信息通信技术…...

机器视觉中的单线程、多线程与跨线程:原理与应用解析

在机器视觉应用中&#xff0c;程序的运行效率直接影响到系统的实时性和稳定性。随着任务复杂度的提高&#xff0c;单线程处理往往无法满足高性能需求&#xff0c;多线程技术因此被广泛应用。此外&#xff0c;跨线程操作&#xff08;如在多线程中更新界面或共享资源&#xff09;…...

性能测试瓶颈:CPU 问题的深度分析和调优

&#x1f345; 点击文末小卡片 &#xff0c;免费获取软件测试全套资料&#xff0c;资料在手&#xff0c;涨薪更快 我们做性能测试的时候&#xff0c;除了使用工具编写脚本并执行之外&#xff0c;最核心的工作就是做性能测试结果分析和问题调优。然后在做性能测试的时候&#xf…...

云手机与Temu矩阵:跨境电商运营新引擎

云手机与 Temu 矩阵结合的基础 云手机技术原理 云手机基于先进的 ARM 虚拟化技术&#xff0c;在服务器端运行 APP。通过在服务器上利用容器虚拟化软件技术&#xff0c;能够虚拟出多个独立的手机操作系统实例&#xff0c;每个实例等同于一部单独的手机&#xff0c;可独立运行各…...

Oracle考试多少分算通过?

OCP和OCM认证的考试及格分数并不是固定的&#xff0c;而是根据考试的难度和考生的整体表现来确定。对于OCP认证&#xff0c;考生需要全面掌握考试要求的知识和技能&#xff0c;并在考试中表现出色才有可能通过。而对于OCM认证&#xff0c;考生则需要在每个模块中都达到一定的水…...

【UE5.3.2】安装metahuman插件

Unable to find plugin ‘MetaHuman’报错 Unable to find plugin MetaHuman (referenced via RPect_5_3.uproject). Install it and try again, or remove it from the required plugin list. 10>Microsoft.MakeFile.Targets(44,5): Error MSB3073 :...

python lambda函数用法

在Python中&#xff0c;lambda函数是一种用于创建匿名函数的简便方式。它允许你快速定义一个简单的函数&#xff0c;而不需要使用传统的def语句。lambda函数通常用于一次性的操作或作为参数传递给其他函数。 lambda函数的语法&#xff1a; lambda 参数1, 参数2, ... : 表达式l…...

acitvemq AMQP:因为消息映射策略配置导致的MQTT接收JMS消息乱码问题 x-opt-jms-dest x-opt-jms-msg-type

使用ActiveMQ&#xff08;5.14.5&#xff09;作消息系统服务的场景下&#xff0c; 当我用Apache Qpid Proton发送消息(使用AMQP协议)发送JMS消息&#xff0c;用Paho MQTT接收消息的时候&#xff0c; 收到的消息前面总是有一串乱码&#xff0c;大概就是这样&#xff1a; 4Sp?AS…...

ida的使用

一.ida的基本设置 在IDA的安装根目录下有许多文件夹&#xff0c;各个文件夹存储不同的内容 1.目录结构 cfg&#xff1a;包含各种配置文件&#xff0c;基本IDA配置文件ida.cfg,GUI配置文件idagui.cfg&#xff0c;文本模式用户界面配置文件idatui.cfg, idc&#xff1a;包含…...

archery docker安装

#下载Archery-1.11.3.tar.gz https://codeload.github.com/hhyo/Archery/tar.gz/refs/tags/v1.11.3 cd /root tar -zxvf Archery-1.11.3.tar.gz cd /root/Archery-1.11.3/src/docker-compose #启动 docker compose -f docker-compose.yml up -d#表结构初始化 docker exec -ti a…...

【zookeeper核心源码解析】第四课:客户端与服务端读写的io核心流程

系列文章目录 【zookeeper核心源码解析】第一课&#xff1a;zk启动类核心流程序列图 【zookeeper核心源码解析】第二课&#xff1a;俯瞰QuorumPeer启动核心流程&#xff0c;实现选举关键流程 【zookeeper核心源码解析】第三课&#xff1a;leader与follower何时开始同步&#…...

影刀进阶指令 | Kimi (对标ChatGPT)

文章目录 影刀进阶指令 | Kimi &#xff08;对标ChatGPT&#xff09;一. 需求二. 流程三. 实现3.1 流程概览3.2 流程步骤讲解1\. 确定问题2\. 填写问题并发送3\. 检测答案是否出完 四. 运维 影刀进阶指令 | Kimi &#xff08;对标ChatGPT&#xff09; 简单讲讲RPA调用kimi实现…...

Linux第99步_Linux之点亮LCD

主要学习如何在Linux开发板点亮屏&#xff0c;以及modetest命令的实现。 很多人踩坑&#xff0c;我也是一样。关键是踩坑后还是实现不了&#xff0c;这样的人确实很多&#xff0c;从群里可以知道。也许其他人没有遇到这个问题&#xff0c;我想是他运气好。 1、修改设备树 1)、…...

【C++决策和状态管理】从状态模式,有限状态机,行为树到决策树(三):基于BT行为树实现复杂敌人BOSS-AI

前言 &#xff08;题外话&#xff09;nav2系列教材&#xff0c;yolov11部署,系统迁移教程我会放到年后一起更新&#xff0c;最近年末手头事情多&#xff0c;还请大家多多谅解。回顾我们整个学习历程&#xff0c;我们已经学习了很多C的代码特性&#xff0c;也学习了很多ROS2的跨…...

SpringCloudAlibaba技术栈-Higress

1、什么是Higress? 云原生网关&#xff0c;干啥的&#xff1f;用通俗易懂的话来说&#xff0c;微服务架构下Higress 就像是一个智能的“交通警察”&#xff0c;它站在你的网络世界里&#xff0c;负责指挥和调度所有进出的“车辆”&#xff08;也就是数据流量&#xff09;。它的…...

《信息传播:人工智能助力驱散虚假信息阴霾》

在信息爆炸的时代&#xff0c;虚假信息和谣言如同脱缰野马&#xff0c;肆意传播&#xff0c;对社会秩序和公众生活造成了严重影响。人工智能作为一种强大的技术工具&#xff0c;正逐渐成为信息传播的有力助手&#xff0c;为防止虚假信息和谣言扩散提供了新的途径。 虚假信息和…...

玩客云v1.0 刷机时无法识别USB

v1.0刷机时公对公插头掉了&#xff0c;刷机失败&#xff0c;再次刷机&#xff0c;一直提示无法识别的USB设备&#xff0c;此时LED一直不亮&#xff0c;就像是刷成砖了一样&#xff0c;查了好多文章最后发现正面还有一个地方需要短接。 背面的短接点 【免费】玩客云刷机包s805-…...