702 B
702 B
layout
| layout |
|---|
| default |
Few-Shot Prompting
Few-shot: Dar ejemplos al LLM para que aprenda el patrón deseado
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"