You're blindfolded. Something quacks. You say "duck." You didn't see it. You didn't read the word. You identified it purely by what it did. This is behavioural recognition โ and it's the foundation of an entire philosophy of computation.
Duck Typing: The Programming Metaphor
In dynamically typed languages, you don't check what something is. You check what it can do:
# Python doesn't care what 'bird' is.
# It cares what 'bird' can do.
bird.quack() # If this works, it's duck enough.
bird.swim() # If this works too, even more duck.
bird.fly() # Hmm. Some ducks can't fly. Behaviour is complicated.
"If it quacks like a duck and swims like a duck, I call it a duck." Identity isn't declared by type โ it's inferred by interface. What it does defines what it is. This isn't just a programming trick. It's a deep epistemological claim.
How Transformers Learn Behaviour
A language model never sees a duck. It reads billions of sentences where the word "duck" appears. It learns what ducks do in text:
"The duck swam across the pond."
"She fed the ducks at the park."
"A duck quacked loudly."
"The mother duck led her ducklings to the water."
"Duck hunting season opens in September."
"He had to duck to avoid the low beam."
The model builds a behavioural profile from statistical co-occurrence. It knows ducks swim, quack, waddle, fly, nest, migrate, get fed bread (unfortunately), and have ducklings. It knows this because those are the verbs that appear near "duck" in the training data. It knows "duck" as a behaviour pattern long before it could ever know "duck" as a visual entity.
Prediction as Behaviour Modelling
When a Transformer predicts the next token, it's doing duck typing on language. Given the context "The duck swam across the ___", the model assigns high probability to tokens like "pond", "lake", "river" โ because those are where ducks swim. It's predicting behaviour from behavioural patterns.
What the Model Learns
Statistical behaviour: ducks appear in contexts with water, parks, bread, ponds, feathers, eggs, hunting.
Relational behaviour: ducks are-a-type-of bird, smaller-than geese, have ducklings, are related to "mallard" and "drake."
Linguistic behaviour: "duck" as noun vs verb, "duck!" as imperative, "sitting duck" as idiom. The model learns every behavioural context the word has ever appeared in.
What This Means
The model's "duck" is a cloud of behavioural associations. It doesn't have a picture of a duck. It has a high-dimensional vector that encodes: "the kind of entity that does these things, appears in these contexts, relates to these other things." Duckness-as-behaviour. The interface, not the implementation.
Interfaces All the Way Down
Duck typing isn't just a metaphor. It's how most recognition works in practice:
API design โ you call an endpoint. If it returns the right shape of data, you don't care what's behind it. Duck typing over HTTP.
Job interviews โ "can you do X, Y, Z?" You're duck-typing a human. If they demonstrate the behaviours, they get the job. What they "are" (their degree, background) matters less.
Medical diagnosis โ symptoms are behaviours. If it presents like flu, respond like flu. The underlying cause matters eventually, but the initial response is behavioural pattern matching.
Scientific models โ if a model predicts the right outcomes, it's useful. Whether it captures "true" underlying reality is a separate (possibly unanswerable) question. Physics is duck-typed.
Where Behaviour Breaks
The parrot problem โ a parrot can quack. Is it a duck? Behavioural mimicry breaks duck typing. The interface matches but the implementation is completely different.
Goodhart's Law โ "when a measure becomes a target, it ceases to be a good measure." If you define duck by behaviour, things will optimise to match the behaviour without being a duck. See: SEO, teaching to the test, gaming metrics.
Hallucination โ an LLM can generate perfectly plausible text about ducks that is factually wrong. The behaviour looks right โ the sentences read naturally โ but the content is fabricated. Duck-shaped output from a non-duck process.
Edge cases โ a penguin swims. Is it a duck? No, because "swims" isn't enough of the interface. How many behaviours do you need to match before something qualifies? The boundary is fuzzy.
Behaviour is the most pragmatic channel. It answers "what does it do?" rather than "what is it?" โ and in most real systems, what it does is all that matters. But behaviour can be mimicked, gamed, and faked. The quack is not the duck.