https://github.com/tinybiggames/lumina
Local Generative AI
https://github.com/tinybiggames/lumina
gen-ai gguf llama-cpp llm-inference local-ai pascal win64 windows-10 windows-11
Last synced: about 2 months ago
JSON representation
Local Generative AI
- Host: GitHub
- URL: https://github.com/tinybiggames/lumina
- Owner: tinyBigGAMES
- License: bsd-3-clause
- Created: 2024-11-02T06:10:52.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-01-15T05:44:16.000Z (9 months ago)
- Last Synced: 2025-08-17T07:36:02.817Z (about 2 months ago)
- Topics: gen-ai, gguf, llama-cpp, llm-inference, local-ai, pascal, win64, windows-10, windows-11
- Language: Pascal
- Homepage:
- Size: 16.7 MB
- Stars: 34
- Watchers: 9
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README

[](https://discord.gg/tPWjMwK)
[](https://bsky.app/profile/tinybiggames.com)# ๐ Lumina: Advanced Local Generative AI for Delphi Developers ๐ป๐ค
Lumina offers a cutting-edge ๐ ๏ธ for Delphi developers to seamlessly integrate advanced generative AI capabilities into their ๐ฑ. Built on the computational backbone of **llama.cpp** ๐ช, Lumina prioritizes data privacy ๐, performance โก, and a user-friendly API ๐, making it a powerful tool for local AI inference ๐ค.
## ๐ง Why Choose Lumina?
- **Localized Processing** ๐ : Operates entirely offline, ensuring sensitive data remains confidential ๐ก๏ธ while offering complete computational control ๐ง .
- **Broad Model Compatibility** ๐: Supports **GGUF models** compliant with llama.cpp standards, granting access to diverse AI architectures ๐งฉ.
- **Intuitive Development Interface** ๐๏ธ: A concise, flexible API simplifies model management ๐๏ธ, inference execution ๐งฎ, and callback customization ๐๏ธ, minimizing implementation complexity.
- **Future-Ready Scalability** ๐: This release emphasizes stability ๐๏ธ and foundational features, with plans for multi-turn conversation ๐ฌ and retrieval-augmented generation (RAG) ๐ in future updates.## ๐ ๏ธ Key Functionalities
### ๐ค Advanced AI Integration
Lumina expands your development toolkit ๐ with capabilities such as:
- Dynamic chatbot creation ๐ฌ.
- Automated text generation ๐ and summarization ๐ฐ.
- Context-sensitive content generation โ๏ธ.
- Real-time inference for adaptive processes โก.### ๐ Privacy-Driven AI Execution
- Operates independently of external networks ๐ก๏ธ, guaranteeing data security.
- Uses Vulkan ๐ฅ๏ธ for optional GPU acceleration to enhance performance.### โ๏ธ Performance Optimization
- Configurable GPU utilization through the `AGPULayers` parameter ๐งฉ.
- Dynamic thread allocation based on hardware capabilities ๐ฅ๏ธ via `AMaxThreads`.
- Comprehensive performance metrics ๐, offering insights into throughput ๐ and efficiency.### ๐ Streamlined Integration
- Embedded dependencies eliminate the need for external libraries ๐ฆ.
- Lightweight architecture (~2.5MB overhead) ensures broad deployment compatibility ๐.## ๐ฅ Installation
1. **Download the Repository** ๐ฆ
- [Download here](https://github.com/tinyBigGAMES/Lumina/archive/refs/heads/main.zip) and extract the files to your preferred directory ๐.2. **Acquire a GGUF Model** ๐ง
- Obtain a model from [Hugging Face](https://huggingface.co), such as [Gemma 2.2B GGUF (Q8_0)](https://huggingface.co/bartowski/gemma-2-2b-it-abliterated-GGUF/resolve/main/gemma-2-2b-it-abliterated-Q8_0.gguf?download=true). Save it to a directory accessible to your application (e.g., `C:/LLM/GGUF`) ๐พ.3. **Ensure GPU Compatibility** ๐ฎ
- Verify Vulkan compatibility for enhanced performance โก. Adjust `AGPULayers` as needed to accommodate VRAM limitations ๐.4. **โจ TLumina Class**
- ๐ Add `Lumina` to your `uses` section.
- ๐ ๏ธ Create an instance of `TLumina`.
- ๐ All functionality will then be at your disposal. That simple! ๐5. **Explore Examples** ๐
- Check the `examples` directory for detailed usage demonstrations ๐.## ๐ ๏ธ Usage
### ๐ง Basic Setup
Integrate Lumina into your Delphi project ๐ฅ๏ธ:
```delphi
var
Lumina: TLumina;
begin
Lumina := TLumina.Create;
try
if Lumina.LoadModel('C:\LLM\GGUF\gemma-2-2b-it-abliterated-Q8_0.gguf',
'', 8192, -1, 8) then
begin
if Lumina.SimpleInference('What is the capital of Italy?') then
WriteLn('Inference completed successfully.')
else
WriteLn('Error: ', Lumina.GetError);
end;
finally
Lumina.Free;
end;
end;
```### ๐๏ธ Customizing Callbacks
Define custom behavior using Luminaโs callback functions ๐ ๏ธ:
```delphi
procedure NextTokenCallback(const AToken: string; const AUserData: Pointer);
begin
Write(AToken);
end;Lumina.SetNextTokenCallback(NextTokenCallback, nil);
```## ๐ API Reference
### ๐งฉ Core Methods
- **LoadModel** ๐
- Parameters:
- `AModelFilename`: Path to the GGUF model file ๐.
- `ATemplate`: Optional inference template ๐.
- `AMaxContext`: Maximum context size (default: 512) ๐ง .
- `AGPULayers`: GPU layer configuration (-1 for maximum) ๐ฎ.
- `AMaxThreads`: Number of CPU threads allocated ๐ฅ๏ธ.
- Returns a boolean indicating success โ .- **SimpleInference** ๐ง
- Accepts a single query for immediate processing ๐.
- Returns a boolean indicating success โ .- **SetNextTokenCallback** ๐ฌ
- Assigns a handler to process tokens during inference ๐งฉ.- **UnloadModel** โ
- Frees resources allocated during model loading ๐๏ธ.- **GetPerformanceResult** ๐
- Provides metrics, including token generation rates ๐.## ๐ ๏ธ Advanced Configurations
### ๐ง Custom Inference Templates
Lumina will use the template defined in the model's meta data by default, but you can also define custom templates to match your modelโs requirements or change its behavor. These are some common model templates โ๏ธ:
```delphi
const
CHATML_TEMPLATE = '<|im_start|>{role} {content}<|im_end|><|im_start|>assistant';
GEMMA_TEMPLATE = '{role} {content}';
PHI_TEMPLATE = '<|{role}|> {content}<|end|><|assistant|>';
```- **{role}** - will be replaced with the role (user, assistant, etc.)
- **{content}** - will be replaced with the content sent to the model### ๐ฎ GPU Optimization
- `AGPULayers` values:
- `-1`: Utilize all available layers (default) ๐ฅ๏ธ.
- `0`: CPU-only processing ๐ฅ๏ธ.
- Custom values for partial GPU utilization ๐๏ธ.### ๐ Performance Metrics
Retrieve detailed operational metrics ๐:
```delphi
var
Perf: TLumina.PerformanceResult;
begin
Perf := Lumina.GetPerformanceResult;
WriteLn('Tokens/Sec: ', Perf.TokensPerSecond);
WriteLn('Input Tokens: ', Perf.TotalInputTokens);
WriteLn('Output Tokens: ', Perf.TotalOutputTokens);
end;
```## ๐๏ธ Media
### ๐ Deep Dive Podcast
Discover in-depth discussions and insights about **Lumina** and its innovative features. ๐โจhttps://github.com/user-attachments/assets/165e3dee-b29f-4478-b9ef-4fb6d2df2485
### ๐ ๏ธ Support and Resources
- Report issues via the [Issue Tracker](https://github.com/tinyBigGAMES/Lumina/issues) ๐.
- Engage in discussions on the [Forum](https://github.com/tinyBigGAMES/Lumina/discussions) and [Discord](https://discord.gg/tPWjMwK) ๐ฌ.
- Learn more at [Learn Delphi](https://learndelphi.org) ๐.### ๐ค Contributing
Contributions to **โจ Lumina** are highly encouraged! ๐
- ๐ **Report Issues:** Submit issues if you encounter bugs or need help.
- ๐ก **Suggest Features:** Share your ideas to make **Lumina** even better.
- ๐ง **Create Pull Requests:** Help expand the capabilities and robustness of the library.Your contributions make a difference! ๐โจ
#### Contributors ๐ฅ๐ค
### ๐ Licensing
**Lumina** is distributed under the ๐ **BSD-3-Clause License**, allowing for redistribution and use in both source and binary forms, with or without modification, under specific conditions. See the [LICENSE](https://github.com/tinyBigGAMES/Lumina?tab=BSD-3-Clause-1-ov-file#BSD-3-Clause-1-ov-file) file for more details.
---
Advance your Delphi applications with Lumina ๐ โ a sophisticated solution for integrating local generative AI ๐ค.
![]()
Made with :heart: in Delphi