The basic idea: you store multiple embedding vectors per document. How do you generate these embeddings?
👨👦Smaller chunks (this is ParentDocumentRetriever)
🌞Summary of document
❓Hypothetical questions
🖐️Manually specified text snippets
Quick 🧵
Language models are getting larger and larger context windows
This is great, because you can pass bigger chunks in!
But if you have larger chunks, then a single embedding per chunk can start to fall flat, as there can be multiple distinct topics in that longer passage
Aug 15, 2023 • 7 tweets • 3 min read
🚢Benchmarking Question/Answering Over CSV Data
Deep dive on improving an application that does question answering over CSV data:
📜3000 word blog post
🎥30min video
🛌Open sourced eval data
🎬Open sourced code for gathering feedback
🤖Open sourced final agent code
Combining documents with LLMs is a key part of retrieval and chaining
We've improved our @LangChainAI reference documentation across the 5 major CombineDocumentsChains and helper functions to help with clarity and understanding of how these work
🧵
📄 `format_document`
Want to control which metadata keys show up in the prompt?
This helper function is rarely exposed, but is key to combining documents with LLMs
It takes a Document and formats it into a string using a PromptTemplate
🧵
Most "chat-your-data" applications involve three steps:
1⃣Condense the chat history into a standalone question
2⃣Retrieve relevant docs based on the standalone question
3⃣Generate a final answer based on the retrieved documents
This involves two total calls to the LLM!
May 24, 2023 • 4 tweets • 3 min read
Want to be able to easily access open source models behind an API?
🧵
Up until now, agents in LangChain have followed the algorithm of:
- take user input
- think about action to take
- take action and observe response
- repeat until done
This is great for simple tasks, but for more complex tasks we've noticed the agent losing focus
May 4, 2023 • 5 tweets • 2 min read
🔀Router Chains🔀
A simple (yet much requested) abstraction that started with a @ShreyaR pr months ago and is finally in @LangChainAI!
- Router Chain does classification to choose sub chain to use
- Call the selected chain with that input
Lots of potential use cases!
🧵
Why add this?
We view this as a basic building block for constructing chains
Just as you could want to run a sequence of chains sequentially, there's also the basic building block of forking and routing to the correct chain
What are some of the use cases?
May 3, 2023 • 5 tweets • 2 min read
🔧Structured Tools🔧
Agents are all about the tools you give it
Tools in @LangChainAI used to just take a single string input. In our new release, tools can now take multiple inputs. We also introduce a new agent type for these tools
🧵
When we started @LangChainAI, LLMs were simple enough that we made tools just a single string input (they couldn't handle anything more complex)
Now models are good enough that they can handle more complex tool interfaces. Accordingly, we're updating the tool interface
Apr 27, 2023 • 9 tweets • 3 min read
Retrieval for QA systems is hard
Vector search is good for capturing semantically similar texts, but often queries specify desired attributes like time, authorship, or other "metadata" fields, which vector search is not great at
Enter... ⭐️SelfQueryRetriever⭐️
The basic idea of SelfQueryRetriever is simple: given a user query, use an LLM to extract:
1. The `query` string to use for vector search 2. A metadata filter to pass in as well
Most vector databases support metadata filters, so this doesn't require any new databases or indexes
Apr 21, 2023 • 9 tweets • 4 min read
⭐️Contextual Compression⭐️
We introduce multiple new methods in @LangChainAI to compress retrieved documents w.r.t. the query before passing to an LLM for generation
Inspired by @willpienaar at the "LLMs in production" conference
The key step in "chat-your-data" or "document question-answering" applications is a retrieval step, which fetches relevant documents and inserts them into a prompt to pass to the LLM