liveBook · Manning

Multi-step reasoning

As explained in Natural Language Processing in Action, Second Edition

Reasoning is the process of deriving conclusions or solving problems by applying relationships among facts, premises, or representations.

Multi-step reasoning derives conclusions by applying relationships among facts, premises, or representations. It matters because reasoning underpins claims of intelligence, yet fluent language generation can imitate reasonable answers without establishing truth, correctness, or reality. section 10.1 section 10.2.3

Assess reasoning claims by separating several capabilities:

  • Generalization reuses patterns in natural-language data, but does not necessarily extend to physical-world understanding. section 10.1
  • A plausible response is not evidence of reasoning: training on question-answer pairs can make familiar tests look solved. section 10.1
  • Scaling model size and training data may improve grammar and vocabulary without reliably improving reasoning. section 10.2.3

Counting legs with GPT-2

Prompting GPT-2 with “There are 2 cows and 2 bulls, how many legs are there?” and sampling ten short completions produces answers such as “four,” “2,” “30,” “one,” and “three.” The varied outputs expose fluent generation without dependable multi-step calculation. section 10.1

Listing 10.1 Counting cow legs with GPT-2
>>> from transformers import pipeline, set_seed
>>> generator = pipeline('text-generation', model='openai-gpt')
>>> set_seed(0)                                                    #1
>>> q = "There are 2 cows and 2 bulls, how many legs are there?"
>>> responses = generator(
...     f"Question: {q}\nAnswer: ",
...     max_new_tokens=5,                   #2
...     num_return_sequences=10)    #3
>>> answers = []
>>> for resp in responses:
...     text = resp['generated_text']
...     answers.append(text[text.find('Answer: ')+9:])
>>> answers
['four', 'only', '2', 'one', '30', 'one', 'three', '1', 'no', '1']

Run the supplied Transformers pipeline example to inspect multiple generated answers and compare apparent fluency with arithmetic reliability. section 10.1

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Explains reasoning conceptually and tests it with one generation experiment, stopping short of formal reasoning algorithms or internals.
Examples
Uses standardized-test performance, post-training programming challenges, and GPT-2’s cow-leg counting outputs.
What you can do after
Evaluate apparent reasoning by inspecting generated outputs and separating plausible language from grounded, reliable conclusions.
How it connects
Connects reasoning with large language models, generalization, artificial intelligence, and hallucination.

Also explained in

Compare how 10 books explain multi-step reasoning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.