Download Latest Version v2.0.1 source code.tar.gz (88.9 MB)
Email in envelope

Get an email when there's a new version of LLM.swift

Home / v2.0.0
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2025-07-13 3.4 kB
v2.0.0 source code.tar.gz 2025-07-13 88.9 MB
v2.0.0 source code.zip 2025-07-13 88.9 MB
Totals: 3 Items   177.8 MB 0

LLM.swift v2.0.0 Release Notes

🚀 Major New Features

✨ @Generatable Macro - Structured Output Generation

The biggest addition to LLM.swift v2.0.0 is the powerful @Generatable macro that enables 100% reliable type-safe structured output generation. No more struggling with prompting to get output in the format you want—it works every time and allows true programmatic flow.

Key Features: - Automatic JSON Schema Generation: Simply annotate your Swift structs and enums - Nested Structure Support: Handles complex nested Generatable structures and arrays - Guaranteed Valid Output: Built-in validation ensures output conforms to your schema - Enum Support: Automatically adds CaseIterable and Codable conformance

Example:

:::swift
@Generatable
struct Person {
    let name: String
    let age: Int
    let occupation: String
    let personality: String
}

let bot = LLM(from: Bundle.main.url(forResource: "model", withExtension: "gguf")!, template: .chatML("You are helpful."))
let result = try await bot.respond(to: "Create a fictional character", as: Person.self)
let person = result.value // Guaranteed to be a valid Person struct

🎛️ repeatPenalty Parameter

Added fine-grained control over model repetition with the new repeatPenalty parameter: - Default value: 1.2 (reduces repetition) - Range: 1.0 (no penalty) to higher values (stronger penalty) - Runtime adjustable: Can be modified during LLM lifetime - Helps prevent: Repetitive responses and loops

📚 DocC Documentation

Complete documentation overhaul with Apple's DocC format: - Comprehensive API docs: Full coverage of all public APIs - Rich examples: Practical usage examples throughout - Cross-platform notes: Platform-specific guidance - Structured topics: Organized by functionality (Core Classes, Model Management, Chat System, etc.)

🔧 Technical Improvements

Enhanced Type Safety

  • Improved Swift macro implementation with better error handling
  • More robust JSON schema generation and validation
  • Better Codable conformance for complex nested structures

Performance Optimizations

  • Optimized token processing with repetition penalty integration
  • Improved sampler chain with penalty parameters
  • Better memory management for structured output generation

🎯 What's New

Structured Output Capabilities

  • Complex nested structures with multiple levels of nesting
  • Array support for collections of Generatable objects
  • Optional field handling with proper null value generation
  • Enum constraints with automatic validation
  • JSON schema validation with detailed error reporting

🙈 Breaking Changes

This is a major version update (v1.8.0 → v2.0.0) but maintains backward compatibility for existing APIs. The new features are additive and don't break existing functionality.

📖 Learn More

Check out the comprehensive test suite in LLMTests.swift for extensive examples of @Generatable usage, including nested structures, enums, and complex scenarios.


What's Changed

Full Changelog: https://github.com/eastriverlee/LLM.swift/compare/v1.8.0...v2.0.0

Source: README.md, updated 2025-07-13