From 833d61adb359f5e9bbb642187565ef8807a20731 Mon Sep 17 00:00:00 2001 From: Vincent Chen <62143443+Mao-Siang@users.noreply.github.com> Date: Fri, 29 Mar 2024 08:02:32 +0800 Subject: [PATCH] docs: update Together README.md (#18004) ## PR message **Description:** This PR adds a README file for the Together API in the `libs/partners` folder of this repository. The README includes: - A brief description of the package - Installation instructions and class introductions - Simple usage examples **Issue:** #17545 This PR only contains document changes. --------- Co-authored-by: Bagatur --- libs/partners/together/README.md | 47 ++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/libs/partners/together/README.md b/libs/partners/together/README.md index 34ab63d561..c63c4f0abc 100644 --- a/libs/partners/together/README.md +++ b/libs/partners/together/README.md @@ -1 +1,48 @@ # langchain-together + +This package contains the LangChain integration for Together's generative models. + +## Installation + +```sh +pip install -U langchain-together +``` + +## Embeddings + +You can use Together's embedding models through `TogetherEmbeddings` class. + +```py +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: + +```py +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})) +```