langchain
langchain
temperature and top_p controls the behavious of the language model within the
langchain frameword
temp: randomness,top_p: it is a nucleus sampling that specifies how many possible
words to consider
temp:0 ->very predictable(nxt possible word) 1-> more likely(randomness)
temp-low, top_p-high -->can have high vocabulary(since top_p is high)
temp-high, top_p-low --> the model make sense on their own
for legal doc.- mostly low temp is preferred.
agents:
______
agents in langchain model is used as a reasoning engine to determine which actions
to take and in which order.
agents combine: language model: decision making and reasoning
tools:external func. or api that the agent can perform specific tasks
decision-making tools: which tools to use, calls the tool and process
the result until the task is complete
Agent Type
Intended Model Type
Supports Chat History
Supports Multi-Input Tools
Supports Parallel Function Calling
Required Model Params
Prompts:
Tools for prompt engineering, including templating (dynamic prompts with variables)
and optimization for better model output. Example:
python
Copy
from langchain import PromptTemplate
template = "Translate this to French: {text}"
prompt = PromptTemplate(input_variables=["text"], template=template)
Chains:
Sequences of modular components (e.g., models, prompts) to handle multi-step tasks.
Chains can be simple (e.g., prompt → model → output) or complex (e.g., retrieval →
summarization).
Chains:
Sequences of modular components (e.g., models, prompts) to handle multi-step tasks.
Chains can be simple (e.g., prompt → model → output) or complex (e.g., retrieval →
summarization).
Agents:
Autonomous components that use LLMs to decide actions (e.g., calling APIs,
searching the web). Agents leverage tools (e.g., calculators, search engines)
dynamically.
Example: An agent might use a search tool to answer real-time questions.
Memory:
Retains context across interactions (e.g., conversation history). Supports short-
term (e.g., chat history) and long-term memory (e.g., summarization of past
interactions).
Example: