作者:Tim Grein
我們很高興地宣布在 Elasticsearch 中推出的最新創(chuàng)新:在 Elastic 的 inference API 中集成了 OpenAI Chat Completions 功能。這一新特性標(biāo)志著我們在整合尖端人工智能能力至 Elasticsearch 的旅程中又邁出了一步,提供了生成類人文本完成等更多易于使用的功能。
更多關(guān)于 OpenAI Chat Completions 的用法,請閱讀文章 “ChatGPT 和 Elasticsearch:OpenAI 遇見私有數(shù)據(jù)(二)”
Elastic 持續(xù)創(chuàng)新的本質(zhì)
Elastic 在所有的人工智能領(lǐng)域都進行了大量投資。我們最近發(fā)布了許多新功能和令人振奮的集成:
- Elasticsearch 的開發(fā) inference API 增加了對 Cohere 嵌入的支持
- 引入 Elasticsearch 向量數(shù)據(jù)庫到 Azure OpenAI 服務(wù)的數(shù)據(jù)上(預(yù)覽版)
- 加速多圖向量搜索
- ……探索更多 Elasticsearch labs 的內(nèi)容,了解最近的發(fā)展情況。
我們的 inference API 中的新 completion 任務(wù)類型,作為第一個支持提供商,已經(jīng)在我們的 Elastic Cloud 的 stateless 提供中可用。它將很快在我們的下一個版本中向所有人提供。
使用新的 completion API
在這個簡短的指南中,我們將展示如何在文檔攝入過程中使用 inference?API 中的新 completion task 類型的簡單示例。請參考 Elastic Search Labs 的 GitHub 倉庫以獲取更深入的指南和交互式筆記本。
要使以下指南工作,你需要擁有一個活躍的 OpenAI 賬戶并獲取一個 API 密鑰。請參考 OpenAI 的快速啟動指南了解你需要遵循的步驟。你可以選擇 OpenAI 的多種模型中的一種。在以下示例中,我們使用了 gpt-3.5-turbo
。
在 Kibana 中,你將可以使用控制臺輸入以下步驟到 Elasticsearch,無需設(shè)置 IDE。
首先,你需要配置一個將執(zhí)行 completion 任務(wù)的模型:
PUT _inference/completion/openai_chat_completions
{
"service": "openai",
"service_settings": {
"api_key": <api-key>,
"model_id": "gpt-3.5-turbo"
}
}
運行此命令后,你應(yīng)該會看到相應(yīng)的 200 OK
狀態(tài),表明模型已正確設(shè)置,可以對任意文本進行推理。
現(xiàn)在,你可以調(diào)用配置的模型對任意文本輸入進行推理:
POST _inference/completion/openai_chat_completions
{
"input": "What is Elastic?"
}
你將收到一個類似于下面的帶有狀態(tài)碼 200 OK
的響應(yīng):
{
"completion": [
{
"result": "Elastic is a software company that provides a range of products and solutions for search, logging, security, and analytics. Its flagship product, Elasticsearch, is a distributed, RESTful search and analytics engine that is used for full-text search, structured search, and analytics. Elastic also offers other products such as Logstash for log collection and parsing, Kibana for data visualization and dashboarding, and Beats for lightweight data shippers. These products can be combined to create powerful data analysis and monitoring solutions for organizations of all sizes."
}
]
}
下一個命令創(chuàng)建了一個示例文檔,我們將使用剛剛配置的模型對其進行總結(jié):
POST _bulk
{ "index" : { "_index" : "docs" } }
{"content": "You know, for search (and analysis) Elasticsearch is the distributed search and analytics engine at the heart of the Elastic Stack. Logstash and Beats facilitate collecting, aggregating, and enriching your data and storing it in Elasticsearch. Kibana enables you to interactively explore, visualize, and share insights into your data and manage and monitor the stack. Elasticsearch is where the indexing, search, and analysis magic happens. Elasticsearch provides near real-time search and analytics for all types of data. Whether you have structured or unstructured text, numerical data, or geospatial data, Elasticsearch can efficiently store and index it in a way that supports fast searches. You can go far beyond simple data retrieval and aggregate information to discover trends and patterns in your data. And as your data and query volume grows, the distributed nature of Elasticsearch enables your deployment to grow seamlessly right along with it. While not every problem is a search problem, Elasticsearch offers speed and flexibility to handle data in a wide variety of use cases: Add a search box to an app or website Store and analyze logs, metrics, and security event data Use machine learning to automatically model the behavior of your data in real time Use Elasticsearch as a vector database to create, store, and search vector embeddings Automate business workflows using Elasticsearch as a storage engine Manage, integrate, and analyze spatial information using Elasticsearch as a geographic information system (GIS) Store and process genetic data using Elasticsearch as a bioinformatics research tool We’re continually amazed by the novel ways people use search. But whether your use case is similar to one of these, or you’re using Elasticsearch to tackle a new problem, the way you work with your data, documents, and indices in Elasticsearch is the same."}
為了總結(jié)多個文檔,我們將使用一個 ingest pipeline,其中包含腳本處理器、推理處理器和刪除處理器,來設(shè)置我們的摘要管道。
PUT _ingest/pipeline/summarization_pipeline
{
"processors": [
{
"script": {
"source": "ctx.prompt = 'Please summarize the following text: ' + ctx.content"
}
},
{
"inference": {
"model_id": "openai_chat_completions",
"input_output": {
"input_field": "prompt",
"output_field": "summary"
}
}
},
{
"remove": {
"field": "prompt"
}
}
]
}
該管道簡單地在內(nèi)容中加上了指令 “Please summarize the following text:?”,放在一個臨時字段中,這樣配置的模型就知道該如何處理文本了。當(dāng)然,你可以根據(jù)需要更改這個文本,這就可以解鎖各種其他流行的用例:
- 問答
- 翻譯
- ...等等!
管道在執(zhí)行推理后刪除臨時字段。
現(xiàn)在,我們通過調(diào)用 reindex API 將我們的文檔(們)通過摘要管道發(fā)送出去。
POST _reindex
{
"source": {
"index": "docs",
"size": 50
},
"dest": {
"index": "docs_summaries",
"pipeline": "summarization_pipeline"
}
}
你的文檔現(xiàn)已被總結(jié),可以進行搜索了。
POST docs_summaries/_search
{
"query": {
"match_all": { }
}
}
這就是全部內(nèi)容了, 你只需通過幾個簡單的 API 調(diào)用就創(chuàng)建了一個強大的摘要化流水線,可與任何攝取機制一起使用!摘要化非常實用,例如在生成語義嵌入或?qū)⒋蠖挝谋巨D(zhuǎn)換為簡潔摘要之前,對大段文本進行摘要化。這可以降低存儲成本,提高價值交付速度,例如,如果你只對大型文檔的摘要感興趣等。順便說一句,如果你想從二進制文檔中提取文本,可以查看我們的開源數(shù)據(jù)提取服務(wù)!
前景令人興奮
但我們不會止步于此。我們正在將 Cohere 的聊天功能作為我們的 completion
任務(wù)的另一個提供商進行整合。我們還在積極探索與 completion API 結(jié)合的新的檢索和攝取用例?,F(xiàn)在就將 Elastic Search Labs 加入書簽,隨時獲取最新信息!
準(zhǔn)備在你的應(yīng)用中構(gòu)建 RAG 嗎?想嘗試使用向量數(shù)據(jù)庫的不同 LLMs 嗎? 請查看我們在 Github 上的 LangChain、Cohere 等樣本 notebooks,并加入即將開始的 Elasticsearch 工程師培訓(xùn)!文章來源:http://www.zghlxwxcb.cn/news/detail-856783.html
原文:Elasticsearch open inference API adds support for OpenAI chat completions — Elastic Search Labs文章來源地址http://www.zghlxwxcb.cn/news/detail-856783.html
到了這里,關(guān)于Elasticsearch 開放 inference API 增加了對 OpenAI chat completions 的支持的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!