mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-06 13:33:37 +00:00
docs: ecosystem/integrations
update 5 (#5752)
- added missed integration to `docs/ecosystem/integrations/` - updated notebooks to consistent format: changed titles, file names; added descriptions #### Who can review? @hwchase17 @dev2049
This commit is contained in:
@@ -7,7 +7,12 @@
|
||||
"source": [
|
||||
"# Anthropic\n",
|
||||
"\n",
|
||||
"This notebook covers how to get started with Anthropic chat models."
|
||||
"\n",
|
||||
">[Anthropic](https://en.wikipedia.org/wiki/Anthropic) is an American artificial intelligence (AI) startup and \n",
|
||||
"> public-benefit corporation, founded by former members of OpenAI. `Anthropic` specializes in developing general AI \n",
|
||||
"> systems and language models, with a company ethos of responsible AI usage.\n",
|
||||
"> `Anthropic` develops a chatbot, named `Claude`. Similar to `ChatGPT`, `Claude` uses a messaging \n",
|
||||
"> interface where users can submit questions or requests and receive highly detailed and relevant responses.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -171,7 +176,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.3"
|
||||
"version": "3.10.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
@@ -4,9 +4,14 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Google Cloud Platform Vertex AI PaLM \n",
|
||||
"# Google Vertex AI PaLM \n",
|
||||
"\n",
|
||||
"Note: This is seperate from the Google PaLM integration. Google has chosen to offer an enterprise version of PaLM through GCP, and this supports the models made available through there. \n",
|
||||
">[Vertex AI](https://cloud.google.com/vertex-ai/docs/start/introduction-unified-platform) is a machine learning (ML) \n",
|
||||
"> platform that lets you train and deploy ML models and AI applications. \n",
|
||||
"> `Vertex AI` combines data engineering, data science, and ML engineering workflows, enabling your teams to \n",
|
||||
"> collaborate using a common toolset.\n",
|
||||
"\n",
|
||||
"**Note:** This is seperate from the Google PaLM integration. Google has chosen to offer an enterprise version of PaLM through GCP, and this supports the models made available through there. \n",
|
||||
"\n",
|
||||
"PaLM API on Vertex AI is a Preview offering, subject to the Pre-GA Offerings Terms of the [GCP Service Specific Terms](https://cloud.google.com/terms/service-terms). \n",
|
||||
"\n",
|
||||
@@ -157,7 +162,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.1"
|
||||
"version": "3.10.6"
|
||||
},
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
|
@@ -1,18 +1,19 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "959300d4",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# PromptLayer ChatOpenAI\n",
|
||||
"\n",
|
||||
"This example showcases how to connect to [PromptLayer](https://www.promptlayer.com) to start recording your ChatOpenAI requests."
|
||||
">[PromptLayer](https://docs.promptlayer.com/what-is-promptlayer/wxpF9EZkUwvdkwvVE9XEvC/how-promptlayer-works/dvgGSxNe6nB1jj8mUVbG8r) \n",
|
||||
"> is a devtool that allows you to track, manage, and share your GPT prompt engineering. \n",
|
||||
"> It acts as a middleware between your code and OpenAI's python library, recording all your API requests \n",
|
||||
"> and saving relevant metadata for easy exploration and search in the [PromptLayer](https://www.promptlayer.com) dashboard."
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "6a45943e",
|
||||
"metadata": {},
|
||||
@@ -56,7 +57,6 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "8564ce7d",
|
||||
"metadata": {},
|
||||
@@ -78,7 +78,6 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "bf0294de",
|
||||
"metadata": {},
|
||||
@@ -110,7 +109,6 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "a2d76826",
|
||||
"metadata": {},
|
||||
@@ -125,7 +123,6 @@
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "c43803d1",
|
||||
"metadata": {},
|
||||
@@ -161,7 +158,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "base",
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -175,7 +172,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.8 (default, Apr 13 2021, 12:59:45) \n[Clang 10.0.0 ]"
|
||||
"version": "3.10.6"
|
||||
},
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
|
@@ -6,7 +6,11 @@
|
||||
"id": "J-yvaDTmTTza"
|
||||
},
|
||||
"source": [
|
||||
"# Beam integration for langchain\n",
|
||||
"# Beam\n",
|
||||
"\n",
|
||||
">[Beam](https://docs.beam.cloud/introduction) makes it easy to run code on GPUs, deploy scalable web APIs, \n",
|
||||
"> schedule cron jobs, and run massively parallel workloads — without managing any infrastructure.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"Calls the Beam API wrapper to deploy and make subsequent calls to an instance of the gpt2 LLM in a cloud deployment. Requires installation of the Beam library and registration of Beam Client ID and Client Secret. By calling the wrapper an instance of the model is created and run, with returned text relating to the prompt. Additional calls can then be made by directly calling the Beam API.\n",
|
||||
"\n",
|
||||
@@ -151,9 +155,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.3"
|
||||
"version": "3.10.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 1
|
||||
"nbformat_minor": 4
|
||||
}
|
||||
|
@@ -5,9 +5,9 @@
|
||||
"id": "959300d4",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Hugging Face Local Pipelines\n",
|
||||
"# Hugging Face Pipeline\n",
|
||||
"\n",
|
||||
"Hugging Face models can be run locally through the `HuggingFacePipeline` class.\n",
|
||||
"`Hugging Face` models can be run locally through the `HuggingFacePipeline` class.\n",
|
||||
"\n",
|
||||
"The [Hugging Face Model Hub](https://huggingface.co/models) hosts over 120k models, 20k datasets, and 50k demo apps (Spaces), all open source and publicly available, in an online platform where people can easily collaborate and build ML together.\n",
|
||||
"\n",
|
||||
@@ -137,7 +137,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.2"
|
||||
"version": "3.10.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
@@ -5,9 +5,9 @@
|
||||
"id": "fdd7864c-93e6-4eb4-a923-b80d2ae4377d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Structured Decoding with JSONFormer\n",
|
||||
"# Jsonformer\n",
|
||||
"\n",
|
||||
"[JSONFormer](https://github.com/1rgs/jsonformer) is a library that wraps local HuggingFace pipeline models for structured decoding of a subset of the JSON Schema.\n",
|
||||
"[Jsonformer](https://github.com/1rgs/jsonformer) is a library that wraps local `HuggingFace pipeline` models for structured decoding of a subset of the JSON Schema.\n",
|
||||
"\n",
|
||||
"It works by filling in the structure tokens and then sampling the content tokens from the model.\n",
|
||||
"\n",
|
||||
@@ -272,7 +272,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.2"
|
||||
"version": "3.10.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
@@ -1,222 +1,233 @@
|
||||
{
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"name": "python3",
|
||||
"display_name": "Python 3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "mesCTyhnJkNS"
|
||||
},
|
||||
"source": [
|
||||
"# Prediction Guard\n",
|
||||
"\n",
|
||||
">[Prediction Guard](https://docs.predictionguard.com/) gives a quick and easy access to state-of-the-art open and closed access LLMs, without needing to spend days and weeks figuring out all of the implementation details, managing a bunch of different API specs, and setting up the infrastructure for model deployments."
|
||||
]
|
||||
},
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "3RqWPav7AtKL"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"! pip install predictionguard langchain"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"import predictionguard as pg\n",
|
||||
"from langchain.llms import PredictionGuard\n",
|
||||
"from langchain import PromptTemplate, LLMChain"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "2xe8JEUwA7_y"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Basic LLM usage\n",
|
||||
"\n"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "mesCTyhnJkNS"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# Optional, add your OpenAI API Key. This is optional, as Prediction Guard allows\n",
|
||||
"# you to access all the latest open access models (see https://docs.predictionguard.com)\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = \"<your OpenAI api key>\"\n",
|
||||
"\n",
|
||||
"# Your Prediction Guard API key. Get one at predictionguard.com\n",
|
||||
"os.environ[\"PREDICTIONGUARD_TOKEN\"] = \"<your Prediction Guard access token>\""
|
||||
],
|
||||
"metadata": {
|
||||
"id": "kp_Ymnx1SnDG"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"pgllm = PredictionGuard(model=\"OpenAI-text-davinci-003\")"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "Ua7Mw1N4HcER"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"pgllm(\"Tell me a joke\")"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "Qo2p5flLHxrB"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Control the output structure/ type of LLMs"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "EyBYaP_xTMXH"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"template = \"\"\"Respond to the following query based on the context.\n",
|
||||
"\n",
|
||||
"Context: EVERY comment, DM + email suggestion has led us to this EXCITING announcement! 🎉 We have officially added TWO new candle subscription box options! 📦\n",
|
||||
"Exclusive Candle Box - $80 \n",
|
||||
"Monthly Candle Box - $45 (NEW!)\n",
|
||||
"Scent of The Month Box - $28 (NEW!)\n",
|
||||
"Head to stories to get ALLL the deets on each box! 👆 BONUS: Save 50% on your first box with code 50OFF! 🎉\n",
|
||||
"\n",
|
||||
"Query: {query}\n",
|
||||
"\n",
|
||||
"Result: \"\"\"\n",
|
||||
"prompt = PromptTemplate(template=template, input_variables=[\"query\"])"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "55uxzhQSTPqF"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# Without \"guarding\" or controlling the output of the LLM.\n",
|
||||
"pgllm(prompt.format(query=\"What kind of post is this?\"))"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "yersskWbTaxU"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# With \"guarding\" or controlling the output of the LLM. See the \n",
|
||||
"# Prediction Guard docs (https://docs.predictionguard.com) to learn how to \n",
|
||||
"# control the output with integer, float, boolean, JSON, and other types and\n",
|
||||
"# structures.\n",
|
||||
"pgllm = PredictionGuard(model=\"OpenAI-text-davinci-003\", \n",
|
||||
" output={\n",
|
||||
" \"type\": \"categorical\",\n",
|
||||
" \"categories\": [\n",
|
||||
" \"product announcement\", \n",
|
||||
" \"apology\", \n",
|
||||
" \"relational\"\n",
|
||||
" ]\n",
|
||||
" })\n",
|
||||
"pgllm(prompt.format(query=\"What kind of post is this?\"))"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "PzxSbYwqTm2w"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Chaining"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "v3MzIUItJ8kV"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"pgllm = PredictionGuard(model=\"OpenAI-text-davinci-003\")"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "pPegEZExILrT"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"template = \"\"\"Question: {question}\n",
|
||||
"\n",
|
||||
"Answer: Let's think step by step.\"\"\"\n",
|
||||
"prompt = PromptTemplate(template=template, input_variables=[\"question\"])\n",
|
||||
"llm_chain = LLMChain(prompt=prompt, llm=pgllm, verbose=True)\n",
|
||||
"\n",
|
||||
"question = \"What NFL team won the Super Bowl in the year Justin Beiber was born?\"\n",
|
||||
"\n",
|
||||
"llm_chain.predict(question=question)"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "suxw62y-J-bg"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"template = \"\"\"Write a {adjective} poem about {subject}.\"\"\"\n",
|
||||
"prompt = PromptTemplate(template=template, input_variables=[\"adjective\", \"subject\"])\n",
|
||||
"llm_chain = LLMChain(prompt=prompt, llm=pgllm, verbose=True)\n",
|
||||
"\n",
|
||||
"llm_chain.predict(adjective=\"sad\", subject=\"ducks\")"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "l2bc26KHKr7n"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [],
|
||||
"metadata": {
|
||||
"id": "I--eSa2PLGqq"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "3RqWPav7AtKL"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"! pip install predictionguard langchain"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "2xe8JEUwA7_y"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"import predictionguard as pg\n",
|
||||
"from langchain.llms import PredictionGuard\n",
|
||||
"from langchain import PromptTemplate, LLMChain"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "kp_Ymnx1SnDG"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Optional, add your OpenAI API Key. This is optional, as Prediction Guard allows\n",
|
||||
"# you to access all the latest open access models (see https://docs.predictionguard.com)\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = \"<your OpenAI api key>\"\n",
|
||||
"\n",
|
||||
"# Your Prediction Guard API key. Get one at predictionguard.com\n",
|
||||
"os.environ[\"PREDICTIONGUARD_TOKEN\"] = \"<your Prediction Guard access token>\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "Ua7Mw1N4HcER"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"pgllm = PredictionGuard(model=\"OpenAI-text-davinci-003\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "Qo2p5flLHxrB"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"pgllm(\"Tell me a joke\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "EyBYaP_xTMXH"
|
||||
},
|
||||
"source": [
|
||||
"# Control the output structure/ type of LLMs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "55uxzhQSTPqF"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"template = \"\"\"Respond to the following query based on the context.\n",
|
||||
"\n",
|
||||
"Context: EVERY comment, DM + email suggestion has led us to this EXCITING announcement! 🎉 We have officially added TWO new candle subscription box options! 📦\n",
|
||||
"Exclusive Candle Box - $80 \n",
|
||||
"Monthly Candle Box - $45 (NEW!)\n",
|
||||
"Scent of The Month Box - $28 (NEW!)\n",
|
||||
"Head to stories to get ALLL the deets on each box! 👆 BONUS: Save 50% on your first box with code 50OFF! 🎉\n",
|
||||
"\n",
|
||||
"Query: {query}\n",
|
||||
"\n",
|
||||
"Result: \"\"\"\n",
|
||||
"prompt = PromptTemplate(template=template, input_variables=[\"query\"])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "yersskWbTaxU"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Without \"guarding\" or controlling the output of the LLM.\n",
|
||||
"pgllm(prompt.format(query=\"What kind of post is this?\"))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "PzxSbYwqTm2w"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# With \"guarding\" or controlling the output of the LLM. See the \n",
|
||||
"# Prediction Guard docs (https://docs.predictionguard.com) to learn how to \n",
|
||||
"# control the output with integer, float, boolean, JSON, and other types and\n",
|
||||
"# structures.\n",
|
||||
"pgllm = PredictionGuard(model=\"OpenAI-text-davinci-003\", \n",
|
||||
" output={\n",
|
||||
" \"type\": \"categorical\",\n",
|
||||
" \"categories\": [\n",
|
||||
" \"product announcement\", \n",
|
||||
" \"apology\", \n",
|
||||
" \"relational\"\n",
|
||||
" ]\n",
|
||||
" })\n",
|
||||
"pgllm(prompt.format(query=\"What kind of post is this?\"))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "v3MzIUItJ8kV"
|
||||
},
|
||||
"source": [
|
||||
"# Chaining"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "pPegEZExILrT"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"pgllm = PredictionGuard(model=\"OpenAI-text-davinci-003\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "suxw62y-J-bg"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"template = \"\"\"Question: {question}\n",
|
||||
"\n",
|
||||
"Answer: Let's think step by step.\"\"\"\n",
|
||||
"prompt = PromptTemplate(template=template, input_variables=[\"question\"])\n",
|
||||
"llm_chain = LLMChain(prompt=prompt, llm=pgllm, verbose=True)\n",
|
||||
"\n",
|
||||
"question = \"What NFL team won the Super Bowl in the year Justin Beiber was born?\"\n",
|
||||
"\n",
|
||||
"llm_chain.predict(question=question)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "l2bc26KHKr7n"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"template = \"\"\"Write a {adjective} poem about {subject}.\"\"\"\n",
|
||||
"prompt = PromptTemplate(template=template, input_variables=[\"adjective\", \"subject\"])\n",
|
||||
"llm_chain = LLMChain(prompt=prompt, llm=pgllm, verbose=True)\n",
|
||||
"\n",
|
||||
"llm_chain.predict(adjective=\"sad\", subject=\"ducks\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "I--eSa2PLGqq"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"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.10.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
||||
|
@@ -5,11 +5,10 @@
|
||||
"id": "fdd7864c-93e6-4eb4-a923-b80d2ae4377d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Structured Decoding with RELLM\n",
|
||||
"# ReLLM\n",
|
||||
"\n",
|
||||
"[RELLM](https://github.com/r2d4/rellm) is a library that wraps local Hugging Face pipeline models for structured decoding.\n",
|
||||
"\n",
|
||||
"It works by generating tokens one at a time. At each step, it masks tokens that don't conform to the provided partial regular expression.\n",
|
||||
">[ReLLM](https://github.com/r2d4/rellm) is a library that wraps local Hugging Face pipeline models for structured decoding.\n",
|
||||
">It works by generating tokens one at a time. At each step, it masks tokens that don't conform to the provided partial regular expression.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"**Warning - this module is still experimental**"
|
||||
@@ -200,7 +199,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.2"
|
||||
"version": "3.10.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# SageMakerEndpoint\n",
|
||||
"# SageMaker Endpoint\n",
|
||||
"\n",
|
||||
"[Amazon SageMaker](https://aws.amazon.com/sagemaker/) is a system that can build, train, and deploy machine learning (ML) models for any use case with fully managed infrastructure, tools, and workflows.\n",
|
||||
"\n",
|
||||
|
@@ -5,7 +5,9 @@
|
||||
"id": "75e378f5-55d7-44b6-8e2e-6d7b8b171ec4",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Bedrock Embeddings"
|
||||
"# Amazon Bedrock\n",
|
||||
"\n",
|
||||
">[Amazon Bedrock](https://aws.amazon.com/bedrock/) is a fully managed service that makes FMs from leading AI startups and Amazon available via an API, so you can choose from a wide range of FMs to find the model that is best suited for your use case.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -67,7 +69,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.11"
|
||||
"version": "3.10.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
@@ -5,7 +5,7 @@
|
||||
"id": "c3852491",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# AzureOpenAI\n",
|
||||
"# Azure OpenAI\n",
|
||||
"\n",
|
||||
"Let's load the OpenAI Embedding class with environment variables set to indicate to use Azure endpoints."
|
||||
]
|
||||
@@ -93,7 +93,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.1"
|
||||
"version": "3.10.6"
|
||||
},
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Google Cloud Platform Vertex AI PaLM \n",
|
||||
"# Google Vertex AI PaLM \n",
|
||||
"\n",
|
||||
"Note: This is seperate from the Google PaLM integration. Google has chosen to offer an enterprise version of PaLM through GCP, and this supports the models made available through there. \n",
|
||||
"\n",
|
||||
@@ -100,7 +100,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.1"
|
||||
"version": "3.10.6"
|
||||
},
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
|
@@ -5,8 +5,8 @@
|
||||
"id": "59428e05",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# InstructEmbeddings\n",
|
||||
"Let's load the HuggingFace instruct Embeddings class."
|
||||
"# HuggingFace Instruct\n",
|
||||
"Let's load the `HuggingFace instruct Embeddings` class."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -85,7 +85,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.1"
|
||||
"version": "3.10.6"
|
||||
},
|
||||
"vscode": {
|
||||
"interpreter": {
|
@@ -1,11 +1,10 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# MosaicML embeddings\n",
|
||||
"# MosaicML\n",
|
||||
"\n",
|
||||
"[MosaicML](https://docs.mosaicml.com/en/latest/inference.html) offers a managed inference service. You can either use a variety of open source models, or deploy your own.\n",
|
||||
"\n",
|
||||
@@ -92,6 +91,11 @@
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
@@ -101,9 +105,10 @@
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3"
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
"nbformat_minor": 4
|
||||
}
|
||||
|
@@ -5,9 +5,9 @@
|
||||
"id": "1f83f273",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# SageMaker Endpoint Embeddings\n",
|
||||
"# SageMaker Endpoint\n",
|
||||
"\n",
|
||||
"Let's load the SageMaker Endpoints Embeddings class. The class can be used if you host, e.g. your own Hugging Face model on SageMaker.\n",
|
||||
"Let's load the `SageMaker Endpoints Embeddings` class. The class can be used if you host, e.g. your own Hugging Face model on SageMaker.\n",
|
||||
"\n",
|
||||
"For instructions on how to do this, please see [here](https://www.philschmid.de/custom-inference-huggingface-sagemaker). **Note**: In order to handle batched requests, you will need to adjust the return line in the `predict_fn()` function within the custom `inference.py` script:\n",
|
||||
"\n",
|
||||
@@ -122,7 +122,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.1"
|
||||
"version": "3.10.6"
|
||||
},
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
|
@@ -1,14 +1,13 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
"id": "ed47bb62",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Sentence Transformers Embeddings\n",
|
||||
"# Sentence Transformers\n",
|
||||
"\n",
|
||||
"[SentenceTransformers](https://www.sbert.net/) embeddings are called using the `HuggingFaceEmbeddings` integration. We have also added an alias for `SentenceTransformerEmbeddings` for users who are more familiar with directly using that package.\n",
|
||||
"[Sentence Transformers](https://www.sbert.net/) embeddings are called using the `HuggingFaceEmbeddings` integration. We have also added an alias for `SentenceTransformerEmbeddings` for users who are more familiar with directly using that package.\n",
|
||||
"\n",
|
||||
"SentenceTransformers is a python package that can generate text and image embeddings, originating from [Sentence-BERT](https://arxiv.org/abs/1908.10084)"
|
||||
]
|
||||
@@ -109,7 +108,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.16"
|
||||
"version": "3.10.6"
|
||||
},
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
|
@@ -5,8 +5,11 @@
|
||||
"id": "fff4734f",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# TensorflowHub\n",
|
||||
"Let's load the TensorflowHub Embedding class."
|
||||
"# Tensorflow Hub\n",
|
||||
"\n",
|
||||
">[TensorFlow Hub](https://www.tensorflow.org/hub) is a repository of trained machine learning models ready for fine-tuning and deployable anywhere.\n",
|
||||
"\n",
|
||||
">[TensorFlow Hub](https://tfhub.dev/) lets you search and discover hundreds of trained, ready-to-deploy machine learning models in one place.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -105,7 +108,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.1"
|
||||
"version": "3.10.6"
|
||||
},
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
|
Reference in New Issue
Block a user