0aff31e2d3
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
42 lines
702 B
Markdown
42 lines
702 B
Markdown
---
|
|
layout: default
|
|
---
|
|
|
|
# Few-Shot Prompting
|
|
|
|
<div class="mt-8 text-sm">
|
|
|
|
<v-click>
|
|
|
|
<div class="mb-6">
|
|
|
|
**Few-shot**: Dar ejemplos al LLM para que aprenda el patrón deseado
|
|
|
|
</div>
|
|
|
|
</v-click>
|
|
|
|
<v-click>
|
|
|
|
```typescript
|
|
import { ChatPromptTemplate } from "@langchain/core/prompts";
|
|
|
|
const template = ChatPromptTemplate.fromMessages([
|
|
["system", "Clasifica el sentimiento de tweets"],
|
|
["human", "Me encanta este producto!"],
|
|
["ai", "positivo"],
|
|
["human", "No funciona bien :("],
|
|
["ai", "negativo"],
|
|
["human", "{tweet}"] // El tweet a clasificar
|
|
]);
|
|
|
|
const response = await model.invoke(
|
|
await template.invoke({ tweet: "Buena experiencia" })
|
|
);
|
|
// → "positivo"
|
|
```
|
|
|
|
</v-click>
|
|
|
|
</div>
|