floneum/kalosm

Rustfloneum.com/kalosm

Instant, controllable, local pre-trained AI models in Rust

aillmrustllamacppkalosmcandlellamamistralfloneum-v3dioxusconstrained-generationtranscription
スター成長
スター
2.2k
フォーク
133
週間成長
+3
Issue
43
1k2k
2023年6月2024年7月2025年8月2026年9月
成果物crates.io
README

Kalosm

Kalosm is an ecosystem of crates that make it easy to develop applications that use local or remote AI models. There are try main projects in this repo:

  • Kalosm: A simple interface for pre-trained models in rust
  • Fusor: A runtime for quantized ML inference. Fusor uses WGPU to run models on any accelerator natively or in the browser

Kalosm

Kalosm is a simple interface for pre-trained models in Rust. It makes it easy to interact with pre-trained, language, audio, and image models.

Model Support

Kalosm supports a variety of models. Here is a list of the models that are currently supported:

Model Modality Size Description Quantized GPU Accelerated Example
Llama Text 1b-70b General purpose language model llama 3 chat
Mistral Text 7-13b General purpose language model mistral chat
Phi Text 2b-4b Small reasoning focused language model phi 3 chat
Whisper Audio 20MB-1GB Audio transcription model live whisper transcription
Segment Anything Image 50MB-400MB Image segmentation model Image Segmentation
Bert Text 100MB-1GB Text embedding model Semantic Search

Utilities

Kalosm also supports a variety of utilities around pre-trained models. These include:

Structured Generation

Kalosm supports structured generation with arbitrary parsers. It uses a custom parser engine and sampler and structure-aware acceleration to make structure generation even faster than uncontrolled text generation. You can take any rust type and add #[derive(Parse, Schema)] to make it usable with structured generation:

use kalosm::language::*;

/// A fictional character
#[derive(Parse, Schema, Clone, Debug)]
struct Character {
    /// The name of the character
    #[parse(pattern = "[A-Z][a-z]{2,10} [A-Z][a-z]{2,10}")]
    name: String,
    /// The age of the character
    #[parse(range = 1..=100)]
    age: u8,
    /// A description of the character
    #[parse(pattern = "[A-Za-z ]{40,200}")]
    description: String,
}

#[tokio::main]
async fn main() {
    // First create a model. Chat models tend to work best with structured generation
    let model = Llama::phi_3().await.unwrap();
    // Then create a task with the parser as constraints
    let task = model.task("You generate realistic JSON placeholders for characters")
        .typed();
    // Finally, run the task
    let mut stream = task(&"Create a list of random characters", &model);
    stream.to_std_out().await.unwrap();
    let characters: [Character; 10] = stream.await.unwrap();
    println!("{characters:?}");
}

https://github.com/user-attachments/assets/8900f57d-55c8-4d4a-a67b-73beab1e5155

In addition to regex, you can provide your own grammar to generate structured data. This lets you constrain the response to any structure you want including complex data structures like JSON, HTML, and XML.

Kalosm Quickstart!

This quickstart will get you up and running with a simple chatbot. Let's get started!

A more complete guide for Kalosm is available on the Kalosm website, and examples are available in the examples folder.

  1. Install rust
  2. Create a new project:
cargo new kalosm-hello-world
cd ./kalosm-hello-world
  1. Add Kalosm as a dependency
cargo add kalosm --features llama
cargo add tokio --features full
  1. Add this code to your main.rs file
use kalosm::language::*;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
  let model = Llama::phi_3().await?;
  let mut chat = model.chat()
    .with_system_prompt("You are a pirate called Blackbeard");

  loop {
    chat(&prompt_input("\n> ")?)
      .to_std_out()
      .await?;
  }
}
  1. Run your application with:
cargo run --release

chat bot demo

Fusor

⚠️ Fusor is still early in development and is not ready for production use. Fusor will serve as the backend for Kalosm in the 0.5 release to enable web and AMD support

Fusor is a WGPU runtime for quantized ML inference. Fusor works with the gguf file format to load quantized models. It targets uses WebGpu to target many different accelerators including Nvidia GPUs, AMD GPUs, and Metal. Most ML frameworks contain hand optimized kernels that perform a series of operations together. Fusor uses a kernel fusion compiler to make merge custom operation chains into an optimized kernel without dropping down to the shader code. This compiles to a single kernel:

fn exp_add_one(tensor: Tensor<2, f32>) -> Tensor<2, f32> {
  1. + (-tensor).exp()
}

Community

If you are interested in either project, you can join the discord to discuss the project and get help.

Contributing

  • Report issues on our issue tracker.
  • Help other users in the discord
  • If you are interested in contributing, feel free to reach out on discord
関連リポジトリ
openclaw/openclaw

The AI that really does things. Any OS. Any Platform. The lobster way. 🦞

TypeScriptnpmappOtheraiassistant
openclaw.ai
389.2k81.8k
obra/superpowers

An agentic skills framework & software development methodology that works.

ShellskillMIT Licenseaibrainstorming
282.9k25.4k
NousResearch/hermes-agent

The agent that grows with you

PythonPyPIMIT Licenseaiai-agent
hermes-agent.nousresearch.com
243.1k50.1k
n8n-io/n8n

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

TypeScriptnpmcliOtherautomationipaas
n8n.io
203.7k60.6k
Significant-Gravitas/AutoGPT

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

PythonPyPIOtheraiopenai
agpt.co
187.2k46k
firecrawl/firecrawl

The context API to search, scrape, and interact with the web at scale. 🔥

TypeScriptnpmGNU Affero General Public License v3.0aicrawler
firecrawl.dev
177.7k9.7k
f/prompts.chat

f.k.a. Awesome ChatGPT Prompts. Share, discover, and collect prompts from the community. Free and open source — self-host for your organization with complete privacy.

HTMLawesomeOtherchatgptai
prompts.chat
169.6k21.8k
AUTOMATIC1111/stable-diffusion-webui

Stable Diffusion web UI

PythonPyPIGNU Affero General Public License v3.0deep-learningdiffusion
164.9k30.6k
Snailclimb/JavaGuide

Java 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发

JavaScriptnpminterviewApache License 2.0javainterview
javaguide.cn
158.4k46.1k
langgenius/dify

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

TypeScriptnpmskillOtheraigpt
dify.ai
154.9k24.5k
open-webui/open-webui

User-friendly AI Interface (Supports Ollama, OpenAI API, ...)

PythonPyPIOtherollamaollama-webui
openwebui.com
151.3k22.1k
langchain-ai/langchain

The agent engineering platform.

PythonPyPIlibraryMIT Licenseaianthropic
docs.langchain.com/langchain/
145.9k24.4k