diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..f0c8e0a --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,20 @@ +# All hail doc master Pau +* @Paulescu + +# Domain owners +/docs/fine-tuning/ @Liquid4All/fine-tuning-team + +/docs/inference @Liquid4All/inference-team +/docs/inference/*-deployment.mdx @tuliren + +/docs/key-concepts/ @mlabonne +/docs/models/audio-models.mdx @haerski +/docs/models/vision-models.mdx @ankke +/docs/models/ @mlabonne + +/leap/ @dbhathena +/leap/edge-sdk/ @iamstuffed +/leap/leap-bundle/ @tuliren +/leap/finetuning.mdx @Liquid4All/fine-tuning-team + +/.github/workflows/ @tuliren diff --git a/docs.json b/docs.json index 80ec89a..b54a2f8 100644 --- a/docs.json +++ b/docs.json @@ -112,13 +112,6 @@ "docs/fine-tuning/unsloth" ] }, - { - "group": "Frameworks", - "icon": "boxes", - "pages": [ - "docs/frameworks/outlines" - ] - }, { "group": "Help", "icon": "book", diff --git a/docs/frameworks/leap.mdx b/docs/frameworks/leap.mdx deleted file mode 100644 index d2c5af0..0000000 --- a/docs/frameworks/leap.mdx +++ /dev/null @@ -1,55 +0,0 @@ ---- -title: "Overview" -description: "LEAP (Liquid Edge AI Platform) is an integrated toolchain that simplifies the entire edge AI development process: from model discovery, through customization, to deployment. Deploy AI models on-device as easily as calling a cloud API." ---- - -## Key Features[​](#key-features "Direct link to Key Features") - -* [**Model Search**](https://leap.liquid.ai/search) helps you find the ideal model for your use case. Set your device constraints, describe your task, and test competitive models to find the best option for your hardware. - -* [**Model Library**](https://leap.liquid.ai/models) provides model bundles ready for download and deployment with the Edge SDK. Browse optimized bundles for LFM2 and Qwen3 models. - -* [**Model Bundling Service**](https://leap.liquid.ai/docs/leap-bundle/quick-start) is a CLI tool for creating deployment-ready model bundles from any base or fine-tuned model. - -## Basic Usage[​](#basic-usage "Direct link to Basic Usage") - -**Install:** - -``` -pip install leap-bundle -``` - -**Authenticate:** - -``` -leap-bundle login -``` - -**Create model bundle:** - -``` -leap-bundle create -``` - -The bundling service handles model quantization, format conversion, and packaging. Once created, check bundle status with `leap-bundle list`. - -## Edge SDK[​](#edge-sdk "Direct link to Edge SDK") - -The [**LEAP Edge SDK**](https://leap.liquid.ai/docs/edge-sdk/overview) enables on-device model inference in mobile apps with minimal code. Deploy model bundles directly into iOS and Android apps in less than 15 lines of code with support for streaming generation, constrained generation, and function calling. - -**Get started:** [iOS Quick Start](https://leap.liquid.ai/docs/edge-sdk/ios/ios-quick-start-guide) | [Android Quick Start](https://leap.liquid.ai/docs/edge-sdk/android/android-quick-start-guide) - -## Laptop Support[​](#laptop-support "Direct link to Laptop Support") - -[**LEAP Laptop Support**](https://leap.liquid.ai/docs/laptop-support) provides optimized pre-compiled llama.cpp binaries for running LFM models on laptops. Pre-compiled binaries eliminate manual compilation and ensure optimal performance for AMD Ryzen™ chips, different OS configurations, and CPU/GPU acceleration. - -## Additional Resources[​](#additional-resources "Direct link to Additional Resources") - -* **[Complete Documentation](https://leap.liquid.ai/docs)** - Full API reference and guides -* **[Apollo App](https://www.liquid.ai/apollo)** - Test LEAP models on your iOS or Android device -* **[Liquid AI Cookbook](https://github.com/Liquid4All/cookbook)** - End‑to‑end finetuning notebooks and project examples -* **[Join the Community](https://discord.gg/liquid-ai)** - Get support and stay updated on Discord - -LEAP is designed for any app developer—regardless of their familiarity with AI—to build powerful edge AI applications with LFM models. - -[Edit this page](https://github.com/Liquid4All/docs/tree/main/lfm/frameworks/leap.md) diff --git a/docs/frameworks/outlines.mdx b/docs/frameworks/outlines.mdx deleted file mode 100644 index 1984a1e..0000000 --- a/docs/frameworks/outlines.mdx +++ /dev/null @@ -1,265 +0,0 @@ ---- -title: "Outlines" -description: "Outlines is a library for constrained text generation with LLMs. It provides two powerful approaches: for structured data extraction and for custom formats like function calling." ---- - - - Use Outlines for guaranteed valid function calls and structured outputs, JSON schema validation and data extraction, and applications requiring pre-defined output formats. - - -Outlines enforces output constraints at generation time with zero runtime overhead, ensuring your model always produces parseable, valid results. - -## Installation[​](#installation "Direct link to Installation") - -Install Outlines with Transformers support: - -``` -pip install outlines transformers torch -``` - -## Setup[​](#setup "Direct link to Setup") - -Outlines provides a simple interface for constrained generation. The examples below use Transformers, but Outlines works with all major inference frameworks including [vLLM](/docs/inference/vllm), [llama.cpp](/docs/inference/llama-cpp), [MLX](/docs/inference/mlx), [Ollama](/docs/inference/ollama), and more. See the [Outlines documentation](https://dottxt-ai.github.io/outlines/latest/) for framework-specific examples. - -Start by wrapping your model: - -```python -import outlines -from transformers import AutoModelForCausalLM, AutoTokenizer - -# Load model with Outlines -model = outlines.from_transformers( - AutoModelForCausalLM.from_pretrained("LiquidAI/LFM2.5-1.2B-Instruct", device_map="auto"), - AutoTokenizer.from_pretrained("LiquidAI/LFM2.5-1.2B-Instruct") -) -``` - -## Basic Output Types[​](#basic-output-types "Direct link to Basic Output Types") - -For simple use cases, Outlines supports several built-in output types that don't require schemas or grammars. - -### Python Types[​](#python-types "Direct link to Python Types") - -Generate outputs constrained to basic Python types: - -```python -# Integer output -result = model("How many states are in the USA?", int, max_new_tokens=10) -print(result) # Output: 50 - -# Float output -result = model("What is pi to 2 decimal places?", float, max_new_tokens=10) -print(result) # Output: 3.14 - -# Boolean output -result = model("Is Python a programming language? Answer true or false.", bool, max_new_tokens=10) -print(result) # Output: True -``` - -### Multiple Choice[​](#multiple-choice "Direct link to Multiple Choice") - -Constrain outputs to a predefined list of options: - -```python -from outlines.types import Choice - -# Simple choice -colors = Choice(["red", "blue", "green", "yellow"]) -result = model("What color is the sky?", colors, max_new_tokens=10) -print(result) # Output: blue - -# Categorical data -categories = Choice(["sports", "politics", "technology", "entertainment"]) -result = model("Classify this headline: 'New AI model breaks records'", categories, max_new_tokens=10) -print(result) # Output: technology -``` - -### Regex Patterns[​](#regex-patterns "Direct link to Regex Patterns") - -Use regular expressions to define custom output formats: - -```python -from outlines.types import Regex - -# Phone number format -phone_pattern = Regex(r"\d{3}-\d{3}-\d{4}") -result = model("Generate a US phone number:", phone_pattern, max_new_tokens=20) -print(result) # Output: 555-123-4567 - -# Email format -email_pattern = Regex(r"[a-z0-9]+@[a-z]+\.[a-z]+") -result = model("Generate an email address:", email_pattern, max_new_tokens=30) -print(result) # Output: user@example.com - -# Date format (YYYY-MM-DD) -date_pattern = Regex(r"\d{4}-\d{2}-\d{2}") -result = model("What is today's date?", date_pattern, max_new_tokens=15) -print(result) # Output: 2025-01-15 -``` - -## Advanced Structured Generation[​](#advanced-structured-generation "Direct link to Advanced Structured Generation") - -For more complex use cases, Outlines offers two powerful approaches: - -## JSON Schema (Structured Data)[​](#json-schema-structured-data "Direct link to JSON Schema (Structured Data)") - -Use `JSONSchema` when you need to extract structured data that maps cleanly to JSON. This is ideal for data extraction, API responses, and structured outputs. - -**When to use:** - -* Extracting information from unstructured text -* Generating API-compatible responses -* Creating structured database entries -* Parsing documents into predefined formats - -```python -from outlines.types import JSONSchema - -schema = JSONSchema(''' -{ - "type": "object", - "properties": { - "name": {"type": "string"}, - "age": {"type": "integer"}, - "city": {"type": "string"} - }, - "required": ["name", "age", "city"] -} -''') - -prompt = "Extract information: John is 30 years old and lives in Boston." -result = model(prompt, schema, max_new_tokens=128) -print(result) -# Output: {"name": "John", "age": 30, "city": "Boston"} -``` - -### Complex JSON Structures[​](#complex-json-structures "Direct link to Complex JSON Structures") - -JSON schemas support nested objects and arrays: - -```python -schema = JSONSchema(''' -{ - "type": "object", - "properties": { - "product": {"type": "string"}, - "price": {"type": "number"}, - "features": { - "type": "array", - "items": {"type": "string"} - } - } -} -''') - -prompt = "Describe this laptop: MacBook Pro with M3 chip and 16GB RAM, priced at $2499." -result = model(prompt, schema, max_new_tokens=256) -``` - -## Grammar-Based Generation (Function Calling)[​](#grammar-based-generation-function-calling "Direct link to Grammar-Based Generation (Function Calling)") - -Use context-free grammars (CFGs) when you need precise control over output format. This approach is more token-efficient than JSON and provides stronger guarantees for function calling and custom formats. - -**When to use:** - -* Function calling with specific syntax (Pythonic, custom formats) -* Token-efficient outputs (fewer tokens than JSON) -* Custom DSLs or specialized formats -* Edge applications where token count matters - -Grammars use [Lark syntax](https://lark-parser.readthedocs.io/) to define valid output structures: - -```python -from outlines.types import CFG - -# Define grammar for function calls -grammar = """ -?start: "<|tool_call_start|>[" function "]<|tool_call_end|>" -?function: play_media | set_volume -?play_media: "play_media(" media_args ")" -?media_args: "device = " device ", source = " source -?device: "'speaker'" | "'tv'" -?source: "'spotify'" | "'netflix'" | "'youtube'" -?set_volume: "set_volume(" volume ")" -?volume: "0" | "0.1" | "0.2" | "0.3" | "0.4" | "0.5" | "0.6" | "0.7" | "0.8" | "0.9" | "1.0" -""" - -# Generate function call -prompt = "Play Spotify on the speaker at high volume." -result = model(prompt, CFG(grammar), max_new_tokens=64) -print(result) -# Output: <|tool_call_start|>[play_media(device = 'speaker', source = 'spotify')]<|tool_call_end|> -``` - -### Grammar Syntax[​](#grammar-syntax "Direct link to Grammar Syntax") - -Grammars define rules using Lark syntax: - -* **Rules**: Define patterns with `rule_name: pattern` -* **Alternatives**: Use `|` for choices (e.g., `"red" | "blue"`) -* **Optional**: Wrap in `()?` for optional parts -* **Repetition**: Use `*` for zero or more, `+` for one or more -* **Literals**: Wrap strings in quotes `"literal"` - -### Multiple Function Calls[​](#multiple-function-calls "Direct link to Multiple Function Calls") - -Grammars support multiple function calls in a single response: - -```python -grammar = """ -?start: "<|tool_call_start|>[" tool_calls "]<|tool_call_end|>" -?tool_calls: (function ", ")* function -?function: play_media | set_volume | close_blinds -?play_media: "play_media(" media_args ")" -?media_args: "device = " device ", source = " source -?device: "'speaker'" | "'tv'" -?source: "'spotify'" | "'netflix'" -?set_volume: "set_volume(" volume ")" -?volume: "0.5" | "0.7" | "0.9" | "1.0" -?close_blinds: "close_blinds(" ("percentage = " percentage)? ")" -?percentage: "50" | "75" | "100" -""" - -prompt = "It's movie time! Close the blinds and play Netflix on the TV at medium volume." -result = model(prompt, CFG(grammar), max_new_tokens=128) -print(result) -# Output: <|tool_call_start|>[close_blinds(percentage = 100), play_media(device = 'tv', source = 'netflix'), set_volume(0.7)]<|tool_call_end|> -``` - -## Choosing the Right Approach[​](#choosing-the-right-approach "Direct link to Choosing the Right Approach") - -| Approach | Best For | Complexity | Token Efficiency | -| ------------------- | ------------------------------------------------- | ---------- | ------------------------------ | -| **Python Types** | Simple typed outputs (int, float, bool) | Lowest | Highest | -| **Multiple Choice** | Classification, categorical data | Low | High | -| **Regex** | Custom formats (phone, email, dates) | Low-Medium | High | -| **JSON Schema** | Data extraction, API responses, nested structures | Medium | Moderate | -| **Grammar (CFG)** | Function calling, custom DSLs, complex formats | High | High - up to 2.6x fewer tokens | - -**Rule of thumb:** - -* Start with **Python Types** or **Multiple Choice** for simple outputs -* Use **Regex** for custom formats like phone numbers or dates -* Use **JSON Schema** for structured data extraction with nested objects -* Use **Grammars** for function calling, custom DSLs, or when token efficiency is critical - -## Edge Applications[​](#edge-applications "Direct link to Edge Applications") - -Outlines is particularly effective for edge deployment with compact models like `LiquidAI/LFM2-350M`. The combination provides: - -* **Reliability**: Constraints guarantee valid outputs every time -* **Efficiency**: Pythonic function calls use \~2.6x fewer tokens than JSON -* **Low latency**: Zero runtime overhead from constraint enforcement -* **Deterministic**: No parsing failures or retry loops - - - Runtime masking adds a small, predictable overhead per step of a few microseconds; compile time scales with schema/grammar complexity. - - -For a detailed example of using Outlines with LFM2-350M for smart home control, see our [blog post on structured generation](https://www.liquid.ai/blog/liquid-txt-collaboration). - -## Reference[​](#reference "Direct link to Reference") - -* [Outlines GitHub](https://github.com/dottxt-ai/outlines) -* [Outlines Documentation](https://dottxt-ai.github.io/outlines/) -* [LFM2 × .txt Collaboration Blog Post](https://www.liquid.ai/blog/liquid-txt-collaboration) diff --git a/docs/key-concepts/text-generation-and-prompting.mdx b/docs/key-concepts/text-generation-and-prompting.mdx index 2cba4ef..35b5852 100644 --- a/docs/key-concepts/text-generation-and-prompting.mdx +++ b/docs/key-concepts/text-generation-and-prompting.mdx @@ -60,7 +60,7 @@ messages = [ ``` -For structured generation with schema validation, see [Outlines](/docs/frameworks/outlines). +For structured generation with schema validation, see [Outlines](https://dottxt-ai.github.io/outlines). ## Text Models