-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1324a2a
commit 170ccb4
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## Chapter 9: Text Summarization | ||
LangChain can be used to efficiently summarize long pieces of text. | ||
|
||
``` | ||
from langchain.chains.summarize import load_summarize_chain | ||
from langchain.llms import OpenAI | ||
from langchain.docstore.document import Document | ||
text = """ | ||
LangChain is a framework for developing applications powered by language models. It enables applications that: | ||
Are context-aware: connect a language model to sources of context (prompt instructions, few shot examples, content to ground its response in, etc.) | ||
Reason: rely on a language model to reason (about how to answer based on provided context, what actions to take, etc.) | ||
""" | ||
docs = [Document(page_content=text)] | ||
chain = load_summarize_chain(OpenAI(temperature=0), chain_type="stuff") | ||
print(chain.run(docs)) | ||
``` |