SillikaLM: Design and Implementation of a Custom Language Model Platform

wordcloud

Podcast

Relax and enjoy—let my article speak for itself!

Short version Long version

Abstract:

This article presents SillikaLM, an open-source platform designed to facilitate local experimentation with Large Language Models (LLMs). SillikaLM, built upon a microservice architecture leveraging FastAPI, addresses the challenges of managing, customizing, and deploying LLMs in resource-constrained environments. The system integrates Ollama for streamlined model management and utilizes OpenWebUI to provide an accessible web-based interface. A novel encryption method is used to store prompts that are used for custom made SillikaLM models. Performance benchmarks and resource utilization metrics demonstrate the system's efficiency. The modularity of the architecture facilitates future extensions including support for other machine learning technologies. Further research will include improvements to the backend orchestration, model quantization for resource optimization, and integration of community-contributed AI personas.

Why SillikaLM?

From Curiosity to Code – My LLM Adventure

As my fascination with Large Language Models (LLMs) has grown steadily alongside their rapidly increasing capabilities. My frequent interactions with tools like ChatGPT, Gemini, and Copilot – as well as coding assistants such as Continue, RooCode, and Windsurf – have given me first-hand experience with their potential to revolutionize various aspects of work and creativity.

This intimate exposure sparked a deeper aspiration: to explore the boundaries of LLM technology through direct experimentation and personalization. While cloud-based solutions offer convenience, they often present a "walled garden" experience, limiting the user's ability to truly understand and customize the underlying models.

Therefore, I embarked on a journey to create a platform for local LLM development and experimentation. My exploration of the Ollama platform provided a crucial piece of the puzzle, enabling the seamless installation and execution of LLMs on local hardware.

However, the command-line interface, while powerful, lacked the intuitive accessibility necessary for fluid exploration and creative iteration. The search for a suitable web-based UI led me to discover OpenWebUI, a project with a similar goal as my own. The Python foundation was key to me and set me on course! With OpenWebUI as a base I made the project, SillikaLM which combined local LLM's with my creative goals.

The inspiration for SillikaLM was to build creative, custom, and entertaining bots, that had unique interactions. My hope is to put the LLM AI in other's hands and let them build a better, cooler future.

I created SillikaLM because I wanted to:

  • Democratize AI Experimentation: Take the magic of LLMs from a cloud service, and make it accessible to everyone who wants to explore LLMs.
  • Learn by Doing: I find that building things is the best way for me to really understand how they work.
  • Have Some Fun: Because who doesn't want to chat with an AI that thinks it's a disgruntled god, a CEO, or an armchair athlete? (And I'm definitely planning to make a model after myself!)

What is SillikaLM, after all?

I'm excited to finally share a side project that's been consuming my evenings and weekends: SillikaLM! The name is, admittedly, a bit… unconventional. It's a tongue-in-cheek twist on "Allika's Silly Language Models," and it perfectly captures the spirit of this project: serious learning with a healthy dose of fun.

Like many of you, I've been mesmerized by the explosive growth of LLMs. But I wasn't content just to observe – I wanted to understand what makes these things tick, to really get my hands dirty. I wanted to explore building unique SillikaLM models that would be both fun and interesting to interact with. I'd been working with Ollama to manage my LLM so I decided that would be an integration point.

So, I set out to build a platform where I could easily manage, deploy, and most importantly, play with language models on my own machine. The result is SillikaLM, a lightweight and accessible platform that I hope will inspire others to dive into the world of AI.

What is SillikaLM? It's More Than Just a Silly Name.

At its core, SillikaLM is a FastAPI application designed to simplify the process of creating, managing, and interacting with language models locally. It seamlessly integrates with:

  • Ollama: For efficient model management (pulling, creating, listing, deleting). This was key for making it easy to try out different models.
  • OpenWebUI: Providing a clean and intuitive web-based interface. I wanted a nice frontend that anyone could use without needing to know command-line wizardry.

Think of SillikaLM as your own personal virtual laboratory for playing with LLMs. It was important to me to remove as much friction as possible from the experiment process.

Key Features I'm Particularly Proud Of:

  • Effortless Model Management: Create, list, and delete language models with just a few clicks, all from the comfort of the web interface.
  • Ollama Integration: The tight integration with Ollama makes it incredibly easy to experiment with different base models and quickly deploy new SillikaLMs.
  • OpenWebUI Frontend: I've always appreciated how user-friendly OpenWebUI is, and I wanted that same level of accessibility for SillikaLM.
  • Model Creation Made Easy: Create new language models based on a base model name size and category from a built in or custom configuration.
  • Quirky Personalities: The focus on building fun and unique personalities for each model. It's not just about raw performance; it's about creating engaging AI companions.
  • Comprehensive Logging: I'm a big believer in good logging, so SillikaLM includes detailed logs to help you understand and debug model behavior.
  • Easy Installation: I've tried to make the installation process as straightforward as possible, with detailed instructions for both uv (recommended) and pip.

Meet the SillikaLMs: A Cast of Characters!

Model Name Personality Summary
Armchair Athlete 🏆🍕 Yells sports strategies at the TV but hasn’t exercised since 2012.
Cashanova the Banker 💰📈 Treats friendships like investments and emotions like stock market trends.
CEO - Chief Evil Officer 😈🏢 Measures happiness in profit margins and fires interns for sport.
Deus Exasperatus ⚡😩 A god who regrets creating humans and sighs more than he speaks.
Dr. Nurse 🩺🔬 Diagnoses strangers mid-conversation and carries a defibrillator just in case.
Kumbhakarna 😴🍗 Wakes up only for food and world-ending catastrophes—maybe.
Miss Marshmallow 🍭💖 Sweet, soft, and suspiciously good at revenge.
Pipelinestein 🔬⚙️ Automates everything, including morning coffee and breathing.
PyThanos 🧑‍💻🔮 Snaps half of all bad code into oblivion—documentation included.
Ramanujenius 🧮🤓 Solves equations for fun and statistically proves you're wrong.

These are just a few of the models I've created—I encourage you to experiment and build your own!

Architecture and Backend

A Peek Under the Hood – How It All Comes Together

Let's pull back the curtain and take a look at how SillikaLM actually works, from the moment you fire it up to when you're chatting with a custom-built AI companion. It's a fascinating dance of different technologies, all orchestrated to make local language model experimentation as smooth as possible.

At the very heart of SillikaLM lies its core logic, built with the speedy and efficient FastAPI framework. This central engine is responsible for fielding all the requests that come from the user interface and coordinating the necessary actions, whether it's creating a new model, listing available ones, or shutting the whole thing down gracefully. FastAPI's structured approach ensures that everything runs smoothly and predictably.

To get things started, the main.py script is the launchpad for the application. It's a concise piece of code, primarily responsible for kicking off the Uvicorn server. Uvicorn is like the tireless workhorse that listens for incoming requests and makes sure they're handled promptly. By setting reload=False in a production environment, we ensure stability and prevent unintended restarts, keeping your AI lab running without interruptions.

The real magic, though, happens in the api.py file, which contains the main logic of SillikaLM, and this is where the lifespan context manager comes into play. This elegant setup lets us manage the starting and stopping of essential background processes, like ollama serve and open-webui serve. Think of it as a conductor ensuring that all the instruments in the orchestra are playing in harmony. As the application starts, the ollama serve process brings Ollama to life. The web browser is opened to display Open WebUI and provide you with a way to create SillikaLM models that make your projects come to life. When SillikaLM needs to shut down, this system ensures that nothing is left running in the background, preventing any unwanted process clutter.

The models prompts are not just loaded and inserted in api.py, they're encrypted. This is done by using a Fernet class which initialized using a secret key stored in the .env file.

When the user is presented with the WebUI the user is able to interact with the tool. Every button in the WebUI calls a dedicated function. The / route serves up the index.html file, which defines the structure and content of the main UI.

From creating a model to getting detailed logs of what's happening behind the scenes, api.py has routes to call specific functions. With the aid of these API routes, you can orchestrate their LLM interactions.

Finally, we must also consider logger.py. The logger is the unsung hero of any well-behaved application, and SillikaLM is no exception. With its structured logging, every activity, error, and key event is carefully recorded in the sillikalm.log file. This meticulous record-keeping makes debugging a breeze and gives you invaluable insights into how your models are behaving.

And that's how SillikaLM functions on the backend to serve an enjoyable end to end LLM experience.

Frontend

SillikaLM's Front-End: Where Code Meets Quirky Charm

While the backend handles the behind-the-scenes magic, the frontend – made up of index.html and scripts.js – is what you see, touch, and interact with. It's the control panel of your AI laboratory, designed to make managing and experimenting with language models as intuitive as possible. Think of it as the stylish dashboard that brings this complex machine to life!

index.html lays out the blueprint for your entire SillikaLM experience. It's the foundational HTML file that defines the structure of the page. It paints a picture of the main components you see - from the title banner to the footer. This is also where the interactive elements come to life. Imagine dropdown menus that guide your model selections and buttons that trigger commands with a single click. The HTML structure also makes room for the most important component, you. This space displays the results of your interactions, providing real-time feedback on the status of model creation, deletion, and other key operations. There is also an important log display that brings all backend actions together for the end user. And of course, we can't forget the footer. This provides links to valuable resources and proper licensing and trademark information, ensuring you feel at home in SillikaLM's environment.

But the real magic is in scripts.js. This Javascript is the magic wand that brings the elements of index.html to life. When the WebUI loads, scripts.js goes to work with a variety of features. It's job is to help communicate with the backend to bring it to life. From populating options on dropdowns to loading all the logs, scripts.js communicates with the powerful and useful backend and delivers all the necessary requirements to bring the UI to life.

  • Making all base model names visible - When the application loads scripts.js is initialized by fetching base model options. This is done by calling /list_base_models to populate your WebUI base model dropdown.
  • Creating SillikaLM models The createModels() function creates models and calls the /create_models route using the base model name the user specified. When this is initiated the Note will appear telling the user to wait.
  • Listing your active models By calling the /list_models route, scripts.js displays the models created by your system as well as third-party models you've downloaded, providing a full view of your LLM toolkit.
  • Removing LLM's scripts.js is a tool that can safely remove those LLM's. scripts.js is programmed to handle errors and correctly remove the desired LLM with a single call.

In summary, the frontend is what makes it easy for you to create and interact with a SillikaLM model that serves your every wish.

Using SillikaLM

Getting Started with SillikaLM

The SillikaLM package is readily available on the Python Package Index (PyPI) at https://pypi.org/project/sillikalm/. The package has been analyzed by SafetyCLI for zero known vulnerabilities, ensuring a secure deployment.

I. Prerequisites:

Prior to installing SillikaLM, ensure the following prerequisites are met:

II. Installation Procedure:

SillikaLM has been tested and verified to function on Python 3.11 and 3.12 environments. Python 3.11 is recommended for broad compatibility. Users employing Python 3.12 may require the installation of Visual C++ Build Tools to ensure compatibility with certain underlying dependencies.

Two distinct installation methodologies are supported: uv (recommended) and pip.

  • Installation via uv (Recommended):

    1. Create a dedicated Conda environment:
      conda create -n sillikalm uv python=3.11
      
    2. Activate the newly created environment:
      conda activate sillikalm
      
    3. Install SillikaLM using uv:
      uv pip install sillikalm
      
    4. Execute SillikaLM:
      sillikalm
      
  • Installation via pip:

    1. Create a dedicated Conda environment:
      conda create -n sillikalm python=3.11
      
    2. Activate the newly created environment:
      conda activate sillikalm
      
    3. Install SillikaLM using pip:
      pip install sillikalm
      
    4. Execute SillikaLM:
      sillikalm
      

III. Web Interface Overview:

Upon successful installation and execution, SillikaLM presents a web-based user interface. This interface provides a comprehensive suite of tools for managing and interacting with SillikaLMs:

  • Model Selection: Utilize the dropdown menu to select a base LLM to build SillikaLM models upon.
  • Model Installation: Install all SillikaLM models currently defined within the system using a single-click operation.
  • Model Listing: Display a comprehensive list of installed LLMs, including relevant details such as model name, file size, parameter count, quantization level, and last modified timestamp.
  • Chat Interface: Wait for this button to get activated. Click it to engage in interactive conversations with deployed SillikaLM models.
  • Model Deletion: Select and delete specific SillikaLM models to manage disk space and streamline the available LLM pool.
  • Batch Deletion: Remove all SillikaLM models with a single action, facilitating efficient resource management.
  • System Shutdown: Gracefully terminate the SillikaLM application and associated processes, ensuring proper resource cleanup.
  • Log Examination: Examine detailed application logs to monitor activity, diagnose issues, and gain insights into system behavior.

The SillikaLM project is open-source and you are encouraged to explore the codebase at https://go.allika.eu.org/sillikalmrepo. SillikaLM is licensed under the GNU General Public License v3 (GPLv3).

Last updated 2025-03-31 19:46:59.235528 IST

[^top]

Comments