久久精品色妇熟妇丰满人妻99,久久久网,和少妇疯狂做爰过程,欧美系列亚洲系列国产系列

廊坊新聞網-主流媒體,廊坊城市門戶

焦點速訊:基于任何數據集創(chuàng)建LLM(Large Language Models)機器人

2023-06-28 07:04:11 來源:Python七號

今天偶然翻到一個倉庫 Embedchain,覺得很實用,分享給大家。倉庫地址如下:

https://github.com/embedchain/embedchain

它是基于 OpenAI 的,但是你可以添加自己的數據集,然后生成一個對話機器人,使用方法簡單,很容易上手。


(資料圖)

Embedchain 簡介

Embedchain 是一個可以方便地基于任何數據集創(chuàng)建 LLM(Large Language Models)機器人的框架。它抽象了加載數據集、分塊、創(chuàng)建嵌入向量以及存儲在向量數據庫中的整個過程。你可以使用.add和.add_local函數添加單個或多個數據集,然后使用.query函數從添加的數據集中查找答案。

假如你崇拜一個很厲害的人 - Naval Ravikant,你想把他的知識做成一個對話機器人,你可以把他的 Youtube 視頻、PDF 書籍、博客文章,以及你提供的一個問題和答案對,添加到 Embedchain,Embedchain 將為你創(chuàng)建一個機器人。這是一個例子:

from embedchain import Appnaval_chat_bot = App()# 嵌入在線資源naval_chat_bot.add("youtube_video", "https://www.youtube.com/watch?v=3qHkcs3kG44")naval_chat_bot.add("pdf_file", "https://navalmanack.s3.amazonaws.com/Eric-Jorgenson_The-Almanack-of-Naval-Ravikant_Final.pdf")naval_chat_bot.add("web_page", "https://nav.al/feedback")naval_chat_bot.add("web_page", "https://nav.al/agi")# 嵌入本地資源naval_chat_bot.add_local("qna_pair", ("Who is Naval Ravikant?", "Naval Ravikant is an Indian-American entrepreneur and investor."))naval_chat_bot.query("What unique capacity does Naval argue humans possess when it comes to understanding explanations or concepts?")# 答案:Naval 認為,人類在理解解釋或概念方面擁有獨特的能力,這是在這個物理現實中可能的最大程度。
Embedchain 使用

要開始使用 Embedchain,首先確保你已經安裝了該包。如果還沒有安裝,可以使用pip進行安裝:

pip install embedchain

Embedchain使用 OpenAI 的嵌入模型創(chuàng)建塊的嵌入,使用 ChatGPT API 作為 LLM,給出相關文檔的答案。確保你有一個 OpenAI 帳戶和 API 密鑰。如果你沒有 API 密鑰,可以通過訪問此鏈接[1]創(chuàng)建一個。

一旦你有了 API 密鑰,將其設置在一個名為OPENAI_API_KEY的環(huán)境變量中

import osos.environ["OPENAI_API_KEY"] = "sk-xxxx"

接下來,從 embedchain 中導入App類并使用.add函數添加任何數據集。

from embedchain import Appnaval_chat_bot = App()# 嵌入在線資源naval_chat_bot.add("youtube_video", "https://www.youtube.com/watch?v=3qHkcs3kG44")naval_chat_bot.add("pdf_file", "https://navalmanack.s3.amazonaws.com/Eric-Jorgenson_The-Almanack-of-Naval-Ravikant_Final.pdf")naval_chat_bot.add("web_page", "https://nav.al/feedback")naval_chat_bot.add("web_page", "https://nav.al/agi")# 嵌入本地資源naval_chat_bot.add_local("qna_pair", ("Who is Naval Ravikant?", "Naval Ravikant is an Indian-American entrepreneur and investor."))

如果在你的腳本或應用中有任何其他的應用實例,你可以更改導入如下

from embedchain import App as EmbedChainApp# 或者from embedchain import App as ECApp

現在你的應用已經創(chuàng)建好了??梢允褂?query函數獲得任何查詢的答案。

print(naval_chat_bot.query("What unique capacity does Naval argue humans possess when it comes to understanding explanations or concepts?"))# answer: Naval argues that humans possess the unique capacity to understand explanations or concepts to the maximum extent possible in this physical reality.
支持的格式

支持以下格式:

Youtube 視頻

要將任何 Youtube 視頻添加到你的應用中,使用數據類型(.add的第一個參數)為youtube_video。例如:

app.add("youtube_video", "a_valid_youtube_url_here")
PDF 文件

要添加任何 PDF 文件,使用數據類型為pdf_file。例如:

app.add("pdf_file", "a_valid_url_where_pdf_file_can_be_accessed")

注意,不支持密碼保護的 PDF。

網頁

要添加任何網頁,使用數據類型為web_page。例如:

app.add("web_page", "a_valid_web_page_url")
文本

要提供你自己的文本,使用數據類型為text并輸入一個字符串。文本不會被處理,這可以非常多樣化。例如:

app.add_local("text", "Seek wealth, not money or status. Wealth is having assets that earn while you sleep. Money is how we transfer time and wealth. Status is your place in the social hierarchy.")

注意:這在示例中沒有使用,因為在大多數情況下,你將提供整個段落或文件。

關鍵詞: