Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def few_shot_learning(llm_agent, task, examples, new_input):
- prompt = f"Task: {task}\n\nExamples:\n"
- for example in examples:
- prompt += f"Input: {example['input']}\nOutput: {example['output']}\n\n"
- prompt += f"Now, given this new input: {new_input}\nOutput:"
- return llm_agent.generate(prompt)
- # Usage
- task = "Translate English to French"
- examples = [
- {"input": "Hello", "output": "Bonjour"},
- {"input": "How are you?", "output": "Comment allez-vous?"}
- ]
- new_input = "Good morning"
- result = few_shot_learning(my_llm_agent, task, examples, new_input)
- print(result) # Expected output: "Bonjour"
Advertisement
Add Comment
Please, Sign In to add comment