Guider des réponses non structurées

Travailler avec Llama 3

Imtihan Ahmed

Machine Learning Engineer

Contrôler la sortie du modèle

  • ✅ Paramètres
  • ✅ Rôles

Comment affiner le modèle

Travailler avec Llama 3

Contrôler la sortie du modèle

  • ✅ Paramètres
  • ✅ Rôles

Comment affiner le modèle - affiner les invites

Travailler avec Llama 3

Contrôler la sortie du modèle

  • ✅ Paramètres
  • ✅ Rôles

Comment affiner le modèle - zero-shot/few-shot prompting

Travailler avec Llama 3

Contrôler la sortie du modèle

  • ✅ Paramètres
  • ✅ Rôles

Comment affiner le modèle - utiliser des mots d’arrêt

Travailler avec Llama 3

Affiner les invites

  • Exemple : synthèse
text_choice1 = "Summarize key trends in the aviation industry from the last year, 
                focusing on fuel efficiency innovations."

text_choice2 = "Tell me about the aviation industry."
output = llm(text_choice1) # Une invite plus précise est plus efficace print(output['choices'][0]['text'])
The aviation industry has made significant strides in fuel efficiency innovations 
over the last year, driven by the need to reduce greenhouse gas emissions and 
operating costs. Sustainable Aviation Fuels (SAFs) have emerged as a key trend...
Travailler avec Llama 3

Composants d’une invite efficace

Composants d’une invite efficace

Travailler avec Llama 3

Composants d’une invite efficace

Composants d’une invite efficace - Précision

Travailler avec Llama 3

Composants d’une invite efficace

Composants d’une invite efficace - Ambiguïté

Travailler avec Llama 3

Composants d’une invite efficace

Composants d’une invite efficace - Mots-clés

Travailler avec Llama 3

Composants d’une invite efficace

Composants d’une invite efficace - Verbes d’action

Travailler avec Llama 3

Composants d’une invite efficace

Composants d’une invite efficace - Exemples

Travailler avec Llama 3

Zero-shot prompting

  • Zero-shot prompting : une seule instruction
text = "Summarize recent mergers in the airline industry."

output = llm(text) print(output['choices'][0]['text'])
Recent mergers in the airline industry include Alaska Air Group's acquisition of 
Hawaiian Airlines in 2024, with both airlines continuing to operate as separate 
brands. In 2022, Delta Air Lines purchased 20% of LATAM Airlines Group...
Travailler avec Llama 3

Affiner les invites zero-shot

  • Distinguer la tâche, la sortie attendue, le contexte
  • Zero-shot prompting avec libellés
text = """
       INSTRUCTION: Write concisely and in 2-3 sentences that cover only key points.
       QUESTION: Summarize recent mergers in the airline industry.
       ANSWER:
       """
Travailler avec Llama 3

Few-shot prompting

  • Few-shot prompting : plusieurs exemples

Invite

Travailler avec Llama 3

Few-shot prompting

  • Few-shot prompting : plusieurs exemples

Invite avec « aircraft model » surligné

Travailler avec Llama 3

Few-shot prompting

  • Few-shot prompting : plusieurs exemples

Invite avec « passenger capacity » surligné

Travailler avec Llama 3

Few-shot prompting

  • Few-shot prompting : plusieurs exemples

Invite avec « fuel consumption » surligné

Travailler avec Llama 3

Few-shot prompting

$$

output = llm(f"Continue the entries: {text}") 

print(output['choices'][0]['text'])
Aircraft Model: Airbus A350-900
Passenger Capacity: 350
Fuel Consumption: 2.39 liters per seat per 100 km
Travailler avec Llama 3

Utiliser des mots d’arrêt

  • Besoin d’insights concis
  • Utiliser des mots de fin stop pour arrêter la réponse à un point précis
  • Exemple : application de questions-réponses
text = "Which airlines operate direct flights from London to Singapore?"


output = llm(text, stop=["Q:"]) # Arrêter les réponses à "Q:"
print(output['choices'][0]['text'])
You can fly direct from London to Singapore with Singapore Airlines and 
British Airways.
Travailler avec Llama 3

Passons à la pratique !

Travailler avec Llama 3

Preparing Video For Download...