chroma docs (#1012)

This commit is contained in:
Harrison Chase
2023-02-12 23:02:01 -08:00
committed by GitHub
parent 0c553d2064
commit 7fb33fca47
18 changed files with 354 additions and 179 deletions

View File

@@ -23,7 +23,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"id": "8244ff60",
"metadata": {},
"outputs": [],
@@ -43,7 +43,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 4,
"id": "7c469c95",
"metadata": {},
"outputs": [],
@@ -54,7 +54,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 5,
"id": "0ec6d950",
"metadata": {},
"outputs": [],
@@ -71,7 +71,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 6,
"id": "207e55f7",
"metadata": {},
"outputs": [],
@@ -105,7 +105,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 7,
"id": "d00b4385",
"metadata": {},
"outputs": [
@@ -142,7 +142,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 8,
"id": "878bcde9",
"metadata": {},
"outputs": [
@@ -168,7 +168,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 9,
"id": "e4bebcd9",
"metadata": {},
"outputs": [
@@ -220,22 +220,31 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 10,
"id": "241bfe80",
"metadata": {},
"outputs": [],
"source": [
"from langchain.prompts.example_selector import SemanticSimilarityExampleSelector\n",
"from langchain.vectorstores import FAISS\n",
"from langchain.vectorstores import Chroma\n",
"from langchain.embeddings import OpenAIEmbeddings"
]
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 11,
"id": "50d0a701",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running Chroma using direct local API.\n",
"Using DuckDB in-memory for database. Data will be transient.\n"
]
}
],
"source": [
"example_selector = SemanticSimilarityExampleSelector.from_examples(\n",
" # This is the list of examples available to select from.\n",
@@ -243,7 +252,7 @@
" # This is the embedding class used to produce embeddings which are used to measure semantic similarity.\n",
" OpenAIEmbeddings(), \n",
" # This is the VectorStore class that is used to store the embeddings and do a similarity search over.\n",
" FAISS, \n",
" Chroma, \n",
" # This is the number of examples to produce.\n",
" k=1\n",
")\n",
@@ -259,7 +268,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 12,
"id": "4c8fdf45",
"metadata": {},
"outputs": [
@@ -284,7 +293,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 13,
"id": "829af21a",
"metadata": {
"scrolled": true
@@ -311,7 +320,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 14,
"id": "3c16fe23",
"metadata": {},
"outputs": [
@@ -347,17 +356,18 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 18,
"id": "ac95c968",
"metadata": {},
"outputs": [],
"source": [
"from langchain.prompts.example_selector import MaxMarginalRelevanceExampleSelector"
"from langchain.prompts.example_selector import MaxMarginalRelevanceExampleSelector\n",
"from langchain.vectorstores import FAISS"
]
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 19,
"id": "db579bea",
"metadata": {},
"outputs": [],
@@ -384,7 +394,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 20,
"id": "cd76e344",
"metadata": {},
"outputs": [
@@ -412,7 +422,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 21,
"id": "cf82956b",
"metadata": {},
"outputs": [
@@ -422,9 +432,6 @@
"text": [
"Give the antonym of every input\n",
"\n",
"Input: happy\n",
"Output: sad\n",
"\n",
"Input: enthusiastic\n",
"Output: apathetic\n",
"\n",
@@ -696,7 +703,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"version": "3.9.1"
}
},
"nbformat": 4,

View File

@@ -242,6 +242,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Running Chroma using direct local API.\n",
"Using DuckDB in-memory for database. Data will be transient.\n",
"Examples most similar to the input: Who was the father of Mary Ball Washington?\n",
"\n",
"\n",
@@ -259,7 +261,7 @@
],
"source": [
"from langchain.prompts.example_selector import SemanticSimilarityExampleSelector\n",
"from langchain.vectorstores import FAISS\n",
"from langchain.vectorstores import Chroma\n",
"from langchain.embeddings import OpenAIEmbeddings\n",
"\n",
"\n",
@@ -269,7 +271,7 @@
" # This is the embedding class used to produce embeddings which are used to measure semantic similarity.\n",
" OpenAIEmbeddings(),\n",
" # This is the VectorStore class that is used to store the embeddings and do a similarity search over.\n",
" FAISS,\n",
" Chroma,\n",
" # This is the number of examples to produce.\n",
" k=1\n",
")\n",
@@ -328,6 +330,14 @@
"\n",
"print(prompt.format(input=\"Who was the father of Mary Ball Washington?\"))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "84c43b97",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
@@ -346,7 +356,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"version": "3.9.1"
},
"vscode": {
"interpreter": {

View File

@@ -71,7 +71,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"id": "094229f4",
"metadata": {},
"outputs": [],
@@ -81,7 +81,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 4,
"id": "ab46bd2a",
"metadata": {},
"outputs": [
@@ -91,7 +91,7 @@
"'Tell me a joke.'"
]
},
"execution_count": 2,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
@@ -104,7 +104,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 5,
"id": "c3ad0fa8",
"metadata": {},
"outputs": [
@@ -114,7 +114,7 @@
"'Tell me a funny joke.'"
]
},
"execution_count": 3,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
@@ -127,7 +127,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"id": "ba577dcf",
"metadata": {},
"outputs": [
@@ -137,7 +137,7 @@
"'Tell me a funny joke about chickens.'"
]
},
"execution_count": 4,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@@ -162,7 +162,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 7,
"id": "d0a0756c",
"metadata": {},
"outputs": [],
@@ -173,7 +173,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 8,
"id": "59046640",
"metadata": {},
"outputs": [
@@ -183,7 +183,7 @@
"PromptTemplate(input_variables=['adjective', 'content'], output_parser=None, template='Tell me a {adjective} joke about {content}.', template_format='f-string', validate_template=True)"
]
},
"execution_count": 3,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
@@ -204,7 +204,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 9,
"id": "53b41b6a",
"metadata": {},
"outputs": [],
@@ -226,7 +226,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 10,
"id": "ba8aabd3",
"metadata": {},
"outputs": [
@@ -236,7 +236,7 @@
"'\\n\\nQuestion: foo\\nAnswer: bar\\n\\nQuestion: 1\\nAnswer: 2\\n'"
]
},
"execution_count": 6,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
@@ -261,7 +261,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 11,
"id": "3eb36972",
"metadata": {},
"outputs": [],
@@ -280,7 +280,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 12,
"id": "80a91d96",
"metadata": {},
"outputs": [],
@@ -290,7 +290,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 13,
"id": "7931e5f2",
"metadata": {},
"outputs": [
@@ -343,7 +343,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 14,
"id": "e710115f",
"metadata": {},
"outputs": [],
@@ -353,7 +353,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 15,
"id": "5bf23a65",
"metadata": {},
"outputs": [],
@@ -374,7 +374,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 16,
"id": "d4036351",
"metadata": {},
"outputs": [
@@ -428,7 +428,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 17,
"id": "7c469c95",
"metadata": {},
"outputs": [],
@@ -438,7 +438,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 18,
"id": "0ec6d950",
"metadata": {},
"outputs": [],
@@ -455,7 +455,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 19,
"id": "207e55f7",
"metadata": {},
"outputs": [],
@@ -485,7 +485,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 20,
"id": "d00b4385",
"metadata": {},
"outputs": [
@@ -522,7 +522,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 21,
"id": "878bcde9",
"metadata": {},
"outputs": [
@@ -548,7 +548,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 22,
"id": "e4bebcd9",
"metadata": {},
"outputs": [
@@ -600,22 +600,31 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 23,
"id": "241bfe80",
"metadata": {},
"outputs": [],
"source": [
"from langchain.prompts.example_selector import SemanticSimilarityExampleSelector\n",
"from langchain.vectorstores import FAISS\n",
"from langchain.vectorstores import Chroma\n",
"from langchain.embeddings import OpenAIEmbeddings"
]
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 24,
"id": "50d0a701",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running Chroma using direct local API.\n",
"Using DuckDB in-memory for database. Data will be transient.\n"
]
}
],
"source": [
"example_selector = SemanticSimilarityExampleSelector.from_examples(\n",
" # This is the list of examples available to select from.\n",
@@ -623,7 +632,7 @@
" # This is the embedding class used to produce embeddings which are used to measure semantic similarity.\n",
" OpenAIEmbeddings(), \n",
" # This is the VectorStore class that is used to store the embeddings and do a similarity search over.\n",
" FAISS, \n",
" Chroma, \n",
" # This is the number of examples to produce.\n",
" k=1\n",
")\n",
@@ -639,7 +648,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 25,
"id": "4c8fdf45",
"metadata": {},
"outputs": [
@@ -732,7 +741,8 @@
"metadata": {},
"outputs": [],
"source": [
"from langchain.prompts.example_selector import MaxMarginalRelevanceExampleSelector"
"from langchain.prompts.example_selector import MaxMarginalRelevanceExampleSelector\n",
"from langchain.vectorstores import FAISS"
]
},
{
@@ -863,7 +873,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"version": "3.9.1"
},
"vscode": {
"interpreter": {