text stringlengths 0 59.1k |
|---|
- **What Orchestration Does:** it optimizes the calls. Either probably to some easy tasks it is dealing with a more trivial, rule based rather than querying the LLM. Or maybe it is caching results of oft used things so that it doesn't trouble the LLM again and again. In other words, it considers both your time and pock... |
:::important Important Note: |
LLMs are not magic wands. They are great tools, of course, but they are no panacea. The key to their successful use is knowing what they are good at and what they are not, and supplementing the weaknesses with intelligent approaches such as orchestration. |
::: |
You can sense that orchestration is far from any "add-on." In fact, it's often a _requirement_ to make LLMs actually powerful and useful applications. So, what does this thing called orchestration comprise? What are the building blocks that come together to create magic? |
## The Basics of LLM Orchestration: Chains, Agents, Memory, and More! |
Excellent, we understand why orchestration is such a key thing. So, how does this system function? What are the fundamental building blocks? Now, let's have a closer look at some of the concepts you'll encounter most frequently, and these will be the crux of it all. |
### Chains: The Dance of LLM Calls |
One of the simplest orchestration concepts is called "chains." You string multiple steps together as implied by its name. Those steps could be LLM calls, using a tool, or just about any form of data processing step. |
- **Simple Chains**: The most straightforward logic. Ask a question to an LLM, receive its answer, forward that answer to another LLM, receive its answer. and so forth. You could, for instance, first summarize some text and then convert that summary into keywords. |
- **Smarter Chains:** Add a bit of logic. For example: If the LLM's answer is 'yes,' do this; if 'no,' do that. Or you take multiple results generated by one LLM and tell another LLM, "Choose the best one among these." |
- _One of my earliest "Aha! All I had just used a chain to get them to classify a user's request with some initial classification and then send it to a specific LLM for that classification. All I had done was get them to share the workload!_ |
<OrchestrationStarterKitAdvisor /> |
### Agents & Tools: Letting LLMs Make the Decisions! |
This is where things get _really_ interesting. Agents transform LLMs from purely taking commands into creatures that think for themselves, decide how to apply which tool when, and make a plan to reach a goal. |
- What is an Agent? At the heart of an agent is an LLM. This LLM understands the task, thinks over what tools it has, and goes through a thought process very much like, "To achieve this task, I first need to do this, then I ought to use this tool, and with the output from that, I should do that." |
- **What Can Tools Be?** Anything you can imagine! |
- **Web Search:** Searching the internet for up-to-date information. |
- **Calculator:** For mathematical operations. (Yes, LLMs can sometimes mess up even simple math; a calculator tool is a lifesaver!) |
**Code Interpreter:** See running the code that's generated by the LLM and the result it produces. |
- **Database Querying:** Retrieving information from your company's database. |
- **API Calls:** Using the API of any external service, such as the weather, maps, and calendar, etc. |
- **Custom Tools:** Your own custom-written tools that accomplish some specific task. |
- **ReAct (Reason + Act) Pattern:** Agents most often apply this very common thought pattern. |
The LLM _reasons_, like: What should I do? Which tool should I select? Then it _acts_-that is to say, applies the tool. Then _observes_-looks at what the tool provides and repeats the cycle as long as needed to be done. When I first saw this, I felt like I was literally reading an AI's "inner voice." Very impressive! |
<ZoomableMermaid chart={`graph LR |
A[Start with Goal/Query] --> B{LLM: Reason} |
B -- Thought --> C[Determine Action & Tool] |
C --> D{Execute Action/Tool} |
D -- Observation --> E[Get Result from Tool/Environment] |
E --> B |
B -- Final Answer --> F[End/Respond to User] |
style A fill:#131B23,stroke:#50C878,stroke-width:2px,color:#CCCCCC |
style B fill:#121E1B,stroke:#059669,stroke-width:3px,color:#FFFFFF |
style C fill:#0F1A15,stroke:#50C878,stroke-width:2px,color:#CCCCCC |
style D fill:#0F1A15,stroke:#50C878,stroke-width:2px,color:#CCCCCC |
style E fill:#131B23,stroke:#50C878,stroke-width:1px,color:#AAAAAA |
style F fill:#0F1A15,stroke:#50C878,stroke-width:2px,color:#50C878 |
`} /> |
:::tip Imagine an Agent |
Suppose that you asked an agent, "Find the lowest fare flight ticket from Los Angeles to San Francisco for tomorrow and send it in my mail." Then the agent might think like this: |
1. _Thought:_ "I need to find a flight ticket. For this, I should use the 'flight search' tool." |
2. _Action:_ Utilizes the flight search tool to look for Los Angeles to San Francisco tickets for tomorrow's date. |
3. _Observation:_ Receives the results from the tool (a list of flights and prices). |
4. _Thinking:_ "I should select the cheapest one and send e-mail. I should select by price, select the cheapest, and then send the e-mail." |
5. _Action:_ Selects the cheapest ticket, passing this selection onto the send e-mail function. |
And voilà! Ticket information right into your inbox. How cool is that? |
6. Memory: No More "What Were We Talking About?" |
As we said, LLMs have a short memory. "Memory" modules are there to solve this problem. They contextualize the LLM by keeping the record of a process or a conversation. |
::: |
- Conversation Memory |
The most common type. This saves all the conversation with the user or important parts of it. Now the LLM can reference earlier steps in the conversation to say something like, "Regarding that X topic you brought up earlier." |
- **Entity Memory:** Pick up and store important entities mentioned in the conversation (names of people, places, products, etc.) and information related to them. |
- **Knowledge Graph Memory:** The LLM can make deeper inferences by storing even more complex relationships in a graph structure. |
- **Long-Term Memory with Vector Databases:** A bit more advanced, but really powerful. You can take any document, old conversation or text data of your interest and convert them into numerical forms called "vector embeddings" and store them in special databases such as Pinecone, Chroma, FAISS, etc. When an LLM gives a... |
This is RAG (Retrieval Augmented Generation) itself! It becomes as if your own personal Google. |
### Data Ingestion & Retrieval (RAG): Feed LLMs Your Own Information |
This is actually very close to the Memory topic, especially the vector databases part. RAG is the key to making LLMs talk to your own private data, company documents, content on your website, or any pool of information. |
- How the Process Works (Simplified): |
- **Data Loading:** You are loading your own documents (PDF, TXT, HTML etc) in the system |
- **Chunking:** The inputted data is subdivided into smaller bits. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.