LLMChain combines a language model with a PromptTemplate, then runs the composed prompt against an input. In phishing detection, it turns an email and a yes/no question into a model response. section 5.3.1
A practical LLMChain workflow includes:
- Create a prompt template with named input variables such as question. section 5.3.1
- Initialize an LLM, such as FLAN-T5 through HuggingFaceHub. section 5.3.1
- Construct the chain by passing both prompt and llm, then call run for one request or generate for many. section 5.3.1 section 5.3.2
- Adapt the prompt to the model: non-chat FLAN-T5 uses an Answer cue, while a chat-based Mistral model does not require it. section 5.3.1 section 5.4.2
Phishing-email classification
Create a chain from a question template and a HuggingFaceHub FLAN-T5 model, pass an email asking “Is this a phishing email? (yes/no),” and print the returned classification. Batch several similar questions with generate. section 5.3.1 section 5.3.2
# create prompt template > LLM chain
llm_chain = LLMChain(
prompt=prompt,
llm=hub_llm
)
Shows the minimal construction that binds a prompt template to an LLM before execution. section 5.3.1
