We talked about Cohere’s latest Command R7B model last week.
It’s a multilingual 7B-parameter open-weight model specialized in enterprise-focused LLM use cases…
…and outperforms other similarly sized open-weight models in core business use cases such as RAG, tool use, and AI agents.
Today, let’s build a multi-agent news generator using this model:
The app will take a user query, search the web for it, and turn it into a well-crafted news article with citations!
Here’s our tech stack for this demo:
Cohere ultra-fast Command R7B as the LLM.
CrewAI for multi-agent orchestration.
We’ll have two agents in this multi-agent app:
Research analyst agent:
Accepts a user query.
Uses the Serper web search tool to fetch results from the internet.
Consolidates the results.
Content writer agent:
Uses the curated results to prepare a polished, publication-ready article.
If you prefer to watch, we have added a video demo above.
You can find the entire code in this GitHub repository: AI Engineering Hub.
Let’s build this application!
Setup
Create a .env
file for their corresponding API keys:
Next, setup the LLM and web search tool as follows:
In the above code, we define the LLM and the search tool.
Notice the use of temperature in this code. We discussed what it is in yesterday’s issue.
Research Analyst Agent
This agent will take a user query and then use the Serper web search tool to fetch results from the internet and consolidate them:
This is implemented below:
Here, we define our first agent and its goal. Along with that, we also give it access to the tools and the LLM.
Next, we must also create a task for it.
Below, we assign the research analyst agent a research task with a description and expected output:
Content writer agent
The role of the content writer is to use the curated results and turn them into a polished, publication-ready news article.
The agent, like Agent 1, is defined below:
Let’s also give it its job, where we describe its writing task with all the details and expected output:
Almost done!
Launch crew
Below, we build our crew of agents and run the multi-agent app:
This produces the following output:
Perfect, it works as expected!
You can find all the code and instructions to run in this GitHub repo: AI Engineering Hub.
We launched this repo recently, wherein we’ll publish the code for such hands-on AI engineering newsletter issues.
This repository will be dedicated to:
In-depth tutorials on LLMs and RAGs.
Real-world AI agent applications.
Examples to implement, adapt, and scale in your projects.
Find it here: AI Engineering Hub (and do star it).
👉 Over to you: What other topics would you like to learn about?
P.S. For those wanting to develop “Industry ML” expertise:
At the end of the day, all businesses care about impact. That’s it!
Can you reduce costs?
Drive revenue?
Can you scale ML models?
Predict trends before they happen?
We have discussed several other topics (with implementations) in the past that align with such topics.
Here are some of them:
Learn sophisticated graph architectures and how to train them on graph data: A Crash Course on Graph Neural Networks – Part 1.
So many real-world NLP systems rely on pairwise context scoring. Learn scalable approaches here: Bi-encoders and Cross-encoders for Sentence Pair Similarity Scoring – Part 1.
Learn techniques to run large models on small devices: Quantization: Optimize ML Models to Run Them on Tiny Hardware.
Learn how to generate prediction intervals or sets with strong statistical guarantees for increasing trust: Conformal Predictions: Build Confidence in Your ML Model’s Predictions.
Learn how to identify causal relationships and answer business questions: A Crash Course on Causality – Part 1
Learn how to scale ML model training: A Practical Guide to Scaling ML Model Training.
Learn techniques to reliably roll out new models in production: 5 Must-Know Ways to Test ML Models in Production (Implementation Included)
Learn how to build privacy-first ML systems: Federated Learning: A Critical Step Towards Privacy-Preserving Machine Learning.
Learn how to compress ML models and reduce costs: Model Compression: A Critical Step Towards Efficient Machine Learning.
All these resources will help you cultivate key skills that businesses and companies care about the most.
Share this post