Elasticsearch:將 Ollama 與推理 API 結合使用

作者:來自 Elastic?Jeffrey Rengifo

Ollama API 與 OpenAI API 兼容,因此將 Ollama 與 Elasticsearch 集成非常容易。

在本文中,我們將學習如何使用 Ollama 將本地模型連接到 Elasticsearch 推理模型,然后使用 Playground 向文檔提出問題。

Elasticsearch 允許用戶使用開放推理 API(Inference API)連接到 LLMs,支持 Amazon Bedrock、Cohere、Google AI、Azure AI Studio、HuggingFace 等提供商(作為服務)等。

Ollama 是一個工具,允許你使用自己的基礎設施(本地機器/服務器)下載和執行 LLM 模型。你可以在此處找到與 Ollama 兼容的可用型號列表。

如果你想要托管和測試不同的開源模型,而又不必擔心每個模型需要以不同的方式設置,或者如何創建 API 來訪問模型功能,那么 Ollama 是一個不錯的選擇,因為 Ollama 會處理所有事情。

由于 Ollama API 與 OpenAI API 兼容,我們可以輕松集成推理模型并使用 Playground 創建 RAG 應用程序。

更多閱讀,請參閱 “Elasticsearch:在 Elastic 中玩轉 DeepSeek R1 來實現 RAG 應用”。

先決條件

  • Elasticsearch 8.17
  • Kibana 8.17
  • Python

步驟

  • 設置 Ollama LLM 服務器
  • 創建映射
  • 索引數據
  • 使用 Playground 提問

設置 Ollama LLM 服務器

我們將設置一個 LLM 服務器,并使用 Ollama 將其連接到我們的 Playground 實例。我們需要:

  • 下載并運行 Ollama。
  • 使用 ngrok 通過互聯網訪問托管 Ollama 的本地 Web 服務器

下載并運行 Ollama

要使用Ollama,我們首先需要下載它。 Ollama 支持 Linux、Windows 和 macOS,因此只需在此處下載與你的操作系統兼容的 Ollama 版本即可。一旦安裝了 Ollama,我們就可以從這個受支持的 LLM 列表中選擇一個模型。在此示例中,我們將使用 llama3.2 模型,這是一個通用的多語言模型。在安裝過程中,你將啟用 Ollama 的命令行工具。下載完成后,你可以運行以下行:

ollama pull llama3.2

這將輸出:

pulling manifest
pulling dde5aa3fc5ff... 100% ▕█████████████████████████████████████████████████████████████████████████████████████████▏ 2.0 GB
pulling 966de95ca8a6... 100% ▕█████████████████████████████████████████████████████████████████████████████████████████▏ 1.4 KB
pulling fcc5a6bec9da... 100% ▕█████████████████████████████████████████████████████████████████████████████████████████▏ 7.7 KB
pulling a70ff7e570d9... 100% ▕█████████████████████████████████████████████████████████████████████████████████████████▏ 6.0 KB
pulling 56bb8bd477a5... 100% ▕█████████████████████████████████████████████████████████████████████████████████████████▏   96 B
pulling 34bb5ab01051... 100% ▕█████████████████████████████████████████████████████████████████████████████████████████▏  561 B
verifying sha256 digest
writing manifest
success

安裝后,你可以使用以下命令進行測試:

ollama run llama3.2

我們來問一個問題:

在模型運行時,Ollama 啟用默認在端口 “11434” 上運行的 API。讓我們按照官方文檔向該 API 發出請求:

curl http://localhost:11434/api/generate -d '{                                          "model": "llama3.2",               "prompt": "What is the capital of France?"
}' 

這是我們得到的答案:

{"model":"llama3.2","created_at":"2024-11-28T21:48:42.152817532Z","response":"The","done":false}
{"model":"llama3.2","created_at":"2024-11-28T21:48:42.251884485Z","response":" capital","done":false}
{"model":"llama3.2","created_at":"2024-11-28T21:48:42.347365913Z","response":" of","done":false}
{"model":"llama3.2","created_at":"2024-11-28T21:48:42.446837322Z","response":" France","done":false}
{"model":"llama3.2","created_at":"2024-11-28T21:48:42.542367394Z","response":" is","done":false}
{"model":"llama3.2","created_at":"2024-11-28T21:48:42.644580384Z","response":" Paris","done":false}
{"model":"llama3.2","created_at":"2024-11-28T21:48:42.739865362Z","response":".","done":false}
{"model":"llama3.2","created_at":"2024-11-28T21:48:42.834347518Z","response":"","done":true,"done_reason":"stop","context":[128006,9125,128007,271,38766,1303,33025,2696,25,6790,220,2366,18,271,128009,128006,882,128007,271,3923,374,279,6864,315,9822,30,128009,128006,78191,128007,271,791,6864,315,9822,374,12366,13],"total_duration":6948567145,"load_duration":4386106503,"prompt_eval_count":32,"prompt_eval_duration":1872000000,"eval_count":8,"eval_duration":684000000}

請注意,此端點的具體響應是流式傳輸。

使用 ngrok 將端點暴露給互聯網

由于我們的端點在本地環境中工作,因此無法通過互聯網從另一個點(如我們的 Elastic Cloud 實例)訪問它。 ngrok 允許我們公開提供公共 IP 的端口。在 ngrok 中創建一個帳戶并按照官方設置指南進行操作。

:這個有點類似在中國提供的 “花生殼” 功能。

一旦安裝并配置了 ngrok 代理,我們就可以使用以下命令公開 Ollama 端口:

ngrok http 11434 --host-header="localhost:11434"

注意:標頭 --host-header="localhost:11434" 保證請求中的 “Host” 標頭與 “localhost:11434” 匹配

執行此命令將返回一個公共鏈接,只要 ngrok 和 Ollama 服務器在本地運行,該鏈接就會起作用。

Session Status                online                                                                                                                                                                              
Account                       xxxx@yourEmailProvider.com (Plan: Free)                                                                                                                                             
Version                       3.18.4                                                                                                                                                                              
Region                        United States (us)                                                                                                                                                                  
Latency                       561ms                                                                                                                                                                               
Web Interface                 http://127.0.0.1:4040                                                                                                                                                               
Forwarding                    https://your-ngrok-url.ngrok-free.app -> http://localhost:11434                                                                                                                   Connections                   ttl     opn     rt1     rt5     p50     p90                                                                                                                                         0       0       0.00    0.00    0.00    0.00                                                ```

在 “Forwarding” 中我們可以看到 ngrok 生成了一個 URL。保存以供以后使用。

讓我們再次嘗試向端點發出 HTTP 請求,現在使用 ngrok 生成的 URL:

curl https://your-ngrok-endpoint.ngrok-free.app/api/generate -d '{                                          "model": "llama3.2",               "prompt": "What is the capital of France?"
}'

響應應與前一個類似。

創建映射

ELSER 端點

對于此示例,我們將使用 Elasticsearch 推理 API 創建一個推理端點。此外,我們將使用 ELSER 來生成嵌入。

PUT _inference/sparse_embedding/medicines-inference
{"service": "elasticsearch","service_settings": {"num_allocations": 1,"num_threads": 1,"model_id": ".elser_model_2_linux-x86_64"}
}

在這個例子中,假設你有一家藥店,銷售兩種類型的藥品:

  • 需要處方的藥物。
  • 不需要處方的藥物。

該信息將包含在每種藥物的描述字段中。

LLM 必須解釋這個字段,因此我們將使用以下數據映射:

PUT medicines
{"mappings": {"properties": {"name": {"type": "text","copy_to": "semantic_field"},"semantic_field": {"type": "semantic_text","inference_id": "medicines-inference"},"text_description": {"type": "text","copy_to": "semantic_field"}}}
}

字段 text_description 將存儲描述的純文本,而 semantic_field(一種 semantic_text 字段類型)將存儲由 ELSER 生成的嵌入。

copy_to 屬性將把字段 name 和 text_description 中的內容復制到語義字段中,以便生成這些字段的嵌入。

索引數據

現在,讓我們使用 _bulk API 對數據進行索引。

POST _bulk
{"index":{"_index":"medicines"}}
{"id":1,"name":"Paracetamol","text_description":"An analgesic and antipyretic that does NOT require a prescription."}
{"index":{"_index":"medicines"}}
{"id":2,"name":"Ibuprofen","text_description":"A nonsteroidal anti-inflammatory drug (NSAID) available WITHOUT a prescription."}
{"index":{"_index":"medicines"}}
{"id":3,"name":"Amoxicillin","text_description":"An antibiotic that requires a prescription."}
{"index":{"_index":"medicines"}}
{"id":4,"name":"Lorazepam","text_description":"An anxiolytic medication that strictly requires a prescription."}
{"index":{"_index":"medicines"}}
{"id":5,"name":"Omeprazole","text_description":"A medication for stomach acidity that does NOT require a prescription."}
{"index":{"_index":"medicines"}}
{"id":6,"name":"Insulin","text_description":"A hormone used in diabetes treatment that requires a prescription."}
{"index":{"_index":"medicines"}}
{"id":7,"name":"Cold Medicine","text_description":"A compound formula to relieve flu symptoms available WITHOUT a prescription."}
{"index":{"_index":"medicines"}}
{"id":8,"name":"Clonazepam","text_description":"An antiepileptic medication that requires a prescription."}
{"index":{"_index":"medicines"}}
{"id":9,"name":"Vitamin C","text_description":"A dietary supplement that does NOT require a prescription."}
{"index":{"_index":"medicines"}}
{"id":10,"name":"Metformin","text_description":"A medication used for type 2 diabetes that requires a prescription."}

響應:

{"errors": false,"took": 34732020848,"items": [{"index": {"_index": "medicines","_id": "mYoeMpQBF7lnCNFTfdn2","_version": 1,"result": "created","_shards": {"total": 2,"successful": 2,"failed": 0},"_seq_no": 0,"_primary_term": 1,"status": 201}},{"index": {"_index": "medicines","_id": "mooeMpQBF7lnCNFTfdn2","_version": 1,"result": "created","_shards": {"total": 2,"successful": 2,"failed": 0},"_seq_no": 1,"_primary_term": 1,"status": 201}},{"index": {"_index": "medicines","_id": "m4oeMpQBF7lnCNFTfdn2","_version": 1,"result": "created","_shards": {"total": 2,"successful": 2,"failed": 0},"_seq_no": 2,"_primary_term": 1,"status": 201}},{"index": {"_index": "medicines","_id": "nIoeMpQBF7lnCNFTfdn2","_version": 1,"result": "created","_shards": {"total": 2,"successful": 2,"failed": 0},"_seq_no": 3,"_primary_term": 1,"status": 201}},{"index": {"_index": "medicines","_id": "nYoeMpQBF7lnCNFTfdn2","_version": 1,"result": "created","_shards": {"total": 2,"successful": 2,"failed": 0},"_seq_no": 4,"_primary_term": 1,"status": 201}},{"index": {"_index": "medicines","_id": "nooeMpQBF7lnCNFTfdn2","_version": 1,"result": "created","_shards": {"total": 2,"successful": 2,"failed": 0},"_seq_no": 5,"_primary_term": 1,"status": 201}},{"index": {"_index": "medicines","_id": "n4oeMpQBF7lnCNFTfdn2","_version": 1,"result": "created","_shards": {"total": 2,"successful": 2,"failed": 0},"_seq_no": 6,"_primary_term": 1,"status": 201}},{"index": {"_index": "medicines","_id": "oIoeMpQBF7lnCNFTfdn2","_version": 1,"result": "created","_shards": {"total": 2,"successful": 2,"failed": 0},"_seq_no": 7,"_primary_term": 1,"status": 201}},{"index": {"_index": "medicines","_id": "oYoeMpQBF7lnCNFTfdn2","_version": 1,"result": "created","_shards": {"total": 2,"successful": 2,"failed": 0},"_seq_no": 8,"_primary_term": 1,"status": 201}},{"index": {"_index": "medicines","_id": "oooeMpQBF7lnCNFTfdn2","_version": 1,"result": "created","_shards": {"total": 2,"successful": 2,"failed": 0},"_seq_no": 9,"_primary_term": 1,"status": 201}}]}

使用 Playground 提問

Playground 是一個 Kibana 工具,允許你使用 Elasticsearch 索引和 LLM 提供程序快速創建 RAG 系統。你可以閱讀本文以了解更多信息。

將本地 LLM 連接到 Playground

我們首先需要創建一個使用我們剛剛創建的公共 URL 的連接器。在 Kibana 中,轉到 Search>Playground,然后單擊 “Connect to an LLM”。

此操作將顯示 Kibana 界面左側的菜單。在那里,點擊 “OpenAI”。

我們現在可以開始配置 OpenAI 連接器。

轉到 “Connector settings”,對于 OpenAI 提供商,選擇 “Other (OpenAI Compatible Service)”:

現在,讓我們配置其他字段。在這個例子中,我們將我們的模型命名為 “medicines-llm”。在 URL 字段中,使用 ngrok 生成的 URL(/v1/chat/completions)。在 “Default model” 字段中,選擇 “llama3.2”。我們不會使用 API 密鑰,因此只需輸入任何隨機文本即可繼續:

點擊 “Save”,點擊 “Add data sources” 添加索引藥品:

太棒了!我們現在可以使用在本地運行的 LLM 作為 RAG 引擎來訪問 Playground。

在測試之前,讓我們向代理添加更具體的指令,并將發送給模型的文檔數量增加到 10,以便答案具有盡可能多的可用文檔。上下文字段將是 semantic_field,它包括藥物的名稱和描述,這要歸功于 copy_to 屬性。

現在讓我們問一個問題:Can I buy Clonazepam without a prescription??看看會發生什么:

https://drive.google.com/file/d/1WOg9yJ2Vs5ugmXk9_K9giZJypB8jbxuN/view?usp=drive_link

正如我們所料,我們得到了正確的答案。

后續步驟

下一步是創建你自己的應用程序! Playground 提供了一個 Python 代碼腳本,你可以在自己的機器上運行它并自定義它以滿足你的需要。例如,通過將其置于 FastAPI 服務器后面來創建由你的 UI 使用的 QA 藥品聊天機器人。

你可以通過點擊 Playground 右上角的?View code?按鈕找到此代碼:

并且你使用 Endpoints & API keys?生成代碼中所需的 ES_API_KEY 環境變量。

對于此特定示例,代碼如下:

## Install the required packages
## pip install -qU elasticsearch openai
import os
from elasticsearch import Elasticsearch
from openai import OpenAI
es_client = Elasticsearch("https://your-deployment.us-central1.gcp.cloud.es.io:443",api_key=os.environ["ES_API_KEY"]
)
openai_client = OpenAI(api_key=os.environ["OPENAI_API_KEY"],
)
index_source_fields = {"medicines": ["semantic_field"]
}
def get_elasticsearch_results():es_query = {"retriever": {"standard": {"query": {"nested": {"path": "semantic_field.inference.chunks","query": {"sparse_vector": {"inference_id": "medicines-inference","field": "semantic_field.inference.chunks.embeddings","query": query}},"inner_hits": {"size": 2,"name": "medicines.semantic_field","_source": ["semantic_field.inference.chunks.text"]}}}}},"size": 3}result = es_client.search(index="medicines", body=es_query)return result["hits"]["hits"]
def create_openai_prompt(results):context = ""for hit in results:inner_hit_path = f"{hit['_index']}.{index_source_fields.get(hit['_index'])[0]}"## For semantic_text matches, we need to extract the text from the inner_hitsif 'inner_hits' in hit and inner_hit_path in hit['inner_hits']:context += '\n --- \n'.join(inner_hit['_source']['text'] for inner_hit in hit['inner_hits'][inner_hit_path]['hits']['hits'])else:source_field = index_source_fields.get(hit["_index"])[0]hit_context = hit["_source"][source_field]context += f"{hit_context}\n"prompt = f"""Instructions:- You are an assistant specializing in answering questions about the sale of medicines.- Answer questions truthfully and factually using only the context presented.- If you don't know the answer, just say that you don't know, don't make up an answer.- You must always cite the document where the answer was extracted using inline academic citation style [], using the position.- Use markdown format for code examples.- You are correct, factual, precise, and reliable.Context:{context}"""return prompt
def generate_openai_completion(user_prompt, question):response = openai_client.chat.completions.create(model="gpt-3.5-turbo",messages=[{"role": "system", "content": user_prompt},{"role": "user", "content": question},])return response.choices[0].message.content
if __name__ == "__main__":question = "my question"elasticsearch_results = get_elasticsearch_results()context_prompt = create_openai_prompt(elasticsearch_results)openai_completion = generate_openai_completion(context_prompt, question)print(openai_completion)

為了使其與 Ollama 一起工作,你必須更改 OpenAI 客戶端以連接到 Ollama 服務器而不是 OpenAI 服務器。你可以在此處找到 OpenAI 示例和兼容端點的完整列表。

openai_client = OpenAI(# you can use http://localhost:11434/v1/ if running this code locally.base_url='https://your-ngrok-url.ngrok-free.app/v1/',# required but ignoredapi_key='ollama',
)

并且在調用完成方法時將模型更改為 llama3.2:

def generate_openai_completion(user_prompt, question):response = openai_client.chat.completions.create(model="llama3.2",messages=[{"role": "system", "content": user_prompt},{"role": "user", "content": question},])return response.choices[0].message.content

讓我們添加一個問題:an I buy Clonazepam without a prescription??對于 Elasticsearch 查詢:

def get_elasticsearch_results():es_query = {"retriever": {"standard": {"query": {"nested": {"path": "semantic_field.inference.chunks","query": {"sparse_vector": {"inference_id": "medicines-inference","field": "semantic_field.inference.chunks.embeddings","query": "Can I buy Clonazepam without a prescription?"}},"inner_hits": {"size": 2,"name": "medicines.semantic_field","_source": ["semantic_field.inference.chunks.text"]}}}}},"size": 3}result = es_client.search(index="medicines", body=es_query)return result["hits"]["hits"]

另外,在完成調用時還會打印一些內容,這樣我們就可以確認我們正在將 Elasticsearch 結果作為問題上下文的一部分發送:

if __name__ == "__main__":question = "Can I buy Clonazepam without a prescription?"elasticsearch_results = get_elasticsearch_results()context_prompt = create_openai_prompt(elasticsearch_results)print("========== Context Prompt START ==========")print(context_prompt)print("========== Context Prompt END ==========")print("========== Ollama Completion START ==========")openai_completion = generate_openai_completion(context_prompt, question)print(openai_completion)print("========== Ollama Completion END ==========")

現在讓我們運行命令:

pip install -qU elasticsearch openaipython main.py

你應該看到類似這樣的內容:

========== Context Prompt START ==========Instructions:- You are an assistant specializing in answering questions about the sale of medicines.- Answer questions truthfully and factually using only the context presented.- If you don't know the answer, just say that you don't know, don't make up an answer.- You must always cite the document where the answer was extracted using inline academic citation style [], using the position.- Use markdown format for code examples.- You are correct, factual, precise, and reliable.Context:Clonazepam---
An antiepileptic medication that requires a prescription.A nonsteroidal anti-inflammatory drug (NSAID) available WITHOUT a prescription.---
IbuprofenAn anxiolytic medication that strictly requires a prescription.---
Lorazepam========== Context Prompt END ==========
========== Ollama Completion START ==========
No, you cannot buy Clonazepam over-the-counter (OTC) without a prescription [1]. It is classified as a controlled substance in the United States due to its potential for dependence and abuse. Therefore, it can only be obtained from a licensed healthcare provider who will issue a prescription for this medication.
========== Ollama Completion END ==========

結論

在本文中,我們可以看到,當將 Ollama 等工具與 Elasticsearch 推理 API 和 Playground 結合使用時,它們的強大功能和多功能性。

經過幾個簡單的步驟,我們就得到了一個可以運行的 RAG 應用程序,該應用程序可以使用 LLM 在我們自己的基礎設施中免費運行的聊天功能。這還使我們能夠更好地控制資源和敏感信息,同時還使我們能夠訪問用于不同任務的各種模型。

想要獲得 Elastic 認證嗎?了解下一期 Elasticsearch 工程師培訓何時舉行!

Elasticsearch 包含許多新功能,可幫助你為你的用例構建最佳的搜索解決方案。深入了解我們的示例筆記本以了解更多信息,開始免費云試用,或立即在本地機器上試用 Elastic。

原文:Using Ollama with the Inference API - Elasticsearch Labs

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/70073.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/70073.shtml
英文地址,請注明出處:http://en.pswp.cn/web/70073.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

openGauss 3.0 數據庫在線實訓課程18:學習視圖管理

前提 我正在參加21天養成好習慣| 第二屆openGauss每日一練活動 課程詳見:openGauss 3.0.0數據庫在線實訓課程 學習目標 掌握openGauss視圖的管理:創建視圖、刪除視圖、查詢視圖的信息、修改視圖的信息。 課程作業 1.創建表,創建普通視圖…

騰訊云大模型知識引擎×DeepSeek賦能文旅

騰訊云大模型知識引擎DeepSeek賦能文旅 ——以合肥文旅為例的技術革新與實踐路徑 一、技術底座:知識引擎與DeepSeek的融合邏輯 騰訊云大模型知識引擎與DeepSeek模型的結合,本質上是**“知識庫檢索增強生成(RAG)實時聯網能力”**…

利用SkinMagic美化MFC應用界面

MFC(Microsoft Foundation Class)應用程序的界面設計風格通常比較保守,而且雖然MFC框架的控件功能強大且易于集成,但視覺效果較為樸素,缺乏現代感。尤其是MFC應用程序的設計往往以功能實現為核心,界面設計可能顯得較為簡潔甚至略顯呆板,用戶體驗可能不如現代應用程序流暢…

qt QOpenGLTexture詳解

1. 概述 QOpenGLTexture 是 Qt5 提供的一個類,用于表示和管理 OpenGL 紋理。它封裝了 OpenGL 紋理的創建、分配存儲、綁定和設置像素數據等操作,簡化了 OpenGL 紋理的使用。 2. 重要函數 構造函數: QOpenGLTexture(const QImage &image,…

nlp|微調大語言模型初探索(2),訓練自己的聊天機器人

前言 上篇文章記錄了具體的微調語言大模型步驟,以及在微調過程中可能遇見的各種報錯,美中不足的是只是基于開源數據集的微調,今天來記錄一下怎么基于自己的數據集去微調大語言模型,訓練自己的智能機器人!!&…

Java 大視界 -- 量子計算時代 Java 大數據的潛在變革與應對策略(88)

💖親愛的朋友們,熱烈歡迎來到 青云交的博客!能與諸位在此相逢,我倍感榮幸。在這飛速更迭的時代,我們都渴望一方心靈凈土,而 我的博客 正是這樣溫暖的所在。這里為你呈上趣味與實用兼具的知識,也…

手機功耗BugReport字段含義介紹

BugReport一般用來分析功耗問題,例如休眠待機,后臺待機,游戲,視頻,相機場景等 BugReport字段含義介紹 BugReport字段 含義 備注 Reboot 設備的重啟事件 CPU running CPU運行狀態,休眠 或者 喚醒 只有…

什么是 近端策略優化算法PPO

什么是 近端策略優化算法PPO 近端策略優化算法(Proximal Policy Optimization,PPO)是OpenAI公司于2017年開發的一系列無模型強化學習算法,用于優化策略網絡以最大化累計獎勵。以下是具體介紹及示例: 算法原理 策略梯度:PPO基于策略梯度算法,通過估計策略網絡的梯度來更…

計算機視覺-局部特征

一、局部特征 1.1全景拼接 先用RANSAC估計出變換,就可以拼接兩張圖片 ①提取特征 ②匹配特征 ③拼接圖像 1.2 點的特征 怎么找到對應點?(才能做點對應關系RANSAC) :特征檢測 我們希望找到的點具有的特征有什么特…

個人搭建CDN加速服務 特網科技

在互聯網快速發展的今天,網站的加載速度對用戶體驗有著至關重要的影響,傳統的網頁加載方式依賴于服務器的性能和網絡環境,這使得某些網站的頁面加載時間過長,用戶體驗不佳,為了解決這個問題,許多企業開始采…

類型通配符上限

主函數 package typeWildcardTop;import java.util.ArrayList;public class typeWildcardTopTest {/**/public static void main(String[] args) { // test1();test2();}/*測試showList接收ArrayList類型 ArrayList接收各種類型參數創建animals cats mincats集合 傳入s…

OpenCV(1):簡介、安裝、入門案例、基礎模塊

1 OpenCV 簡介 OpenCV 是一個功能強大、應用廣泛的計算機視覺庫,它為開發人員提供了豐富的工具和算法,可以幫助他們快速構建各種視覺應用。隨著計算機視覺技術的不斷發展,OpenCV 也將會繼續發揮重要的作用。OpenCV 提供了大量的計算機視覺算法…

FTP自動上傳/vue打包自動上傳

ftp自動上傳 在我們平時開發項目時,需要將本地代碼編譯后上傳到服務器,我們可以借助Node.js庫中的ssh2來實現自動上傳 首先我們先來說下ssh2的安裝和使用 安裝ssh2 npm install ssh2創建ssh2實例 const { Client } require(ssh2);連接服務器 const c…

SQL復習

SQL復習 MySQL SQL介紹 SQL SQL的全拼是什么? SQL全拼:Structured Query Language,也叫結構化查詢語言。 SQL92和SQL99有什么區別呢? SQL92和SQL99分別代表了92年和99年頒布的SQL標準。 在 SQL92 中采用(&#xff…

nlp|微調大語言模型初探索(1),LLaMA-Factory

前言 微調模型通常比從零開始訓練一個模型的技術要求低。公司不需要擁有大量的深度學習專家,利用現有的開源工具和庫(如Hugging Face的Transformers等),中小型公司可以輕松地使用和微調大型模型,從而快速實現AI能力的集…

軟件定義汽車時代的功能安全和信息安全

我是穿拖鞋的漢子,魔都中堅持長期主義的汽車電子工程師。 老規矩,分享一段喜歡的文字,避免自己成為高知識低文化的工程師: 簡單,單純,喜歡獨處,獨來獨往,不易合同頻過著接地氣的生活…

內容中臺驅動企業數字化內容管理高效協同架構

內容概要 在數字化轉型加速的背景下,企業對內容管理的需求從單一存儲向全鏈路協同演進。內容中臺作為核心支撐架構,通過統一的內容資源池與智能化管理工具,重塑了內容生產、存儲、分發及迭代的流程。其核心價值在于打破部門壁壘,…

【探商寶】:大數據與AI賦能,助力中小企業精準拓客引

引言:在數據洪流中,如何精準鎖定商機? 在競爭激烈的商業環境中,中小企業如何從海量信息中快速篩選出高價值客戶?如何避免無效溝通,精準觸達目標企業? 探商寶——一款基于大數據與AI技術的企業信…

springboot接入ShardingJDBC

ShardingJDBC 是 Apache ShardingSphere 的一個子項目,它是一個開源的分庫分表中間件,提供了透明化的數據分片、分布式事務和數據庫治理等功能。ShardingJDBC 以 JDBC Driver 的形式提供,支持任何基于 JDBC 的 ORM 框架、持久層框架和數據庫連…

Dify平臺搭建面試機器人

無代碼搭建面試機器人 什么是Dify 什么是Dify Dify 是一款開源的大語言模型(LLM) 應用開發平臺。它融合了后端即服務(Backend as Service)和 LLMOps 的理念,使開發者可以快速搭建生產級的生成式 AI 應用。即使你是非技術人員,也能…