Notes on DeepLearning.AI's course

  • Lang Chain

Components

Models

1. LLMs
2. Chat Models
3. Text Embedding Models

Prompts

1. Prompt Templates,
2. Output Parsers: (Retry/Fixing Logic) 
   langchain libaray function parse the LLM output assuming that it will use certain keywords.`
3. Memory: LLM are stateless and transaction is independent, Memory here refers to the convesation history as 'context'
   1. Unlimited: ConversationBufferMemory, allows for storing of messages and then extracts the messages in a variable
   2. Windowed, keep a few rounds ($k$ rounds) conversations as a list of the interactions of the conversation over time: ConversationBufferWindowMemory
   3. Token Length as parameter, keeps a buffer of recent interactions in memory, ans uses token length rahter than number of interactions to determine when to flush interactions :  ConversationTokenBufferMemory
   4. LLM summarize the conversation over time as context: ConversationSummaryMemory
   5. Vector Data Memory: Store text (from conversation or elsewhere) in a vector database and retrieves the most releveant blocks of text
   6. Entity Memories: Using an LLM, it remembers details about specific entities
    You can also use multiple memories at one timee. E.g. Conversation memory + Entity memory to recall individuals
    Store the conversation in a conversational database (such as key-value store or SQL)
4. Example Selectors

Indexes

create small chunks and index using embeddings, and retrival based on vector similarity
1. Document Loaders
2. Text Splitters
3. Vector Stores
   1. Embedding captures semantic meaning
   2. Text with similar content will have similar vectors
4. Retrievers

Chains

1. Prompt+LLM+Ouput parsing
2. As building blocks for longer chains
   1. Sequential Chain
   2. Routher Chain
3. Application Specific chains
4. Question and Answering: 
   * Stuffing is the simplest method, you simply stuff all data into the prompt as context to pass  to the LLM, Drawback is the LLMs have a context length and for large documents this will not work as it will result in a prompt larger than the context length.
   * Map_reduce, checks->each map to 1 llm -> join into one LLM -> final answer
   * Refine, Iterative incrase
   * Map_rerank, select highest call
5. Evaluation
   1. Manual
   2. LLM assited
   3. Turn on langchain debug to True

Agents

1. Agent Types
   1. Algorithms for getting LLMs to use tools
2. Agent Toolkits:
   1. Agents armed with specific tools for a specific application