mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-22 14:49:29 +00:00
docs: update nvidia docs v2 (#21288)
More doc updates por favor @baskaryan!
This commit is contained in:
parent
6feddfae88
commit
27e73ebe57
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
> [NVIDIA AI Foundation Endpoints](https://www.nvidia.com/en-us/ai-data-science/foundation-models/) give users easy access to NVIDIA hosted API endpoints for
|
> [NVIDIA AI Foundation Endpoints](https://www.nvidia.com/en-us/ai-data-science/foundation-models/) give users easy access to NVIDIA hosted API endpoints for
|
||||||
> NVIDIA AI Foundation Models like `Mixtral 8x7B`, `Llama 2`, `Stable Diffusion`, etc. These models,
|
> NVIDIA AI Foundation Models like `Mixtral 8x7B`, `Llama 2`, `Stable Diffusion`, etc. These models,
|
||||||
> hosted on the [NVIDIA NGC catalog](https://catalog.ngc.nvidia.com/ai-foundation-models), are optimized, tested, and hosted on
|
> hosted on the [NVIDIA API catalog](https://build.nvidia.com/), are optimized, tested, and hosted on
|
||||||
> the NVIDIA AI platform, making them fast and easy to evaluate, further customize,
|
> the NVIDIA AI platform, making them fast and easy to evaluate, further customize,
|
||||||
> and seamlessly run at peak performance on any accelerated stack.
|
> and seamlessly run at peak performance on any accelerated stack.
|
||||||
>
|
>
|
||||||
|
@ -85,9 +85,6 @@
|
|||||||
"import getpass\n",
|
"import getpass\n",
|
||||||
"import os\n",
|
"import os\n",
|
||||||
"\n",
|
"\n",
|
||||||
"## API Key can be found by going to NVIDIA NGC -> AI Foundation Models -> (some model) -> Get API Code or similar.\n",
|
|
||||||
"## 10K free queries to any endpoint (which is a lot actually).\n",
|
|
||||||
"\n",
|
|
||||||
"# del os.environ['NVIDIA_API_KEY'] ## delete key and reset\n",
|
"# del os.environ['NVIDIA_API_KEY'] ## delete key and reset\n",
|
||||||
"if os.environ.get(\"NVIDIA_API_KEY\", \"\").startswith(\"nvapi-\"):\n",
|
"if os.environ.get(\"NVIDIA_API_KEY\", \"\").startswith(\"nvapi-\"):\n",
|
||||||
" print(\"Valid NVIDIA_API_KEY already in environment. Delete to reset\")\n",
|
" print(\"Valid NVIDIA_API_KEY already in environment. Delete to reset\")\n",
|
||||||
@ -112,11 +109,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Initialization\n",
|
"## Initialization\n",
|
||||||
"\n",
|
"\n",
|
||||||
"The main requirement when initializing an embedding model is to provide the model name. An example is `nvolveqa_40k` below.\n",
|
"When initializing an embedding model you can select a model by passing it, e.g. `ai-embed-qa-4` below, or use the default by not passing any arguments."
|
||||||
"\n",
|
|
||||||
"For `nvovleqa_40k`, you can also specify the `model_type` as `passage` or `query`. When doing retrieval, you will get best results if you embed the source documents with the `passage` type and the user queries with the `query` type.\n",
|
|
||||||
"\n",
|
|
||||||
"If not provided, the `embed_query` method will default to the `query` type, and the `embed_documents` mehod will default to the `passage` type."
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -129,10 +122,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"from langchain_nvidia_ai_endpoints import NVIDIAEmbeddings\n",
|
"from langchain_nvidia_ai_endpoints import NVIDIAEmbeddings\n",
|
||||||
"\n",
|
"\n",
|
||||||
"embedder = NVIDIAEmbeddings(model=\"nvolveqa_40k\")\n",
|
"embedder = NVIDIAEmbeddings(model=\"ai-embed-qa-4\")"
|
||||||
"\n",
|
|
||||||
"# Alternatively, if you want to specify whether it will use the query or passage type\n",
|
|
||||||
"# embedder = NVIDIAEmbeddings(model=\"nvolveqa_40k\", model_type=\"passage\")"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -156,7 +146,7 @@
|
|||||||
"id": "pcDu3v4CbmWk"
|
"id": "pcDu3v4CbmWk"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### **Similarity/Speed Test**\n",
|
"### **Similarity**\n",
|
||||||
"\n",
|
"\n",
|
||||||
"The following is a quick test of the methods in terms of usage, format, and speed for the use case of embedding the following data points:\n",
|
"The following is a quick test of the methods in terms of usage, format, and speed for the use case of embedding the following data points:\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -250,7 +240,7 @@
|
|||||||
"s = time.perf_counter()\n",
|
"s = time.perf_counter()\n",
|
||||||
"# To use the \"query\" mode, we have to add it as an instance arg\n",
|
"# To use the \"query\" mode, we have to add it as an instance arg\n",
|
||||||
"q_embeddings = NVIDIAEmbeddings(\n",
|
"q_embeddings = NVIDIAEmbeddings(\n",
|
||||||
" model=\"nvolveqa_40k\", model_type=\"query\"\n",
|
" model=\"ai-embed-qa-4\", model_type=\"query\"\n",
|
||||||
").embed_documents(\n",
|
").embed_documents(\n",
|
||||||
" [\n",
|
" [\n",
|
||||||
" \"What's the weather like in Komchatka?\",\n",
|
" \"What's the weather like in Komchatka?\",\n",
|
||||||
@ -501,7 +491,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"vectorstore = FAISS.from_texts(\n",
|
"vectorstore = FAISS.from_texts(\n",
|
||||||
" [\"harrison worked at kensho\"],\n",
|
" [\"harrison worked at kensho\"],\n",
|
||||||
" embedding=NVIDIAEmbeddings(model=\"nvolveqa_40k\"),\n",
|
" embedding=NVIDIAEmbeddings(model=\"ai-embed-qa-4\"),\n",
|
||||||
")\n",
|
")\n",
|
||||||
"retriever = vectorstore.as_retriever()\n",
|
"retriever = vectorstore.as_retriever()\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -515,7 +505,7 @@
|
|||||||
" ]\n",
|
" ]\n",
|
||||||
")\n",
|
")\n",
|
||||||
"\n",
|
"\n",
|
||||||
"model = ChatNVIDIA(model=\"mixtral_8x7b\")\n",
|
"model = ChatNVIDIA(model=\"ai-mixtral-8x7b-instruct\")\n",
|
||||||
"\n",
|
"\n",
|
||||||
"chain = (\n",
|
"chain = (\n",
|
||||||
" {\"context\": retriever, \"question\": RunnablePassthrough()}\n",
|
" {\"context\": retriever, \"question\": RunnablePassthrough()}\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user