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
Close
Hashes for langchain_together-0.0.2.post2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6926b52b5b303f504870064f3f22e0ab3e75e3663e55ca18c0c8761bb516037 |
|
MD5 | d60b470767047b7a95ad688a8fe4c3d9 |
|
BLAKE2b-256 | 5dc062d25d673511fcfead20874b2ec98baa458b0c435504839eb5b3254c12dc |
Close
Hashes for langchain_together-0.0.2.post2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5a6e336792813f080e4bc675bf71f9ec1be5ce5435cd33733af2fb4f8f53427 |
|
MD5 | 217acab6cdea53ca03e95baf88b8f9d1 |
|
BLAKE2b-256 | 25bc871cb66a964bea5ef17bba8ebbb3854b58d323f0c0ee97fb92133abfed0e |