ollama Articles / Blogs / Perficient https://blogs.perficient.com/tag/ollama/ Expert Digital Insights Wed, 30 Jul 2025 05:50:16 +0000 en-US hourly 1 https://blogs.perficient.com/files/favicon-194x194-1-150x150.png ollama Articles / Blogs / Perficient https://blogs.perficient.com/tag/ollama/ 32 32 30508587 Build, Run, and Integrate Your Own LLM with Ollama https://blogs.perficient.com/2025/08/01/build-run-and-integrate-your-own-llm-with-ollama/ https://blogs.perficient.com/2025/08/01/build-run-and-integrate-your-own-llm-with-ollama/#comments Fri, 01 Aug 2025 15:49:51 +0000 https://blogs.perficient.com/?p=384831

As the demand for customizable AI increases, developers are seeking ways to build and control their own Large Language Models (LLMs) locally — without relying on external APIs or heavy cloud dependencies. Building your own model gives you full control over behavior, tone, and responses, enabling tailored interactions for niche use cases. It also removes limitations imposed by third-party providers such as token limits, unpredictable uptime, and privacy concerns.

That’s where Ollama comes in.

Ollama makes it easy to define your own LLM behavior using a simple Modelfile, run it directly on your machine, and integrate it with your apps and workflows — all without needing a GPU or Docker setup.

This guide will walk you through:

  • Creating a detailed Modelfile
  • Building a custom model with Ollama
  • Using the model in a Python integration

Prerequisites

  • Ollama Installed
    Get it from the official site: https://ollama.com
  • A Base Model Pulled
    Example: ollama pull mistral

If you want help with this process, refer to my previous blog at: https://blogs.perficient.com/ollama-power-automate-integration

Step 1: Create Your Own LLM Using a Modelfile

The heart of Ollama customization lies in the Modelfile. Think of it like a Dockerfile for your model — it defines the base model, system prompts, parameters, and any additional files or functions.

Step 1.1: Create a New Folder

Make a new folder to organize your custom model project. Here, we created a folder on the desktop named ‘myOllamaModel’ and created a file in Notepad named ‘Modelfile’.

myOllamaModel

Figure 1: MyOllamaModel folder saved on desktop.

Step 1.2: Create the Modelfile

Create a file named exactly Modelfile

Here’s a sample Modelfile:

Open Notepad on your computer and type this in, then save it in the folder(myOllamaModel) with the name “Modelfile” exactly as it is.

notepad ollama prompt

Figure 2: How to save your Instructions in a Modelfile

Here’s the code we used:

FROM mistral 

SYSTEM "You are Dev_assistant, a witty assistant who always replies with puns but also is extremely helpful to the developer." 

PARAMETER temperature 0.8

#ADD yourfile.txt /app/yourfile.txt

Modelfile Explained

DirectiveDescriptionExample
FROMBase model to useFROM mistral
SYSTEMSystem prompt injected before every promptYou are a helpful assistant
PARAMETERModify model parametersPARAMETER temperature 0.8
ADDAdd files to the model imageADD config.json /app/config.json

To check, go to your Modelfile, click on View, and then on File Extensions. If .txt is mentioned, remove it.

Blog 4.2

 

Step 1.3: Create the Model Using the Modelfile

Let’s check our list of all the available models in our device.
command prompt for ollama

 

Now run the following command:

Before running the command, ensure you are in the path for the saved folder by making sure about the directory: cd”<copy_path to the folder> “. Then use

ollama create Dev_assistant -f Modelfile to create your LLM.
  • Dev_assistant is the name of your new local model.
  • -f Modelfile points to your file.command prompt for ollama

Step 1.4: Run Your Custom Model

ollama run Dev_assistant

You’ll see the system prompt in action! Try typing:

What's the weather today?

And watch it reply with pun-filled responses.

Check Your Custom Model

Run:

ollama list

Your custom model (Dev_assistant) should now appear in the list of available local models.

command prompt for ollama

Step 2: Integrate the LLM in Python

Ollama provides a native Python client for easy integration. You can use your new model directly in scripts, apps, or bots.

Sample Python Usage:

import ollama

response = ollama.chat(
    model='Dev_assistant',
    messages=[
        {'role': 'user', 'content': 'Explain Python decorators in simple terms.'}
    ]
)

print(response['message']['content'])

 

You can further control the output by modifying parameters or injecting dynamic prompts.

Bonus: Use Cases for Your Local Model

Use Case Description
Offline Developer Bot Build a VS Code or terminal assistant that answers programming questions offline
Automation Integrator Trigger model responses in Power Automate, Zapier, or shell scripts
Custom Assistants Use different Modelfiles to create niche bots (e.g., legal, medical, UX writing)
API-less Privacy Flows Keep all data local by avoiding cloud-hosted models

Conclusion

With just a Modelfile and a few commands, you can spin up an entirely local and customized LLM using Ollama. It’s lightweight, developer-friendly, and ideal for both experimentation and production.

Whether you’re building a markdown-savvy chatbot, a code-aware assistant, or simply exploring how LLMs can work offline — Ollama makes it possible.

]]>
https://blogs.perficient.com/2025/08/01/build-run-and-integrate-your-own-llm-with-ollama/feed/ 1 384831
Connect Ollama to Your Workflows: Power Automate + VS Code Integration Guide https://blogs.perficient.com/2025/07/30/ollama-power-automate-integration/ https://blogs.perficient.com/2025/07/30/ollama-power-automate-integration/#comments Wed, 30 Jul 2025 15:00:44 +0000 https://blogs.perficient.com/?p=384725

AI is evolving rapidly, and the ability to install Ollama local models on your machine opens up powerful new possibilities for developers, hobbyists, and builders. Whether you’re working on automation, development tools, or privacy-sensitive applications, cloud-based models aren’t always ideal.

That’s where Ollama comes in.

Ollama makes it easy to run, customize, and serve LLMs directly from your machine — no GPU setup or Docker needed. You can run models like LLaMA2, Mistral, or Gemma, or even build your own using a simple Modelfile.

To take it further, you can integrate Ollama with Power Automate to trigger real-time, AI-powered workflows — all while keeping your data local and secure. This integration lets you automate tasks like generating email replies, summarizing content, or logging AI responses to SharePoint or Teams — without relying on cloud APIs.

In this blog, I’ll walk you through everything you need to get started with Ollama — from downloading and interacting with models in VS Code to integrating responses into Power Automate flows.

What is Ollama?

Ollama is a local LLM (Large Language Model) runtime that can be installed directly on your PC, making it completely cloud independent. You can use it as your personal AI assistant with the added benefit of enhanced security and privacy since everything runs locally.

Why Do We Need Ollama?

  • Works without internet — ideal for offline or network-restricted environments
  • No cloud dependency — full control over your data and usage
  • Acts like a custom assistant tailored to your tasks
  • Allows you to build your own models using a simple Modelfile

Steps to Download and Install Ollama

  1. Visit the official site: https://ollama.com/download
  2. You can install Ollama local models on Windows, macOS, or Linux, depending on your OS.
  3. Run the downloaded installer (.exe or .dmg)
  4. Once you install Ollama local models, you can run them directly in your command prompt but first check whether it was installed or not with:
    ollama --version

    or

    ollama
  5. Explore the available commands using:
    ollama --help
    
    Command prompt 

Ollama Command Reference (Terminal Commands)

Command ContextDescriptionExample
ollama run TerminalRuns the specified model for chat interaction.ollama run mistral
ollama pull TerminalDownloads the model to your machine.ollama pull llama2
ollama listTerminalShows all downloaded models locally.ollama list
ollama create -f ModelfileTerminalCreates a new model from a custom Modelfile.ollama create mistral_assistant -f Modelfile
ollama serveTerminalStarts the Ollama API server for integrations.ollama serve

Downloading a Model / Choosing a Model

  1. Visit the model library: https://ollama.com/library — here, you can explore model usage, specialties, and space requirements.
  2. Choose a model (e.g., mistral)
  3. Pull the model by running:
    ollama pull mistral

    or

    ollama pull <model_name>
  4. Confirm the download with:
    ollama list
  5. To interact with the model, use:
    ollama run mistral or ollama run <model_name>

    Terminal command for run and /bye

  6. When you’re done, type /bye to end the session — otherwise, it will keep running in the background.

Inside the model session, use /help or /? to see available commands.

In-Model Commands

When you’re interacting inside a model session (after running ollama run <model>), the following shortcuts and commands are available:

CommandDescriptionExample
/? or /helpLists all available chat commands./?
/byeEnds the current model session./bye
/systemSets a system prompt to guide the model’s behavior./system You are a polite assistant.
/resetClears the current conversation history./reset

Using Ollama in VS Code

  1. Install the Python package:
    pip install ollama
  2. Ensure Ollama is running in the background by either:
    • Running ollama serve in the terminal, or
    • Searching for “Ollama” and clicking on its icon.
  3. Use this sample Python script to interact with a model:
import ollama

response = ollama.chat(
    model='mistral',
    messages= [
        {
            'role': 'user',
            'content': 'Explain quantum computing in simple terms'
        }
    ],
    options={
        'temperature': 0.8
    }
)

print(response['message']['content'])

Now let’s understand what each part of the code means:
Code LineExplanation
import ollamaImports the Ollama Python library to interact with local language models.
model='mistral', options={'temperature': 0.8}Specifies the model to use (mistral) and sets the temperature option.

temperature = 0.8 means the output will be more creative and diverse.
Lower values (e.g., 0.2) produce more focused and predictable answers.
messages=[{'role': 'user', 'content': 'Explain quantum computing in simple terms'}]Defines the user message you want to send to the model.

You can add multiple messages in a list to maintain chat context.
print(response['message']['content'])Displays only the model’s reply (text content) in the console.

As you can see, we’ve received a valid response from Ollama.

Vs code and prompt generation for ollama

4. You can also adjust parameters like temperature, top_p, and repeat_penalty for more control.

Integrate Ollama with Power Automate

You can connect Ollama to Power Automate by triggering HTTP flows using Python or any backend script. For example, after getting a response from Ollama, you can forward it to Power Automate using a simple POST request. Alternatively, you can use this code and replace the URL with your own to utilize it.

Make sure you have already created a flow in Power Automate with a “When an HTTP request is received” trigger.
As you can see, the Python script successfully triggers the Power Automate flow.

Integrate Ollama with Power Automate

and as you can see the python script is triggering the flow successfully. Integrate Ollama with Power Automate

Here’s the code.

import ollama
import requests

# Step 1: Get response from Ollama
response = ollama.chat(
    model='mistral',
    messages=[
        {'role': 'user', 'content': 'Explain quantum computing in simple terms'}
    ],
    options={'temperature': 0.8}
)

result_text = response['message']['content']

# Step 2: Send response to Power Automate
flow_url = 'https://prod-xxx.westus.logic.azure.com:443/workflows/xyz/triggers/manual/paths/invoke?...'  # Replace with your real URL

payload = {
    'response': result_text
}

headers = {
    'Content-Type': 'application/json'
}

r = requests.post(flow_url, json=payload, headers=headers)

print(f"Power Automate Status Code: {r.status_code}")

For step-by-step integration, refer to my other blog:
Python Meets Power Automate: Trigger via URL / Blogs / Perficient

Conclusion

Now you know how to:

  • Install and run Ollama locally
  • Download and interact with models
  • Use Ollama in VS Code
  • Integrate Ollama with Power Automate

Coming Up Next

In the next part of this series, we’ll explore how to create your own model using Ollama and run it using a Modelfile.

Stay tuned!

]]>
https://blogs.perficient.com/2025/07/30/ollama-power-automate-integration/feed/ 1 384725
Using AI to Compare Retail Product Performance https://blogs.perficient.com/2025/06/30/using-ai-to-compare-retail-product-performance/ https://blogs.perficient.com/2025/06/30/using-ai-to-compare-retail-product-performance/#respond Mon, 30 Jun 2025 13:00:12 +0000 https://blogs.perficient.com/?p=383632

AI this, AI that. It seems like everyone is trying to shoehorn AI into everything even if it doesn’t make sense. Many of the use cases I come across online are either not a fit for AI or could be easily done without it. However, below I explore a use case that is not only a good fit, but also very much accelerated by the use of AI.

The Use Case

In the retail world, sometimes you have products that don’t seem to sell well even though they might be very similar to another product that does. Being able to group these products and analyze them as a cohort is the first useful step in understanding why.

The Data and Toolset

For this particular exercise I will be using a retail sales dataset from Zara that I got from Kaggle. It contains information about sales as well as the description of the items.

The tools I will be using are:

    • Python
        • Pandas
        • Langchain

High-level actions

I spend a lot of my time design solutions and one thing I’ve learned is that creating a high-level workflow is crucial in the early stages of solutioning. It allows for quick critique, communication, and change, if needed. This particular solution is not very complex, nevertheless, below are the high-level actions we will be performing.

  1. Load the csv data onto memory using Pandas
  2. Create a Vector Store to store our embeddings.
    1. Embed the description of the products
  3. Modify the Pandas dataframe to accommodate the results we want to get.
  4. Create a template that will be sent to the LLM for analysis
  5. Process each product on its own
    1. Get a list of comparable products based on the description. (This is where we leverage the LLM)
    2. Capture comparable products
    3. Rank the comparable products based on sales volume
  6. Output the data onto a new CSV
  7. Load the CSV onto PowerBI for visualization
    1. Add thresholding and filters.

The Code

All of the code for this exercise can be found here

The Template

Creating a template to send to the LLM is crucial. You can play around with it to see what works best and modify it to fit your scenario. What I used was this:

 
template = """<br>    You are an expert business analyst that specializes in retail sales analysis.<br>    The data you need is provided below. It is in dictionary format including:<br>    "Product Position": Where the product is positioned within the store,<br>    "Sales Volume": How many units of a given product were sold,<br>    "Product Category": The category for the product,<br>    "Promotion": Whether or not the product was sold during a promotion.<br>    There is additional information such as the name of the product, price, description, and more.<br>    Here is all the data you need to answer questions: {data}<br>    Here is the question to answer: {question}<br>    When referencing products, add a list of the Product IDs at the end of your response in the following format: 'product_ids = [<id1>, <id2>, ... ]'.<br>"""

When we iterate, we will use the following as the question:

 
question = f"Look for 5 products that loosely match this description: {product['description']}?"

The output

Once python does its thing and iterates over all the products we get something like this:

Product ID Product Name Product Description Sales Volume Comparable Product 1 Comparable Product 2 Group Ranking
185102 BASIC PUFFER JACKET Puffer jacket made of tear-resistant… 2823 133100 128179 1
187234 STRETCH POCKET OVERSHIRT Overshirt made of stretchy fabric…. 2575 134104 182306 0.75

Power BI

We then load the data onto Power BI to visualize it better. This will allow us to not only analyze the data using filtering and conditional formatting, but we can also explore the data even further with Copilot.

Look at the screenshot below. I’ve initially setup conditional formatting so that all the products that rank low within their group are highlighted.

I then used Copilot to ask how all of these relate to each other. It was quick to point out that all of them were jackets.

Pbi Copilot

This arms us with enough information to go down a narrower search to figure out why the products are not performing. Some other questions we could ask are:

  1. Is this data seasonal and only includes summer sales?
  2. How long have these jackets been on sale?
  3. Are they all sold within a specific region or along all the stores?
  4. etc.

Conclusion

Yes, there are many, many use cases that don’t make sense for AI, however there are many that do! I hope that what you just read sparks some creativity in how you can use AI to further analyze data. The one thing to remember is that in order for AI to work as it should, it needs contextual information about the data. That can be accomplished via semantic layers. To know more, got to my post on semantic layers

Do you have a business problem and need to talk to an expert about how to go about it? Are you unsure how AI can help? Reach out and we can talk about it!

]]>
https://blogs.perficient.com/2025/06/30/using-ai-to-compare-retail-product-performance/feed/ 0 383632