id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
49
117
d87293930eeb-8
Document(page_content='And for our LGBTQ+ Americans, let’s finally get the bipartisan Equality Act to my desk. The onslaught of state laws targeting transgender Americans and their families is wrong. \n\nAs I said last year, especially to our younger transgender Americans, I will always have your back as your President...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
d87293930eeb-9
Document(page_content='Tonight, I’m announcing a crackdown on these companies overcharging American businesses and consumers. \n\nAnd as Wall Street firms take over more nursing homes, quality in those homes has gone down and costs have gone up. \n\nThat ends on my watch. \n\nMedicare is going to set higher standards ...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
d87293930eeb-10
[Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \n\nTonight, I’d like to honor someone who has dedicated his life to serve this country: Justic...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
d87293930eeb-11
Document(page_content='Tonight, I’m announcing a crackdown on these companies overcharging American businesses and consumers. \n\nAnd as Wall Street firms take over more nursing homes, quality in those homes has gone down and costs have gone up. \n\nThat ends on my watch. \n\nMedicare is going to set higher standards ...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
d87293930eeb-12
Document(page_content='A former top litigator in private practice. A former federal public defender. And from a family of public school educators and police officers. A consensus builder. Since she’s been nominated, she’s received a broad range of support—from the Fraternal Order of Police to former judges appointed by...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
d87293930eeb-13
Document(page_content='And for our LGBTQ+ Americans, let’s finally get the bipartisan Equality Act to my desk. The onslaught of state laws targeting transgender Americans and their families is wrong. \n\nAs I said last year, especially to our younger transgender Americans, I will always have your back as your President...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
d87293930eeb-14
username = "<username>" # your username on app.activeloop.ai dataset_path = f"hub://{username}/langchain_test" # could be also ./local/path (much faster locally), s3://bucket/path/to/dataset, gcs://path/to/dataset, etc. embedding = OpenAIEmbeddings() db = DeepLake(dataset_path=dataset_path, embedding_function=embedd...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
d87293930eeb-15
'd6d6ccb7-e187-11ed-b66d-41c5f7b85421'] query = "What did the president say about Ketanji Brown Jackson" docs = db.similarity_search(query) print(docs[0].page_content) Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so ...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
d87293930eeb-16
}) s3://hub-2.0-datasets-n/langchain_test loaded successfully. Evaluating ingest: 100%|██████████| 1/1 [00:10<00:00 \ Dataset(path='s3://hub-2.0-datasets-n/langchain_test', tensors=['embedding', 'ids', 'metadata', 'text']) tensor htype shape dtype compression ------- ------- ------- ------- ----...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
d87293930eeb-17
username = "davitbun" # your username on app.activeloop.ai source = f"hub://{username}/langchain_test" # could be local, s3, gcs, etc. destination = f"hub://{username}/langchain_test_copy" # could be local, s3, gcs, etc. deeplake.deepcopy(src=source, dest=destination, overwrite=True) Copying dataset: 100%|██████████...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
d87293930eeb-18
metadata json (4, 1) str None text text (4, 1) str None Evaluating ingest: 100%|██████████| 1/1 [00:31<00:00 - Dataset(path='hub://davitbun/langchain_test_copy', tensors=['embedding', 'ids', 'metadata', 'text']) tensor htype shape dtype compression ------- -...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html
ccee28396ad5-0
.ipynb .pdf Atlas Atlas# Atlas is a platform for interacting with both small and internet scale unstructured datasets by Nomic. This notebook shows you how to use functionality related to the AtlasDB vectorstore. !pip install spacy !python3 -m spacy download en_core_web_sm !pip install nomic import time from langchain....
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/atlas.html
ccee28396ad5-1
Hide embedded project Explore on atlas.nomic.ai previous Annoy next Chroma By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/atlas.html
4c7a95f74568-0
.ipynb .pdf Milvus Milvus# Milvus is a database that stores, indexes, and manages massive embedding vectors generated by deep neural networks and other machine learning (ML) models. This notebook shows how to use functionality related to the Milvus vector database. To run, you should have a Milvus instance up and runni...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/milvus.html
4c7a95f74568-1
docs = vector_db.similarity_search(query) docs[0].page_content 'Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \n\nTonight, I’d like to honor someone who has dedicate...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/milvus.html
d74469d80bc9-0
.ipynb .pdf Zilliz Zilliz# Zilliz Cloud is a fully managed service on cloud for LF AI Milvus®, This notebook shows how to use functionality related to the Zilliz Cloud managed vector database. To run, you should have a Zilliz Cloud instance up and running. Here are the installation instructions !pip install pymilvus We...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/zilliz.html
d74469d80bc9-1
"password": ZILLIZ_CLOUD_PASSWORD, "secure": True } ) query = "What did the president say about Ketanji Brown Jackson" docs = vector_db.similarity_search(query) docs[0].page_content 'Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it...
https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/zilliz.html
208b2c54a1ce-0
.rst .pdf Chat Models Chat Models# Note Conceptual Guide Chat models are a variation on language models. While chat models use language models under the hood, the interface they expose is a bit different. Rather than expose a “text in, text out” API, they expose an interface where “chat messages” are the inputs and out...
https://python.langchain.com/en/latest/modules/models/chat.html
d406bd2d0d10-0
.rst .pdf Text Embedding Models Text Embedding Models# Note Conceptual Guide This documentation goes over how to use the Embedding class in LangChain. The Embedding class is a class designed for interfacing with embeddings. There are lots of Embedding providers (OpenAI, Cohere, Hugging Face, etc) - this class is design...
https://python.langchain.com/en/latest/modules/models/text_embedding.html
003c4e73da1d-0
.ipynb .pdf Getting Started Contents Language Models text -> text interface messages -> message interface Getting Started# One of the core value props of LangChain is that it provides a standard interface to models. This allows you to swap easily between models. At a high level, there are two main types of models: La...
https://python.langchain.com/en/latest/modules/models/getting_started.html
003c4e73da1d-1
Contents Language Models text -> text interface messages -> message interface By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/models/getting_started.html
fdfbfdd2ae43-0
.rst .pdf LLMs LLMs# Note Conceptual Guide Large Language Models (LLMs) are a core component of LangChain. LangChain is not a provider of LLMs, but rather provides a standard interface through which you can interact with a variety of LLMs. The following sections of documentation are provided: Getting Started: An overvi...
https://python.langchain.com/en/latest/modules/models/llms.html
93720c36b685-0
.ipynb .pdf Getting Started Getting Started# This notebook goes over how to use the LLM class in LangChain. The LLM class is a class designed for interfacing with LLMs. There are lots of LLM providers (OpenAI, Cohere, Hugging Face, etc) - this class is designed to provide a standard interface for all of them. In this p...
https://python.langchain.com/en/latest/modules/models/llms/getting_started.html
93720c36b685-1
llm_result.generations[-1] [Generation(text="\n\nWhat if love neverspeech\n\nWhat if love never ended\n\nWhat if love was only a feeling\n\nI'll never know this love\n\nIt's not a feeling\n\nBut it's what we have for each other\n\nWe just know that love is something strong\n\nAnd we can't help but be happy\n\nWe just f...
https://python.langchain.com/en/latest/modules/models/llms/getting_started.html
93720c36b685-2
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/models/llms/getting_started.html
a7ceb7dd9212-0
.rst .pdf Integrations Integrations# The examples here are all “how-to” guides for how to integrate with various LLM providers. AI21 Aleph Alpha Anyscale Azure OpenAI Banana Beam integration for langchain CerebriumAI Cohere C Transformers Databricks DeepInfra ForefrontAI Google Cloud Platform Vertex AI PaLM GooseAI GPT...
https://python.langchain.com/en/latest/modules/models/llms/integrations.html
15b4f377c8ee-0
.rst .pdf Generic Functionality Generic Functionality# The examples here all address certain “how-to” guides for working with LLMs. How to use the async API for LLMs How to write a custom LLM wrapper How (and why) to use the fake LLM How (and why) to use the human input LLM How to cache LLM calls How to serialize LLM c...
https://python.langchain.com/en/latest/modules/models/llms/how_to_guides.html
752fc371ad33-0
.ipynb .pdf PipelineAI Contents Install pipeline-ai Imports Set the Environment API Key Create the PipelineAI instance Create a Prompt Template Initiate the LLMChain Run the LLMChain PipelineAI# PipelineAI allows you to run your ML models at scale in the cloud. It also provides API access to several LLM models. This ...
https://python.langchain.com/en/latest/modules/models/llms/integrations/pipelineai_example.html
752fc371ad33-1
Run the LLMChain# Provide a question and run the LLMChain. question = "What NFL team won the Super Bowl in the year Justin Beiber was born?" llm_chain.run(question) previous Petals next PredictionGuard Contents Install pipeline-ai Imports Set the Environment API Key Create the PipelineAI instance Create a Prompt Te...
https://python.langchain.com/en/latest/modules/models/llms/integrations/pipelineai_example.html
9b4ef4b8fee4-0
.ipynb .pdf Anyscale Anyscale# Anyscale is a fully-managed Ray platform, on which you can build, deploy, and manage scalable AI and Python applications This example goes over how to use LangChain to interact with Anyscale service import os os.environ["ANYSCALE_SERVICE_URL"] = ANYSCALE_SERVICE_URL os.environ["ANYSCALE_S...
https://python.langchain.com/en/latest/modules/models/llms/integrations/anyscale.html
9b4ef4b8fee4-1
def send_query(llm, prompt): resp = llm(prompt) return resp futures = [send_query.remote(llm, prompt) for prompt in prompt_list] results = ray.get(futures) previous Aleph Alpha next Azure OpenAI By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/models/llms/integrations/anyscale.html
920aa6aaf5bc-0
.ipynb .pdf Hugging Face Local Pipelines Contents Load the model Integrate the model in an LLMChain Hugging Face Local Pipelines# Hugging Face models can be run locally through the HuggingFacePipeline class. The Hugging Face Model Hub hosts over 120k models, 20k datasets, and 50k demo apps (Spaces), all open source a...
https://python.langchain.com/en/latest/modules/models/llms/integrations/huggingface_pipelines.html
920aa6aaf5bc-1
question = "What is electroencephalography?" print(llm_chain.run(question)) /Users/wfh/code/lc/lckg/.venv/lib/python3.11/site-packages/transformers/generation/utils.py:1288: UserWarning: Using `max_length`'s default (64) to control the generation length. This behaviour is deprecated and will be removed from the config ...
https://python.langchain.com/en/latest/modules/models/llms/integrations/huggingface_pipelines.html
6b4d015f2172-0
.ipynb .pdf SageMakerEndpoint Contents Set up Example SageMakerEndpoint# Amazon 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. This notebooks goes over how to use an LLM hosted on a SageMaker endpoint. !pip...
https://python.langchain.com/en/latest/modules/models/llms/integrations/sagemaker.html
6b4d015f2172-1
import json query = """How long was Elizabeth hospitalized? """ prompt_template = """Use the following pieces of context to answer the question at the end. {context} Question: {question} Answer:""" PROMPT = PromptTemplate( template=prompt_template, input_variables=["context", "question"] ) class ContentHandler(LLMC...
https://python.langchain.com/en/latest/modules/models/llms/integrations/sagemaker.html
98b272d1235a-0
.ipynb .pdf GooseAI Contents Install openai Imports Set the Environment API Key Create the GooseAI instance Create a Prompt Template Initiate the LLMChain Run the LLMChain GooseAI# GooseAI is a fully managed NLP-as-a-Service, delivered via API. GooseAI provides access to these models. This notebook goes over how to u...
https://python.langchain.com/en/latest/modules/models/llms/integrations/gooseai_example.html
98b272d1235a-1
previous Google Cloud Platform Vertex AI PaLM next GPT4All Contents Install openai Imports Set the Environment API Key Create the GooseAI instance Create a Prompt Template Initiate the LLMChain Run the LLMChain By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/models/llms/integrations/gooseai_example.html
c7c228dbfadb-0
.ipynb .pdf MosaicML MosaicML# MosaicML offers a managed inference service. You can either use a variety of open source models, or deploy your own. This example goes over how to use LangChain to interact with MosaicML Inference for text completion. # sign up for an account: https://forms.mosaicml.com/demo?utm_source=la...
https://python.langchain.com/en/latest/modules/models/llms/integrations/mosaicml.html
7979ccfeb2fa-0
.ipynb .pdf Beam integration for langchain Beam integration for langchain# 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 instan...
https://python.langchain.com/en/latest/modules/models/llms/integrations/beam.html
7979ccfeb2fa-1
"torch", "pillow", "accelerate", "safetensors", "xformers",], max_length="50", verbose=False) llm._deploy() response = llm._call("Running machine learning on a remote GPU") print(response) previous Banana next CerebriumAI By Harrison Chas...
https://python.langchain.com/en/latest/modules/models/llms/integrations/beam.html
777e04c69c23-0
.ipynb .pdf NLP Cloud NLP Cloud# The NLP Cloud serves high performance pre-trained or custom models for NER, sentiment-analysis, classification, summarization, paraphrasing, grammar and spelling correction, keywords and keyphrases extraction, chatbot, product description and ad generation, intent classification, text g...
https://python.langchain.com/en/latest/modules/models/llms/integrations/nlpcloud.html
8e559345e5d0-0
.ipynb .pdf Cohere Cohere# Cohere is a Canadian startup that provides natural language processing models that help companies improve human-machine interactions. This example goes over how to use LangChain to interact with Cohere models. # Install the package !pip install cohere # get a new token: https://dashboard.cohe...
https://python.langchain.com/en/latest/modules/models/llms/integrations/cohere.html
8e559345e5d0-1
llm_chain.run(question) " Let's start with the year that Justin Beiber was born. You know that he was born in 1994. We have to go back one year. 1993.\n\n1993 was the year that the Dallas Cowboys won the Super Bowl. They won over the Buffalo Bills in Super Bowl 26.\n\nNow, let's do it backwards. According to our inform...
https://python.langchain.com/en/latest/modules/models/llms/integrations/cohere.html
d88c7a4f0523-0
.ipynb .pdf AI21 AI21# AI21 Studio provides API access to Jurassic-2 large language models. This example goes over how to use LangChain to interact with AI21 models. # install the package: !pip install ai21 # get AI21_API_KEY. Use https://studio.ai21.com/account/account from getpass import getpass AI21_API_KEY = getpa...
https://python.langchain.com/en/latest/modules/models/llms/integrations/ai21.html
bc61ce5d9487-0
.ipynb .pdf DeepInfra Contents Imports Set the Environment API Key Create the DeepInfra instance Create a Prompt Template Initiate the LLMChain Run the LLMChain DeepInfra# DeepInfra provides several LLMs. This notebook goes over how to use Langchain with DeepInfra. Imports# import os from langchain.llms import DeepIn...
https://python.langchain.com/en/latest/modules/models/llms/integrations/deepinfra_example.html
bc61ce5d9487-1
llm_chain.run(question) previous Databricks next ForefrontAI Contents Imports Set the Environment API Key Create the DeepInfra instance Create a Prompt Template Initiate the LLMChain Run the LLMChain By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/models/llms/integrations/deepinfra_example.html
b1407d9b4a77-0
.ipynb .pdf Databricks Contents Wrapping a serving endpoint Wrapping a cluster driver proxy app Databricks# The Databricks Lakehouse Platform unifies data, analytics, and AI on one platform. This example notebook shows how to wrap Databricks endpoints as LLMs in LangChain. It supports two endpoint types: Serving endp...
https://python.langchain.com/en/latest/modules/models/llms/integrations/databricks.html
b1407d9b4a77-1
# See https://docs.databricks.com/dev-tools/auth.html#databricks-personal-access-tokens # We strongly recommend not exposing the API token explicitly inside a notebook. # You can use Databricks secret manager to store your API token securely. # See https://docs.databricks.com/dev-tools/databricks-utils.html#secrets-uti...
https://python.langchain.com/en/latest/modules/models/llms/integrations/databricks.html
b1407d9b4a77-2
It uses a port number between [3000, 8000] and litens to the driver IP address or simply 0.0.0.0 instead of localhost only. You have “Can Attach To” permission to the cluster. The expected server schema (using JSON schema) is: inputs: {"type": "object", "properties": { "prompt": {"type": "string"}, "stop": {"...
https://python.langchain.com/en/latest/modules/models/llms/integrations/databricks.html
b1407d9b4a77-3
self.matched = self.stop[i] return True return False def llm(prompt, stop=None, **kwargs): check_stop = CheckStop(stop) result = dolly(prompt, stopping_criteria=[check_stop], **kwargs) return result[0]["generated_text"].rstrip(check_stop.matched) app = Flask("dolly") @app.route('/', method...
https://python.langchain.com/en/latest/modules/models/llms/integrations/databricks.html
b1407d9b4a77-4
# Use `transform_input_fn` and `transform_output_fn` if the app # expects a different input schema and does not return a JSON string, # respectively, or you want to apply a prompt template on top. def transform_input(**request): full_prompt = f"""{request["prompt"]} Be Concise. """ request["prompt"] = f...
https://python.langchain.com/en/latest/modules/models/llms/integrations/databricks.html
2bde97209629-0
.ipynb .pdf Modal Modal# The Modal Python Library provides convenient, on-demand access to serverless cloud compute from Python scripts on your local computer. The Modal itself does not provide any LLMs but only the infrastructure. This example goes over how to use LangChain to interact with Modal. Here is another exam...
https://python.langchain.com/en/latest/modules/models/llms/integrations/modal.html
2bde97209629-1
llm_chain.run(question) previous Manifest next MosaicML By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/models/llms/integrations/modal.html
628a20c85bfe-0
.ipynb .pdf Writer Writer# Writer is a platform to generate different language content. This example goes over how to use LangChain to interact with Writer models. You have to get the WRITER_API_KEY here. from getpass import getpass WRITER_API_KEY = getpass() import os os.environ["WRITER_API_KEY"] = WRITER_API_KEY from...
https://python.langchain.com/en/latest/modules/models/llms/integrations/writer.html
a72ebd01a734-0
.ipynb .pdf Manifest Contents Compare HF Models Manifest# This notebook goes over how to use Manifest and LangChain. For more detailed information on manifest, and how to use it with local hugginface models like in this example, see https://github.com/HazyResearch/manifest Another example of using Manifest with Langc...
https://python.langchain.com/en/latest/modules/models/llms/integrations/manifest.html
a72ebd01a734-1
state_of_the_union = f.read() mp_chain.run(state_of_the_union) 'President Obama delivered his annual State of the Union address on Tuesday night, laying out his priorities for the coming year. Obama said the government will provide free flu vaccines to all Americans, ending the government shutdown and allowing business...
https://python.langchain.com/en/latest/modules/models/llms/integrations/manifest.html
a72ebd01a734-2
) manifest3 = ManifestWrapper( client=Manifest( client_name="huggingface", client_connection="http://127.0.0.1:5002" ), llm_kwargs={"temperature": 0.01} ) llms = [manifest1, manifest2, manifest3] model_lab = ModelLaboratory(llms) model_lab.compare("What color is a flamingo?") Input: What col...
https://python.langchain.com/en/latest/modules/models/llms/integrations/manifest.html
abffc1cbdc8e-0
.ipynb .pdf C Transformers C Transformers# The C Transformers library provides Python bindings for GGML models. This example goes over how to use LangChain to interact with C Transformers models. Install %pip install ctransformers Load Model from langchain.llms import CTransformers llm = CTransformers(model='marella/gp...
https://python.langchain.com/en/latest/modules/models/llms/integrations/ctransformers.html
0103bff5f1e2-0
.ipynb .pdf CerebriumAI Contents Install cerebrium Imports Set the Environment API Key Create the CerebriumAI instance Create a Prompt Template Initiate the LLMChain Run the LLMChain CerebriumAI# Cerebrium is an AWS Sagemaker alternative. It also provides API access to several LLM models. This notebook goes over how ...
https://python.langchain.com/en/latest/modules/models/llms/integrations/cerebriumai_example.html
0103bff5f1e2-1
Run the LLMChain# Provide a question and run the LLMChain. question = "What NFL team won the Super Bowl in the year Justin Beiber was born?" llm_chain.run(question) previous Beam integration for langchain next Cohere Contents Install cerebrium Imports Set the Environment API Key Create the CerebriumAI instance Crea...
https://python.langchain.com/en/latest/modules/models/llms/integrations/cerebriumai_example.html
039855f89c05-0
.ipynb .pdf Llama-cpp Llama-cpp# llama-cpp is a Python binding for llama.cpp. It supports several LLMs. This notebook goes over how to run llama-cpp within LangChain. !pip install llama-cpp-python Make sure you are following all instructions to install all necessary model files. You don’t need an API_TOKEN! from langch...
https://python.langchain.com/en/latest/modules/models/llms/integrations/llamacpp.html
039855f89c05-1
' First we need to identify what year Justin Beiber was born in. A quick google search reveals that he was born on March 1st, 1994. Now we know when the Super Bowl was played in, so we can look up which NFL team won it. The NFL Superbowl of the year 1994 was won by the San Francisco 49ers against the San Diego Chargers...
https://python.langchain.com/en/latest/modules/models/llms/integrations/llamacpp.html
232b5ca3bc6c-0
.ipynb .pdf Replicate Contents Setup Calling a model Chaining Calls Replicate# Replicate runs machine learning models in the cloud. We have a library of open-source models that you can run with a few lines of code. If you’re building your own machine learning models, Replicate makes it easy to deploy them at scale. T...
https://python.langchain.com/en/latest/modules/models/llms/integrations/replicate.html
232b5ca3bc6c-1
Note that only the first output of a model will be returned. llm = Replicate(model="replicate/dolly-v2-12b:ef0e1aefc61f8e096ebe4db6b2bacc297daf2ef6899f0f7e001ec445893500e5") prompt = """ Answer the following yes/no question by reasoning step by step. Can a dog drive a car? """ llm(prompt) 'The legal driving age of dog...
https://python.langchain.com/en/latest/modules/models/llms/integrations/replicate.html
232b5ca3bc6c-2
from langchain.chains import SimpleSequentialChain First, let’s define the LLM for this model as a flan-5, and text2image as a stable diffusion model. dolly_llm = Replicate(model="replicate/dolly-v2-12b:ef0e1aefc61f8e096ebe4db6b2bacc297daf2ef6899f0f7e001ec445893500e5") text2image = Replicate(model="stability-ai/stable-...
https://python.langchain.com/en/latest/modules/models/llms/integrations/replicate.html
232b5ca3bc6c-3
catchphrase = overall_chain.run("colorful socks") print(catchphrase) > Entering new SimpleSequentialChain chain... novelty socks todd & co. https://replicate.delivery/pbxt/BedAP1PPBwXFfkmeD7xDygXO4BcvApp1uvWOwUdHM4tcQfvCB/out-0.png > Finished chain. https://replicate.delivery/pbxt/BedAP1PPBwXFfkmeD7xDygXO4BcvApp1uvWOwU...
https://python.langchain.com/en/latest/modules/models/llms/integrations/replicate.html
e50c87836ecd-0
.ipynb .pdf Google Cloud Platform Vertex AI PaLM Google Cloud Platform Vertex AI PaLM# 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. PaLM API on Vertex AI is a Preview offering, su...
https://python.langchain.com/en/latest/modules/models/llms/integrations/google_vertex_ai_palm.html
e50c87836ecd-1
prompt = PromptTemplate(template=template, input_variables=["question"]) llm = VertexAI() llm_chain = LLMChain(prompt=prompt, llm=llm) question = "What NFL team won the Super Bowl in the year Justin Beiber was born?" llm_chain.run(question) 'Justin Bieber was born on March 1, 1994. The Super Bowl in 1994 was won by the...
https://python.langchain.com/en/latest/modules/models/llms/integrations/google_vertex_ai_palm.html
3998fa682c86-0
.ipynb .pdf Banana Banana# Banana is focused on building the machine learning infrastructure. This example goes over how to use LangChain to interact with Banana models # Install the package https://docs.banana.dev/banana-docs/core-concepts/sdks/python !pip install banana-dev # get new tokens: https://app.banana.dev/ ...
https://python.langchain.com/en/latest/modules/models/llms/integrations/banana.html
1ad62b021e54-0
.ipynb .pdf Petals Contents Install petals Imports Set the Environment API Key Create the Petals instance Create a Prompt Template Initiate the LLMChain Run the LLMChain Petals# Petals runs 100B+ language models at home, BitTorrent-style. This notebook goes over how to use Langchain with Petals. Install petals# The p...
https://python.langchain.com/en/latest/modules/models/llms/integrations/petals_example.html
1ad62b021e54-1
Run the LLMChain# Provide a question and run the LLMChain. question = "What NFL team won the Super Bowl in the year Justin Beiber was born?" llm_chain.run(question) previous OpenLM next PipelineAI Contents Install petals Imports Set the Environment API Key Create the Petals instance Create a Prompt Template Initiat...
https://python.langchain.com/en/latest/modules/models/llms/integrations/petals_example.html
a5f32f701c04-0
.ipynb .pdf PromptLayer OpenAI Contents Install PromptLayer Imports Set the Environment API Key Use the PromptLayerOpenAI LLM like normal Using PromptLayer Track PromptLayer OpenAI# PromptLayer is the first platform that allows you to track, manage, and share your GPT prompt engineering. PromptLayer acts a middleware...
https://python.langchain.com/en/latest/modules/models/llms/integrations/promptlayer_openai.html
a5f32f701c04-1
The above request should now appear on your PromptLayer dashboard. Using PromptLayer Track# If you would like to use any of the PromptLayer tracking features, you need to pass the argument return_pl_id when instantializing the PromptLayer LLM to get the request id. llm = PromptLayerOpenAI(return_pl_id=True) llm_results...
https://python.langchain.com/en/latest/modules/models/llms/integrations/promptlayer_openai.html
c7c350895d24-0
.ipynb .pdf GPT4All Contents Specify Model GPT4All# GitHub:nomic-ai/gpt4all an ecosystem of open-source chatbots trained on a massive collections of clean assistant data including code, stories and dialogue. This example goes over how to use LangChain to interact with GPT4All models. %pip install gpt4all > /dev/null ...
https://python.langchain.com/en/latest/modules/models/llms/integrations/gpt4all.html
c7c350895d24-1
# # send a GET request to the URL to download the file. Stream since it's large # response = requests.get(url, stream=True) # # open the file in binary mode and write the contents of the response to it in chunks # # This is a large file, so be prepared to wait. # with open(local_path, 'wb') as f: # for chunk in tqd...
https://python.langchain.com/en/latest/modules/models/llms/integrations/gpt4all.html
99bd5fcaa19e-0
.ipynb .pdf Structured Decoding with JSONFormer Contents HuggingFace Baseline JSONFormer LLM Wrapper Structured Decoding with JSONFormer# JSONFormer is a library that wraps local HuggingFace pipeline models for structured decoding of a subset of the JSON Schema. It works by filling in the structure tokens and then sa...
https://python.langchain.com/en/latest/modules/models/llms/integrations/jsonformer_experimental.html
99bd5fcaa19e-1
{arg_schema} EXAMPLES ---- Human: "So what's all this about a GIL?" AI Assistant:{{ "action": "ask_star_coder", "action_input": {{"query": "What is a GIL?", "temperature": 0.0, "max_new_tokens": 100}}" }} Observation: "The GIL is python's Global Interpreter Lock" Human: "Could you please write a calculator program ...
https://python.langchain.com/en/latest/modules/models/llms/integrations/jsonformer_experimental.html
99bd5fcaa19e-2
original_model = HuggingFacePipeline(pipeline=hf_model) generated = original_model.predict(prompt, stop=["Observation:", "Human:"]) print(generated) Setting `pad_token_id` to `eos_token_id`:50256 for open-end generation. 'What's the difference between an iterator and an iterable?' That’s not so impressive, is it? It d...
https://python.langchain.com/en/latest/modules/models/llms/integrations/jsonformer_experimental.html
b94921ff5495-0
.ipynb .pdf Azure OpenAI Contents API configuration Deployments Azure OpenAI# This notebook goes over how to use Langchain with Azure OpenAI. The Azure OpenAI API is compatible with OpenAI’s API. The openai Python package makes it easy to use both OpenAI and Azure OpenAI. You can call Azure OpenAI the same way you ...
https://python.langchain.com/en/latest/modules/models/llms/integrations/azure_openai_example.html
b94921ff5495-1
import openai response = openai.Completion.create( engine="text-davinci-002-prod", prompt="This is a test", max_tokens=5 ) !pip install openai import os os.environ["OPENAI_API_TYPE"] = "azure" os.environ["OPENAI_API_VERSION"] = "2022-12-01" os.environ["OPENAI_API_BASE"] = "..." os.environ["OPENAI_API_KEY"] ...
https://python.langchain.com/en/latest/modules/models/llms/integrations/azure_openai_example.html
bceff10f8e7a-0
.ipynb .pdf PredictionGuard Contents Basic LLM usage Chaining PredictionGuard# How to use PredictionGuard wrapper ! pip install predictionguard langchain import predictionguard as pg from langchain.llms import PredictionGuard Basic LLM usage# pgllm = PredictionGuard(name="default-text-gen", token="<your access token>...
https://python.langchain.com/en/latest/modules/models/llms/integrations/predictionguard.html
ed93ce1f177d-0
.ipynb .pdf StochasticAI StochasticAI# Stochastic Acceleration Platform aims to simplify the life cycle of a Deep Learning model. From uploading and versioning the model, through training, compression and acceleration to putting it into production. This example goes over how to use LangChain to interact with Stochastic...
https://python.langchain.com/en/latest/modules/models/llms/integrations/stochasticai.html
c07550599734-0
.ipynb .pdf Structured Decoding with RELLM Contents Hugging Face Baseline RELLM LLM Wrapper Structured Decoding with RELLM# RELLM is a library that wraps local Hugging Face pipeline models for structured decoding. It works by generating tokens one at a time. At each step, it masks tokens that don’t conform to the pro...
https://python.langchain.com/en/latest/modules/models/llms/integrations/rellm_experimental.html
c07550599734-1
Setting `pad_token_id` to `eos_token_id`:50256 for open-end generation. generations=[[Generation(text=' "What\'s the capital of Maryland?"\n', generation_info=None)]] llm_output=None That’s not so impressive, is it? It didn’t answer the question and it didn’t follow the JSON format at all! Let’s try with the structured...
https://python.langchain.com/en/latest/modules/models/llms/integrations/rellm_experimental.html
ec049cd55476-0
.ipynb .pdf Huggingface TextGen Inference Huggingface TextGen Inference# Text Generation Inference is a Rust, Python and gRPC server for text generation inference. Used in production at HuggingFace to power LLMs api-inference widgets. This notebooks goes over how to use a self hosted LLM using Text Generation Inference...
https://python.langchain.com/en/latest/modules/models/llms/integrations/huggingface_textgen_inference.html
9f03ccca6fe8-0
.ipynb .pdf Hugging Face Hub Contents Examples StableLM, by Stability AI Dolly, by DataBricks Camel, by Writer Hugging Face Hub# The Hugging Face Hub is a platform with over 120k models, 20k datasets, and 50k demo apps (Spaces), all open source and publicly available, in an online platform where people can easily col...
https://python.langchain.com/en/latest/modules/models/llms/integrations/huggingface_hub.html
9f03ccca6fe8-1
StableLM, by Stability AI# See Stability AI’s organization page for a list of available models. repo_id = "stabilityai/stablelm-tuned-alpha-3b" # Others include stabilityai/stablelm-base-alpha-3b # as well as 7B parameter versions llm = HuggingFaceHub(repo_id=repo_id, model_kwargs={"temperature":0, "max_length":64}) # ...
https://python.langchain.com/en/latest/modules/models/llms/integrations/huggingface_hub.html
9f03ccca6fe8-2
Hugging Face Local Pipelines Contents Examples StableLM, by Stability AI Dolly, by DataBricks Camel, by Writer By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/models/llms/integrations/huggingface_hub.html
a29d0cb5342b-0
.ipynb .pdf ForefrontAI Contents Imports Set the Environment API Key Create the ForefrontAI instance Create a Prompt Template Initiate the LLMChain Run the LLMChain ForefrontAI# The Forefront platform gives you the ability to fine-tune and use open source large language models. This notebook goes over how to use Lang...
https://python.langchain.com/en/latest/modules/models/llms/integrations/forefrontai_example.html
a29d0cb5342b-1
DeepInfra next Google Cloud Platform Vertex AI PaLM Contents Imports Set the Environment API Key Create the ForefrontAI instance Create a Prompt Template Initiate the LLMChain Run the LLMChain By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/models/llms/integrations/forefrontai_example.html
d2496f805f55-0
.ipynb .pdf Aleph Alpha Aleph Alpha# The Luminous series is a family of large language models. This example goes over how to use LangChain to interact with Aleph Alpha models # Install the package !pip install aleph-alpha-client # create a new token: https://docs.aleph-alpha.com/docs/account/#create-a-new-token from ge...
https://python.langchain.com/en/latest/modules/models/llms/integrations/aleph_alpha.html
785c31df3918-0
.ipynb .pdf OpenAI Contents OpenAI if you are behind an explicit proxy, you can use the OPENAI_PROXY environment variable to pass through OpenAI# OpenAI offers a spectrum of models with different levels of power suitable for different tasks. This example goes over how to use LangChain to interact with OpenAI models #...
https://python.langchain.com/en/latest/modules/models/llms/integrations/openai.html
15e108fd089f-0
.ipynb .pdf OpenLM Contents Setup Using LangChain with OpenLM OpenLM# OpenLM is a zero-dependency OpenAI-compatible LLM provider that can call different inference endpoints directly via HTTP. It implements the OpenAI Completion class so that it can be used as a drop-in replacement for the OpenAI API. This changeset u...
https://python.langchain.com/en/latest/modules/models/llms/integrations/openlm.html
15e108fd089f-1
for model in ["text-davinci-003", "huggingface.co/gpt2"]: llm = OpenLM(model=model) llm_chain = LLMChain(prompt=prompt, llm=llm) result = llm_chain.run(question) print("""Model: {} Result: {}""".format(model, result)) Model: text-davinci-003 Result: France is a country in Europe. The capital of France ...
https://python.langchain.com/en/latest/modules/models/llms/integrations/openlm.html
52efda04cd42-0
.ipynb .pdf Runhouse Runhouse# The Runhouse allows remote compute and data across environments and users. See the Runhouse docs. This example goes over how to use LangChain and Runhouse to interact with models hosted on your own GPU, or on-demand GPUs on AWS, GCP, AWS, or Lambda. Note: Code uses SelfHosted name instead...
https://python.langchain.com/en/latest/modules/models/llms/integrations/runhouse.html
52efda04cd42-1
llm_chain = LLMChain(prompt=prompt, llm=llm) question = "What NFL team won the Super Bowl in the year Justin Beiber was born?" llm_chain.run(question) INFO | 2023-02-17 05:42:23,537 | Running _generate_text via gRPC INFO | 2023-02-17 05:42:24,016 | Time to send message: 0.48 seconds "\n\nLet's say we're talking sports ...
https://python.langchain.com/en/latest/modules/models/llms/integrations/runhouse.html
52efda04cd42-2
) return pipe def inference_fn(pipeline, prompt, stop = None): return pipeline(prompt)[0]["generated_text"][len(prompt):] llm = SelfHostedHuggingFaceLLM(model_load_fn=load_pipeline, hardware=gpu, inference_fn=inference_fn) llm("Who is the current US president?") INFO | 2023-02-17 05:42:59,219 | Running _generat...
https://python.langchain.com/en/latest/modules/models/llms/integrations/runhouse.html
b3a4916e0bfb-0
.ipynb .pdf How to serialize LLM classes Contents Loading Saving How to serialize LLM classes# This notebook walks through how to write and read an LLM Configuration to and from disk. This is useful if you want to save the configuration for a given LLM (e.g., the provider, the temperature, etc). from langchain.llms i...
https://python.langchain.com/en/latest/modules/models/llms/examples/llm_serialization.html
b3a4916e0bfb-1
llm.save("llm.json") llm.save("llm.yaml") previous How to cache LLM calls next How to stream LLM and Chat Model responses Contents Loading Saving By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/models/llms/examples/llm_serialization.html
57f836b58ab0-0
.ipynb .pdf How to write a custom LLM wrapper How to write a custom LLM wrapper# This notebook goes over how to create a custom LLM wrapper, in case you want to use your own LLM or a different wrapper than one that is supported in LangChain. There is only one required thing that a custom LLM needs to implement: A _call...
https://python.langchain.com/en/latest/modules/models/llms/examples/custom_llm.html