id
stringlengths
14
15
text
stringlengths
17
2.72k
source
stringlengths
47
115
980fdf1a8fbc-1
"\n\nLet's say we're talking sports teams who won the Super Bowl in the year Justin Beiber" You can also load more custom models through the SelfHostedHuggingFaceLLM interface: llm = SelfHostedHuggingFaceLLM( model_id="google/flan-t5-small", task="text2text-generation", hardware=gpu, ) llm("What is the capital of Germa...
https://python.langchain.com/docs/integrations/llms/runhouse
980fdf1a8fbc-2
llm = SelfHostedPipeline.from_pipeline(pipeline="models/pipeline.pkl", hardware=gpu)
https://python.langchain.com/docs/integrations/llms/runhouse
45f43c13facd-0
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. example_doc_1 = """ Peter and Elizabeth took a taxi to attend the night party i...
https://python.langchain.com/docs/integrations/llms/sagemaker
6e770194b86c-0
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 StochasticAI models. You have to get...
https://python.langchain.com/docs/integrations/llms/stochasticai
715589b4fbc9-0
Nebula is a large language model (LLM) built by Symbl.ai. It is trained to perform generative tasks on human conversations. Nebula excels at modeling the nuanced details of a conversation and performing tasks on the conversation. This example goes over how to use LangChain to interact with the Nebula platform. Use a co...
https://python.langchain.com/docs/integrations/llms/symblai_nebula
715589b4fbc9-1
instruction = "Identify the main objectives mentioned in this conversation." prompt = PromptTemplate.from_template("{instruction}\n{conversation}") llm_chain = LLMChain(prompt=prompt, llm=llm) llm_chain.run(instruction=instruction, conversation=conversation)
https://python.langchain.com/docs/integrations/llms/symblai_nebula
2a1f520ac188-0
TextGen GitHub:oobabooga/text-generation-webui A gradio web UI for running Large Language Models like LLaMA, llama.cpp, GPT-J, Pythia, OPT, and GALACTICA. This example goes over how to use LangChain to interact with LLM models via the text-generation-webui API integration. Please ensure that you have text-generation-we...
https://python.langchain.com/docs/integrations/llms/textgen
9732c5eeb6de-0
Titan Takeoff TitanML helps businesses build and deploy better, smaller, cheaper, and faster NLP models through our training, compression, and inference optimization platform. Our inference server, Titan Takeoff enables deployment of LLMs locally on your hardware in a single command. Most generative model architecture...
https://python.langchain.com/docs/integrations/llms/titan_takeoff
9732c5eeb6de-1
To shutdown the server, run the following command. You will be presented with options on which Takeoff server to shut down, in case you have multiple running servers. iris takeoff --shutdown # shutdown the server Inferencing your model​ To access your LLM, use the TitanTakeoff LLM wrapper: from langchain.llms import Ti...
https://python.langchain.com/docs/integrations/llms/titan_takeoff
9732c5eeb6de-2
llm = TitanTakeoff( baseURL="http://localhost:8000", generate_max_length=128, temperature=1.0 ) prompt = "What is the largest planet in the solar system?" llm(prompt) No parameters are needed by default, but a baseURL that points to your desired URL where Takeoff is running can be specified and generation parameters ...
https://python.langchain.com/docs/integrations/llms/titan_takeoff
5e0ea664fbe5-0
Tongyi Qwen Tongyi Qwen is a large-scale language model developed by Alibaba's Damo Academy. It is capable of understanding user intent through natural language understanding and semantic analysis, based on user input in natural language. It provides services and assistance to users in different domains and tasks. By p...
https://python.langchain.com/docs/integrations/llms/tongyi
d9df6565aa20-0
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 langchain.llms im...
https://python.langchain.com/docs/integrations/llms/writer
7711a378b110-0
vLLM vLLM is a fast and easy-to-use library for LLM inference and serving, offering: State-of-the-art serving throughput Efficient management of attention key and value memory with PagedAttention Continuous batching of incoming requests Optimized CUDA kernels This notebooks goes over how to use a LLM with langchain an...
https://python.langchain.com/docs/integrations/llms/vllm
7711a378b110-1
1. The first Pokemon game was released in 1996. 2. The president was Bill Clinton. 3. Clinton was president from 1993 to 2001. 4. The answer is Clinton. Distributed Inference​ vLLM supports distributed tensor-parallel inference and serving. To run multi-GPU inference with the LLM class, set the tensor_parallel_siz...
https://python.langchain.com/docs/integrations/llms/vllm
36cb2ce670e9-0
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 = getpass() from langchai...
https://python.langchain.com/docs/integrations/llms/ai21
c98519e78278-0
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 getpass import getpass ALE...
https://python.langchain.com/docs/integrations/llms/aleph_alpha
0b3a36488652-0
Amazon API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. APIs act as the "front door" for applications to access data, business logic, or functionality from your backend services. Using API Gateway, you can create RESTful APIs a...
https://python.langchain.com/docs/integrations/llms/amazon_api_gateway
f7c12c4d9e60-0
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. It will send the requests to Anyscale Service endpoint, which is concatenate ANYSCALE_SERVICE_URL and ANYSCALE...
https://python.langchain.com/docs/integrations/llms/anyscale
349b8acb9338-0
Azure ML Azure ML is a platform used to build, train, and deploy machine learning models. Users can explore the types of models to deploy in the Model Catalog, which provides Azure Foundation Models and OpenAI Models. Azure Foundation Models include various open-source models and popular Hugging Face models. Users can ...
https://python.langchain.com/docs/integrations/llms/azure_ml
349b8acb9338-1
def format_response_payload(self, output: bytes) -> str: response_json = json.loads(output) return response_json[0]["summary_text"] content_formatter = CustomFormatter() llm = AzureMLOnlineEndpoint( endpoint_api_key=os.getenv("BART_ENDPOINT_API_KEY"), endpoint_url=os.getenv("BART_ENDPOINT_URL"), model_kwargs={"tempe...
https://python.langchain.com/docs/integrations/llms/azure_ml
349b8acb9338-2
On June 1, 2021, Loona announced that they would be having a comeback on June 28, with their fourth EP, [&] (read as and). [48] The following day, on June 2, a teaser was posted to Loona's official social media accounts showing twelve sets of eyes, confirming the return of member HaSeul who had been on hiatus since ea...
https://python.langchain.com/docs/integrations/llms/azure_ml
349b8acb9338-3
formatter_template = "Write a {word_count} word essay about {topic}." prompt = PromptTemplate( input_variables=["word_count", "topic"], template=formatter_template ) content_formatter = DollyContentFormatter() llm = AzureMLOnlineEndpoint( endpoint_api_key=os.getenv("DOLLY_ENDPOINT_API_KEY"), endpoint_url=os.getenv("...
https://python.langchain.com/docs/integrations/llms/azure_ml
7ead5839a9ae-0
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 call OpenAI with the exceptions noted below. API configuration​ You c...
https://python.langchain.com/docs/integrations/llms/azure_openai
7ead5839a9ae-1
To use AAD in Python with LangChain, install the azure-identity package. Then, set OPENAI_API_TYPE to azure_ad. Next, use the DefaultAzureCredential class to get a token from AAD by calling get_token as shown below. Finally, set the OPENAI_API_KEY environment variable to the token value. import os from azure.identity i...
https://python.langchain.com/docs/integrations/llms/azure_openai
7ead5839a9ae-2
# Get the Azure Credential credential = DefaultAzureCredential() # Set the API type to `azure_ad` os.environ["OPENAI_API_TYPE"] = "azure_ad" # Set the API_KEY to the token from the Azure credential os.environ["OPENAI_API_KEY"] = credential.get_token("https://cognitiveservices.azure.com/.default").token The DefaultAzur...
https://python.langchain.com/docs/integrations/llms/azure_openai
7ead5839a9ae-3
os.environ["OPENAI_API_TYPE"] = "azure" os.environ["OPENAI_API_VERSION"] = "2023-05-15" os.environ["OPENAI_API_BASE"] = "..." os.environ["OPENAI_API_KEY"] = "..." # Import Azure OpenAI from langchain.llms import AzureOpenAI # Create an instance of Azure OpenAI # Replace the deployment name with your own llm = AzureOpen...
https://python.langchain.com/docs/integrations/llms/azure_openai
13bce588ddac-0
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/ # We need two tokens, ...
https://python.langchain.com/docs/integrations/llms/banana
75adb6b8ae70-0
Baseten Baseten provides all the infrastructure you need to deploy and serve ML models performantly, scalably, and cost-efficiently. This example demonstrates using Langchain with models deployed on Baseten. Setup To run this notebook, you'll need a Baseten account and an API key. You'll also need to install the Basete...
https://python.langchain.com/docs/integrations/llms/baseten
75adb6b8ae70-1
menu_maker = SimpleSequentialChain( chains=[link_one, link_two, link_three], verbose=True ) menu_maker.run("South Indian")
https://python.langchain.com/docs/integrations/llms/baseten
f70300cc8276-0
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 prom...
https://python.langchain.com/docs/integrations/llms/beam
05ddc0e160b3-0
Amazon 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 from langchain.chains import ConversationChain from langchain.memory import ConversationBufferMemory conv...
https://python.langchain.com/docs/integrations/llms/bedrock
b44edc385454-0
Users can view their logs, requests, and API keys on the Validator Endpoint Frontend. However, changes to the configuration are currently prohibited; otherwise, the user's queries will be blocked. If you encounter any difficulties or have any questions, please feel free to reach out to our developer on GitHub, Discord ...
https://python.langchain.com/docs/integrations/llms/bittensor
b44edc385454-1
llm_chain = LLMChain(prompt=prompt, llm=llm) question = "What is bittensor?" llm_chain.run(question) from langchain.agents import ( AgentType, initialize_agent, load_tools, ZeroShotAgent, Tool, AgentExecutor, ) from langchain.memory import ConversationBufferMemory from langchain import LLMChain, PromptTemplate from la...
https://python.langchain.com/docs/integrations/llms/bittensor
d096c10d3a6a-0
ChatGLM ChatGLM-6B is an open bilingual language model based on General Language Model (GLM) framework, with 6.2 billion parameters. With the quantization technique, users can deploy locally on consumer-grade graphics cards (only 6GB of GPU memory is required at the INT4 quantization level). ChatGLM2-6B is the second-...
https://python.langchain.com/docs/integrations/llms/chatglm
d096c10d3a6a-1
llm_chain.run(question) ChatGLM payload: {'prompt': '北京和上海两座城市有什么不同?', 'temperature': 0.1, 'history': [['我将从美国到中国来旅游,出行前希望了解中国的城市', '欢迎问我任何问题。']], 'max_length': 80000, 'top_p': 0.9, 'sample_model_args': False}
https://python.langchain.com/docs/integrations/llms/chatglm
d096c10d3a6a-2
'北京和上海是中国的两个首都,它们在许多方面都有所不同。\n\n北京是中国的政治和文化中心,拥有悠久的历史和灿烂的文化。它是中国最重要的古都之一,也是中国历史上最后一个封建王朝的都城。北京有许多著名的古迹和景点,例如紫禁城、天安门广场和长城等。\n\n上海是中国最现代化的城市之一,也是中国商业和金融中心。上海拥有许多国际知名的企业和金融机构,同时也有许多著名的景点和美食。上海的外滩是一个历史悠久的商业区,拥有许多欧式建筑和餐馆。\n\n除此之外,北京和上海在交通和人口方面也有很大差异。北京是中国的首都,人口众多,交通拥堵问题较为严重。而上海是中国的商业和金融中心,人口密度较低,交通相对较为便利。\n\n总的来说,北京和上海是两个拥有...
https://python.langchain.com/docs/integrations/llms/chatglm
94bbc300f6b0-0
CerebriumAI Cerebrium is an AWS Sagemaker alternative. It also provides API access to several LLM models. This notebook goes over how to use Langchain with CerebriumAI. Install cerebrium​ The cerebrium package is required to use the CerebriumAI API. Install cerebrium using pip3 install cerebrium. # Install the package ...
https://python.langchain.com/docs/integrations/llms/cerebriumai
0f03b85eedad-0
Clarifai Clarifai is an AI Platform that provides the full AI lifecycle ranging from data exploration, data labeling, model training, evaluation, and inference. This example goes over how to use LangChain to interact with Clarifai models. To use Clarifai, you must have an account and a Personal Access Token (PAT) key....
https://python.langchain.com/docs/integrations/llms/clarifai
0f03b85eedad-1
llm_chain.run(question) 'Justin Bieber was born on March 1, 1994. So, we need to figure out the Super Bowl winner for the 1994 season. The NFL season spans two calendar years, so the Super Bowl for the 1994 season would have taken place in early 1995. \n\nThe Super Bowl in question is Super Bowl XXIX, which was played ...
https://python.langchain.com/docs/integrations/llms/clarifai
acd047259637-0
" 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 information, the Green Bay Pac...
https://python.langchain.com/docs/integrations/llms/cohere
7d63c9b6d590-0
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/gpt-2-ggml") Generate Text pr...
https://python.langchain.com/docs/integrations/llms/ctransformers
067901ad2050-0
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: If the model signature is incompatible or you want to insert extra configs, you can set transform_input_fn and transform_o...
https://python.langchain.com/docs/integrations/llms/databricks
067901ad2050-1
llm = Databricks(endpoint_name="dolly", transform_input_fn=transform_input) llm("How are you?") If the server schema is incompatible or you want to insert extra configs, you can use transform_input_fn and transform_output_fn accordingly. The following is a minimal example for running a driver proxy app to serve an LLM...
https://python.langchain.com/docs/integrations/llms/databricks
067901ad2050-2
llm("How are you?") # If the app accepts extra parameters like `temperature`, # you can set them in `model_kwargs`. llm = Databricks(cluster_driver_port="7777", model_kwargs={"temperature": 0.1}) llm("How are you?") # Use `transform_input_fn` and `transform_output_fn` if the app # expects a different input schema and ...
https://python.langchain.com/docs/integrations/llms/databricks
8c9719d9c357-0
DeepInfra DeepInfra provides several LLMs. This notebook goes over how to use Langchain with DeepInfra. Imports​ import os from langchain.llms import DeepInfra from langchain import PromptTemplate, LLMChain Set the Environment API Key​ Make sure to get your API key from DeepInfra. You have to Login and get a new token....
https://python.langchain.com/docs/integrations/llms/deepinfra
6a07d1787331-0
This page covers how to use the DeepSparse inference runtime within LangChain. It is broken into two parts: installation and setup, and then examples of DeepSparse usage. There exists a DeepSparse LLM wrapper, that provides a unified interface for all models: config = {'max_generated_tokens': 256} llm = DeepSparse(mod...
https://python.langchain.com/docs/integrations/llms/deepsparse
07d333bf83c0-0
Eden AI Eden AI is revolutionizing the AI landscape by uniting the best AI providers, empowering users to unlock limitless possibilities and tap into the true potential of artificial intelligence. With an all-in-one comprehensive and hassle-free platform, it allows users to deploy AI features to production lightning fa...
https://python.langchain.com/docs/integrations/llms/edenai
07d333bf83c0-1
# Open the image using PIL image = Image.open(image_stream) # Display the image image.show() text2image = EdenAI( feature="image" , provider= "openai", resolution="512x512" ) image_output = text2image("A cat riding a motorcycle by Picasso") print_base64_image(image_output) text generation with callback​ from langchain...
https://python.langchain.com/docs/integrations/llms/edenai
a90009a358fb-0
This example goes over how to use LangChain to interact with Fireworks models. Set up your model using a model id. If the model is not set, the default model is fireworks-llama-v2-7b-chat. You can use the LLMs to call the model for specified prompt(s).
https://python.langchain.com/docs/integrations/llms/fireworks
a90009a358fb-1
[[Generation(text='\nThe best cricket player in 2016 is a matter of opinion, but some of the top contenders for the title include:\n\n1. Virat Kohli (India): Kohli had a phenomenal year in 2016, scoring over 1,000 runs in Test cricket, including four centuries, and averaging over 70. He also scored heavily in ODI crick...
https://python.langchain.com/docs/integrations/llms/fireworks
a90009a358fb-2
now, which is just amazing.\n\nBut don't just take my word for it - there are plenty of other great players in the league who could make a strong case for being the best. Guys like Kevin Durant, Steph Curry, James Harden, and Giannis Antetokounmpo are all having incredible seasons, and they've all got their own unique ...
https://python.langchain.com/docs/integrations/llms/fireworks
a90009a358fb-3
Create a prompt template to be used with the LLM Chain. Once this prompt template is created, initialize the chain with the LLM and prompt template, and run the chain with the specified prompts.
https://python.langchain.com/docs/integrations/llms/fireworks
f491ebb7a6e3-0
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 Langchain with ForefrontAI. Imports​ import os from langchain.llms import ForefrontAI from langchain import PromptTemplate, LLMChain Set the Environment API Key​ Make sure ...
https://python.langchain.com/docs/integrations/llms/forefrontai
0e82c9efa47f-0
Google Vertex AI PaLM Note: This is seperate from the Google PaLM integration, it exposes Vertex AI PaLM API on Google Cloud. Setting up​ By default, Google Cloud does not use customer data to train its foundation models as part of Google Cloud's AI/ML Privacy Commitment. More details about how Google processes data c...
https://python.langchain.com/docs/integrations/llms/google_vertex_ai_palm
0e82c9efa47f-1
llm_chain.run(question) '```python\ndef is_prime(n):\n """\n Determines if a number is prime.\n\n Args:\n n: The number to be tested.\n\n Returns:\n True if the number is prime, False otherwise.\n """\n\n # Check if the number is 1.\n if n == 1:\n return False\n\n # Check if the number is 2.\n if n == 2:\n return True\...
https://python.langchain.com/docs/integrations/llms/google_vertex_ai_palm
dcf54c530c12-0
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 Note: you may need to restart the kernel to us...
https://python.langchain.com/docs/integrations/llms/gpt4all
a4177d75d2e5-0
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 use Langchain with GooseAI. Install openai​ The openai package is required to use the GooseAI API. Install openai using pip3 install openai. Imports​ import os from langchain.l...
https://python.langchain.com/docs/integrations/llms/gooseai
b6d5b44bfd44-0
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 collaborate and build ML together. This example showcases how to connect to the Hugging Face Hub and use different mo...
https://python.langchain.com/docs/integrations/llms/huggingface_hub
b6d5b44bfd44-1
print(llm_chain.run(question)) The FIFA World Cup was held in the year 1994. West Germany won the FIFA World Cup in 1994 Dolly, by Databricks​ See Databricks organization page for a list of available models. repo_id = "databricks/dolly-v2-3b" llm = HuggingFaceHub( repo_id=repo_id, model_kwargs={"temperature": 0.5, "max...
https://python.langchain.com/docs/integrations/llms/huggingface_hub
b6d5b44bfd44-2
Question: Who Camel, by Writer​ See Writer's organization page for a list of available models. repo_id = "Writer/camel-5b-hf" # See https://huggingface.co/Writer for other options llm = HuggingFaceHub( repo_id=repo_id, model_kwargs={"temperature": 0.5, "max_length": 64} ) llm_chain = LLMChain(prompt=prompt, llm=llm) pr...
https://python.langchain.com/docs/integrations/llms/huggingface_hub
b6d5b44bfd44-3
llm = HuggingFaceHub( repo_id=repo_id, model_kwargs={"max_length": 128, "temperature": 0.5} ) llm_chain = LLMChain(prompt=prompt, llm=llm) print(llm_chain.run(question))
https://python.langchain.com/docs/integrations/llms/huggingface_hub
07d660b7273d-0
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 and publicly available, in an online platform where people can easily collaborate and build ML together....
https://python.langchain.com/docs/integrations/llms/huggingface_pipelines
b5a08ee969e0-0
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. To use, you should have the text_generation python package installed. f...
https://python.langchain.com/docs/integrations/llms/huggingface_textgen_inference
4b975a57b43d-0
KoboldAI is a "a browser-based front-end for AI-assisted writing with multiple local & remote AI models...". It has a public and local API that is able to be used in langchain. This example goes over how to use LangChain with that API. Documentation can be found in the browser adding /api to the end of your endpoint (i...
https://python.langchain.com/docs/integrations/llms/koboldai
021178807d90-0
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 sampling the content tokens from the model. Warning - this module is still experimental pip install --upgrade jsonformer > /dev/nul...
https://python.langchain.com/docs/integrations/llms/jsonformer_experimental
021178807d90-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 in ...
https://python.langchain.com/docs/integrations/llms/jsonformer_experimental
021178807d90-2
'What's the difference between an iterator and an iterable?' That's not so impressive, is it? It didn't follow the JSON format at all! Let's try with the structured decoder. JSONFormer LLM Wrapper​ Let's try that again, now providing a the Action input's JSON Schema to the model. decoder_schema = { "title": "Decoding ...
https://python.langchain.com/docs/integrations/llms/jsonformer_experimental
005dccede428-0
Llama.cpp llama-cpp-python is a Python binding for llama.cpp. It supports inference for many LLMs, which can be accessed on HuggingFace. This notebook goes over how to run llama-cpp-python within LangChain. Note: new versions of llama-cpp-python use GGUF model files (see here). This is a breaking change. To convert ex...
https://python.langchain.com/docs/integrations/llms/llamacpp
005dccede428-1
CMAKE_ARGS="-DLLAMA_METAL=on" FORCE_CMAKE=1 pip install --upgrade --force-reinstall llama-cpp-python --no-cache-dir Installation with Windows​ It is stable to install the llama-cpp-python library by compiling from the source. You can follow most of the instructions in the repository itself but there are some windows sp...
https://python.langchain.com/docs/integrations/llms/llamacpp
005dccede428-2
Answer: Let's work this out in a step by step way to be sure we have the right answer.""" prompt = PromptTemplate(template=template, input_variables=["question"]) # Callbacks support token-wise streaming callback_manager = CallbackManager([StreamingStdOutCallbackHandler()]) CPU​ Example using a LLaMA 2 7B model # Make...
https://python.langchain.com/docs/integrations/llms/llamacpp
005dccede428-3
llama_print_timings: load time = 358.60 ms llama_print_timings: sample time = 172.55 ms / 256 runs ( 0.67 ms per token, 1483.59 tokens per second) llama_print_timings: prompt eval time = 613.36 ms / 16 tokens ( 38.33 ms per token, 26.09 tokens per second) llama_print_timings: eval time = 10151.17 ms / 255 runs ( 39.81 ...
https://python.langchain.com/docs/integrations/llms/llamacpp
005dccede428-4
1. First, find out when Justin Bieber was born. 2. We know that Justin Bieber was born on March 1, 1994. 3. Next, we need to look up when the Super Bowl was played in that year. 4. The Super Bowl was played on January 28, 1995. 5. Finally, we can use this information to answer the question. The NFL team that won the Su...
https://python.langchain.com/docs/integrations/llms/llamacpp
005dccede428-5
# Make sure the model path is correct for your system! llm = LlamaCpp( model_path="/Users/rlm/Desktop/Code/llama.cpp/models/openorca-platypus2-13b.gguf.q4_0.bin", n_gpu_layers=n_gpu_layers, n_batch=n_batch, callback_manager=callback_manager, verbose=True, # Verbose is required to pass to the callback manager ) llm_chai...
https://python.langchain.com/docs/integrations/llms/llamacpp
005dccede428-6
"\n\n1. Identify Justin Bieber's birth date: Justin Bieber was born on March 1, 1994.\n\n2. Find the Super Bowl winner of that year: The NFL season of 1993 with the Super Bowl being played in January or of 1994.\n\n3. Determine which team won the game: The Dallas Cowboys faced the Buffalo Bills in Super Bowl XXVII on J...
https://python.langchain.com/docs/integrations/llms/llamacpp
005dccede428-7
ggml_metal_init: allocating ggml_metal_init: using MPS ... You also could check Activity Monitor by watching the GPU usage of the process, the CPU usage will drop dramatically after turn on n_gpu_layers=1. For the first call to the LLM, the performance may be slow due to the model compilation in Metal GPU. Grammars​ W...
https://python.langchain.com/docs/integrations/llms/llamacpp
005dccede428-8
llama_print_timings: load time = 357.51 ms llama_print_timings: sample time = 1213.30 ms / 144 runs ( 8.43 ms per token, 118.68 tokens per second) llama_print_timings: prompt eval time = 356.78 ms / 9 tokens ( 39.64 ms per token, 25.23 tokens per second) llama_print_timings: eval time = 3947.16 ms / 143 runs ( 27.60 ms...
https://python.langchain.com/docs/integrations/llms/llamacpp
537501a21295-0
LLM Caching integrations This notebook covers how to cache results of individual LLM calls using different caches. import langchain from langchain.llms import OpenAI # To make the caching really obvious, lets use a slower model. llm = OpenAI(model_name="text-davinci-002", n=2, best_of=2) In Memory Cache​ from langchai...
https://python.langchain.com/docs/integrations/llms/llm_caching
537501a21295-1
'\n\nWhy did the chicken cross the road?\n\nTo get to the other side.' Redis Cache​ Standard Cache​ Use Redis to cache prompts and responses. # We can do the same thing with a Redis cache # (make sure your local Redis instance is running first before running this example) from redis import Redis from langchain.cache im...
https://python.langchain.com/docs/integrations/llms/llm_caching
537501a21295-2
"\n\nWhy don't scientists trust atoms?\nBecause they make up everything." GPTCache​ We can use GPTCache for exact match caching OR to cache results based on semantic similarity Let's first start with an example of exact match from gptcache import Cache from gptcache.manager.factory import manager_factory from gptcache....
https://python.langchain.com/docs/integrations/llms/llm_caching
537501a21295-3
langchain.llm_cache = GPTCache(init_gptcache) # The first time, it is not yet in cache, so it should take longer llm("Tell me a joke") CPU times: user 1.42 s, sys: 279 ms, total: 1.7 s Wall time: 8.44 s '\n\nWhy did the chicken cross the road?\n\nTo get to the other side.' # This is an exact match, so it finds it ...
https://python.langchain.com/docs/integrations/llms/llm_caching
537501a21295-4
'\n\nWhy did the chicken cross the road?\n\nTo get to the other side!' # The second time it is, so it goes faster # When run in the same region as the cache, latencies are single digit ms llm("Tell me a joke") CPU times: user 3.16 ms, sys: 2.98 ms, total: 6.14 ms Wall time: 57.9 ms '\n\nWhy did the chicken cross t...
https://python.langchain.com/docs/integrations/llms/llm_caching
537501a21295-5
engine = create_engine("postgresql://postgres:postgres@localhost:5432/postgres") langchain.llm_cache = SQLAlchemyCache(engine, FulltextLLMCache) Optional Caching​ You can also turn off caching for specific LLMs should you choose. In the example below, even though global caching is enabled, we turn it off for a specific...
https://python.langchain.com/docs/integrations/llms/llm_caching
537501a21295-6
'\n\nPresident Biden is discussing the American Rescue Plan and the Bipartisan Infrastructure Law, which will create jobs and help Americans. He also talks about his vision for America, which includes investing in education and infrastructure. In response to Russian aggression in Ukraine, the United States is joining w...
https://python.langchain.com/docs/integrations/llms/llm_caching
d7e46e4a14b9-0
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 Langchain. from manifest import Manifest from langchain....
https://python.langchain.com/docs/integrations/llms/manifest
d7e46e4a14b9-1
text_splitter = CharacterTextSplitter() mp_chain = MapReduceChain.from_params(llm, prompt, text_splitter) with open("../../../state_of_the_union.txt") as f: 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 p...
https://python.langchain.com/docs/integrations/llms/manifest
d7e46e4a14b9-2
ManifestWrapper Params: {'model_name': 'bigscience/T0_3B', 'model_path': 'bigscience/T0_3B', 'temperature': 0.01} pink ManifestWrapper Params: {'model_name': 'EleutherAI/gpt-neo-125M', 'model_path': 'EleutherAI/gpt-neo-125M', 'temperature': 0.01} A flamingo is a small, round ManifestWrapper Params: {'model_name': 'go...
https://python.langchain.com/docs/integrations/llms/manifest
0c4f3a8cc63e-0
Minimax Minimax is a Chinese startup that provides natural language processing models for companies and individuals. This example demonstrates using Langchain to interact with Minimax. Setup To run this notebook, you'll need a Minimax account, an API key, and a Group ID Single model call from langchain.llms import Mini...
https://python.langchain.com/docs/integrations/llms/minimax
e277a858b3fe-0
Modal The Modal cloud platform provides convenient, on-demand access to serverless cloud compute from Python scripts on your local computer. Use modal to run your own custom LLM models instead of depending on LLM APIs. This example goes over how to use LangChain to interact with a modal HTTPS web endpoint. Question-ans...
https://python.langchain.com/docs/integrations/llms/modal
e277a858b3fe-1
Answer: Let's think step by step.""" prompt = PromptTemplate(template=template, input_variables=["question"]) endpoint_url = "https://ecorp--custom-llm-endpoint.modal.run" # REPLACE ME with your deployed Modal web endpoint's URL llm = Modal(endpoint_url=endpoint_url) llm_chain = LLMChain(prompt=prompt, llm=llm) questi...
https://python.langchain.com/docs/integrations/llms/modal
df795edbe3cb-0
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=langchain from getpass ...
https://python.langchain.com/docs/integrations/llms/mosaicml
e4a140ad4035-0
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 generation, image genera...
https://python.langchain.com/docs/integrations/llms/nlpcloud
f4ffda6c6422-0
This example goes over how to use LangChain to interact with OctoAI LLM endpoints llm = OctoAIEndpoint( model_kwargs={ "max_new_tokens": 200, "temperature": 0.75, "top_p": 0.95, "repetition_penalty": 1, "seed": None, "stop": [], }, ) '\nLeonardo da Vinci was an Italian polymath and painter regarded by many as one of th...
https://python.langchain.com/docs/integrations/llms/octoai
3fc137062b34-0
Ollama allows you to run open-source large language models, such as Llama 2, locally. Ollama bundles model weights, configuration, and data into a single package, defined by a Modelfile. It optimizes setup and configuration details, including GPU usage. For a complete list of supported models and model variants, see t...
https://python.langchain.com/docs/integrations/llms/ollama
3fc137062b34-1
Task decomposition can be approached in three ways: (1) using simple prompting like "Steps for XYZ.\n1.", "What are the subgoals for achieving XYZ?", (2) by using task-specific instructions, or (3) with human inputs.{'model': 'llama2', 'created_at': '2023-08-08T04:01:09.005367Z', 'done': True, 'context': [1, 29871, 1, ...
https://python.langchain.com/docs/integrations/llms/ollama
3fc137062b34-2
1016, 29915, 29873, 1073, 278, 1234, 304, 263, 1139, 29892, 3113, 1016, 29915, 29873, 6232, 2089, 2472, 29889, 13, 13, 29966, 829, 14816, 29903, 6778, 13, 13, 29961, 25580, 29962, 4803, 278, 1494, 12785, 310, 3030, 304, 1234, 278, 1139, 472, 278, 1095, 29889, 29871, 13, 3644, 366, 1016, 29915, 29873, 1073, 278, 1234, 2...
https://python.langchain.com/docs/integrations/llms/ollama
3fc137062b34-3
29999, 29973, 613, 313, 29906, 29897, 491, 773, 3414, 29899, 14940, 11994, 29936, 321, 29889, 29887, 29889, 376, 6113, 263, 5828, 27887, 1213, 363, 5007, 263, 9554, 29892, 470, 313, 29941, 29897, 411, 5199, 10970, 29889, 13, 13, 5398, 26227, 508, 367, 2309, 313, 29896, 29897, 491, 365, 26369, 411, 2560, 9508, 292, 763,...
https://python.langchain.com/docs/integrations/llms/ollama
3fc137062b34-4
567, 363, 1060, 29979, 29999, 7790, 29876, 29896, 19602, 376, 5618, 526, 278, 1014, 1484, 1338, 363, 3657, 15387, 1060, 29979, 29999, 29973, 613, 313, 29906, 29897, 491, 773, 3414, 29899, 14940, 11994, 29936, 321, 29889, 29887, 29889, 376, 6113, 263, 5828, 27887, 1213, 363, 5007, 263, 9554, 29892, 470, 313, 29941, 2989...
https://python.langchain.com/docs/integrations/llms/ollama
3fc137062b34-5
1319, 673, 29901, 518, 29914, 25580, 29962, 13, 5398, 26227, 508, 367, 26733, 297, 2211, 5837, 29901, 313, 29896, 29897, 773, 2560, 9508, 292, 763, 376, 7789, 567, 363, 1060, 29979, 29999, 7790, 29876, 29896, 19602, 376, 5618, 526, 278, 1014, 1484, 1338, 363, 3657, 15387, 1060, 29979, 29999, 29973, 613, 313, 29906, 298...
https://python.langchain.com/docs/integrations/llms/ollama
ae8b65ca644d-0
OpaquePrompts OpaquePrompts is a service that enables applications to leverage the power of language models without compromising user privacy. Designed for composability and ease of integration into existing applications and services, OpaquePrompts is consumable via a simple Python library as well as through LangChain....
https://python.langchain.com/docs/integrations/llms/opaqueprompts
ae8b65ca644d-1
Here's how to handle these changes: * Consider these masked phrases just as placeholders, but still refer to them in a relevant way when answering. * It's possible that different masked terms might mean the same thing. Stick with the given term and don't modify it. * All masked terms follow the "TYPE_ID" pattern. * Ple...
https://python.langchain.com/docs/integrations/llms/opaqueprompts