# Harnessing Local AI: Creating AI Agents and Managed Jobs with Qwen 3 and SkyPilot

Maxim Dudko

Hatched by Maxim Dudko

Jul 21, 2025

4 min read

0

Harnessing Local AI: Creating AI Agents and Managed Jobs with Qwen 3 and SkyPilot

The rapidly evolving landscape of Artificial Intelligence (AI) has unlocked extraordinary opportunities for developers and enthusiasts alike. The ability to run powerful Large Language Models (LLMs) directly on local machines is one of the most exciting trends, enhancing privacy, reducing costs, and enabling offline functionality. This article explores how to leverage the Qwen 3 family of LLMs with the Ollama tool to create local AI agents, while also discussing the benefits of SkyPilot’s managed jobs for scaling out AI workloads effectively.

The Shift to Local AI

Running LLMs locally offers significant advantages, primarily in terms of privacy and cost. When data is processed on the user's machine, it eliminates the risk of exposure to third-party APIs. Furthermore, using open-source models like Qwen 3 with tools such as Ollama means that users can avoid subscription fees associated with cloud-based services. This democratization of AI technology empowers users to experiment and develop without incurring substantial financial burdens.

Setting Up Your Local AI Lab

To get started, you will need a foundational understanding of Python programming and some command line experience. Ensure that Python 3 is installed on your system. The installation process for Ollama is straightforward, whether you are using Linux, macOS, or Windows. Once Ollama is installed, users can choose from various Qwen 3 models based on their hardware capabilities and intended tasks.

Key Steps for Setup:

  1. Install Ollama: Use the command line to install the Ollama tool.
  2. Select a Qwen 3 Model: Choose a model based on your system's resources.
  3. Run the Model: Pull and run your selected Qwen 3 model with Ollama.

Building a Retrieval-Augmented Generation (RAG) System

With the local AI environment established, users can build a RAG system that enhances LLM capabilities by providing them with external knowledge sources. This process involves loading documents, splitting them into manageable chunks, and indexing them for efficient retrieval.

Building Blocks of a RAG System:

  • Prepare Your Data: Organize your documents in a structured format.
  • Load and Split Documents: Use LangChain’s document loaders to read and segment the content into smaller, semantically relevant chunks.
  • Embedding and Indexing: Transform the text into vectors and store these embeddings in a vector database like ChromaDB for efficient querying.

Creating Local AI Agents

Beyond generating text responses, Qwen 3 can also drive local AI agents capable of executing tasks and utilizing custom-defined tools. This section outlines how to set up a simple AI agent using Qwen 3.

Steps to Build an AI Agent:

  1. Define Custom Tools: Create Python functions that the agent can utilize. Properly formatted docstrings are crucial for the LLM’s understanding.
  2. Set Up the Agent's LLM: Instantiate a ChatOllama model with defined parameters to ensure it can effectively use the tools.
  3. Create the Agent Prompt: Use structured prompts to guide the agent’s reasoning.
  4. Build and Run the Agent: Combine the LLM, tools, and prompt into a runnable unit, and execute the agent with user inputs.

Introducing Managed Jobs with SkyPilot

For those looking to scale their AI workloads, SkyPilot offers an innovative solution with managed jobs. This feature simplifies the process of running jobs long-term or in parallel, automatically retrying failures and recovering from interruptions.

Benefits of Managed Jobs:

  • Cost-Effective Resource Utilization: Managed jobs can run on cost-efficient spot instances, significantly reducing expenses.
  • Scalability Across Regions: Easily manage thousands of jobs across multiple regions and clouds.
  • Failure Recovery: Automatic retries and recovery mechanisms prevent job failures from causing significant downtime.

Actionable Advice for Building Your Local AI and Managed Workflows

  1. Optimize Your Hardware Resources: Ensure your machine has sufficient GPU VRAM and RAM to run larger models effectively. Consider quantizing models to decrease resource requirements while maintaining performance.

  2. Experiment with RAG Configurations: Fine-tune parameters like num_ctx for context length and chunk sizes to maximize the efficiency and effectiveness of your RAG system.

  3. Leverage SkyPilot for Job Management: Use SkyPilot’s managed jobs to streamline your workflow, taking advantage of automatic retries and cost savings from spot instances.

Conclusion and Next Steps

The integration of Qwen 3 with Ollama for local AI applications, combined with the powerful capabilities of SkyPilot for managed job execution, represents a significant step forward in how developers can approach AI. By following the steps outlined in this article, you can build a local AI system that not only meets your specific needs but also scales efficiently. Whether you are querying documents or creating intelligent agents, these tools make advanced AI capabilities more accessible than ever. Embrace the local AI revolution and explore the endless possibilities it offers!

Sources

← Back to Library

Hatch New Ideas with Glasp AI 🐣

Glasp AI allows you to hatch new ideas based on your curated content. Let's curate and create with Glasp AI :)

Start Hatching 🐣