Prompt Engineering

di il
0 risposte

Prompt Engineering

Questo e' un elenco di link da cui partire per studiare il Prompt Engineering, 
cioe' il modo per "convincere" gli LLM a fare quello che ci serve.

Ci sono due siti web molto buoni:

https://learnprompting.org/
https://www.promptingguide.ai/it 

Ogni azienda che fornisce un LLM ha una sezione nelladocumentazione che spiega come si fa il "Prompt Engineering".
MA sono mooolto miseri.

Ilibri della O'Reilly sono buoni:

AI Engineering - 2025
Prompt Engineering for Generative AI - 2024
Prompt Engineering for LLMs - 2025

Personalmente trovo questi sistemi l'ANTITESI della programmazione :-)

  1. un LLM e' NON DETERMINISTICO, se gli chiedi di fare 2 volte la stessa cosa, ti dara' 2 risposte diverse
  2. va bene che ci siano differenze tra l'LLM di un'azienda e quello di un'altra, 
    MA anche DUE VERSIONI DIVERSE dello stesso LLM avranno comportamenti diversi.
    Quindi il fatto che un prompt funziona con un LLM  NON VUOL DIRE che funziona anche con la versione successiva.
  3. Il Prompt Engineering e' un'ARTE,  NON una scienza. 

Alla faccia della "standardizzazione/compatibilita' all'indietro" ...

Detto papale, papale: gli LLM sono un gran BLUFF!!!.

  1. pompati all'impossibile dalle aziende che li "affittano" perche' costano un botto e quindi  servono soldi
  2. pompati all'impossibile dai produttori di hardware, cosi' vendono nuovo hardware
  3. pompati all'impossibile dal modo della ricerca, perche' cosi' si scrivono articoli
  4. pompati all'impossibile con l'idea che ragionino SOLO PERCHE" GENERANO testo che SEMBRA scritto in modo corretto, MA quello che dicono e' spesso e volentieri solo "scemenze". SE DEVO controllare tutto quello che mi risponde, a che mi serve?
  5. pompati all'impossibile dal mondo dell'informazione, che non capisce una cippa, e quindi scrive un sacco di scemenze

.
Il "ragionamento degli LLM" e' tutta una frottola.
La loro capacita' di risolvere problemi matematici/logici e' tutta una truffa :-)

Ma per piacere !!!!

Prompt Engineering
------------------

   Learn Prompting (meglio di Prompt Engineering Guide)
   
       https://learnprompting.org/

   Prompt Engineering Guide

       https://www.promptingguide.ai/
       https://www.promptingguide.ai/it
       https://github.com/dair-ai/Prompt-Engineering-Guide  (sono sempre loro)

   Text generation and prompting
       https://platform.openai.com/docs/guides/prompt-engineering

Platforms
---------
   Forniscono documentazione minimale.


   OpenAI/ChatGPT
       https://platform.openai.com/docs/guides/prompt-engineering

   Google/Gemini
       https://cloud.google.com/discover/what-is-prompt-engineering

   Anthropic/Caude
       https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/overview

   Microsoft/Perplexity
       https://docs.perplexity.ai/guides/prompt-guide

   TogetherAI/DeepSeek
       https://docs.together.ai/docs/prompting-deepseek-r1

   MetaAI/Llama
       https://www.llama.com/docs/how-to-guides/prompting/

   MistralAI/Mistral
       https://docs.mistral.ai/guides/prompting_capabilities/

   X/Groq
       https://console.groq.com/docs/prompting


Altri siti interessanti
-----------------------
   
       https://lilianweng.github.io/posts/2021-01-02-controllable-text-generation/#smart-prompt-design
           (del 2021)

       https://lilianweng.github.io/posts/2023-03-15-prompt-engineering/
           Zero-Shot
           Few-shot
           Instruction Prompting
           Self-Consistency Sampling
           Chain-of-Thought (CoT)
           Types of CoT prompts
               Few-shot CoT
               Zero-shot CoT
           Tips and Extensions
               Self-consistency sampling
               Complexity-based consistency
               Self-Ask
               ReAct
               Tree of Thoughts
           Automatic Prompt Design
               AutoPrompt 
               Prefix-Tuning
               P-Tuning
               Prompt-Tuning
           Augmented Language Models
           Retrieval
           Programming Language    (code generation to solve a problem. LLM with skills to generate code)
           External APIs


       https://github.com/brexhq/prompt-engineering
           boh!


Rules
-----
   https://www.promptingguide.ai/introduction/tips

   Settings
       Temperature in [0,1]
           0 -> deperministic
           default -> 0.7 ?
           1 -> random
       Top P in [0,1]
           low: more confident tokens
           note: chane 'Temperature' XOR 'Top P' (NOT both)
       Max Length
           max number of tokens
       Stop Sequences
           which seq of chars to use to stop the sequence
       Frequency Penalty
           penalty on single words
       Presence Penalty
           penalty on sentences

   Roles (personas)
       system 
       user
       assistant


   Roles (OpenAI)
       https://model-spec.openai.com/2025-02-12.html#chain_of_command
       
       platform
       developer (system?)
       user
       guideline (?)
       ?assistant


   Patterns (QA system):
       <Question>?
       or
       <Instruction>
       
       Q: <Question>?
       A:

   Few-shot prompting
       <Question>?
       <Answer>
       <Question>?
       <Answer>
       <Question>?
       <Answer>
       <Question>?

   Few-shot prompting (QA system):
       Q: <Question>?
       A: <Answer>
       Q: <Question>?
       A: <Answer>
       Q: <Question>?
       A: <Answer>
       Q: <Question>?
       A:

   Few-shot prompting (Classification)
       <sentence> // <classification>
       <sentence> // <classification>
       <sentence> // <classification>
       <sentence> //


   Prompt Element
       Instruction      - a specific task or instruction you want the model to perform
       Context          - external information or additional context that can steer the model to better responses
       Input Data       - the input or question that we are interested to find a response for
       Output Indicator - the type or format of the output.

   Rules
       Start Simple
       The Instruction: use verb
                        "Write", "Classify", "Summarize", "Translate", "Order", ...
       Specificity
       Avoid Impreciseness
       To do or not to do?     To do only
       
       ### Instruction ###

   Actions
       Text Summarization
       Information Extraction
       Question Answering
       Text Classification
       Conversation
       Code Generation
       Reasoning

   Prompting Techniques
       Zero-Shot Prompting
       Few-Shot Prompting
       Chain-of-Thought Prompting
           Chain-of-Thought (CoT) Prompting
           Zero-shot CoT Prompting
           Automatic Chain-of-Thought (Auto-CoT)
       Meta Prompting
           Structure-oriented
           Syntax-focused
           Abstract examples
           Versatile
           Categorical approach
       Self-Consistency
       Generated Knowledge Prompting
       Prompt Chaining
       Tree of Thoughts (ToT)
       Retrieval Augmented Generation (RAG)
       Automatic Reasoning and Tool-use (ART)
       Automatic Prompt Engineer (APE)
       Active-Prompt
       Directional Stimulus Prompting
       PAL (Program-Aided Language Models)
       ReAct Prompting
       Reflexion
       Multimodal CoT Prompting
       GraphPrompts

Devi accedere o registrarti per scrivere nel forum
0 risposte