TensorFlow Hub is a repository of trained machine learning models ready for fine-tuning and deployable anywhere. Reuse trained models like BERT and Faster R-CNN with just a few lines of code.
Let’s load the TensorflowHub Embedding class.
Copy
Ask AI
from langchain_community.embeddings import TensorflowHubEmbeddings
Copy
Ask AI
embeddings = TensorflowHubEmbeddings()
Copy
Ask AI
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 FMATo 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 FMATo enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Copy
Ask AI
text = "This is a test document."
Copy
Ask AI
query_result = embeddings.embed_query(text)
Copy
Ask AI
doc_results = embeddings.embed_documents(["foo"])
Copy
Ask AI
doc_results
Assistant
Responses are generated using AI and may contain mistakes.