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

png免费素材网站网页图片显示不出来打叉

png免费素材网站,网页图片显示不出来打叉,郴州seo服务,培训机构退费法律规定作者#xff1a;来自 Elastic Essodjolo Kahanam 本博客介绍如何使用语义搜索以自然语言表达形式从 Elasticsearch 索引中获取信息。我们将创建一个无服务器 Elasticsearch 项目#xff0c;将之前的奥运会数据集加载到索引中#xff0c;使用推理处理器和 ELSER 模型生成推理…作者来自 Elastic Essodjolo Kahanam 本博客介绍如何使用语义搜索以自然语言表达形式从 Elasticsearch 索引中获取信息。我们将创建一个无服务器 Elasticsearch 项目将之前的奥运会数据集加载到索引中使用推理处理器和 ELSER 模型生成推理数据在稀疏向量场中最后借助文本扩展text expansion查询以自然语言表达形式搜索历史奥运会比赛信息。 工具和数据集 对于这个项目我们将使用 Elasticsearch serverless 项目和无服务器 Python 客户端 (elasticsearch_serverless) 与 Elasticsearch 交互。要创建 serverless 项目只需按照 serverless 入门指南操作即可。有关 serverless 的更多信息包括定价可在此处找到。 设置 serverless 项目时请务必选择 Elasticsearch 选项和用于本教程的通用选项。 使用的数据集是从 Kaggle (Athletes_summer_games.csv) 获得的 1896 年至 2020 年夏季奥运会参赛者的数据集。它包含有关比赛年份、比赛类型、参赛者姓名、他们是否赢得奖牌以及最终获得哪枚奖牌以及其他信息的信息。 对于数据集操作我们将使用 Eland这是一个用于 Elasticsearch 中的 DataFrames 和机器学习的 Python 客户端和工具包。 最后使用的自然语言处理 (NLP) 模型是 Elastic Learned Sparse EncodeR (ELSER)这是一个由 Elastic 训练的检索模型允许通过语义搜索检索更相关的搜索结果。 在执行以下步骤之前请确保你已安装 severless Python 客户端和 Eland。 pip install elasticsearch_serverless pip install eland请注意下面我使用的版本。如果你使用的不是同一个版本则可能需要根据你使用的版本中的任何最终语法更改来调整代码。 ➜ ~ python3 --version Python 3.9.6 ➜ ~ pip3 list | grep -E elasticsearch-serverless|eland eland 8.14.0 elasticsearch-serverless 0.3.0.20231031 下载并部署 ELSER 模型 我们将使用 Python 客户端下载并部署 ELSER 模型。在此之前让我们先确认我们可以连接到我们的 serverless 项目。下面的 URL 和 API 密钥是从环境变量中读取的你需要根据自己的情况使用适当的值或者使用你喜欢的任何方法来读取凭据。 from elasticsearch_serverless import Elasticsearch from os import environserverless_endpoint environ.get(SERVERLESS_ENDPOINT_URL) serverless_api_key environ.get(SERVERLESS_API_KEY)client Elasticsearch(serverless_endpoint,api_keyserverless_api_key )client.info()如果一切配置正确你应该得到如下输出 ObjectApiResponse({name: serverless, cluster_name: d6c6698e28c34e58b6f858df9442abac, cluster_uuid: hOuAhMUPQkumEM-PxW_r-Q, version: {number: 8.11.0, build_flavor: serverless, build_type: docker, build_hash: 00000000, build_date: 2023-10-31, build_snapshot: False, lucene_version: 9.7.0, minimum_wire_compatibility_version: 8.11.0, minimum_index_compatibility_version: 8.11.0}, tagline: You Know, for Search})现在我们已经确认 Python 客户端已成功连接到无服务器 Elasticsearch 项目让我们下载并部署 ELSER 模型。我们将检查该模型是否之前已部署并将其删除以执行全新安装。此外由于部署阶段可能需要几分钟我们将不断检查模型配置信息以确保在进入下一阶段之前模型定义存在。有关更多信息请查看Get trained models API。 from elasticsearch_serverless import Elasticsearch, exceptions import time# delete model if already downloaded and deployed try:client.ml.delete_trained_model(model_id.elser_model_2, forceTrue)print(Model deleted successfully, We will proceed with creating one) except exceptions.NotFoundError:print(Model doesnt exist, but We will proceed with creating one)# Creates the ELSER model configuration. Automatically downloads the model if it doesnt exist. client.ml.put_trained_model(model_id.elser_model_2,input{field_names: [concatenated_textl]} )# Check the download and deploy progress while True:status client.ml.get_trained_models(model_id.elser_model_2, includedefinition_status)if status[trained_model_configs][0][fully_defined]:print(ELSER Model is downloaded and ready to be deployed.)breakelse:print(ELSER Model is downloaded but not ready to be deployed.)time.sleep(5)一旦我们确认模型已下载并准备部署我们就可以继续启动 ELSER。完全准备好部署可能需要一点时间。 # A function to check the models routing state # https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models-stats.html def get_model_routing_state(model_id.elser_model_2):try:status client.ml.get_trained_models_stats(model_id.elser_model_2,)return status[trained_model_stats][0][deployment_stats][nodes][0][routing_state][routing_state]except:return None# If ELSER is already started, then we are fine. if get_model_routing_state(.elser_model_2) started:print(ELSER Model has been already deployed and is currently started.)# Otherwise, we will deploy it, and monitor the routing state to make sure it is started. else:print(ELSER Model will be deployed.)# Start trained model deploymentclient.ml.start_trained_model_deployment(model_id.elser_model_2,number_of_allocations16,threads_per_allocation4,wait_forstarting)while True:if get_model_routing_state(.elser_model_2) started:print(ELSER Model has been successfully deployed.)breakelse:print(ELSER Model is currently being deployed.)time.sleep(5)使用 Eland 将数据集加载到 Elasticsearch eland.csv_to_eland 允许将逗号分隔值 (csv) 文件读入存储在 Elasticsearch 索引中的数据框中。我们将使用它将奥运会数据 (Athletes_summer_games.csv) 加载到 Elasticsearch 中。es_type_overrides 允许覆盖默认映射。 import eland as edindexelser-olympic-games csv_fileAthletes_summer_games.csved.csv_to_eland(csv_file,es_clientclient,es_dest_indexindex,es_if_existsreplace,es_dropnaTrue,es_refreshTrue,index_col0,es_type_overrides{City: text,Event: text,Games: text,Medal: text,NOC: text,Name: text,Season: text,Sport: text,Team: text} )执行上述代码后数据将写入索引 elser-olympic-games。你还可以将生成的数据框 (eland.DataFrame) 检索到变量中以供进一步操作。 基于 ELSER 创建用于推理的摄取管道 我们使用语义搜索探索过去奥运会比赛数据的下一步是创建一个包含运行 ELSER 模型的 inference processor 的摄取管道。已选择一组字段并将其串联成推理处理器将在其上工作的单个字段。根据你的用例你可能需要使用另一种策略。 串联是使用 script processor 完成的。推理处理器使用先前部署的 ELSER 模型将串联字段作为输入并将输出存储在稀疏向量类型字段中参见以下要点。 client.ingest.put_pipeline(idelser-ingest-pipeline,descriptionIngest pipeline for ELSER,processors[{script: {description: Concatenate some selected fields value into concatenated_text field,lang: painless,source: ctx[concatenated_text] ctx[Name] ctx[Team] ctx[Games] ctx[City] ctx[Event];}},{inference: {model_id: .elser_model_2,ignore_missing: True,input_output: [{input_field: concatenated_text,output_field: concatenated_text_embedding}]}}] )准备索引 这是使用自然语言表达查询过去奥运会比赛数据之前的最后一个阶段。我们将更新之前创建的索引的映射添加一个 sparse vector 类型字段。 更新映射添加稀疏向量字段 我们将通过添加一个用于保存串联数据concatenated data的字段和一个用于保存推理处理器使用 ELSER 模型计算出的推断信息的稀疏向量字段来更新索引映射。 indexelser-olympic-gamesmappings_properties{concatenated_text: {type: text},concatenated_text_embedding: {type: sparse_vector} }client.indices.put_mapping(indexindex,propertiesmappings_properties )填充稀疏向量字段 我们将通过运行 update by query 来调用之前创建的摄取管道以便填充每个文档中的稀疏向量字段。 client.update_by_query(indexelser-olympic-games,pipelineelser-ingest-pipeline,wait_for_completionFalse )该请求将需要一些时间具体取决于文档数量以及用于部署 ELSER 的分配数量和每个分配的线程数。完成此步骤后我们现在可以开始使用语义搜索探索过去的奥运会数据集。 让我们使用语义搜索探索奥运会数据集 现在我们将使用 text expansion 查询使用自然语言表达来检索有关过去奥运会比赛的信息。在进行演示之前让我们创建一个函数来检索和格式化搜索结果。 def semantic_search(search_text):response client.search(indexelser-olympic-games,size3,query{bool: {must: [{text_expansion: {concatenated_text_embedding: {model_id: .elser_model_2,model_text: search_text}}},{exists: {field: Medal}}]}},source_excludes*_embedding, concatenated_text)for hit in response[hits][hits]:doc_id hit[_id]score hit[_score]year hit[_source][Year]event hit[_source][Event]games hit[_source][Games]sport hit[_source][Sport]city hit[_source][City]team hit[_source][Team]name hit[_source][Name]medal hit[_source][Medal]print(fScore: {score}\nDocument ID: {doc_id}\nYear: {year}\nEvent: {event}\nName: {name}\nCity: {city}\nTeam: {team}\nMedal: {medal}\n)上述函数将接收有关往届奥运会比赛获胜者的问题并使用 Elastic 的 text expansion 查询执行语义搜索。检索到的结果将被格式化并打印出来。请注意我们强制查询中存在奖牌因为我们只对获胜者感兴趣。我们还将结果的大小限制为 3因为我们预计会有三名获胜者金牌、银牌、铜牌。同样根据你的用例你可能不一定会做同样的事情。 ️‍♂️ “Who won the Golf competition in 1900?” 请求 semantic_search(Who won the Golf competition in 1900?)响应 Score: 18.184263 Document ID: 206566 Year: 1900 Event: Golf Mens Individual Name: Walter Mathers Rutherford City: Paris Team: Great Britain Medal: SilverScore: 17.443663 Document ID: 209892 Year: 1900 Event: Golf Mens Individual Name: Charles Edward Sands City: Paris Team: United States Medal: GoldScore: 16.939331 Document ID: 192747 Year: 1900 Event: Golf Womens Individual Name: Myra Abigail Abbie Pratt (Pankhurst-, Wright-, -Karageorgevich) City: Paris Team: United States Medal: Bronze“Women archery winners of 1908” 请求 semantic_search(Women archery winners of 1908)响应 Score: 21.876282 Document ID: 96010 Year: 1908 Event: Archery Womens Double National Round Name: Beatrice Geraldine Hill-Lowe (Ruxton-, -Thompson) City: London Team: Great Britain Medal: BronzeScore: 21.0998 Document ID: 170250 Year: 1908 Event: Archery Womens Double National Round Name: Sybil Fenton Newall City: London Team: Great Britain Medal: GoldScore: 21.079535 Document ID: 56686 Year: 1908 Event: Archery Womens Double National Round Name: Charlotte Lottie Dod City: London Team: Great Britain Medal: Silver‍♂️ “Who won the individual cycling competition in 1972?” 请求 semantic_search(Who won the cycling competition in 1972?)响应 Score: 20.554308 Document ID: 215559 Year: 1972 Event: Cycling Mens Road Race, Individual Name: Kevin Clyde Sefton City: Munich Team: Australia Medal: SilverScore: 20.267525 Document ID: 128598 Year: 1972 Event: Cycling Mens Road Race, Individual Name: Hendrikus Andreas Hennie Kuiper City: Munich Team: Netherlands Medal: GoldScore: 19.108923 Document ID: 19225 Year: 1972 Event: Cycling Mens Team Pursuit, 4,000 metres Name: Michael John Mick Bennett City: Munich Team: Great Britain Medal: Bronze结论 本博客展示了如何使用 serverlss 的 Python 编程语言通过 Elastic Learned Sparse EncodeR (ELSER) NLP 模型执行语义搜索。运行本教程后你需要确保关闭 serverless以避免任何额外费用。要进一步了解请随时查看我们的 Elasticsearch 相关性引擎 (ESRE​​) 工程师课程你可以在其中学习如何利用 Elasticsearch 相关性引擎 (ESRE​​) 和大型语言模型 (LLMs) 构建高级 RAG检索增强生成应用程序将 Elasticsearch 的存储、处理和搜索功能与 LLM 的生成能力相结合。 本文中描述的任何特性或功能的发布和时间均由 Elastic 自行决定。任何当前不可用的特性或功能可能无法按时交付或根本无法交付。 准备好自己尝试一下了吗开始免费试用。 想要获得 Elastic 认证了解下一期 Elasticsearch 工程师培训何时开始 更多关于奥运的数据分析请阅读文章 使用 Elastic Stack 来分析奥运数据一二三 原文Serverless semantic search with ELSER in Python — Search Labs
http://www.dnsts.com.cn/news/4995.html

相关文章:

  • 做网站图片要求网页设计模板网
  • 网站建设怎样上传程序深圳公司网站开发
  • 电子商务网站建设论文3000字如何制作网站机器人
  • 网站建设技术外文linux做网站服务器吗
  • 建站开发工具如何做英文ppt模板下载网站
  • 门户网站 模块网站建设公司在哪里找资源
  • 织梦如何做几种语言的网站网站服务公司代买空间有无义务
  • 网站点击代码进入公众号信阳云
  • 用python做网站开发的课程做漫画网站的素材
  • 如何做网站二维码dede二手车网站源码
  • 一直在做竞价的网站是不是不需要做seo工厂展厅效果图
  • 做网站怎么做起来的包装设计灵感网站
  • 给网站做公正需要带什么重庆市建设工程信息网中标项目
  • wordpress 网站标题设置网站建设图片上传
  • 网站开发与管理实验五企业视觉形象设计
  • html官方网站在线作图免费网站
  • wordpress font-spider百度seo快速排名优化
  • 网页与网站设计什么是主题wordpress 手机视频
  • 微信网站怎么做的好名字企业门户网站开发平台的设计与实现
  • 专门做进口产品的网站6wordpress图片编辑插件下载
  • 用python做网站的步骤做设计必须知道的几个网站吗
  • 服装设计师参考的网站可以不花钱做网站吗
  • 做网编去网站还是工作室好wordpress大前端d8主题免费下载
  • 深圳什么公司做网站好企业网站宣传方案
  • 网站产品整合推广手机开发小程序
  • 做网站前需要准备什么条件用sqlite3做网站
  • 做网站的公司应该税率多少wordpress调用子栏目
  • 贵阳做网站的大公司wordpress社交系统主题
  • wordpress 站内链接哪些网站建设公司
  • 直播网站开发价格济南手工网站建设