Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nociones sobre Prompt Engineering #4

Open
UO291047 opened this issue Feb 6, 2025 · 1 comment
Open

Nociones sobre Prompt Engineering #4

UO291047 opened this issue Feb 6, 2025 · 1 comment
Assignees

Comments

@UO291047
Copy link

UO291047 commented Feb 6, 2025

Como base para hacer buenos prompts, aquí se enumeran los pasos a seguir y las técnicas a aplicar para lograr los mejores resultados:

Atacando la parte más práctica del problema, os redirijo a la siguiente conversación con ChatGPT:

En la cual se mencionan ideas para mejorar las respuestas de la IA e incluso implementaciones y ejemplos de dichas ideas.

@nalleta
Copy link

nalleta commented Feb 8, 2025

Documentación de LLM

Resultados y enlaces

Blog interesante sobre las limitaciones con enlaces a proyectos de GitHub:
https://tryolabs.com/blog/strategies-and-tools-for-controlling-responses

Bases sobre prompt engeneering con ejemplos de respuestas y razonamientos:
https://huggingface.co/docs/transformers/main/en/tasks/prompting#basics-of-prompting

Guía muy completa sobre gran cantidad de temas:
https://www.promptingguide.ai

Comentarios

He estado buscando información sobre la aplicación de los LLM a quizz por si ya se había hecho algo similar pero está más enfocado en utilizar la ia para generar las propias preguntas en vez de pruebas, por lo que me he centrado en formas de aplicar las restricciones a una ia para el contexto de pistas que tenemos.

Primer Enlace

Sobre el primer blog, en conclusiones da algunos términos que pueden ser interesantes a la hora de tomar ejemplos:

Prompt tuning is a powerful tool for guiding the model's output. By carefully crafting the input prompt, one can influence the model's responses. However, this method requires a deep understanding of how the model interprets prompts and may not always yield consistent results due to the inherent randomness in the model's output.

Logit filtering is a more advanced technique that involves manipulating the model's logits to prevent it from generating certain words or phrases. This method can be highly effective, but it requires a deep understanding of the model's inner workings and can be computationally expensive.

Parameter tuning, such as adjusting the temperature and top-k sampling, provides a way to control the randomness and diversity of the model's output. While these methods offer a degree of control, they do not guarantee the elimination of harmful or inappropriate content.

Guardrails are a proactive approach to limit the model's output by setting predefined rules or boundaries. This method can be effective in preventing the model from generating certain types of content. However, it may also limit the model's creativity and versatility, and there's always a risk that some unwanted content may slip through.

Parsing involves analyzing the model's output after it has been generated, allowing for the removal or modification of unwanted content. This method can be effective, but it is reactive rather than proactive, meaning that harmful or inappropriate content may be generated before it is caught and removed.

Si vais al link, en todos hay ejemplos y enlaces a proyectos interesantes de GitHub.

Segundo enlace

Ya ha incluido David algunas cosas muy interesantes sobre las bases por lo que he añadido otra donde además añade ejemplos y respuestas de la IA así como recomendaciones básicas y avanzadas. Aquí os pongo las básicas para que no tengáis que buscar dentro:

In this section of the guide we have compiled a list of best practices that tend to improve the prompt results:

  • When choosing the model to work with, the latest and most capable models are likely to perform better.
  • Start with a simple and short prompt, and iterate from there.
  • Put the instructions at the beginning of the prompt, or at the very end. When working with large context, models apply various optimizations to prevent Attention complexity from scaling quadratically. This may make a model more attentive to the beginning or end of a prompt than the middle.
  • Clearly separate instructions from the text they apply to - more on this in the next section.
  • Be specific and descriptive about the task and the desired outcome - its format, length, style, language, etc.
  • Avoid ambiguous descriptions and instructions.
  • Favor instructions that say “what to do” instead of those that say “what not to do”.
  • “Lead” the output in the right direction by writing the first word (or even begin the first sentence for the model).
  • Use advanced techniques like Few-shot prompting and Chain-of-thought
  • Test your prompts with different models to assess their robustness.
  • Version and track the performance of your prompts.

Además habla de otro término muy interesante llamado "Chain-of-thought" en https://huggingface.co/docs/transformers/main/en/tasks/prompting#chain-of-thought. Que trata de mostrar el razonamiento de algo para ir mejorando el resultado, no se si es aplicable a nuestro caso con las preguntas pero al menos lo veo interesante de mencionar:

hain-of-thought (CoT) prompting is a technique that nudges a model to produce intermediate reasoning steps thus improving the results on complex reasoning tasks.

There are two ways of steering a model to producing the reasoning steps:

  • few-shot prompting by illustrating examples with detailed answers to questions, showing the model how to work through a problem.
  • by instructing the model to reason by adding phrases like “Let’s think step by step” or “Take a deep breath and work through the problem step by step.”
    If we apply the CoT technique to the muffins example from the reasoning section and use a larger model, such as (tiiuae/falcon-180B-chat) which you can play with in the HuggingChat, we’ll get a significant improvement on the reasoning result:
Let's go through this step-by-step:
1. You start with 15 muffins.
2. You eat 2 muffins, leaving you with 13 muffins.
3. You give 5 muffins to your neighbor, leaving you with 8 muffins.
4. Your partner buys 6 more muffins, bringing the total number of muffins to 14.
5. Your partner eats 2 muffins, leaving you with 12 muffins.
Therefore, you now have 12 muffins.

Tercer enlace

El tercer enlace lo dejo pues tiene gran cantidad de términos y cosas interesantes. Si tenéis alguna duda hay cosas como:

  1. Árboles de pensamientos: https://www.promptingguide.ai/techniques/tot
  2. Encadenamiento de prompts (Prompt Chaining): https://www.promptingguide.ai/techniques/prompt_chaining
  3. Meta-prompting, útil para establecer estructuras de prompt que podemos utilizar para las pistas: https://www.promptingguide.ai/techniques/meta-prompting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants