What temperature does
It divides the logits before the softmax. Below one the distribution sharpens and the top token dominates; above one it flattens and unlikely tokens become reachable.
At zero it is effectively deterministic — right for classification, extraction and anything your code parses. Above about 1.5 output is frequently incoherent, because the distribution is close to uniform.
Top-p against top-k
Top-k keeps a fixed number of candidates regardless of how confident the model is. Top-p keeps as many as are needed to reach a probability mass, so it adapts: on a confident prediction it keeps one or two, on an uncertain one it keeps many.
That adaptivity is why top-p is generally preferred. Change one of temperature and top-p, never both — they control overlapping things and tuning them together makes the effect of either impossible to attribute.