Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: moving FireworksEmbeddings documentation to docs folder #19398

Merged
merged 3 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
118 changes: 118 additions & 0 deletions docs/docs/integrations/text_embedding/fireworks.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "b14a24db",
"metadata": {},
"source": [
"# FireworksEmbeddings\n",
"\n",
"This notebook explains how to use Fireworks Embeddings, which is included in the langchain_fireworks package, to embed texts in langchain. We use the default nomic-ai v1.5 model in this example."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0ab948fc",
"metadata": {},
"outputs": [],
"source": [
"%pip install -qU langchain-fireworks"
]
},
{
"cell_type": "markdown",
"id": "67c637ca",
"metadata": {},
"source": [
"## Setup"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "5709b030",
"metadata": {},
"outputs": [],
"source": [
"from langchain_fireworks import FireworksEmbeddings"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3d81e58c",
"metadata": {},
"outputs": [],
"source": [
"import getpass\n",
"import os\n",
"\n",
"if \"FIREWORKS_API_KEY\" not in os.environ:\n",
" os.environ[\"FIREWORKS_API_KEY\"] = getpass.getpass(\"Fireworks API Key:\")"
]
},
{
"cell_type": "markdown",
"id": "4a2a098d",
"metadata": {},
"source": [
"# Using the Embedding Model\n",
"With `FireworksEmbeddings`, you can directly use the default model 'nomic-ai/nomic-embed-text-v1.5', or set a different one if available."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "584b9af5",
"metadata": {},
"outputs": [],
"source": [
"embedding = FireworksEmbeddings(mode=\"nomic-ai/nomic-embed-text-v1.5\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "be18b873",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.01367950439453125, 0.0103607177734375, -0.157958984375, -0.003070831298828125, 0.05926513671875]\n",
"[0.0369873046875, 0.00545501708984375, -0.179931640625, -0.018707275390625, 0.0552978515625]\n"
]
}
],
"source": [
"res_query = embedding.embed_query(\"The test information\")\n",
"res_document = embedding.embed_documents([\"test1\", \"another test\"])\n",
"print(res_query[:5])\n",
"print(res_document[1][:5])"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "poetry-venv-2",
"language": "python",
"name": "poetry-venv-2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
}
},
"nbformat": 4,
"nbformat_minor": 5
}