6 Melhores Práticas para Geração de Código com LLM
De Wikiprompt, a enciclopédia livre de prompts
6 Melhores Práticas para Geração de Código com LLM Uma lista abrangente de seis melhores práticas de engeniería de prompts para usar LLMs na geração de código, cobrindo saída YAML, análise com bullets, código modular, validação dupla, decisões atrasadas e supervisão orientada ao fluxo.
Conteúdo do PromptSalvar
🌐
1. Use YAML structured output instead of JSON format
- YAML has higher error tolerance, JSON is prone to format errors that cannot be parsed
- YAML content consumes fewer tokens
2. Bullet points analysis
- When asking LLM to analyze problems, requesting output in bullet points yields better results
- Bullets promote deep understanding and logical semantic segmentation
- Example: self-reflection questions with bullets for general description, goals and rules, input structure, output structure
3. LLMs excel at generating modular code
- Instruct: 'Split the generated code into multiple small sub-function modules and give them meaningful names'
- Results in fewer errors and higher success in iterative fixes
4. Flexible decision-making and double validation
- After initial output, ask the model to generate the same output again and correct if necessary
- Example: feed the model its own AI tests as input, regenerate tests, and correct errors
- More effective than asking 'Is this test correct?' yes/no questions
5. Delay decision-making, avoid direct questions, give exploration space
- Start with simplest task: self-reflection and reasoning about public test cases
- Then generate additional AI tests and possible solutions
- Only after model answers, proceed to actual code generation and iterative fixing
- Evaluate and rank multiple possible solutions, prioritize top-ranked ones for initial coding
6. Flow-oriented supervision
- Design a scientific flow, accumulate data step by step, add new data at each stage
- Example for CodeContests: two-phase flow with steps for reflection, public test analysis, solution generation
- Validate and select data at each step, with iterative correction if errors occur
Entre para ver o prompt completo
Continuar com:
Ao entrar, você concorda com nossos Termos de uso e Política de privacidade
Uso
Este prompt foi projetado para uso com coding. Copie o conteúdo acima e cole na sua ferramenta de IA preferida.
Para melhores resultados, personalize os marcadores (indicados por colchetes ou maiúsculas) com seus requisitos específicos.
Referências
- Categoria: Prompts de coding
- Fonte: https://x.com/dotey/status/1748827229109334363
Discussão
0 comentários