You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesi贸n a prueba de IA

Antes: $249

Currency
$209
Suscr铆bete

Termina en:

1 D铆as
9 Hrs
40 Min
11 Seg

Tipos de ChatTemplates: Few-Shot Prompting

9/26
Resources

Fused-Shot Prompting is a technique that allows guiding the language model by providing specific examples within the same prompt. This improves the accuracy of responses by showing the model how it should behave through clear examples. It is useful when we want the model to learn patterns from the instructions and examples we provide.

1. Types of Fused-Shot Prompting

There are two main ways to implement this technique:

  • Fixed examples: here we establish a static set of examples that will be used in all interactions. These examples do not change and serve as a reference for the model to understand how to respond to certain types of questions or inputs.
  • Dynamic examples: In this mode, examples are selected dynamically based on the semantic similarity between the user's input and the stored examples. This means that the system chooses the most relevant examples in real time, based on what the user asks.

Both ways help the model improve its answers by providing direct guidance on how to proceed in different situations.

2. Improving Answers with Concrete Examples

Providing clear examples within the prompt helps the model more accurately interpret ambiguous situations. For example, if we want the model to understand the use of emojis in mathematical operations, we can teach it with examples such as:

  • Input: "How much is 馃+馃?"
  • Expected output: "2"

These examples will help the model to interpret the emoji as a numerical value, instead of trying to infer an abstract or symbolic meaning.

3. Advantages of Fused-Shot Prompting

Fused-Shot Prompting allows:

  • Guide the model clearly: By including explicit examples of the relationship between input and output, the model has a clear reference for how it should respond.
  • Customize the interaction: You can adjust the examples according to the type of interaction or context you need, allowing you to adapt the model's behavior for specific cases.
  • Improve accuracy in specific tasks: This approach is particularly useful in tasks where the model must follow specific rules, such as calculations, translations or symbolic interpretations.

4. Integration of Examples with Prompt Templates

To implement Fused-Shot Prompting in LangChain, you can use prompt templates that accept both static and dynamic examples. Instead of simply providing an instruction, you can include several examples in the same template, showing the model how it should process similar inputs.

The model processes these examples and learns the expected pattern, which increases the accuracy of responses for similar input that the user may provide in the future.

5. Structure of a Dynamic Prompt

When working with dynamic examples, the model selects the most appropriate examples based on similarity to the user's input. This is useful in scenarios where there are a wide variety of possible inputs, and you want the model to select the most relevant examples to generate its response.

Dynamic selection ensures that the examples that are semantically closest to the user's input are used as a reference, which maximizes the relevance of the response.

6. Using Chains to Integrate the Prompt and the Model

In LangChain, you can integrate the prompt with the model usingchains. Once you have configured the examples with Fused-Shot Prompting, you can combine the prompt and the model into a chain, allowing both to be invoked together. This facilitates continuous interaction without the need to repeat the model or prompt configuration for each query.

Chains allow you to chain the behavior of the model and prompt in a logical sequence, making it easier to query the model efficiently while maintaining the context of the conversation and the examples provided.

7. Conclusion

Fused-Shot Prompting is a powerful technique for teaching the model to respond more accurately and adapted to specific contexts. By providing examples within the prompt, we can guide the model's behavior, improve the relevance of responses, and make it better interpret user input. By using fixed or dynamic examples, and combining them with tools such as chains, it is possible to build more sophisticated applications, such as conversational agents, virtual assistants or recommender systems, that provide more accurate and consistent responses.

This technique is especially useful when you want the model to follow predefined patterns or when you need it to correctly interpret less conventional elements such as emojis, symbols or ambiguous situations.

Contributions 5

Questions 3

Sort by:

Want to see more contributions, questions and answers from the community?

**Few-shot Prompting** es una t茅cnica que permite a los modelos de lenguaje aprender a responder de manera m谩s precisa utilizando ejemplos concretos dentro del mismo prompt. Los ejemplos ayudan a guiar las respuestas del modelo, mejorando su relevancia. Hay dos formas de implementar esta t茅cnica: usando ejemplos fijos o din谩micos, lo que permite adaptar las interacciones seg煤n la entrada. ### Conceptos Principales: 1. **Few-shot Prompting**: Utiliza ejemplos dentro del prompt para ense帽ar al modelo c贸mo debe comportarse. Los ejemplos act煤an como gu铆as para que el modelo aprenda a responder de manera precisa. * **Ejemplo**: Si queremos que el modelo interprete emojis como operaciones matem谩ticas, proporcionamos ejemplos como "2 馃 2 = 4" para que el modelo aprenda la relaci贸n. 2. **Ejemplos Fijos**: Conjunto est谩tico de ejemplos que se utilizan en cada interacci贸n, independientemente de la entrada del usuario. * **Ejemplo**: Siempre usar "2 馃 2 = 4" y "2 馃 3 = 5" para que el modelo entienda c贸mo operar con emojis. 3. **Ejemplos Din谩micos**: Los ejemplos se seleccionan seg煤n la similitud sem谩ntica entre la entrada del usuario y los ejemplos almacenados. * **Ejemplo**: Si el usuario pregunta "驴cu谩nto es 5 emoji 5?", se selecciona un ejemplo similar para que el modelo aprenda a sumar usando emojis. 4. **Prompt Template**: Pasa ejemplos al modelo. Cada ejemplo tiene una entrada (input) y una salida (output) esperada, generalmente estructurados en formato de diccionario. * **Ejemplo**: Un diccionario con `{input: "2 馃 2", output: "4"}` ense帽a al modelo que el emoji representa una operaci贸n matem谩tica. 5. **Chains**: Permite integrar m煤ltiples pasos en una cadena, combinando el modelo con ejemplos y roles para crear interacciones m谩s complejas. * **Ejemplo**: Encadenar un prompt que define al modelo como "un mago de las matem谩ticas" junto con ejemplos para que se comporte de acuerdo a la expectativa.
Un buen approach que le podemos dar a este curso, no solo es compartiendo cuestiones t茅cnicas, sino tambi茅n c贸mo podemos aplicar esto en la vida real ya sea en las empresas o proyectos en los que trabajamos. Esto nos puede ayudar como brainstorming o feedback de lo que estemos haciendo. Caso de uso que le v铆: AI agent que est茅 atendiendo un chat. Por ejemplo, podr铆amos iniciar con la identificaci贸n de consultas m谩s comunes de los clientes que suele recibir en el chat (ya sea que lo haga un Data Science o Data Analyst). Luego dise帽amos ejemplos de interacciones con cada tipo de consulta y los podemos incluir en el prompt del modelo, esto podr谩 guiar de forma contextual al modelo y pueda responder de forma precisa.
La barra vertical en windows es con Alt + 124
**Few-shot Prompting** es una t茅cnica donde un modelo es capaz de aprender o adaptarse a una tarea a partir de un n煤mero de ejemplos. Consiste b谩sicamente en mostrar al modelo algunos ejemplos (llamados shots) de lo que quieres que haga. ## **Variantes del shot prompting** * 0 shot prompting: Sin mostrar ejemplos al modelo * 1 shot prompting: 1 ejemplo mostrado al modelo * few shot prompting: 2+ ejemplos mostrados al modelo
Una de las propuestas que se pueden realizar con este tipo de entrenamiento es la creaci贸n de preguntas de cuestionario, tipo: Pregunta: Donde naci贸 Sim贸n Bol铆var? A. respuesta 1 B. respuesta 2 C. respuesta 3