An integration package connecting Together and LangChain
Project description
langchain-together
This package contains the LangChain integration for Together's generative models.
Installation
pip install -U langchain-together
Embeddings
You can use Together's embedding models through TogetherEmbeddings
class.
from langchain_together import TogetherEmbeddings
embeddings = TogetherEmbeddings(
model='togethercomputer/m2-bert-80M-8k-retrieval'
)
embeddings.embed_query("What is a large language model?")
LLMs
You can use Together's generative AI models as Langchain LLMs:
from langchain_together import Together
from langchain_core.prompts import PromptTemplate
llm = Together(
model="togethercomputer/RedPajama-INCITE-7B-Base",
temperature=0.7,
max_tokens=64,
top_k=1,
# together_api_key="..."
)
template = """Question: {question}
Answer: """
prompt = PromptTemplate.from_template(template)
chain = prompt | llm
question = "Who was the president in the year Justin Beiber was born?"
print(chain.invoke({"question": question}))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file langchain_together-0.1.0.tar.gz
.
File metadata
- Download URL: langchain_together-0.1.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04a131edf8f5f1a686599651573afcbdf3438845c6e98cc14478c0c11d0cb0f6 |
|
MD5 | 6e0132367dea90b83bf0b4003e8cc3e8 |
|
BLAKE2b-256 | d7343bd05b3b21c7841449432bfd2ecb38a05ecb8d335a947a8ca917890a754d |
File details
Details for the file langchain_together-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: langchain_together-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 725977b01a08042a44fc92af5c38c6b0010802cc84288658dc15a4382fce1586 |
|
MD5 | 7d047b30d4a28d4e6f78d164e18bed64 |
|
BLAKE2b-256 | 64e8cd518f84ecdd95de32a3023ce47fbf2e90c481a0258d3081c10174b036ae |