Updated embeddings.ipynb (#531)

updated embeddings.ipynb
pull/539/head
Rubens Mau 2 years ago committed by GitHub
parent ca9aaac36e
commit 020e73017b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -77,36 +77,130 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"id": "42f76e43", "id": "42f76e43",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Cohere\n", "## Cohere\n",
"\n", "\n",
"TODO: add documentation for Cohere embeddings." "Let's load the Cohere Embedding class."
] ]
}, },
{ {
"cell_type": "code",
"execution_count": 1,
"id": "6b82f59f",
"metadata": {},
"outputs": [],
"source": [
"from langchain.embeddings import CohereEmbeddings"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "26895c60",
"metadata": {},
"outputs": [],
"source": [
"embeddings = CohereEmbeddings(cohere_api_key= cohere_api_key)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "eea52814",
"metadata": {},
"outputs": [],
"source": [
"text = \"This is a test document.\""
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "fbe167bf",
"metadata": {},
"outputs": [],
"source": [
"query_result = embeddings.embed_query(text)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "38ad3b20",
"metadata": {},
"outputs": [],
"source": [
"doc_result = embeddings.embed_documents([text])"
]
},
{
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"id": "ed47bb62", "id": "ed47bb62",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Hugging Face Hub\n", "## Hugging Face Hub\n",
"TODO: add documentation for Hugging Face Hub embeddings." "Let's load the Hugging Face Embedding class."
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 7,
"id": "861521a9",
"metadata": {},
"outputs": [],
"source": [
"from langchain.embeddings import HuggingFaceEmbeddings"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "ff9be586", "id": "ff9be586",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": [
"embeddings = HuggingFaceEmbeddings()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "d0a98ae9",
"metadata": {},
"outputs": [],
"source": [
"text = \"This is a test document.\""
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "5d6c682b",
"metadata": {},
"outputs": [],
"source": [
"query_result = embeddings.embed_query(text)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "bb5e74c0",
"metadata": {},
"outputs": [],
"source": [
"doc_result = embeddings.embed_documents([text])"
]
} }
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3 (ipykernel)", "display_name": "cohere",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },
@ -120,7 +214,12 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.10.9" "version": "3.10.8"
},
"vscode": {
"interpreter": {
"hash": "ce6f9b0d7cdac41515b0e0c38d0e6e153a2edce81d579281cb1ab99da6e8ea6d"
}
} }
}, },
"nbformat": 4, "nbformat": 4,

Loading…
Cancel
Save