Some time ago OpenAI published Swarm: an educational framework for building multi-agent systems.
Their approach focuses on two main concepts: ・ 𝐑𝐨𝐮𝐭𝐢𝐧𝐞𝐬: Each agent follows specific 📜 instructions and uses 🛠️ tools to execute them. ・ 𝐇𝐚𝐧𝐝𝐨𝐟𝐟𝐬 🤝: Agents can transfer control to one another using tool/function calling.
When I first read these ideas, I thought: 𝘴𝘪𝘮𝘱𝘭𝘦 𝘣𝘶𝘵 𝘱𝘰𝘸𝘦𝘳𝘧𝘶𝘭! And they pair well with the recent unified tool support in Haystack.
🧑💻 So, I decided to re-implement these concepts using Haystack, and in just a few lines of code, I had a working prototype.
🆒 Bonus feature: this implementation isn't tied to a single model provider - different agents can be powered by different models!
I replicated the ACME customer service example from the original article, with 3 Agents: 🐝 Triage Agent - Llama 3.2 running on Ollama 🐝 Sales Agent - Anthropic Claude 3.5 Sonnet 🐝 Issues and Repairs Agent - OpenAI GPT-4o mini
Want to see the full implementation and give it a try? Check out the blog post and notebook! ✨
It's a recent technique for creating synthetic instruction datasets.
Magpie is based on a simple but ingenious idea 👇 if you prompt an instruction-tuned model with a pre-query template, you can make it generate a plausible user query/instruction
Here's an example: model: Llama-3-8B-Instruct pre-query template: "<|begin_of_text|><|start_header_id|>user<|end_header_id|>" generated user instruction: "What are some of the responsibilities of a commercial pilot?"
You can then feed this instruction back into the same model to get the assistant response.
By repeating this process, it's possible to generate large synthetic datasets with relatively little effort.
🪄 The authors demonstrate that using these datasets for Supervised Fine Tuning (SFT) can yield strong performance, even competitive with the original instruct model.
🧗𝐆𝐞𝐧𝐞𝐫𝐚𝐭𝐢𝐧𝐠 𝐧𝐨𝐧-𝐄𝐧𝐠𝐥𝐢𝐬𝐡 𝐝𝐚𝐭𝐚
Most Language Models are primarily trained on English texts, so they tend to produce data in English.
How can we overcome this?
Earlier approaches were complex or costly.
Then @mrm8488 found a simple solution: add the target language to the pre-query template. For Spanish, the template becomes "<|begin_of_text|><|start_header_id|>user<|end_header_id|>spanish:".
This method works for Spanish and German!
❌ Unfortunately, it does not work well for other languages (🇮🇹, 🇳🇱, ...)