Home/AI/ML Notes/GenAI and LLMs Summary/Temperature, Function Calling & LSTMs
⌂ Main Page
GenAI and LLMs Summary

Temperature, Function Calling & LSTMs

Sampling temperature, function calling, and LSTMs vs. transformers.

On this page

Temperature Explained

Default=1.0. Higher temperature - more creative, diverse outputs, lower - more focused and deterministic generated text - hyperparameter affecting proba distribution of generated tokens generated by the GPT model.

Mathematically, the temperature is incorporated into the softmax function (converts raw logits produced by the GPT model into a probability distribution) which becomes temperature-scaled softmax:

A mathematical equation with numbers and symbols Description automatically generated

Formulas 2 and 3 are equivalent: β=1/τ​.

Here logits r scores. If they r energy (Boltzman), use “–β”

Parameter tau - temperature - controls softness of proba distribution. When tau gets lower, the biggest value in x gets more probability, when tau gets larger - the proba will be split more evenly on different elements.

Function Calling

Developers can now describe functions to LLM, and have the model intelligently choose to output a JSON object containing arguments to call those functions. Example: define function for weather as json output = { ‘city’: city, ‘state’: state, ‘country’: country, ‘temperature’: degrees Farenheit}. By providing schemas for "functions", the LLM will choose one and attempt to output a response matching that schema.

LSTM vs. Transformer

LSTM models consist of RNN cells designed to store and manipulate info across time steps -address the vanishing gradient problem, captures somewhat long dependencies in sequences. Transformers contain a stack of encoder and decoder layers, each consisting of self-attention and feed-forward neural network components. Self-attention - the most notable difference is the absence of RNN cells in Transformer architecture, which allows it to process inputs in parallel, resulting in faster computation. This architecture allows Transformers to process sequence data without the need for recurrent connections or cells, enabling:

LSTMs can still perform well on shorter sequences in tasks not requiring the full power and complexity of a Transformer model, e.g. sentiment or time-series prediction.

Transformer disadvantages: