
LANGCHAIN — What Is Kay X Cybersyn X Langchain?
Programming isn’t about what you know; it’s about what you can figure out. — Chris Pine
Kay x Cybersyn x LangChain is a collaborative effort to make financial data processing more accessible. The SEC Retriever on LangChain, powered by Kay and Cybersyn, allows developers to retrieve context from SEC Filings for generative and conversational agents. Here’s a tutorial on how to get started with this API and an overview of the infrastructure behind it.
Getting Started
First, install Kay (pip install kay) and obtain your free API key on Kay.ai.
Initialize the KayAiRetriever with the datasets you need. For example, to access 10-K and 10-Qs and retrieve the top 6 chunks for a given query, use the following code:
from langchain.retrievers import KayAiRetriever
retriever = KayAiRetriever.create(dataset_id="company", data_types=["10-K", "10-Q"], num_contexts=6)Now you can plug this context into your existing prompts and pass it to your favorite LLM.
Use Cases
SEC Filings are large, unstructured documents that capture crucial information about US public companies. Here are a few examples of how users are utilizing this data:
- Analyzing Financial Performance
- Identifying Sales Opportunities
- Monitoring Industry Trends
- Compliance Research
Behind the Scenes: Infrastructure
The infrastructure behind RAG systems consists of three essential components: data, representation, and retrieval.
Collecting data
Cybersyn builds derived data products from proprietary and public datasets, including SEC Filings, and loads them onto the Snowflake Marketplace. This significantly improves ease of access to the data.
Generating embeddings
After enriching the raw text data with company and document metadata, an embedding model is chosen. In this case, gte-base was selected. To handle SEC data, dynamic variable chunking based on sections is implemented, and Ray's parallelization framework is used for offline batch embedding jobs.
Optimizing Retrieval
The retrieval process involves building a Query Intent Classifier (QIC) powered by LLMs, and dynamically selecting between vector search and hybrid search. Additionally, Cohere’s Re-rank is applied to the retrieved chunks.
Resources and Next Steps
For further exploration, you can refer to the SEC Retriever on LangChain, Cybersyn’s LLM Training Essentials, Snowflake Marketplace, and Kay’s Github.
This tutorial provides a comprehensive overview of Kay x Cybersyn x LangChain and demonstrates how to utilize the SEC Retriever API for financial data processing. By following the provided code snippets and examples, developers can easily integrate this powerful tool into their applications.
