Skip to main content

llm-kelt

Knowledge · Embedding · Learning · Training

Python Type Hints Linting: Ruff CI License

Persistent memory and fine-tuning data for LLM applications, backed by Postgres.

Store the things an LLM needs to know or learn from — facts, feedback, preferences, predictions, directives — under an isolation key. Retrieve them for prompt injection or RAG. Export them to DPO/SFT/classifier datasets. Train LoRA/DPO/Prompt adapters from the exported data.

Requirements

  • Python 3.11+
  • PostgreSQL 16+ with the vector extension (pgvector)
  • For training: CUDA GPU (or MPS on Apple Silicon)

Supported Python versions

CI tests every push on:

  • Linux (Ubuntu): Python 3.11, 3.12, 3.13, 3.14

requires-python = ">=3.11" is declared in package metadata; newer Python versions are validated in CI before being added to the matrix.

Install

pip install llm-kelt              # runtime
pip install llm-kelt[training]    # + torch / transformers / peft / trl

Minimal example

import os

from appinfra.dot_dict import DotDict
from appinfra.log import LogConfig, LoggerFactory
from llm_kelt import ClientContext, ClientFactory
from llm_kelt.inference import ContextBuilder

lg = LoggerFactory.create_root(LogConfig.from_params(level="warning"))
database_url = os.environ.get("DATABASE_URL", "postgresql://postgres:postgres@127.0.0.1:5432/kelt")
config = DotDict({"dbs": {"main": {"url": database_url, "create_db": True}}})

kelt = ClientFactory(lg).create_from_config(
    context=ClientContext(context_key="my-agent"),
    config=config,
)

kelt.atomic.assertions.add("Timezone: UTC", category="settings")
kelt.atomic.assertions.add("Prefers concise, code-first answers", category="style")

system_prompt = ContextBuilder(kelt.atomic.assertions).build_system_prompt(
    base_prompt="You are a helpful assistant.",
)
# → "You are a helpful assistant.\n\n## About the user:\n- Timezone: UTC\n- ..."

That's the whole shape: put things in under a context_key, pull them back out grouped for prompt injection. Everything else (RAG, feedback, preferences, training) builds on the same model.

Where to go next

  • Quickstart — 5 minutes from install to first RAG query.
  • Concepts — context keys, schemas, atomic vs KG. Read once before the tutorials.
  • Atomic memory — the seven fact clients (assertions, feedback, preferences, predictions, directives, interactions, solutions) and how they relate.
  • Context & RAG — embedding facts, semantic search, ContextQuery.
  • Conversation — multi-turn sessions, token accounting, compaction, storage.
  • Training — manifest workflow, LoRA/DPO/SFT/Prompt, exports, adapter registry.
  • Knowledge graph — entities, aliases, hierarchical scopes.
  • Multi-schemaSchemaMode, with_schema(), isolation.
  • CLI referencellm-kelt atomic|proxy|train|session.
  • Glossary — project-specific terms.

Configuration

ClientFactory.create_from_config accepts any dict-like config (a DotDict, a plain dict, or the object returned by appinfra's Config after loading a yaml file). For a yaml-backed setup, the shape is:

dbs:
  main:
    url: postgresql://user:pass@localhost:5432/llm_kelt
    extensions: [vector]

llm:
  default: local
  backends:
    local:
      base_url: http://localhost:8000/v1
      model: default

embedding:
  type: openai
  base_url: http://localhost:8001/v1
  model: text-embedding-3-small

kelt:
  adapters:
    lora:
      base_path: ~/models/adapters

llm, embedding, and kelt.adapters are only required for the subsystems that use them (ContextQuery, RAG, and training respectively).

Examples

Runnable scripts in examples/:

Suggested reading order:

  1. facts_and_context.py — assertions + ContextBuilder.
  2. rag_retrieval.py — embeddings, search_similar, ContextQuery with RAG.
  3. training_export.py — feedback + preferences → DPO/SFT/classifier JSONL.
  4. lora_training.py — end-to-end LoRA training.
  5. conversation.pyConversation, compaction, FileSessionStorage.

License

Apache 2.0

Maintained by LLM Works LLC and contributors.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_kelt-0.4.3.tar.gz (330.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_kelt-0.4.3-py3-none-any.whl (270.9 kB view details)

Uploaded Python 3

File details

Details for the file llm_kelt-0.4.3.tar.gz.

File metadata

  • Download URL: llm_kelt-0.4.3.tar.gz
  • Upload date:
  • Size: 330.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for llm_kelt-0.4.3.tar.gz
Algorithm Hash digest
SHA256 812938c181dea5e8796e7348a5feb817324d0a44643ee986353cfe14c2137bc5
MD5 0fb0f8c192738e72af96707bdb64d169
BLAKE2b-256 21e1027e19f7352c72603d673da34bea8a853804bffc63a0799d57e633134537

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_kelt-0.4.3.tar.gz:

Publisher: release.yml on llm-works/llm-kelt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llm_kelt-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: llm_kelt-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 270.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for llm_kelt-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c2c4bd66f5ceaf3906ea7c4e7d8e1051f4cd9bf89a6fe9912a0db14eae3fc2a7
MD5 7c3d6fdaf6688aadacf165a8288c2e66
BLAKE2b-256 3061ec7aac4ff5115eca3179a2048390755de7a2f879e1350f02424548385cc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_kelt-0.4.3-py3-none-any.whl:

Publisher: release.yml on llm-works/llm-kelt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.4.5

2 files

0.4.4

2 files

This release

0.4.3 This release

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page