Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9,101 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

allama

🌐 Language / 语言 / 言語 / Sprache / Langue

English | 简体中文 | 繁體中文 | 日本語 | Deutsch | Français


🇬🇧 English

allama

Security License: MIT Build Status

Aerospace-Level Security Enhanced LLM Inference Engine

This is a security-hardened, aerospace-grade version of llama.cpp with comprehensive security, fault tolerance, and enterprise-grade features for mission-critical deployments.

🚀 Key Features

Aerospace-Level Security

  • Comprehensive Authentication (API keys, JWT, Basic auth)
  • Code Signing & Verification (HMAC-SHA256 based)
  • Audit Logging (all operations logged with tamper-evidence)
  • Rate Limiting (configurable per-user limits)
  • Resource Monitoring (CPU, GPU, memory tracking)
  • File Sandbox (restricted file system access)
  • Secure Memory (encrypted memory regions)
  • GPU Isolation (dedicated GPU resource management)
  • Anomaly Detection (real-time threat detection)
  • Network Isolation (firewall and network segmentation)
  • Backup System (automatic state backup and recovery)

Fault Tolerance

  • Timeout Protection (all operations have configurable timeouts)
  • Watchdog Timers (prevent infinite loops and deadlocks)
  • Retry Mechanisms (exponential backoff for transient failures)
  • Graceful Degradation (system continues with reduced functionality on failures)
  • Signal Handling (clean shutdown on SIGTERM/SIGINT)

Model Management

  • Local Model Registry (SQLite-based metadata storage)
  • Hugging Face Model Catalog (cached catalog of available models with auto-update)
  • Allama CLI (model management commands: pull, list, show, rm, cp, add, create, search, stats, validate, mem, catalog, cache, logs, tag)
  • Modelfile Support (model definition DSL for custom configurations)
  • REST API (Ollama-compatible endpoints: /api/tags, /api/show, /api/delete, /api/copy, /api/ps, /api/pull, /api/version)
  • Tag Management (add, remove, list custom tags for models)
  • Cache Management (view cache statistics, clear cache)
  • Audit Logging (view and clear audit logs)
  • Configuration File Support (load settings from ~/.allama/config)
  • Command Aliases (ls, remove, delete, copy, search, update)
  • Color Output (automatic terminal detection with NO_COLOR support)
  • Edge Case Handling (input validation and error handling)
  • Unified AI Interface (single endpoint for all models with automatic routing)

Performance

  • All llama.cpp performance optimizations preserved
  • Metal (Apple Silicon), CUDA (NVIDIA), HIP (AMD), Vulkan support
  • 1.5-bit to 8-bit quantization
  • CPU+GPU hybrid inference
  • Speculative decoding

📋 Quick Start

Building from Source

# Clone the repository
git clone https://github.com/arkCyber/allama.git
cd allama

# Create build directory
mkdir build && cd build

# Configure and build
cmake ..
make -j$(nproc)

# Install (optional)
sudo make install

Using Allama CLI

# Initialize model registry
./bin/allama stats

# Add a local model
./bin/allama add my-model /path/to/model.gguf

# List all models
./bin/allama list

# Show model details
./bin/allama show my-model

# Validate model integrity
./bin/allama validate my-model

# Search models
./bin/allama search "llama"

# Display memory usage and model memory requirements
./bin/allama mem

# Start allama serve (unified AI interface - port 11435)
./bin/allama serve

# Manage model tags
./bin/allama tag add llama3:latest production
./bin/allama tag list llama3:latest
./bin/allama tag remove llama3:latest production

# Manage cache
./bin/allama cache stats
./bin/allama cache clear

# View audit logs
./bin/allama logs view
./bin/allama logs clear

# Use command aliases
./bin/allama ls              # same as list
./bin/allama remove model   # same as rm
./bin/allama copy src dst   # same as cp

Quick Start with Gemma4 26B

# 1. Build allama
cargo build --bin allama

# 2. Build llama-server
cd build && cmake .. && make -j$(nproc)

# 3. Start llama-server for Gemma4 26B (port 8082)
./bin/llama-server \
  -m /path/to/gemma-4-26b.gguf \
  -c 98304 \
  --port 8082 \
  -t 8 \
  --gpu-layers 0 \
  --cache-type-k f16 \
  --cache-type-v f16

# 4. Start allama serve (unified interface - port 11435)
./target/debug/allama serve --port 11435

# 5. Use unified API
curl -X POST http://127.0.0.1:11435/api/chat \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer allama_esVUQHQCvtrjOtlPt6vV579u3QNOeI5t" \
  -d '{"model":"gemma4-26b","messages":[{"role":"user","content":"Hello"}]}'

Using the Enhanced Server

# Start allama serve (unified AI interface - port 11435)
./bin/allama serve

# Start llama-server for Gemma4 26B (port 8082)
./bin/llama-server \
  -m /path/to/gemma-4-26b.gguf \
  -c 98304 \
  --port 8082 \
  -t 8 \
  --gpu-layers 0 \
  --cache-type-k f16 \
  --cache-type-v f16

# Use unified API (allama serve automatically routes to correct backend)
curl -H "Authorization: Bearer your-secret-key" \
  http://localhost:11435/api/chat \
  -d '{"model":"gemma4-26b","messages":[{"role":"user","content":"Hello"}]}'

# For Gemma4 26B, request is automatically forwarded to llama-server (port 8082)
# For other models, internal inference engine is used

Unified AI Interface

Allama serve now provides a unified AI interface on port 11435 that automatically routes requests to the appropriate backend:

  • Gemma4 26B models → Forwarded to llama-server (port 8082)
  • Other models → Handled by internal inference engine

Benefits:

  • Single endpoint for all AI models
  • Transparent backend routing
  • No need to know which service handles which model
  • Ollama-compatible API

Example:

# All these requests go through the same endpoint (11435)
curl -X POST http://localhost:11435/api/chat \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-secret-key" \
  -d '{"model":"gemma4-26b","messages":[{"role":"user","content":"Hello"}]}'

curl -X POST http://localhost:11435/api/chat \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-secret-key" \
  -d '{"model":"llama3","messages":[{"role":"user","content":"Hello"}]}'

Configuration File

Create a configuration file at ~/.allama/config to customize allama settings:

# Model registry settings
registry_path=~/.allama/registry.db
models_path=~/.allama/models
max_models=1000

# Model catalog settings
catalog_path=~/.allama/catalog.db
cache_path=~/.allama/cache
remote_url=https://huggingface.co/ggml-org
max_entries=10000
cache_ttl=3600
enable_auto_update=true

CLI Features

Color Output

  • Automatic terminal detection
  • Respects NO_COLOR environment variable
  • Respects TERM environment variable
  • Color-coded success, error, warning, and info messages

Command Aliases

  • lslist
  • removerm
  • deleterm
  • copycp
  • searchcatalog
  • updatecatalog-update

Enhanced Error Messages

  • Color-coded error messages
  • Usage information with examples
  • Better user guidance

Input Validation

  • Model name validation (empty check, length check, invalid characters)
  • Tag name validation (empty check, length check)
  • Configuration key validation (whitelist-based)

🔒 Security Architecture

Authentication

The authentication system supports multiple methods:

// API Key authentication
auth_config_t config = {
    .require_auth = true,
    .api_keys = {"secret-key-1", "secret-key-2"},
    .api_key_count = 2
};
auth_init(&config);

// JWT authentication
auth_validate_jwt(token, &user_id);

// Basic authentication
auth_validate_basic(username, password, &user_id);

Code Signing

Sign and verify model files for integrity:

# Sign a model file
./bin/allama sign-model /path/to/model.gguf

# Verify a model file
./bin/allama verify-model /path/to/model.gguf.sig

# Sign a binary
./bin/allama sign-binary /path/to/binary

# Verify a binary
./bin/allama verify-binary /path/to/binary.sig

Audit Logging

All security-relevant operations are logged:

[INFO] [2024-01-01 12:00:00] AUTH: User authenticated via API key
[INFO] [2024-01-01 12:00:05] CODE_SIGN: Model signature verified
[WARNING] [2024-01-01 12:00:10] RATE_LIMIT: User exceeded rate limit
[ERROR] [2024-01-01 12:00:15] SECURITY_VIOLATION: Invalid signature detected

🛡️ Fault Tolerance

Timeout Protection

All operations have configurable timeouts:

// Short timeout (5 seconds) for quick operations
ft_timeout_t timeout;
ft_timeout_init(&timeout, SHORT_TIMEOUT);

// Loop with timeout protection
while (condition && !ft_timeout_check(&timeout)) {
    // Do work
}

ft_timeout_cleanup(&timeout);

Watchdog Timer

System-level watchdog prevents hangs:

// Initialize global fault tolerance
ft_global_init();

// Check for shutdown request
if (ft_is_shutdown_requested()) {
    // Clean shutdown
    ft_global_cleanup();
}

📊 REST API Endpoints

Ollama-Compatible Endpoints

  • GET /api/tags - List all models
  • GET /api/show?name=<model> - Show model details
  • POST /api/delete - Delete a model
  • POST /api/copy - Copy a model
  • GET /api/ps - System info and running models
  • POST /api/pull - Pull a model (placeholder for remote registry)
  • GET /api/version - Version information

OpenAI-Compatible Endpoints

  • POST /v1/chat/completions - Chat completions
  • POST /v1/completions - Text completions
  • POST /v1/embeddings - Generate embeddings

🏗️ Architecture

Core Components

common/
├── auth.c/h                    # Authentication system
├── code-sign.c/h               # Code signing and verification
├── audit-log.c/h               # Audit logging
├── model-registry.c/h           # Model registry
├── modelfile.c/h               # Modelfile parser
├── resource-monitor.c/h         # Resource monitoring
├── file-sandbox.c/h             # File sandbox
├── rate-limit.c/h               # Rate limiting
├── secure-memory.c/h            # Secure memory
├── gpu-isolation.c/h            # GPU isolation
├── anomaly-detection.c/h        # Anomaly detection
├── backup-system.c/h            # Backup system
├── network-isolation.c/h        # Network isolation
└── fault-tolerance.c/h          # Fault tolerance framework

tools/
├── allama/                      # Allama CLI tool
└── server/                      # Enhanced llama-server

🧪 Testing

Comprehensive Test Results

This project has been extensively tested with the following results:

CLI Commands Tested (14):

  • llama-server ✅
  • llama-embedding ✅
  • llama-batched ✅
  • llama-simple ✅
  • llama-gguf ✅
  • llama-mtmd-cli ⚠️ Requires mmproj (multimodal)
  • llama-simple-chat ❌ Chat template error
  • llama-gguf-hash ✅
  • llama-debug ✅
  • llama-idle ⚠️ User canceled
  • llama-eval-callback ✅
  • llama-lookahead ✅
  • llama-gemma3-cli ⚠️ Deprecated (use llama-mtmd-cli)
  • test-allama-cli ✅ (Fixed binary path issue)

Test Commands Tested (21):

  • test-arg-parser ✅
  • test-alloc ✅
  • test-chat ✅
  • test-jinja ✅
  • test-quantize-fns ✅
  • test-tokenizer-0 ⚠️ Requires vocab file
  • test-grammar-parser ✅
  • test-peg-parser ✅
  • test-sampling ✅
  • test-backend-ops ⚠️ User canceled
  • test-autorelease ⚠️ Requires model file
  • test-barrier ✅
  • test-chat-template ✅
  • test-grammar-integration ✅
  • test-json-schema-to-grammar ✅
  • test-model-registry ⚠️ User canceled
  • test-llama-archs ✅
  • test-gguf ✅ (111/111 tests passed)
  • test-c ✅
  • test-log ✅
  • test-modelfile ⚠️ 85.7% success rate (9 failures)

Total: 35 commands tested, ~28 commands remain untested (mostly performance tests, security tests, tokenizer tests, and multimodal commands)

Run Security Module Tests

cd build
./bin/test-security-modules

Run CLI Tests

./bin/test-allama-cli

Run Model Registry Tests

./bin/test-model-registry

📖 Documentation

🤝 Contributing

This project follows the llama.cpp contributing guidelines with additional requirements for security features:

  1. All security changes must include comprehensive tests
  2. Code signing must be maintained for all security-critical binaries
  3. Audit logging must be added for all new security-relevant operations
  4. Fault tolerance mechanisms must be applied to all new features

Important: This project does not accept fully AI-generated pull requests. AI tools may be used only in an assistive capacity. See CONTRIBUTING.md for details.

📄 License

MIT License - Same as llama.cpp

🙏 Acknowledgments

Based on llama.cpp by Georgi Gerganov and contributors.

Security enhancements inspired by aerospace industry standards and DO-178C certification requirements.

🔗 Links

🇨🇳 简体中文

allama (中文)

Security License: MIT Build Status

航空航天级安全增强型 LLM 推理引擎

这是 llama.cpp 的安全加固、航空航天级版本,具有全面的安全、容错和企业级功能,专为关键任务部署而设计。

🚀 主要特性

航空航天级安全

  • 全面认证(API 密钥、JWT、Basic 认证)
  • 代码签名与验证(基于 HMAC-SHA256)
  • 审计日志(所有操作均记录,具有防篡改证据)
  • 速率限制(可配置的每用户限制)
  • 资源监控(CPU、GPU、内存跟踪)
  • 文件沙箱(受限的文件系统访问)
  • 安全内存(加密内存区域)
  • GPU 隔离(专用 GPU 资源管理)
  • 异常检测(实时威胁检测)
  • 网络隔离(防火墙和网络分段)
  • 备份系统(自动状态备份和恢复)

容错能力

  • 超时保护(所有操作都有可配置的超时)
  • 看门狗定时器(防止无限循环和死锁)
  • 重试机制(指数退避处理瞬态故障)
  • 优雅降级(系统在故障时以降低功能继续运行)
  • 信号处理(SIGTERM/SIGINT 上的干净关闭)

模型管理

  • 本地模型注册表(基于 SQLite 的元数据存储)
  • Allama CLI(模型管理命令:pull、list、show、rm、cp、add、create、search、stats、validate、mem)
  • Modelfile 支持(自定义配置的模型定义 DSL)
  • REST API(Ollama 兼容端点:/api/tags、/api/show、/api/delete、/api/copy、/api/ps、/api/pull、/api/version)
  • 统一 AI 接口(单一端点访问所有模型,自动路由)

性能

  • 保留所有 llama.cpp 性能优化
  • Metal(Apple Silicon)、CUDA(NVIDIA)、HIP(AMD)、Vulkan 支持
  • 1.5 位到 8 位量化
  • CPU+GPU 混合推理
  • 推测性解码

📋 快速开始

从源代码构建

# 克隆仓库
git clone https://github.com/arkCyber/allama.git
cd allama

# 创建构建目录
mkdir build && cd build

# 配置和构建
cmake ..
make -j$(nproc)

# 安装(可选)
sudo make install

使用 Allama CLI

# 初始化模型注册表
./bin/allama stats

# 添加本地模型
./bin/allama add my-model /path/to/model.gguf

# 列出所有模型
./bin/allama list

# 显示模型详细信息
./bin/allama show my-model

# 验证模型完整性
./bin/allama validate my-model

# 搜索模型
./bin/allama search "llama"

# 显示内存使用情况和模型内存需求
./bin/allama mem

# 启动 allama serve(统一 AI 接口 - 端口 11435)
./bin/allama serve

Gemma4 26B 快速开始

# 1. 构建 allama
cargo build --bin allama

# 2. 构建 llama-server
cd build && cmake .. && make -j$(nproc)

# 3. 启动 Gemma4 26B 的 llama-server(端口 8082)
./bin/llama-server \
  -m /path/to/gemma-4-26b.gguf \
  -c 98304 \
  --port 8082 \
  -t 8 \
  --gpu-layers 0 \
  --cache-type-k f16 \
  --cache-type-v f16

# 4. 启动 allama serve(统一接口 - 端口 11435)
./target/debug/allama serve --port 11435

# 5. 使用统一 API
curl -X POST http://127.0.0.1:11435/api/chat \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer allama_esVUQHQCvtrjOtlPt6vV579u3QNOeI5t" \
  -d '{"model":"gemma4-26b","messages":[{"role":"user","content":"你好"}]}'

使用增强版服务器

# 启动 allama serve(统一 AI 接口 - 端口 11435)
./bin/allama serve

# 启动 Gemma4 26B 的 llama-server(端口 8082)
./bin/llama-server \
  -m /path/to/gemma-4-26b.gguf \
  -c 98304 \
  --port 8082 \
  -t 8 \
  --gpu-layers 0 \
  --cache-type-k f16 \
  --cache-type-v f16

# 使用统一 API(allama serve 自动路由到正确的后端)
curl -H "Authorization: Bearer your-secret-key" \
  http://localhost:11435/api/chat \
  -d '{"model":"gemma4-26b","messages":[{"role":"user","content":"你好"}]}'

# 对于 Gemma4 26B,请求自动转发到 llama-server(端口 8082)
# 对于其他模型,使用内置推理引擎

统一 AI 接口

Allama serve 现在提供统一 AI 接口,端口 11435,自动将请求路由到适当的后端:

  • Gemma4 26B 模型 → 转发到 llama-server(端口 8082)
  • 其他模型 → 由内置推理引擎处理

优势:

  • 所有模型的单一端点
  • 透明的后端路由
  • 无需知道哪个服务处理哪个模型
  • Ollama 兼容 API

示例:

# 所有请求都通过同一个端点(11435)
curl -X POST http://localhost:11435/api/chat \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-secret-key" \
  -d '{"model":"gemma4-26b","messages":[{"role":"user","content":"你好"}]}'

curl -X POST http://localhost:11435/api/chat \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-secret-key" \
  -d '{"model":"llama3","messages":[{"role":"user","content":"你好"}]}'

🔒 安全架构

认证

认证系统支持多种方法:

// API 密钥认证
auth_config_t config = {
    .require_auth = true,
    .api_keys = {"secret-key-1", "secret-key-2"},
    .api_key_count = 2
};
auth_init(&config);

// JWT 认证
auth_validate_jwt(token, &user_id);

// Basic 认证
auth_validate_basic(username, password, &user_id);

代码签名

对模型文件进行签名和验证以确保完整性:

# 对模型文件签名
./bin/allama sign-model /path/to/model.gguf

# 验证模型文件
./bin/allama verify-model /path/to/model.gguf.sig

# 对二进制文件签名
./bin/allama sign-binary /path/to/binary

# 验证二进制文件
./bin/allama verify-binary /path/to/binary.sig

审计日志

所有安全相关操作都会被记录:

[信息] [2024-01-01 12:00:00] 认证: 用户通过 API 密钥认证
[信息] [2024-01-01 12:00:05] 代码签名: 模型签名验证成功
[警告] [2024-01-01 12:00:10] 速率限制: 用户超过速率限制
[错误] [2024-01-01 12:00:15] 安全违规: 检测到无效签名

🛡️ 容错能力

超时保护

所有操作都有可配置的超时:

// 短超时(5 秒)用于快速操作
ft_timeout_t timeout;
ft_timeout_init(&timeout, SHORT_TIMEOUT);

// 带超时保护的循环
while (condition && !ft_timeout_check(&timeout)) {
    // 执行工作
}

ft_timeout_cleanup(&timeout);

看门狗定时器

系统级看门狗防止挂起:

// 初始化全局容错
ft_global_init();

// 检查关机请求
if (ft_is_shutdown_requested()) {
    // 干净关闭
    ft_global_cleanup();
}

📊 REST API 端点

Ollama 兼容端点

  • GET /api/tags - 列出所有模型
  • GET /api/show?name=<model> - 显示模型详细信息
  • POST /api/delete - 删除模型
  • POST /api/copy - 复制模型
  • GET /api/ps - 系统信息和运行中的模型
  • POST /api/pull - 拉取模型(远程注册表的占位符)
  • GET /api/version - 版本信息

OpenAI 兼容端点

  • POST /v1/chat/completions - 聊天完成
  • POST /v1/completions - 文本完成
  • POST /v1/embeddings - 生成嵌入

🏗️ 架构

核心组件

common/
├── auth.c/h                    # 认证系统
├── code-sign.c/h               # 代码签名和验证
├── audit-log.c/h               # 审计日志
├── model-registry.c/h           # 模型注册表
├── modelfile.c/h               # Modelfile 解析器
├── resource-monitor.c/h         # 资源监控
├── file-sandbox.c/h             # 文件沙箱
├── rate-limit.c/h               # 速率限制
├── secure-memory.c/h            # 安全内存
├── gpu-isolation.c/h            # GPU 隔离
├── anomaly-detection.c/h        # 异常检测
├── backup-system.c/h            # 备份系统
├── network-isolation.c/h        # 网络隔离
└── fault-tolerance.c/h          # 容错框架

tools/
├── allama/                      # Allama CLI 工具
└── server/                      # 增强版 llama-server

🧪 测试

综合测试结果

本项目已经过广泛测试,结果如下:

已测试的CLI命令 (14个):

  • llama-server ✅
  • llama-embedding ✅
  • llama-batched ✅
  • llama-simple ✅
  • llama-gguf ✅
  • llama-mtmd-cli ⚠️ 需要mmproj (多模态)
  • llama-simple-chat ❌ chat template错误
  • llama-gguf-hash ✅
  • llama-debug ✅
  • llama-idle ⚠️ 用户取消
  • llama-eval-callback ✅
  • llama-lookahead ✅
  • llama-gemma3-cli ⚠️ 已弃用 (使用llama-mtmd-cli)
  • test-allama-cli ✅ (已修复二进制路径问题)

已测试的Test命令 (21个):

  • test-arg-parser ✅
  • test-alloc ✅
  • test-chat ✅
  • test-jinja ✅
  • test-quantize-fns ✅
  • test-tokenizer-0 ⚠️ 需要vocab文件
  • test-grammar-parser ✅
  • test-peg-parser ✅
  • test-sampling ✅
  • test-backend-ops ⚠️ 用户取消
  • test-autorelease ⚠️ 需要模型文件
  • test-barrier ✅
  • test-chat-template ✅
  • test-grammar-integration ✅
  • test-json-schema-to-grammar ✅
  • test-model-registry ⚠️ 用户取消
  • test-llama-archs ✅
  • test-gguf ✅ (111/111测试通过)
  • test-c ✅
  • test-log ✅
  • test-modelfile ⚠️ 85.7%成功率 (9个失败)

总计: 已测试35个命令,约28个命令未测试 (主要是性能测试、安全测试、tokenizer测试和多模态命令)

运行安全模块测试

cd build
./bin/test-security-modules

运行 CLI 测试

./bin/test-allama-cli

运行模型注册表测试

./bin/test-model-registry

📖 文档

🤝 贡献

本项目遵循 llama.cpp 贡献指南,并对安全功能有额外要求:

  1. 所有安全更改必须包含全面的测试
  2. 必须为所有安全关键二进制文件维护代码签名
  3. 必须为所有新的安全相关操作添加审计日志
  4. 必须将容错机制应用于所有新功能

重要: 本项目不接受完全 AI 生成的拉取请求。AI 工具只能以辅助方式使用。详情请参阅 CONTRIBUTING.md

📄 许可证

MIT 许可证 - 与 llama.cpp 相同

🙏 致谢

基于 llama.cpp,作者为 Georgi Gerganov 和贡献者。

安全增强功能受航空航天行业标准 和 DO-178C 认证要求启发。

🔗 链接

🇩🇪 Deutsch

allama (Deutsch)

Security License: MIT Build Status

Aerospace-Level Security Enhanced LLM Inference Engine

Dies ist eine sicherheitshärtete, aerospace-grade Version von llama.cpp mit umfassenden Sicherheits-, Fehlertoleranz- und Enterprise-Features für mission-critical Deployments.

🚀 Hauptfunktionen

Aerospace-Level Sicherheit

  • Umfassende Authentifizierung (API-Schlüssel, JWT, Basic-Auth)
  • Code-Signing & Verifizierung (HMAC-SHA256-basiert)
  • Audit-Logging (alle Operationen werden mit Beweis gegen Manipulation protokolliert)
  • Rate-Limiting (konfigurierbare pro-Benutzer-Limits)
  • Ressourcen-Monitoring (CPU-, GPU-, Speicher-Tracking)
  • File-Sandbox (eingeschränkter Dateisystem-Zugriff)
  • Secure Memory (verschlüsselte Speicherbereiche)
  • GPU-Isolation (dedizierte GPU-Ressourcenverwaltung)
  • Anomalie-Erkennung (Echtzeit-Bedrohungserkennung)
  • Netzwerk-Isolation (Firewall und Netzwerk-Segmentierung)
  • Backup-System (automatische Zustandssicherung und -wiederherstellung)

Fehlertoleranz

  • Timeout-Schutz (alle Operationen haben konfigurierbare Timeouts)
  • Watchdog-Timer (verhindern Endlosschleifen und Deadlocks)
  • Retry-Mechanismen (exponentielles Backoff für transiente Fehler)
  • Graceful Degradation (System läuft bei Fehlern mit reduzierter Funktionalität weiter)
  • Signal-Handling (sauberes Herunterfahren bei SIGTERM/SIGINT)

Modell-Management

  • Lokales Modell-Register (SQLite-basierte Metadatenspeicherung)
  • Allama CLI (Modell-Management-Befehle: pull, list, show, rm, cp, add, create, search, stats, validate, mem)
  • Modelfile-Support (Modell-Definition-DSL für benutzerdefinierte Konfigurationen)
  • REST API (Ollama-kompatible Endpunkte: /api/tags, /api/show, /api/delete, /api/copy, /api/ps, /api/pull, /api/version)

Leistung

  • Alle llama.cpp-Performance-Optimierungen beibehalten
  • Metal (Apple Silicon), CUDA (NVIDIA), HIP (AMD), Vulkan-Support
  • 1.5-Bit bis 8-Bit-Quantisierung
  • CPU+GPU-Hybrid-Inferenz
  • Spekulatives Decoding

📋 Schnellstart

Aus dem Quellcode bauen

# Repository klonen
git clone https://github.com/arkCyber/allama.git
cd allama

# Build-Verzeichnis erstellen
mkdir build && cd build

# Konfigurieren und bauen
cmake ..
make -j$(nproc)

# Installieren (optional)
sudo make install

Allama CLI verwenden

# Modell-Register initialisieren
./bin/allama stats

# Lokales Modell hinzufügen
./bin/allama add my-model /path/to/model.gguf

# Alle Modelle auflisten
./bin/allama list

# Modell-Details anzeigen
./bin/allama show my-model

# Modell-Integrität validieren
./bin/allama validate my-model

# Modelle suchen
./bin/allama search "llama"

# Speichernutzung und Modell-Speicheranforderungen anzeigen
./bin/allama mem

# Server mit Modell-Register starten
./bin/allama serve

Erweiterten Server verwenden

# Server mit Sicherheitsfunktionen starten
./bin/llama-server \
  --model-registry-path ~/.allama/registry.db \
  --models-path ~/.allama/models \
  --port 8080 \
  --auth-api-key your-secret-key \
  --enable-audit-log

# API mit Authentifizierung verwenden
curl -H "Authorization: Bearer your-secret-key" \
  http://localhost:8080/v1/chat/completions

🔒 Sicherheitsarchitektur

Authentifizierung

Das Authentifizierungssystem unterstützt mehrere Methoden:

// API-Schlüssel-Authentifizierung
auth_config_t config = {
    .require_auth = true,
    .api_keys = {"secret-key-1", "secret-key-2"},
    .api_key_count = 2
};
auth_init(&config);

// JWT-Authentifizierung
auth_validate_jwt(token, &user_id);

// Basic-Authentifizierung
auth_validate_basic(username, password, &user_id);

Code-Signing

Modell-Dateien signieren und verifizieren für Integrität:

# Modell-Datei signieren
./bin/allama sign-model /path/to/model.gguf

# Modell-Datei verifizieren
./bin/allama verify-model /path/to/model.gguf.sig

# Binary signieren
./bin/allama sign-binary /path/to/binary

# Binary verifizieren
./bin/allama verify-binary /path/to/binary.sig

Audit-Logging

Alle sicherheitsrelevanten Operationen werden protokolliert:

[INFO] [2024-01-01 12:00:00] AUTH: Benutzer über API-Schlüssel authentifiziert
[INFO] [2024-01-01 12:00:05] CODE_SIGN: Modell-Signatur verifiziert
[WARNING] [2024-01-01 12:00:10] RATE_LIMIT: Benutzer hat Rate-Limit überschritten
[ERROR] [2024-01-01 12:00:15] SECURITY_VIOLATION: Ungültige Signatur erkannt

🛡️ Fehlertoleranz

Timeout-Schutz

Alle Operationen haben konfigurierbare Timeouts:

// Kurzes Timeout (5 Sekunden) für schnelle Operationen
ft_timeout_t timeout;
ft_timeout_init(&timeout, SHORT_TIMEOUT);

// Schleife mit Timeout-Schutz
while (condition && !ft_timeout_check(&timeout)) {
    // Arbeit ausführen
}

ft_timeout_cleanup(&timeout);

Watchdog-Timer

Systemweiter Watchdog verhindert Hängen:

// Globale Fehlertoleranz initialisieren
ft_global_init();

// Auf Shutdown-Anfrage prüfen
if (ft_is_shutdown_requested()) {
    // Sauberes Herunterfahren
    ft_global_cleanup();
}

📊 REST API Endpunkte

Ollama-kompatible Endpunkte

  • GET /api/tags - Alle Modelle auflisten
  • GET /api/show?name=<model> - Modell-Details anzeigen
  • POST /api/delete - Modell löschen
  • POST /api/copy - Modell kopieren
  • GET /api/ps - System-Info und laufende Modelle
  • POST /api/pull - Modell pullen (Platzhalter für Remote-Register)
  • GET /api/version - Versionsinformationen

OpenAI-kompatible Endpunkte

  • POST /v1/chat/completions - Chat-Completions
  • POST /v1/completions - Text-Completions
  • POST /v1/embeddings - Embeddings generieren

🏗️ Architektur

Kernkomponenten

common/
├── auth.c/h                    # Authentifizierungssystem
├── code-sign.c/h               # Code-Signing und -Verifizierung
├── audit-log.c/h               # Audit-Logging
├── model-registry.c/h           # Modell-Register
├── modelfile.c/h               # Modelfile-Parser
├── resource-monitor.c/h         # Ressourcen-Monitoring
├── file-sandbox.c/h             # File-Sandbox
├── rate-limit.c/h               # Rate-Limiting
├── secure-memory.c/h            # Secure Memory
├── gpu-isolation.c/h            # GPU-Isolation
├── anomaly-detection.c/h        # Anomalie-Erkennung
├── backup-system.c/h            # Backup-System
├── network-isolation.c/h        # Netzwerk-Isolation
└── fault-tolerance.c/h          # Fehlertoleranz-Framework

tools/
├── allama/                      # Allama CLI Tool
└── server/                      # Erweitertes llama-server

🧪 Tests

Sicherheitsmodul-Tests ausführen

cd build
./bin/test-security-modules

CLI-Tests ausführen

./bin/test-allama-cli

Modell-Register-Tests ausführen

./bin/test-model-registry

📖 Dokumentation

🤝 Mitwirken

Dieses Projekt folgt den llama.cpp Contributing-Richtlinien mit zusätzlichen Anforderungen für Sicherheitsfunktionen:

  1. Alle Sicherheitsänderungen müssen umfassende Tests enthalten
  2. Code-Signing muss für alle sicherheitskritischen Binaries gepflegt werden
  3. Audit-Logging muss für alle neuen sicherheitsrelevanten Operationen hinzugefügt werden
  4. Fehlertoleranz-Mechanismen müssen auf alle neuen Funktionen angewendet werden

Wichtig: Dieses Projekt akzeptiert keine vollständig KI-generierten Pull Requests. KI-Tools dürfen nur in unterstützender Funktion verwendet werden. Details siehe CONTRIBUTING.md.

📄 Lizenz

MIT-Lizenz - Gleich wie llama.cpp

🙏 Danksagungen

Basierend auf llama.cpp von Georgi Gerganov und Mitwirkenden.

Sicherheitsverbesserungen inspiriert von Aerospace-Industriestandards und DO-178C-Zertifizierungsanforderungen.

🔗 Links

🇹🇼 繁體中文

allama (繁體中文)

Security License: MIT Build Status

航空航天級安全增強型 LLM 推理引擎

這是 llama.cpp 的安全加固、航空航天級版本,具有全面的安全、容錯和企業級功能,專為關鍵任務部署而設計。

🚀 主要特性

航空航天級安全

  • 全面認證(API 密鑰、JWT、Basic 認證)
  • 代碼簽名與驗證(基於 HMAC-SHA256)
  • 審計日誌(所有操作均記錄,具有防篡改證據)
  • 速率限制(可配置的每用戶限制)
  • 資源監控(CPU、GPU、內存跟蹤)
  • 文件沙箱(受限的文件系統訪問)
  • 安全內存(加密內存區域)
  • GPU 隔離(專用 GPU 資源管理)
  • 異常檢測(實時威脅檢測)
  • 網絡隔離(防火牆和網絡分段)
  • 備份系統(自動狀態備份和恢復)

容錯能力

  • 超時保護(所有操作都有可配置的超時)
  • 看門狗定時器(防止無限循環和死鎖)
  • 重試機制(指數退避處理瞬態故障)
  • 優雅降級(系統在故障時以降低功能繼續運行)
  • 信號處理(SIGTERM/SIGINT 上的乾淨關閉)

模型管理

  • 本地模型註冊表(基於 SQLite 的元數據存儲)
  • Allama CLI(模型管理命令:pull、list、show、rm、cp、add、create、search、stats、validate、mem)
  • Modelfile 支持(自定義配置的模型定義 DSL)
  • REST API(Ollama 兼容端點:/api/tags、/api/show、/api/delete、/api/copy、/api/ps、/api/pull、/api/version)

性能

  • 保留所有 llama.cpp 性能優化
  • Metal(Apple Silicon)、CUDA(NVIDIA)、HIP(AMD)、Vulkan 支持
  • 1.5 位到 8 位量化
  • CPU+GPU 混合推理
  • 推測性解碼

📋 快速開始

從源代碼構建

# 克隆倉庫
git clone https://github.com/arkCyber/allama.git
cd allama

# 創建構建目錄
mkdir build && cd build

# 配置和構建
cmake ..
make -j$(nproc)

# 安裝(可選)
sudo make install

使用 Allama CLI

# 初始化模型註冊表
./bin/allama stats

# 添加本地模型
./bin/allama add my-model /path/to/model.gguf

# 列出所有模型
./bin/allama list

# 顯示模型詳細信息
./bin/allama show my-model

# 驗證模型完整性
./bin/allama validate my-model

# 搜索模型
./bin/allama search "llama"

# 顯示內存使用情況和模型內存需求
./bin/allama mem

# 啟動帶有模型註冊表的服務器
./bin/allama serve

使用增強版服務器

# 啟用安全功能啟動服務器
./bin/llama-server \
  --model-registry-path ~/.allama/registry.db \
  --models-path ~/.allama/models \
  --port 8080 \
  --auth-api-key your-secret-key \
  --enable-audit-log

# 使用帶認證的 API
curl -H "Authorization: Bearer your-secret-key" \
  http://localhost:8080/v1/chat/completions

🔒 安全架構

認證

認證系統支持多種方法:

// API 密鑰認證
auth_config_t config = {
    .require_auth = true,
    .api_keys = {"secret-key-1", "secret-key-2"},
    .api_key_count = 2
};
auth_init(&config);

// JWT 認證
auth_validate_jwt(token, &user_id);

// Basic 認證
auth_validate_basic(username, password, &user_id);

代碼簽名

對模型文件進行簽名和驗證以確保完整性:

# 對模型文件簽名
./bin/allama sign-model /path/to/model.gguf

# 驗證模型文件
./bin/allama verify-model /path/to/model.gguf.sig

# 對二進制文件簽名
./bin/allama sign-binary /path/to/binary

# 驗證二進制文件
./bin/allama verify-binary /path/to/binary.sig

審計日誌

所有安全相關操作都會被記錄:

[信息] [2024-01-01 12:00:00] 認證: 用戶通過 API 密鑰認證
[信息] [2024-01-01 12:00:05] 代碼簽名: 模型簽名驗證成功
[警告] [2024-01-01 12:00:10] 速率限制: 用戶超過速率限制
[錯誤] [2024-01-01 12:00:15] 安全違規: 檢測到無效簽名

🛡️ 容錯能力

超時保護

所有操作都有可配置的超時:

// 短超時(5 秒)用於快速操作
ft_timeout_t timeout;
ft_timeout_init(&timeout, SHORT_TIMEOUT);

// 帶超時保護的循環
while (condition && !ft_timeout_check(&timeout)) {
    // 執行工作
}

ft_timeout_cleanup(&timeout);

看門狗定時器

系統級看門狗防止掛起:

// 初始化全局容錯
ft_global_init();

// 檢查關機請求
if (ft_is_shutdown_requested()) {
    // 乾淨關閉
    ft_global_cleanup();
}

📊 REST API 端點

Ollama 兼容端點

  • GET /api/tags - 列出所有模型
  • GET /api/show?name=<model> - 顯示模型詳細信息
  • POST /api/delete - 刪除模型
  • POST /api/copy - 複製模型
  • GET /api/ps - 系統信息和運行中的模型
  • POST /api/pull - 拉取模型(遠程註冊表的佔位符)
  • GET /api/version - 版本信息

OpenAI 兼容端點

  • POST /v1/chat/completions - 聊天完成
  • POST /v1/completions - 文本完成
  • POST /v1/embeddings - 生成嵌入

🏗️ 架構

核心組件

common/
├── auth.c/h                    # 認證系統
├── code-sign.c/h               # 代碼簽名和驗證
├── audit-log.c/h               # 審計日誌
├── model-registry.c/h           # 模型註冊表
├── modelfile.c/h               # Modelfile 解析器
├── resource-monitor.c/h         # 資源監控
├── file-sandbox.c/h             # 文件沙箱
├── rate-limit.c/h               # 速率限制
├── secure-memory.c/h            # 安全內存
├── gpu-isolation.c/h            # GPU 隔離
├── anomaly-detection.c/h        # 異常檢測
├── backup-system.c/h            # 備份系統
├── network-isolation.c/h        # 網絡隔離
└── fault-tolerance.c/h          # 容錯框架

tools/
├── allama/                      # Allama CLI 工具
└── server/                      # 增強版 llama-server

🧪 測試

運行安全模塊測試

cd build
./bin/test-security-modules

運行 CLI 測試

./bin/test-allama-cli

運行模型註冊表測試

./bin/test-model-registry

📖 文檔

🤝 貢獻

本項目遵循 llama.cpp 貢獻指南,並對安全功能有額外要求:

  1. 所有安全更改必須包含全面的測試
  2. 必須為所有安全關鍵二進制文件維護代碼簽名
  3. 必須為所有新的安全相關操作添加審計日誌
  4. 必須將容錯機制應用於所有新功能

重要: 本項目不接受完全 AI 生成的拉取請求。AI 工具只能以輔助方式使用。詳情請參閱 CONTRIBUTING.md

📄 許可證

MIT 許可證 - 與 llama.cpp 相同

🙏 致謝

基於 llama.cpp,作者為 Georgi Gerganov 和貢獻者。

安全增強功能受航空航天行業標準 和 DO-178C 認證要求啟發。

🔗 鏈接

🇯🇵 日本語

allama (日本語)

Security License: MIT Build Status

航空宇宙レベルのセキュリティ強化型 LLM 推論エンジン

これは llama.cpp のセキュリティ強化、航空宇宙級バージョンであり、ミッションクリティカルなデプロイ向けの包括的なセキュリティ、障害耐性、エンタープライズ機能を備えています。

🚀 主な機能

航空宇宙レベルのセキュリティ

  • 包括的な認証(API キー、JWT、Basic 認証)
  • コード署名と検証(HMAC-SHA256 ベース)
  • 監査ログ(すべての操作が改ざん証拠付きで記録)
  • レート制限(ユーザーごとの設定可能な制限)
  • リソース監視(CPU、GPU、メモリ追跡)
  • ファイルサンドボックス(制限されたファイルシステムアクセス)
  • セキュアメモリ(暗号化メモリ領域)
  • GPU 分離(専用 GPU リソース管理)
  • 異常検知(リアルタイム脅威検知)
  • ネットワーク分離(ファイアウォールとネットワークセグメンテーション)
  • バックアップシステム(自動状態バックアップと復元)

障害耐性

  • タイムアウト保護(すべての操作に設定可能なタイムアウト)
  • ウォッチドッグタイマー(無限ループとデッドロックの防止)
  • 再試行メカニズム(一時的な障害に対する指数バックオフ)
  • グレースフルデグラデーション(障害時に機能を低下させて継続)
  • 信号処理(SIGTERM/SIGINT でのクリーンシャットダウン)

モデル管理

  • ローカルモデルレジストリ(SQLiteベースのメタデータストレージ)
  • Allama CLI(モデル管理コマンド:pull、list、show、rm、cp、add、create、search、stats、validate、mem)
  • Modelfileサポート(カスタム設定用のモデル定義DSL)
  • REST API(Ollama互換エンドポイント:/api/tags、/api/show、/api/delete、/api/copy、/api/ps、/api/pull、/api/version)

パフォーマンス

  • すべての llama.cpp パフォーマンス最適化を保持
  • Metal(Apple Silicon)、CUDA(NVIDIA)、HIP(AMD)、Vulkan サポート
  • 1.5 ビットから 8 ビット量子化
  • CPU+GPU ハイブリッド推論
  • 投機的デコード

📋 クイックスタート

ソースからビルド

# リポジトリをクローン
git clone https://github.com/arkCyber/allama.git
cd allama

# ビルドディレクトリを作成
mkdir build && cd build

# 設定とビルド
cmake ..
make -j$(nproc)

# インストール(オプション)
sudo make install

Allama CLI の使用

# モデルレジストリを初期化
./bin/allama stats

# ローカルモデルを追加
./bin/allama add my-model /path/to/model.gguf

# すべてのモデルを一覧表示
./bin/allama list

# モデル詳細を表示
./bin/allama show my-model

# モデル整合性を検証
./bin/allama validate my-model

# モデルを検索
./bin/allama search "llama"

# メモリ使用量とモデルメモリ要件を表示
./bin/allama mem

# モデルレジストリ付きでサーバーを起動
./bin/allama serve

拡張サーバーの使用

# セキュリティ機能を有効にしてサーバーを起動
./bin/llama-server \
  --model-registry-path ~/.allama/registry.db \
  --models-path ~/.allama/models \
  --port 8080 \
  --auth-api-key your-secret-key \
  --enable-audit-log

# 認証付き API を使用
curl -H "Authorization: Bearer your-secret-key" \
  http://localhost:8080/v1/chat/completions

🔒 セキュリティアーキテクチャ

認証

認証システムは複数のメソッドをサポート:

// API キー認証
auth_config_t config = {
    .require_auth = true,
    .api_keys = {"secret-key-1", "secret-key-2"},
    .api_key_count = 2
};
auth_init(&config);

// JWT 認証
auth_validate_jwt(token, &user_id);

// Basic 認証
auth_validate_basic(username, password, &user_id);

コード署名

整合性のためにモデルファイルに署名と検証:

# モデルファイルに署名
./bin/allama sign-model /path/to/model.gguf

# モデルファイルを検証
./bin/allama verify-model /path/to/model.gguf.sig

# バイナリに署名
./bin/allama sign-binary /path/to/binary

# バイナリを検証
./bin/allama verify-binary /path/to/binary.sig

監査ログ

すべてのセキュリティ関連操作が記録:

[情報] [2024-01-01 12:00:00] 認証: ユーザーがAPIキーで認証されました
[情報] [2024-01-01 12:00:05] コード署名: モデル署名が検証されました
[警告] [2024-01-01 12:00:10] レート制限: ユーザーがレート制限を超過しました
[エラー] [2024-01-01 12:00:15] セキュリティ違反: 無効な署名が検出されました

🛡️ 障害耐性

タイムアウト保護

すべての操作に設定可能なタイムアウト:

// 短いタイムアウト(5 秒)高速操作用
ft_timeout_t timeout;
ft_timeout_init(&timeout, SHORT_TIMEOUT);

// タイムアウト保護付きループ
while (condition && !ft_timeout_check(&timeout)) {
    // 作業を実行
}

ft_timeout_cleanup(&timeout);

ウォッチドッグタイマー

システム全体のウォッチドッグがハングを防止:

// グローバル障害耐性を初期化
ft_global_init();

// シャットダウン要求をチェック
if (ft_is_shutdown_requested()) {
    // クリーンシャットダウン
    ft_global_cleanup();
}

📊 REST API エンドポイント

Ollama 互換エンドポイント

  • GET /api/tags - すべてのモデルを一覧表示
  • GET /api/show?name=<model> - モデル詳細を表示
  • POST /api/delete - モデルを削除
  • POST /api/copy - モデルをコピー
  • GET /api/ps - システム情報と実行中のモデル
  • POST /api/pull - モデルをプル(リモートレジストリのプレースホルダー)
  • GET /api/version - バージョン情報

OpenAI 互換エンドポイント

  • POST /v1/chat/completions - チャット補完
  • POST /v1/completions - テキスト補完
  • POST /v1/embeddings - 埋め込み生成

🏗️ アーキテクチャ

コアコンポーネント

common/
├── auth.c/h                    # 認証システム
├── code-sign.c/h               # コード署名と検証
├── audit-log.c/h               # 監査ログ
├── model-registry.c/h           # モデルレジストリ
├── modelfile.c/h               # Modelfile パーサー
├── resource-monitor.c/h         # リソース監視
├── file-sandbox.c/h             # ファイルサンドボックス
├── rate-limit.c/h               # レート制限
├── secure-memory.c/h            # セキュアメモリ
├── gpu-isolation.c/h            # GPU 分離
├── anomaly-detection.c/h        # 異常検知
├── backup-system.c/h            # バックアップシステム
├── network-isolation.c/h        # ネットワーク分離
└── fault-tolerance.c/h          # 障害耐性フレームワーク

tools/
├── allama/                      # Allama CLI ツール
└── server/                      # 拡張 llama-server

🧪 テスト

セキュリティモジュールテストを実行

cd build
./bin/test-security-modules

CLI テストを実行

./bin/test-allama-cli

モデルレジストリテストを実行

./bin/test-model-registry

📖 ドキュメント

🤝 貢献

このプロジェクトは llama.cpp 貢献ガイドライン に従い、セキュリティ機能に追加要件があります:

  1. すべてのセキュリティ変更には包括的なテストが必要
  2. すべてのセキュリティ重要バイナリのコード署名を維持
  3. すべての新しいセキュリティ関連操作に監査ログを追加
  4. すべての新機能に障害耐性メカニズムを適用

重要: このプロジェクトは完全に AI 生成されたプルリクエストを受け入れません。AI ツールは補助的な使用のみ可能です。詳細は CONTRIBUTING.md を参照してください。

📄 ライセンス

MIT ライセンス - llama.cpp と同じ

🙏 謝辞

llama.cpp に基づいており、著者は Georgi Gerganov と貢献者です。

セキュリティ強化は航空宇宙業界標準と DO-178C 認証要件に触発されています。

🔗 リンク

  • llama.cpp - 元のプロジェクト
  • ggml - テンソルライブラリ
  • Ollama - モデル管理リファレンス
🇫🇷 Français

allama (Français)

Security License: MIT Build Status

Moteur d'inférence LLM renforcé au niveau aérospatial

Il s'agit d'une version sécurisée et de niveau aérospatial de llama.cpp avec des fonctionnalités de sécurité complètes, de tolérance aux pannes et de niveau entreprise pour les déploiements critiques.

🚀 Fonctionnalités principales

Sécurité de niveau aérospatial

  • Authentification complète (clés API, JWT, authentification basique)
  • Signature et vérification de code (basé sur HMAC-SHA256)
  • Journal d'audit (toutes les opérations sont enregistrées avec preuve d'intégrité)
  • Limitation de débit (limites configurables par utilisateur)
  • Surveillance des ressources (suivi CPU, GPU, mémoire)
  • Bac à sable de fichiers (accès restreint au système de fichiers)
  • Mémoire sécurisée (régions de mémoire chiffrées)
  • Isolation GPU (gestion dédiée des ressources GPU)
  • Détection d'anomalies (détection de menaces en temps réel)
  • Isolation réseau (pare-feu et segmentation réseau)
  • Système de sauvegarde (sauvegarde et récupération automatique de l'état)

Tolérance aux pannes

  • Protection contre les délais d'attente (toutes les opérations ont des délais configurables)
  • Chiens de garde (prévention des boucles infinies et des interblocages)
  • Mécanismes de nouvelle tentative (exponential backoff pour les pannes transitoires)
  • Dégradation gracieuse (le système continue avec une fonctionnalité réduite en cas de panne)
  • Gestion des signaux (arrêt propre sur SIGTERM/SIGINT)

Gestion de modèles

  • Registre de modèles local (stockage de métadonnées basé sur SQLite)
  • Catalogue de modèles Hugging Face (catalogue mis en cache des modèles disponibles avec mise à jour automatique)
  • CLI Allama (commandes de gestion de modèles : pull, list, show, rm, cp, add, create, search, stats, validate, mem, catalog)
  • Support Modelfile (DSL de définition de modèle pour configurations personnalisées)
  • API REST (points de terminaison compatibles Ollama : /api/tags, /api/show, /api/delete, /api/copy, /api/ps, /api/pull, /api/version)

Performance

  • Toutes les optimisations de performance llama.cpp conservées
  • Support Metal (Apple Silicon), CUDA (NVIDIA), HIP (AMD), Vulkan
  • Quantification de 1,5 à 8 bits
  • Inférence hybride CPU+GPU
  • Décodage spéculatif

📋 Démarrage rapide

Construction à partir du code source

# Cloner le dépôt
git clone https://github.com/arkCyber/allama.git
cd allama

# Créer le répertoire de construction
mkdir build && cd build

# Configurer et construire
cmake ..
make -j$(nproc)

# Installer (optionnel)
sudo make install

Utilisation d'Allama CLI

# Initialiser le registre de modèles
./bin/allama stats

# Ajouter un modèle local
./bin/allama add my-model /path/to/model.gguf

# Lister tous les modèles
./bin/allama list

# Afficher les détails du modèle
./bin/allama show my-model

# Valider l'intégrité du modèle
./bin/allama validate my-model

# Rechercher des modèles
./bin/allama search "llama"

# Afficher l'utilisation de la mémoire et les besoins en mémoire des modèles
./bin/allama mem

# Démarrer le serveur avec le registre de modèles
./bin/allama serve

Utilisation du serveur amélioré

# Démarrer le serveur avec les fonctionnalités de sécurité activées
./bin/llama-server \
  --model-registry-path ~/.allama/registry.db \
  --models-path ~/.allama/models \
  --port 8080 \
  --auth-api-key your-secret-key \
  --enable-audit-log

# Utiliser l'API avec authentification
curl -H "Authorization: Bearer your-secret-key" \
  http://localhost:8080/v1/chat/completions

🔒 Architecture de sécurité

Authentification

Le système d'authentification prend en charge plusieurs méthodes :

// Authentification par clé API
auth_config_t config = {
    .require_auth = true,
    .api_keys = {"secret-key-1", "secret-key-2"},
    .api_key_count = 2
};
auth_init(&config);

// Authentification JWT
auth_validate_jwt(token, &user_id);

// Authentification basique
auth_validate_basic(username, password, &user_id);

Signature de code

Signer et vérifier les fichiers de modèle pour garantir l'intégrité :

# Signer un fichier de modèle
./bin/allama sign-model /path/to/model.gguf

# Vérifier un fichier de modèle
./bin/allama verify-model /path/to/model.gguf.sig

# Signer un binaire
./bin/allama sign-binary /path/to/binary

# Vérifier un binaire
./bin/allama verify-binary /path/to/binary.sig

Journal d'audit

Toutes les opérations liées à la sécurité sont enregistrées :

[INFO] [2024-01-01 12:00:00] AUTH: Utilisateur authentifié via clé API
[INFO] [2024-01-01 12:00:05] CODE_SIGN: Signature de modèle vérifiée
[WARNING] [2024-01-01 12:00:10] RATE_LIMIT: Utilisateur a dépassé la limite de débit
[ERROR] [2024-01-01 12:00:15] SECURITY_VIOLATION: Signature invalide détectée

🛡️ Tolérance aux pannes

Protection contre les délais d'attente

Toutes les opérations ont des délais configurables :

// Délai court (5 secondes) pour les opérations rapides
ft_timeout_t timeout;
ft_timeout_init(&timeout, SHORT_TIMEOUT);

// Boucle avec protection contre les délais
while (condition && !ft_timeout_check(&timeout)) {
    // Effectuer le travail
}

ft_timeout_cleanup(&timeout);

Chiens de garde

Chiens de garde au niveau du système pour prévenir les blocages :

// Initialiser la tolérance aux pannes globale
ft_global_init();

// Vérifier la demande d'arrêt
if (ft_is_shutdown_requested()) {
    // Arrêt propre
    ft_global_cleanup();
}

📊 Points de terminaison REST API

Points de terminaison compatibles Ollama

  • GET /api/tags - Lister tous les modèles
  • GET /api/show?name=<model> - Afficher les détails du modèle
  • POST /api/delete - Supprimer un modèle
  • POST /api/copy - Copier un modèle
  • GET /api/ps - Informations système et modèles en cours d'exécution
  • POST /api/pull - Tirer un modèle (espace réservé pour le registre distant)
  • GET /api/version - Informations de version

Points de terminaison compatibles OpenAI

  • POST /v1/chat/completions - Complétions de chat
  • POST /v1/completions - Complétions de texte
  • POST /v1/embeddings - Générer des embeddings

🏗️ Architecture

Composants principaux

common/
├── auth.c/h                    # Système d'authentification
├── code-sign.c/h               # Signature et vérification de code
├── audit-log.c/h               # Journal d'audit
├── model-registry.c/h           # Registre de modèles
├── modelfile.c/h               # Analyseur Modelfile
├── resource-monitor.c/h         # Surveillance des ressources
├── file-sandbox.c/h             # Bac à sable de fichiers
├── rate-limit.c/h               # Limitation de débit
├── secure-memory.c/h            # Mémoire sécurisée
├── gpu-isolation.c/h            # Isolation GPU
├── anomaly-detection.c/h        # Détection d'anomalies
├── backup-system.c/h            # Système de sauvegarde
├── network-isolation.c/h        # Isolation réseau
└── fault-tolerance.c/h          # Framework de tolérance aux pannes

tools/
├── allama/                      # Outil CLI Allama
└── server/                      # llama-server amélioré

🧪 Tests

Exécuter les tests de modules de sécurité

cd build
./bin/test-security-modules

Exécuter les tests CLI

./bin/test-allama-cli

Exécuter les tests de registre de modèles

./bin/test-model-registry

📖 Documentation

🤝 Contribution

Ce projet suit les directives de contribution llama.cpp avec des exigences supplémentaires pour les fonctionnalités de sécurité :

  1. Tous les changements de sécurité doivent inclure des tests complets
  2. La signature de code doit être maintenue pour tous les binaires critiques pour la sécurité
  3. Le journal d'audit doit être ajouté pour toutes les nouvelles opérations liées à la sécurité
  4. Les mécanismes de tolérance aux pannes doivent être appliqués à toutes les nouvelles fonctionnalités

Important : Ce projet n'accepte pas les demandes de tirage entièrement générées par l'IA. Les outils IA ne peuvent être utilisés que de manière assistive. Voir CONTRIBUTING.md pour plus de détails.

📄 Licence

Licence MIT - Identique à llama.cpp

🙏 Remerciements

Basé sur llama.cpp par Georgi Gerganov et les contributeurs.

Les améliorations de sécurité sont inspirées par les normes de l'industrie aérospatiale et les exigences de certification DO-178C.

🔗 Liens

  • llama.cpp - Projet original
  • ggml - Bibliothèque de tenseurs
  • Ollama - Référence de gestion de modèles

↑ Back to top

About

LLM inference in C/C++

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages