Petals runs 100B+ language models at home, BitTorrent-style.
This notebook goes over how to use LangChain with Petals.
Install petals
Thepetals package is required to use the Petals API. Install petals using pip3 install petals.
For Apple Silicon(M1/M2) users please follow this guide https://github.com/bigscience-workshop/petals/issues/147#issuecomment-1365379642 to install petals
Imports
Set the environment API Key
Make sure to get your API key from Huggingface.Create the petals instance
You can specify different parameters such as the model name, max new tokens, temperature, etc.Create a Prompt template
We will create a prompt template for Question and Answer.Initiate the LLMChain
Run the LLMChain
Provide a question and run the LLMChain.Connect these docs to Claude, VSCode, and more via MCP for real-time answers.