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

设计电子商务网站方式网络托管运营

设计电子商务网站方式,网络托管运营,织梦网站图片修改不了,wordpress 亲子模板下载作者#xff1a;来自 Elastic Gustavo Llermaly 使用 Ollama 通过 Go 创建 RAG 应用程序来利用本地模型。 关于各种开放模型#xff0c;有很多话要说。其中一些被称为 Mixtral 系列#xff0c;各种规模都有#xff0c;而一种可能不太为人所知的是 openbiollm#xff0c;这…作者来自 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 Crohns 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/v8latest 现在创建一个 main.go 文件其中包含测试一切是否配置正确的最少内容 main.go package mainimport (github.com/parakeet-nest/parakeet/completiongithub.com/parakeet-nest/parakeet/enums/optiongithub.com/parakeet-nest/parakeet/llmfmt )func main() {ollamaUrl : http://localhost:11434model : llama3.2:latestoptions : 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 (contextencoding/jsonfmtstringsgithub.com/elastic/go-elasticsearch/v8github.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:titleContent 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 (fmtlogollama-rag/elasticsearchgithub.com/parakeet-nest/parakeet/completiongithub.com/parakeet-nest/parakeet/enums/optiongithub.com/parakeet-nest/parakeet/llm )func main() {ollamaUrl : http://localhost:11434chatModel : llama3.2:latestquestion : Summarize document: JAK Inhibitors vs. Monoclonal Antibodies in Rheumatoid Arthritis Treatmentsize : 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 字段类型你可以创建一个使用 ELSERElastic Sparse 嵌入模型的语义查询就绪索引而无需任何其他配置从而简化了分块、索引和向量查询过程。 Elasticsearch 与行业领先的 Gen AI 工具和提供商进行了原生集成。查看我们的网络研讨会了解如何超越 RAG 基础知识或构建可用于生产的应用程序 Elastic Vector Database。 要为你的用例构建最佳搜索解决方案请立即开始免费云试用或在你的本地机器上试用 Elastic。 原文Using Ollama and Go for RAG applications - Elasticsearch Labs
http://www.tj-hxxt.cn/news/134423.html

相关文章:

  • 网站建设的博客专门做网站网站犯法吗
  • 做直播网站成都设计公司视频制作
  • 四线城市网站建设方向及营利点哪家公司做网站专业
  • 怎样用盒子做汽车视频网站安装wordpress中文包
  • 上海官方网站建设wordpress chianz
  • php简易购物网站开发网站域名申请了该怎么做
  • 怎么学习做网站营销型网站分类
  • 什么网站是最全的国外销售网站怎样建设
  • 四川省住房和城乡建设厅官网站网怎样做网站快照
  • 湖州市城乡建设局网站重庆招商网
  • 企业网站建设方案价格百度网盘怎么增大免费空间
  • 百度手机网站优化企业信用网站建设
  • 吉林分销网站建设可信网站认证的区别
  • 海南网站搭建ui设计的定义
  • 长春建站费用国外 素材 网站
  • 设置网站的默认页面昆明几大网站
  • 网站 图文混编西宁网站建设报价cu君博规范
  • 网站建设软硬件平台wordpress怎么装修网页
  • 哪个网站做简历免费下载app与手机网站
  • 评价一个网站的优缺点建设部网站1667号下载
  • 湖州 网站建设公司哪家好做网站项目需要多少钱
  • 常州建网站精湛的网站建设
  • 临沂国际外贸网站建设临平做网站
  • 手机网站要求浦东新区网站建设
  • 什么是网站推广优化php wordpress教程 pdf
  • 聊城建设银行官方网站贵阳监理建设网站
  • 兰州网站排名优化服务房地产建设企业网站
  • 网站开发服务费计入哪个科目wordpress模版下载
  • 私人做网站a做网站 钱
  • 花卉网站建设策划书南宁站建站时间