跳到主要內容
Open In ColabOpen on GitHub

TensorFlow Hub

TensorFlow Hub 是一個已訓練好的機器學習模型儲存庫,可隨時進行微調並部署到任何地方。只需幾行程式碼,即可重複使用已訓練好的模型,例如 BERTFaster R-CNN

讓我們載入 TensorflowHub 嵌入類別。

from langchain_community.embeddings import TensorflowHubEmbeddings
API 參考文件:TensorflowHubEmbeddings
embeddings = TensorflowHubEmbeddings()
2023-01-30 23:53:01.652176: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-01-30 23:53:34.362802: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
text = "This is a test document."
query_result = embeddings.embed_query(text)
doc_results = embeddings.embed_documents(["foo"])
doc_results

此頁面是否對您有幫助?