• Updated:
  • Featured post

How LLMs generate the next token

(este post es una explicación de la teoría. dejo aquí otro post con el detalle práctico de como usar la temperature, top_k y top_p a efectos prácticos)

Explicación más en detalle de cómo obtienen los LLMs las probabilidades para generar el siguiente token

Sampling

En cada posición el modelo tiene una bolsa con miles de tokens posibles. Sampling es el proceso de no coger siempre el token más probable, si no de orientarlo a coger respuestas con determinadas características.

Si el modelo escogiera siempre el token con más probabilidades, obtendríamos respuestas aburridas y repetitivas.

Logits

Para generar el siguiente token, una red neuronal calcula primero los vectores de logits, donde cada logit corresponde a un valor posible. El tamaño de estos vectores de logits es tan grande como el vocabulario completo del modelo.

(representación de vectores de logits)

flowchart LR
	N1["What's your favorite color?"]:::note --> Z
	Z --> A1 --> A
	Z --> B1 --> B
	Z --> C1 --> C
	Z --> D1 --> D
	
	Z["Neural network"]
    A["a"]
    A1["(-0.5)"]
    B["green"]
    B1["(0.7)"]
    C["red"]
    C1["(0.5)"]
    D["the"]
    D1["(-1.2)"]
    
    classDef note fill:none,stroke:none,color:#777;    

Los logits NO representan probabilidades ya que no suman 1 y pueden incluso ser negativos (la probabilidades no pueden). Para convertir logits a probabilidades se usa una Softmax layer

Temperature

La temperatura es una constante que se aplica a los logits antes de la transformación de la Softmax layer. Se usa para ajustar la creatividad del modelo y redistribuir la probabilidad de los valores. Una temperatura más alta hace que el modelo sea más creativo ya que aumenta las posibilidades de elegir tokens menos probables.

xychart-beta
  title "Temperatura vs Probabilidad"
  x-axis "Temperatura (T)" [0.1, 0.2, 0.5, 1, 2, 5]
  y-axis "Probabilidad" 0 --> 1
  line "P(token1)" [0.9999546, 0.9933071, 0.8807971, 0.7310586, 0.6224593, 0.5498340]
  line "P(token2)" [0.0000454, 0.0066929, 0.1192029, 0.2689414, 0.3775407, 0.4501660]

Ejemplos de temperaturas:

  • Low (0.2-0.3): El modelo es cauto y elige las palabras más probables. Output factual y predecible.
  • Medium (0.5-0.7): Un mix de confiabilidad y engagement
  • High (0.9-1.0): Toma riesgos y es impredecible

Read More

Advanced SQL

UNION

The union sentence is used to accumulate results for two SELECT sentences.

SELECT column1, column2 FROM table1
UNION
SELECT column1, column2 FROM table2

We have the following tables

company1

per name surname
1 ANTONIO PEREZ
2 PEDRO RUIZ

company2

per name surname
1 LUIS LOPEZ
2 ANTONIO PEREZ

Read More

Count number of entries in filtered table

(for this post some formulas and menu names are in spanish as my excel and computer are in spanish and excel formulas depend on this).

The formula is:

=AGREGAR(3;3;J:J)-1

The first two parameters are for the function itself. The important one is J:J which marks the column to count. What’s important here is this is not going to count filtered items in tables.

Watch out with headers! If you have headers in your table, add -1 to your formula.

Find differences for big dynamic lists in Excel

(for this post some formulas and menu names are in spanish as my excel and computer are in spanish and excel formulas depend on this).

Here is how to find and mark differences in unequal, really long lists or tables in Excel. For my example, one list is a partial list from other. Some items are missing and you’ve to find which ones are.

This is the full list.

Read More

OAuth 2.0

Authentication process of verifying an identity. We confirm they’re who they say they are. (username & pwd).

Authorization process of verifying what someone is allowed to do. (Permissions and access control).

Past solutions

From worst one to best one and the problems they originate:

Credential Sharing

The worst one. An App is not able to differentiate between real user access and programmatical access.
Permissions are typically too broad. It also the ability to access more content than it should.

We could redirect the user off to the API where they could enter their credentials and get a cookie. This allows an app to access the API.

Dangerous because CSRF attacks. We’ve authorised the whole browser and not the app.

Read More

How to solve VirtualBox disk has run out of space

How to solve the problem “Low disk space on ‘Filesystem root’. The volume has only xMB disk space remaining” when you completely fill a virtual disk in VirtualBox.

(You have to delete all your snapshots first)

Open a cmd terminal and run the following command:

"c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifymedium  
"c:\Users\mario\VirtualBox VMs\Ubuntu OTAN\Ubuntu OTAN.vdi" --resize 30000

The first path is an executable included with VirtualBox.
The second one is where your VDI actually is. --resize takes the size in MBs.

Open gpartitioner and resize it.

SCRUM PSM1 Certification - Index

TODO: add scrum-psm1-badge image

Status: Certified!

This notes are my watered-down, personal version of The Scrum Guide 2020 and the following Udemy Course: “Preparation For Professional Scrum Master Level 1 (PSM1)” by Vladimir Raykov.

If you want to get ready for the certification exam, I fully recommend buying and watching his course, several times, in Udemy.

Scrum Guide 2020
1. Scrum Guide 2020 Notes
2. Scrum Glossary

“Preparation For Professional Scrum Master Level 1 (PSM1)” by Vladimir Raykov
1. Scrum Introduction
2. The Scrum Team
3. Scrum Events
4. Scrum Artifacts
5. Scrum Practices and Charts
6. A few words before the Exam
7. Recap of key concepts
8. Possible exam questions