NCA-GENL - Experimentation - Section 3.5

Use LangChain to organise and compose LLM workflows.

Use LangChain to compose LLM-powered workflows by chaining prompts, memory, tools, and retrievers into coherent pipelines for tasks such as document question answering and autonomous agents. Recognise how LangChain abstractions like chains, agents, and document loaders reduce boilerplate and simplify experimentation.

LangChain

Practice question for this objective

Free sampleExperimentationmedium

A data science team uses LangChain to build a multi-step pipeline: first summarise a document, then classify the summary into one of five categories. The team wants the classification step to receive only a clean category label string, not a raw JSON blob. Which LangChain mechanism should they add after the classification LLM call to achieve this?

  • AReplace the classification LLM call with a zero-shot agent so that the agent decides the category and returns only plain text by default
  • BAttach an OutputParser, such as a StrOutputParser or a custom parser, to the classification chain so that it extracts and returns the label string from the model response Correct
  • CSet the chain's verbose flag to False so that intermediate JSON tokens are suppressed from the final output string
  • DStore the raw JSON output in ConversationBufferMemory and retrieve only the category field in the next chain invocation
Identify OutputParsers as the correct LangChain component for transforming raw LLM responses into structured or cleaned output values. When a LangChain chain calls an LLM, the response is an AIMessage or a raw string depending on the model wrapper. An OutputParser sits at the end of the chain and converts that raw response into the desired Python type - a string, a list, a Pydantic model, or any structured object. StrOutputParser strips the message envelope to a plain string, making it ideal for label extraction. Agents, memory, and verbose settings all serve different purposes and do not perform response parsing.

Why A is wrong: Replacing a deterministic classification step with a zero-shot agent introduces unnecessary overhead, unpredictable intermediate actions, and does not guarantee a clean label output - it is a heavier tool for a problem that parsing solves simply.

Why B is correct: OutputParsers are the LangChain abstraction responsible for transforming a raw model response into a typed or cleaned Python value. StrOutputParser returns the content string directly, while custom parsers can extract a specific field - exactly the right tool for producing a clean label.

Why C is wrong: The verbose flag controls logging/tracing output to the terminal; it has no effect on the actual string value returned by the chain to the caller. The model's raw JSON reply would still be present in the chain's output.

Why D is wrong: Memory is designed to persist conversational context across turns, not to parse structured fields out of a single model response. Using memory here adds complexity without addressing the parsing requirement.

See more NCA-GENL practice questions, answers explained.

More in this domain

Back to all Experimentation objectives, or the NCA-GENL cert hub.

Examworthy is not affiliated with or endorsed by NVIDIA. Original, blueprint-aligned practice material only.