Approcci di fine-tuning

Introduzione agli LLM in Python

Jasmin Ludolf

Senior Data Science Content Developer, DataCamp

Fine-tuning

 

Caso d'uso di fine-tuning LLM in chimica

Introduzione agli LLM in Python

Full fine-tuning

 

  • Si aggiornano tutti i pesi del modello
  • Computazionalmente costoso

 

Full fine-tuning

Introduzione agli LLM in Python

Partial fine-tuning

 

  • Alcuni layer sono fissi
  • Si aggiornano solo i layer specifici del task

 

Partial fine-tuning

Introduzione agli LLM in Python

Transfer learning

 

  • Un modello pre-addestrato è adattato a un task diverso ma correlato
  • Sfrutta conoscenze da un dominio a uno correlato

Il paradigma del transfer learning

Introduzione agli LLM in Python

N-shot learning

  • Zero-shot learning: nessun esempio
  • One-shot learning: un esempio
  • Few-shot learning: alcuni esempi
Introduzione agli LLM in Python

One-shot learning

from transformers import pipeline

generator = pipeline(task="sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")

input_text = """
Classify the sentiment of this sentence as either Positive or Negative.
Example:
Text: "I'm feeling great today!" Sentiment: Positive
Text: "The weather today is lovely." Sentiment:
"""

result = generator(input_text, max_length=100)
print(result[0]["label"])
POSITIVE
Introduzione agli LLM in Python

Passons à la pratique !

Introduzione agli LLM in Python

Preparing Video For Download...